void OpenALController::hello() {
	ALuint helloBuffer, helloSource;
	//alutInit(NULL, NULL);
	helloBuffer = alutCreateBufferHelloWorld();
	alGenSources(1, &helloSource);
	alSourcei(helloSource, AL_BUFFER, helloBuffer);
	alSourcePlay(helloSource);
	alutSleep(1);
	alDeleteSources(1, &helloSource);
	alDeleteBuffers(1, &helloBuffer);
	//alutExit();
}
Пример #2
0
Handle<Value> ALUTCreateBufferHelloWorldCallback(const Arguments& args) {
	//if less that nbr of formal parameters then do nothing
	if (args.Length() < 0)
		return v8::Undefined();
	
	//get arguments

	//make call
	alutCreateBufferHelloWorld();
	
	return v8::Undefined();
}
Пример #3
0
int
main (int argc, char **argv)
{

	ALuint helloBuffer, helloSource;
	ALuint fileSize;
#define FILE_NAME "s2.snd"
	int n;	
	int16* buffer;
	FILE* file;

  // make sure s3esound is ready (tends to skip a few seconds of audio on startup)
	int channel = s3eSoundGetFreeChannel();
	int rate = s3eSoundChannelGetInt(channel, S3E_CHANNEL_RATE);
	int volume = s3eSoundChannelGetInt(channel, S3E_CHANNEL_VOLUME);
  
	//s3eAudioPlay(FILE_NAME, 1);
	//alutSleep(5);

	s3eSoundChannelRegister(channel, S3E_CHANNEL_STOP_AUDIO, test_close, NULL);
	file = fopen(FILE_NAME, "rb");

	if( file ) {
		fseek(file, 0L, SEEK_END);
		fileSize = ftell(file);
		fseek(file, 0L, SEEK_SET);
		buffer = (int16*)malloc(fileSize);
		n = fread(buffer, sizeof(int16), fileSize / sizeof(int16), file);
		fclose(file);
		//s3eAudioPlayFromBuffer(buffer, n, 0);
		channel = s3eSoundGetFreeChannel();
		s3eSoundChannelSetInt(channel, S3E_CHANNEL_RATE, 8000);
		//s3eSoundChannelSetInt(channel, S3E_CHANNEL_VOLUME, 19);

		s3eSoundChannelPlay(channel, buffer, n, 1, 0);
		while( !g_closed ) {
			alutSleep(1);
		}
		free(buffer);
	}
	s3eSoundChannelSetInt(channel, S3E_CHANNEL_RATE, rate);

	alutInit (&argc, argv);
	helloBuffer = alutCreateBufferHelloWorld ();
	alGenSources (1, &helloSource);
	alSourcei (helloSource, AL_BUFFER, helloBuffer);
	alSourcePlay (helloSource);
	alutSleep (20);
	s3eSoundChannelSetInt(channel, S3E_CHANNEL_VOLUME, volume);
	alutExit ();
	return EXIT_SUCCESS;
}
Пример #4
0
int
main (int argc, char **argv)
{
  ALuint helloBuffer, helloSource;
  alutInit (&argc, argv);
  helloBuffer = alutCreateBufferHelloWorld ();
  alGenSources (1, &helloSource);
  alSourcei (helloSource, AL_BUFFER, helloBuffer);
  alSourcePlay (helloSource);
  alutSleep (1);
  alutExit ();
  return EXIT_SUCCESS;
}
  Sound_Buffer::Sound_Buffer()
    : m_buffer(AL_NONE),
      m_loader(0),
      m_thread(0)
  {
    get_Sound();

#ifndef DISABLE_AL
    m_buffer = alutCreateBufferHelloWorld();

    if(m_buffer == AL_NONE) {
      cerr << "ALUT error on Hello World: " << alutGetErrorString(alutGetError()) << endl;
      throw Sound_Buffer_Init_Failure();
    }
#endif
  }
Пример #6
0
int main (int argc, char **argv){

#pragma region // --- my init ---
	float pitchnow = 1.0;
	alListener3f(AL_POSITION, 0.0, 0.0, 0.0);

#pragma endregion

#pragma region // --- al init ---
// alut の初期化
	
alutInit (&argc, argv);
  
// Hello World としゃべる音声の作成
ALuint helloBuffer = alutCreateBufferHelloWorld();
ALuint MusicBuffer = alutCreateBufferFromFile(FILENAME);
if(AL_NONE == helloBuffer){std::cerr<<"error:nofile"<<std::endl;exit(1);}
  
// ソースの作成
ALuint helloSource;
alGenSources (1, &helloSource);
ALuint MusicSource;
alGenSources (1, &MusicSource);
  

// ソースにバッファをバインド
alSourcei (helloSource, AL_BUFFER, helloBuffer);
alSourcei (MusicSource, AL_BUFFER, MusicBuffer);
#pragma endregion

  cv::namedWindow("hoge");
  alSourcePlay(MusicSource);
  
  alSource3f(MusicSource, AL_POSITION, 100.0, 0.0, 0.0);
  alSource3f(MusicSource, AL_VELOCITY, 10.0, 0.0, 0.0);

  while(1){
	
	  char key = cv::waitKey(1);
	  if(key=='s'){
		alSourcePlay(helloSource);
		//alutSleep(1);
	  }
	  if(key == 'p'){
		  int state;
		  alGetSourcei(MusicSource, AL_SOURCE_STATE, &state);
		  if(state ==AL_PAUSED)alSourcePlay(MusicSource);
			else alSourcePause(MusicSource);
	  }
	  else if(key == 'q'){
		  std::cout<<"good bye"<<std::endl;
		break;
	  }
	  else if(key == 'u'){
		  pitchnow *= 2;
		  alSourcef(MusicSource, AL_PITCH, pitchnow);
	  }
	  else if(key == 'd'){
		  pitchnow /= 2;
		  alSourcef(MusicSource, AL_PITCH, pitchnow);
	  }

	  // roop
	  int state;
	  alGetSourcei(MusicSource, AL_SOURCE_STATE, &state);
	  if(state != AL_PLAYING) alSourcePlay(MusicSource);
  
  }

  
	#pragma region --- release ---
	  // リソースを開放
	 alSourceStop(helloSource);
  alDeleteSources( 1, &helloSource );
  alDeleteBuffers( 1, &helloBuffer );
	 alSourceStop(MusicSource);
  alDeleteSources( 1, &MusicSource );
  alDeleteBuffers( 1, &MusicBuffer );
  alutExit ();
	#pragma endregion

  return 0;
}