当前位置: 首页>>代码示例>>C++>>正文


C++ Blip_Buffer::end_frame方法代码示例

本文整理汇总了C++中Blip_Buffer::end_frame方法的典型用法代码示例。如果您正苦于以下问题:C++ Blip_Buffer::end_frame方法的具体用法?C++ Blip_Buffer::end_frame怎么用?C++ Blip_Buffer::end_frame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Blip_Buffer的用法示例。


在下文中一共展示了Blip_Buffer::end_frame方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	// Setup left buffer and wave
	int left_time = 0;
	int left_amp = 0;
	setup_demo( left, left_synth );
	left.clock_rate( left.sample_rate() * 100 );
	
	// Setup right buffer and wave
	int right_time = 0;
	int right_amp = 0;
	setup_demo( right, right_synth );
	right.clock_rate( right.sample_rate() * 100 );
	
	while ( !button_pressed() )
	{
		blip_time_t length = 100000;
		
		// mouse sets frequency of left wave
		int period = 1000 + 6 * mouse_x();
		
		// Add saw wave to left buffer
		do {
			left_synth.update( left_time, left_amp = (left_amp + 1) % 10 );
		} while ( (left_time += period) < length );
		left.end_frame( length );
		left_time -= length;
		
		// Add saw wave of slightly lower pitch to right buffer
		do {
			right_synth.update( right_time, right_amp = (right_amp + 1) % 10 );
		} while ( (right_time += 1000) < length );
		right.end_frame( length );
		right_time -= length;
		
		// buffer to read samples into
		int const buf_size = 2048;
		static blip_sample_t samples [buf_size];
		
		// Read left channel into even samples, right channel into odd samples:
		// LRLRLRLRLR...
		long count = left.read_samples( samples, buf_size / 2, 1 );
		right.read_samples( samples + 1, count, 1 );
		
		play_stereo_samples( samples, count * 2 );
	}
	
	return 0;
}
开发者ID:Drenn1,项目名称:GameYob,代码行数:49,代码来源:stereo.cpp

示例2: main

int main()
{
	setup_demo( buf, synth );
	
	// generate 1000 clocks of square wave
	int length = 1000;
	int amplitude = 1;
	for ( int time = 0; time < length; time += 10 )
	{
		synth.update( time, amplitude );
		amplitude = -amplitude;
	}
	
	// find out how many samples of sine wave to generate
	int count = buf.count_samples( length );
	blip_sample_t temp [4096];
	for ( int i = 0; i < count; i++ )
	{
		double y = sin( i * (3.14159 / 100) );
		temp [i] = y * 0.30 * blip_sample_max; // convert to blip_sample_t's range
	}
	
	// mix sine wave's samples into Blip_Buffer
	buf.mix_samples( temp, count );
	
	// end frame and show samples
	buf.end_frame( length );
	show_buffer( buf );
	wait_button();
	 
	return 0;
}
开发者ID:Drenn1,项目名称:GameYob,代码行数:32,代码来源:external_mixing.cpp

示例3: main

// Quick test of functions
int main()
{
	Blip_Buffer buf;
	Blip_Synth<blip_low_quality,20> synth;
	
	// Setup buffer
	buf.clock_rate( 44100 );
	if ( buf.set_sample_rate( 44100 ) )
		return 1;
	synth.output( &buf );
	synth.volume( 0.5 );
	
	// Add wave that goes from 0 to 50% to -50%
	synth.update( 4,  10 );
	synth.update( 8, -10 );
	buf.end_frame( 30 );
	
	// Read samples as this type
	typedef float sample_t; // floating-point
	//typedef unsigned short sample_t; // unsigned 16-bit
	//typedef unsigned char sample_t; // unsigned 8-bit
	
	// Read and display samples
	const int max_samples = 30;
	sample_t samples [max_samples];
	int count = read_samples( buf, samples, max_samples );
	
	for ( int i = buf.output_latency() + 1; i < count; i++ )
		printf( "%.2f,", (double) samples [i] );
	printf( "\n" );
	
	return 0;
}
开发者ID:Drenn1,项目名称:GameYob,代码行数:34,代码来源:sample_formats.cpp

示例4: main

int main()
{
	while ( !button_pressed() )
	{
		setup_demo( buf, synth );
		
		// base frequency and amplitude on mouse position
		int period = mouse_x() * 100 + 10;
		int amplitude = mouse_y() * 9 + 1;
		
		// generate alternating signs of square wave, spaced by period
		int time = 0;
		while ( time < 1000 )
		{
			amplitude = -amplitude;
			synth.update( time, amplitude );
			time += period;
		}
		buf.end_frame( 1000 );
		
		show_buffer( buf );
	}
	
	return 0;
}
开发者ID:Drenn1,项目名称:GameYob,代码行数:25,代码来源:2.square.cpp

示例5: main

int main()
{
	long sample_rate = 44100;
	
	// Sample rate sets how many samples are generated per second
	if ( buf.set_sample_rate( sample_rate ) )
		return 1; // out of memory
	buf.bass_freq( 0 ); // keep waveforms perfectly flat
	
	// Setup synth
	synth.output( &buf );
	synth.volume( 0.50 );
	
	while ( !button_pressed() )
	{
		// Mouse sets clock rate, higher to the right. The higher the clock
		// rate, the more packed the waveform becomes.
		long rate = sample_rate * (mouse_x() * 10 + 1);
		
		// Clock rate sets how many time units there are per second
		buf.clock_rate( rate );
		
		// Generate random waveform, with each transition spaced 50 clocks apart.
		srand( 1 );
		buf.clear();
		for ( int time = 0; time < 500; time += 50 )
			synth.update( time, rand() % 20 - 10 );
		
		buf.end_frame( 600 );
		
		show_buffer_unscaled( buf );
	}
	
	return 0;
}
开发者ID:Drenn1,项目名称:GameYob,代码行数:35,代码来源:3.clock_rate.cpp

示例6: StreamCB

// Callback called when Alure needs more data to ffed a buffer
ALuint StreamCB (void* userdata, ALubyte *data, ALuint bytes) {

  double period = SR / (2* freq);  // How many samples need to do a half cycle.
  size_t lenght = bytes / 2;          // Lenght in "samples"

  unsigned const amplitude = 9;
  while (offset < lenght) {
      sign = -sign;
      synth.update(offset, amplitude * sign);
      offset += period;
  }
  blipbuf.end_frame(lenght);
  offset -= lenght; // adjust time to new frame

  return 2* blipbuf.read_samples ((blip_sample_t*) data, lenght ); // return bytes!

}
开发者ID:Zardoz89,项目名称:blip_buff_alure,代码行数:18,代码来源:main.cpp


注:本文中的Blip_Buffer::end_frame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。