Esempio n. 1
0
bool COggVorbisFileHelper::play()
{
	int16 dummydata[16];
	memset(dummydata, 0, 16);
	if( nStatus == OH_STOPPED)
	{
		stop();
		nStatus = OH_BUFFERING;
		bStopDecoding = false;
		if(mDecThread.thread_status == CThread::TIDLE) mDecThread.Start(this);
		s3eSoundChannelPlay(nSoundChannel, dummydata,8, 1, 0);
		return true;
	}
	if (nStatus == OH_PAUSED) 
	{
		resume();
		return true;
	}
	if(nStatus == OH_READY)
	{
		//buffering
		nStatus = OH_BUFFERING;
		bStopDecoding = false;
		if(mDecThread.thread_status == CThread::TIDLE) mDecThread.Start(this);
		s3eSoundChannelPlay(nSoundChannel, dummydata,8, 1, 0);
		
		return true;
	}
	return false;
}
Esempio n. 2
0
s3eResult Play(int i, int repeat)
{
    if (g_UseSoundPool)
        return s3eSoundPoolSamplePlay(g_Samples[i], repeat, 0);
    else
        return s3eSoundChannelPlay(i, g_SampleData[i], g_SampleDataLen[i]/2, repeat, 0);
}
Esempio n. 3
0
void Sounds::playSound(Sounds::Sound* sound) {
	if(Settings::getInstance()->soundEnabled == false)
		return;
	int channel = s3eSoundGetFreeChannel();
	if(s3eSoundChannelPlay(channel, sound->buffer, sound->fileSize/2, 1, 0) == S3E_RESULT_ERROR) {
		char buffer[200];
		sprintf(buffer, "Error in s3eSoundChannelPlay: %s", s3eSoundGetErrorString());
		IGLog(buffer);
	}
}
void ResourceManager::PlayAudio(uint32 audioHandle)
{
    if(audioHandle == 0 || audioHandle >= audioData->size() || audioData->at(audioHandle) == null)
    {
        return;
    }

    int channel = s3eSoundGetFreeChannel();

    s3eSoundChannelPlay(channel, audioData->at(audioHandle), audioSizes->at(audioHandle)/2, 1, 0);
}
Esempio n. 5
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;
}
	unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath)
	{
					
		
		int channel = s3eSoundGetFreeChannel();
		
		s3eSoundChannelPlay(channel, g_SoundBuffer, g_SoundFileSize/2, 1, 0);
		
		if (s3eSoundGetError()!= S3E_SOUND_ERR_NONE)
		{
			IwAssertMsg(GAME, this, ("Play sound %s Failed. Error Code : %s", pszFilePath, s3eSoundGetErrorString()));	
		}

		return channel;

	}
Esempio n. 7
0
	unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop)
	{
		SoundFxMap::iterator it = g_pSoundFxMap->find(pszFilePath) ;
		
		int16* buff = 0 ;
		if( it==g_pSoundFxMap->end() ) {
			preloadEffect(pszFilePath) ;
		}
		buff = (*g_pSoundFxMap)[pszFilePath].data ;

		int channel = s3eSoundGetFreeChannel();
		
		s3eSoundChannelPlay(channel, buff, (*g_pSoundFxMap)[pszFilePath].size/2, (bLoop ? 0 : 1), 0);
		
		if (s3eSoundGetError()!= S3E_SOUND_ERR_NONE) {
			IwAssertMsg(GAME, false, ("Play sound %s Failed. Error Code : %s", pszFilePath, s3eSoundGetErrorString()));	
		}

		return channel;

	}
	unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop)
	{
		// Changing file path to full path
		std::string fullPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);

		SoundFxMap::iterator it = g_pSoundFxMap->find(fullPath) ;
		
		int16* buff = 0 ;
		if( it==g_pSoundFxMap->end() ) {
			preloadEffect(fullPath.c_str()) ;
		}
		buff = (*g_pSoundFxMap)[fullPath].data ;

		int channel = s3eSoundGetFreeChannel();
		
		s3eSoundChannelPlay(channel, buff, (*g_pSoundFxMap)[fullPath].size/2, (bLoop ? 0 : 1), 0);
		
		if (s3eSoundGetError()!= S3E_SOUND_ERR_NONE) {
			IwAssertMsg(GAME, false, ("Play sound %s Failed. Error Code : %s", fullPath.c_str(), s3eSoundGetErrorString()));	
		}

		return channel;

	}