Example #1
0
int main(int argc, char **argv)
{
  /* Initialise ALUT and eat any ALUT-specific commandline flags. */
  if (!alutInit(&argc, argv))
  {
    ALenum error = alutGetError();

    fprintf(stderr, "%s\n", alutGetErrorString(error));
    exit(EXIT_FAILURE);
  }

  /* Check for correct usage. */
  if (argc != 2)
  {
    fprintf(stderr, "usage: playfile <fileName>\n");
    alutExit();
    exit(EXIT_FAILURE);
  }

  /* If everything is OK, play the sound file and exit when finished. */
  playFile(argv[1]);

  if (!alutExit())
  {
    ALenum error = alutGetError();

    fprintf(stderr, "%s\n", alutGetErrorString(error));
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}
// play a sample from a sound id
void SokobanSoundManager::PlaySample(SampleID _SampleID)
{
	// error check
	if(!IsSetup()) return;

	ALenum error;

	// clear errors
	alGetError();

	// if the source is in use then the new sound takes priorty
	ALint status;
	alGetSourcei (source, AL_SOURCE_STATE, &status);
	if (status == AL_PLAYING)
	{
		// stop the current sound playing
		alSourceStop(source);
	}

	// attach the buffer to it and start playing.
	alSourcei (source, AL_BUFFER, _SampleID);

	// Normally nothing should go wrong above, but one never knows...
	error = alGetError ();
	if (error != ALUT_ERROR_NO_ERROR)
	{
		// fprintf (stderr, "%s\n", alGetString (error));
		MessageBox (HWND_DESKTOP, alGetString(error), "Error Attaching Buffer", MB_OK | MB_ICONEXCLAMATION);
		alutExit ();
		exit (EXIT_FAILURE);
	}

	alSourcePlay (source);
	// Normally nothing should go wrong above, but one never knows...
	error = alGetError ();
	if (error != ALUT_ERROR_NO_ERROR)
	{
		//	fprintf (stderr, "%s\n", alGetString (error));
		MessageBox (HWND_DESKTOP, alGetString(error), "Error Playing Buffer", MB_OK | MB_ICONEXCLAMATION);
		alutExit ();
		exit (EXIT_FAILURE);
	}

	// add to list of active sounds
	//m_ActiveSounds.push_back(source);

	return;
}
Example #3
0
void
RoboySpeechProduction::terminate()
{
	std::cerr << " SPEECH PRODUCTION TERMINATE " << std::endl;
	alutExit ();
	filetoplay = "";
}
Example #4
0
void terminate_notify()
{
#if defined(SOUND_NOTIFY) || defined(BOX_NOTIFY)
    control_lock();

    if ( !Control.poll_active ) {
        control_unlock();
        return;
    }

    Control.poll_active = 0;
    control_unlock();

    graceful_clear();
#endif

#ifdef SOUND_NOTIFY
    int i = 0;
    for (; i < SOUNDS_SIZE; i ++) free(Control.sounds[i]);
    alutExit();
#endif /* SOUND_NOTIFY */

#ifdef BOX_NOTIFY
    notify_uninit();
#endif
}
Example #5
0
int bind_noaudio_set(void *b, int v)
{
	int i = bind_common_onoffset_inverted(b, v);
	
	if(v)
	{
		alutExit();
		printf("-- Unloaded ALUT\n");
		
		if(resources.state & RS_SfxLoaded)
		{
			delete_sounds();
			resources.state &= ~RS_SfxLoaded;
		}
	}
	else
	{
		if(!alutInit(NULL, NULL))
		{
			warnx("Error initializing audio: %s", alutGetErrorString(alutGetError()));
			tconfig.intval[NO_AUDIO] = 1;
			return 1;	// index of "off"
		}
		tconfig.intval[NO_AUDIO] = 0;
		printf("-- ALUT\n");
		
		load_resources();
	}
	
	return i;
}
Example #6
0
OpenALSampler::~OpenALSampler()
{
	alDeleteSources(NUM_SOURCES, source);
	alDeleteBuffers(NUM_BUFFERS, buffers);

	alutExit();
}
Example #7
0
int main(int argc, char **argv)
{
  ALboolean ok = AL_FALSE;

  alutInit(&argc, argv);

#ifdef ALUT_API_MAJOR_VERSION
  if (alutGetMajorVersion() != ALUT_API_MAJOR_VERSION || alutGetMinorVersion() != ALUT_API_MINOR_VERSION)
  {
    fprintf(stderr,
            "WARNING: The ALUT library is version %d.%d.x but <AL/alut.h> says it's %d.%d.x!\n",
            alutGetMajorVersion(), alutGetMinorVersion(), ALUT_API_MAJOR_VERSION, ALUT_API_MINOR_VERSION);
  }
  else
  {
    fprintf(stderr, "The ALUT library is at version %d.%d.x.\n", alutGetMajorVersion(), alutGetMinorVersion());
    ok = AL_TRUE;
  }
#else
  fprintf(stderr, "WARNING: Your copy of <AL/alut.h> is pre-1.0.0,\n");
  fprintf(stderr, "but you are running the ALUT test suite from ALUT\n");
  fprintf(stderr, "version 1.0.0 or later.\n");
#endif

  alutExit();
  return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
  Sound::~Sound() {
#ifndef DISABLE_AL
    delete m_bgm_source;
    delete m_bgm;
    alutExit();
#endif
  }
Example #9
0
int main(int argc, char **argv)
{
  /* Initialise ALUT and eat any ALUT-specific commandline flags. */
  if (!alutInit(&argc, argv))
  {
    ALenum error = alutGetError();

    fprintf(stderr, "%s\n", alutGetErrorString(error));
    exit(EXIT_FAILURE);
  }

  /* If everything is OK, play the sound files and exit when finished. */
  playFile("file1.wav");
  playFile("file2.au");
  playFile("file3.raw");

  if (!alutExit())
  {
    ALenum error = alutGetError();

    fprintf(stderr, "%s\n", alutGetErrorString(error));
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}
Example #10
0
void free_resources() {	
	if(resources.state & RS_SfxLoaded) {
		printf("-- freeing sounds\n");
		delete_sounds();
		printf("-- alutExit()\n");
		alutExit();
	}
	
	printf("-- freeing textures\n");
	delete_textures();
	
	printf("-- freeing models\n");
	delete_animations();
	
	printf("-- freeing VBOs\n");
	delete_vbo(&_vbo);
	
	if(resources.state & RS_ShaderLoaded) {
		printf("-- freeing FBOs\n");
		delete_fbo(&resources.fbg[0]);
		delete_fbo(&resources.fbg[1]);
		delete_fbo(&resources.fsec);
		
		printf("-- freeing shaders\n");
		delete_shaders();
	}
}
Example #11
0
void TextToSpeech::play_wav()
{
	// alutの初期化
	int alut_argc = 0;
	char* alut_argv[] = {};
	alutInit(&alut_argc, alut_argv);

	// ソースの用意
	ALuint buf;
	ALenum state;
	buf = alutCreateBufferFromFile(wav_filename_.c_str());
	alGenSources(1, &wav_src_);
	alSourcei(wav_src_, AL_BUFFER, buf);

	alSourcePlay(wav_src_);

	alGetSourcei(wav_src_, AL_SOURCE_STATE, &state);
	while (state == AL_PLAYING) {
		alGetSourcei(wav_src_, AL_SOURCE_STATE, &state);
	}

	// 後片付け
	alDeleteSources(1, &wav_src_);
	alDeleteBuffers(1, &buf);
	alutExit();
}
SimpleAudioEngine::~SimpleAudioEngine()
{
#ifdef ENABLE_MPG123
    mpg123_exit();
#endif
    alutExit();
}
ALSequencer::~ALSequencer()
{
	bDestroying = true;

	WaitForSingleObject(hThread, INFINITE);

	Stop();

	alutExit();

	ShutdownOpenAL();

	if (pOutput)
		free(pOutput);

	for (unsigned long ulLoop = 0; ulLoop < ulNumEffects; ulLoop++)
	{
		if (pEffectOutput[ulLoop])
			free(pEffectOutput[ulLoop]);
	}

	if (pWaveLoader)
	{
		for (int i = 0; i < fileCount; i++) {
			if (pWaveLoader->IsWaveID(files[i]))
				pWaveLoader->DeleteWaveFile(files[i]);
		}

		delete pWaveLoader;
	}
}
/**
    This method actually plays the file. Don't call this directly, as it won't be threaded. Use play_ogg instead.
*/
void ogg_player(char *filename, bool loop) {
    ogg_stream ogg;
    printf("Attempting to play %s...\n", filename);
    alutInit(0, 0);
    do {
        try {
            ogg.open(filename);
            #if debugAudio
                ogg.display();
            #endif
            if(!ogg.playback()) throw string("Ogg refused to play.\n");
            while(ogg.update()) {
                if(!ogg.playing()) {
                    if(!ogg.playback()) {
                        throw string("Ogg abruptly stopped.\n");
                    } else {
                        cout << "Ogg stream was interrupted.\n";
                    }
                }
            }
        } catch(string error) {
            cout << error;
            cin.get();
            ogg.release();
            return;
        }
        ogg.release();
        println("looping playback stream");
    } while (loop && running);
    alutExit();
    return;
}
Example #15
0
/* Interface method for stopping this service */
void SoundService::stop()
{
	for (SoundInstanceStore::iterator I = mInstances.begin(); I != mInstances.end(); ++I) {
		S_LOG_WARNING("Found a still registered SoundInstance when shutting down sound service. This shouldn't normally happen, since all instances should be handled by their proper owners and removed well in advance of the SoundService shutting down. We'll now delete the instance, which might lead to a segfault or similar problem as the instance owner might still expect it to be existing.");
		delete *I;
	}
	mInstances.clear();
	
	for (SoundSampleStore::iterator I = mBaseSamples.begin(); I != mBaseSamples.end(); ++I) {
		delete I->second;
	}
	mBaseSamples.clear();
	
 	if (isEnabled()) {
 		#ifndef __WIN32__
 			alutExit();
 		#else
 			alcMakeContextCurrent(nullptr);
 			alcDestroyContext(mContext);
 			alcCloseDevice(mDevice);
 			mDevice = 0;
 			mContext = 0;
 		#endif
 	}
	mEnabled = false;
	Service::stop();
}
Example #16
0
Audio :: ~Audio()
{
    auto l = lock();
    alcDestroyContext(m_pContext);
    alcCloseDevice(m_pDevice);
    alutExit();
}
Example #17
0
Sound::~Sound()
{
    alDeleteSources(NUM_SOUNDS, source_);
    alDeleteBuffers(NUM_SOUNDS, buffers_);

    alutExit();

}
// Start the sound sub-system
void SokobanSoundManager::Setup(void)
{
	// Initialise ALUT and eat any ALUT-specific command line flags
	if (!alutInit (NULL, NULL))
	{
		ALenum error = alutGetError ();
		fprintf (stderr, "%s\n", alutGetErrorString (error));
		// exit (EXIT_FAILURE);
		m_bIsSetup = false;
		return;
	}

	// Load the default sound
	//////////////////////////////////////////////////////////////////////////
	// NOTE: Cant use LoadSampleFromFile because if it fails it returns m_DefaultSoundID
	
	// Create an AL buffer from the given sound file
	m_DefaultSoundID = alutCreateBufferFromFile (".\\audio\\default.wav");
	if (m_DefaultSoundID == AL_NONE)
	{
		ALenum error = alutGetError ();
		fprintf (stderr, "Error loading file: '%s'\n", alutGetErrorString (error));
		alutExit ();
		// exit (EXIT_FAILURE);
		m_bIsSetup = false;
		return;
	}

	// Generate a single source
	alGenSources (1, &source);

	// Error check source generation
	ALenum error = alGetError ();
	if (error != ALUT_ERROR_NO_ERROR)
	{
		//	fprintf (stderr, "%s\n", alGetString (error));
		MessageBox (HWND_DESKTOP, alGetString(error), "Error 1", MB_OK | MB_ICONEXCLAMATION);
		alutExit ();
		exit (EXIT_FAILURE);
	}

	// toggle IsSetup
	m_bIsSetup = true;

	return;
}
Example #19
0
Lab::~Lab() {
    // Whale, whale, whale, what have we here?
    //
    //    ___\|/__
    //   /^  >    \/|
    //   \-_______/\|
    //
    alutExit();
}
SoundManager::~SoundManager(){
  // Stop all sources before deleting them
  for(int i = 0; i < nSources; ++i) {
    Stop(i);
  }
  AL_CHECK_ERR(alDeleteSources(MAX_SOURCES, sources));
  AL_CHECK_ERR(alDeleteBuffers(MAX_BUFFERS, buffers));
  AL_CHECK_ERR(alutExit());
}
Example #21
0
OpenALPlayer::~OpenALPlayer() {
    alDeleteSources(10, moveSources);
    alDeleteSources(10, eatSources);
    alDeleteSources(10, hitSources);
    alDeleteBuffers(1, &moveBufferNumber);
    alDeleteBuffers(1, &eatBufferNumber);
    alDeleteBuffers(1, &hitBufferNumber);
    alutExit();
}
Example #22
0
void GLApplication::destroy() {
	if (windowManager) {
		delete windowManager;
		windowManager = nullptr;
	}

	alutExit();

	objModel.destroy();

}
Example #23
0
static void
playFile (const char *fileName)
{
  ALuint buffer;
  ALuint source;
  ALenum error;
  ALint status;

  /* Create an AL buffer from the given sound file. */
  buffer = alutCreateBufferFromFile (fileName);
  if (buffer == AL_NONE)
    {
      error = alutGetError ();
      fprintf (stderr, "Error loading file: '%s'\n",
               alutGetErrorString (error));
      alutExit ();
      exit (EXIT_FAILURE);
    }

  /* Generate a single source, attach the buffer to it and start playing. */
  alGenSources (1, &source);
  alSourcei (source, AL_BUFFER, buffer);
  alSourcePlay (source);

  /* Normally nothing should go wrong above, but one never knows... */
  error = alGetError ();
  if (error != ALUT_ERROR_NO_ERROR)
    {
      fprintf (stderr, "%s\n", alGetString (error));
      alutExit ();
      exit (EXIT_FAILURE);
    }

  /* Check every 0.1 seconds if the sound is still playing. */
  do
    {
      alutSleep (0.1f);
      alGetSourcei (source, AL_SOURCE_STATE, &status);
    }
  while (status == AL_PLAYING);
}
Example #24
0
File: bind.cpp Project: Qard/jsgame
Handle<Value> ALUTExitCallback(const Arguments& args) {
	//if less that nbr of formal parameters then do nothing
	if (args.Length() < 0)
		return v8::Undefined();
	
	//get arguments

	//make call
	alutExit();
	
	return v8::Undefined();
}
Example #25
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;
}
Example #26
0
void close()
{
	SDL_DestroyRenderer(gRenderer);
	gRenderer = NULL;

	SDL_DestroyWindow(gWindow);
	gWindow = NULL;

	alutExit();
	IMG_Quit();
	TTF_Quit();
	SDL_Quit();
}
Example #27
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;
}
Example #28
0
	cSoundParser::~cSoundParser()
	{
		this->Destroy();
		m_siNumSoundManager--;
		if( m_siNumSoundManager == 0 )
		{
			SAFE_DELETE(cSoundParser::m_spbUsedBGSourceData);
			for( int i=0;i<m_siNumSourceID;++i )
			{
				alSourceStop(m_psuiSourceID[i]);
				alDeleteSources(1, &m_psuiSourceID[i]);
				int error = alGetError();
				if(error != AL_NO_ERROR)
				{
					//assert(0);
				}
			}
			SAFE_DELETE_ARRAY(m_psuiSourceID);
			SAFE_DELETE_ARRAY(m_psuiSourceUsingIDIndex);
	#ifdef DEBUG
			int error = alGetError();
			if(error != AL_NO_ERROR)
			{
				wchar_t*l_sterrorCode = 0;
				if( 0xA001 == error )
					l_sterrorCode = L"AL_INVALID_NAME";
				else
				if(error == 0xA002)
					l_sterrorCode = L"AL_INVALID_ENUM  File data type error??";
				else
				if(error == 0xA003)
					l_sterrorCode = L"AL_INVALID_VALUE";
				else
				if(error == 0xA004)
					l_sterrorCode = L"AL_INVALID_OPERATION";
				else
				if(error == 0xA005)
					l_sterrorCode = L"AL_OUT_OF_MEMORY";
				this->m_strErrorMsg += l_sterrorCode;
			}
	#endif
	#if defined(IOS) || defined(ANDROID)
			// destroy the context
			alcDestroyContext(m_pContext);
			// close the device
			alcCloseDevice(m_pDevice);
	#elif defined(WIN32)			
			alutExit();
	#endif
		}
	}
// virtual
void LLAudioEngine_OpenAL::shutdown()
{
	llinfos << "Entering LLAudioEngine::shutdown()" << llendl;

	LLAudioEngine::shutdown();

	llinfos << "Entering alutExit()" << llendl;
	if (!alutExit())
	{
		llwarns << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString(alutGetError()) << llendl;
	}
	else
	{
		llinfos << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << llendl;
	}

	delete mListenerp;
	mListenerp = NULL;

	ALenum error;

	alcMakeContextCurrent(NULL);
	error = alGetError();
	if (error != AL_NO_ERROR)
	{
		llinfos << "AL error: " << convertALErrorToString(error) << ". Could not make current context NULL!" << llendl;
	}

	alcDestroyContext(mContext);
	error = alGetError();
	if (error != AL_NO_ERROR)
	{
		llinfos << "AL error: " << convertALErrorToString(error) << ". Could not destroy context!" << llendl;
	}
	else
	{
		mContext = NULL;
	}

    alcCloseDevice(mDevice);
	error = alGetError();
	if (error != AL_NO_ERROR)
	{
		llinfos << "AL error: " << convertALErrorToString(error) << ". Could not close device!" << llendl;
	}
	else
	{
		mDevice = NULL;
	}
}
Example #30
0
int
main (int argc, char *argv[])
{
  alutInit (&argc, argv);
  checkForErrors ();

  printALUTInfo ();
  printALCInfo ();
  printALInfo ();
  checkForErrors ();

  alutExit ();

  return EXIT_SUCCESS;
}