コード例 #1
0
ファイル: player.cpp プロジェクト: Drenn1/GameYob
void show_buffer_unscaled( Blip_Buffer& in )
{
	blip_sample_t buf [scope_width];
	long count = in.read_samples( buf, scope_width );
	while ( count < scope_width )
		buf [count++] = 0;
	
	scope.draw( buf, scope_width );
	
	// remove remaining samples
	while ( in.read_samples( buf, scope_width ) ) { }
}
コード例 #2
0
ファイル: stereo.cpp プロジェクト: Drenn1/GameYob
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;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Zardoz89/blip_buff_alure
// 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!

}
コード例 #4
0
ファイル: player.cpp プロジェクト: Drenn1/GameYob
void show_buffer( Blip_Buffer& in )
{
	long count = in.read_samples( sample_buf, buf_size );
	scope.draw( sample_buf, scope_width, (double) count / scope_width );
}