Esempio n. 1
0
bool Audio::Play(Sample *sample)
{
    FMOD_RESULT res;
    if (sample == NULL) return false;
    if (sample->sample == NULL) return false;

    try {
        res = FMOD_System_PlaySound(
                  system,
                  FMOD_CHANNEL_FREE,
                  sample->sample,
                  true,
                  &sample->channel);

        if (res!= FMOD_OK) return false;

        FMOD_Channel_SetLoopCount(sample->channel, -1);
        FMOD_Channel_SetPaused(sample->channel, false);

    } catch (...) {
        return false;
    }

    return true;
}
Esempio n. 2
0
bool Audio::Play(std::string name)
{
    FMOD_RESULT res;
    Sample *sample = FindSample(name);
//***BUG
    if (!sample) return false;

    if (sample->sample != NULL) {
        try {
            //sample found, play it
            res = FMOD_System_PlaySound(
                      system,
                      FMOD_CHANNEL_FREE,
                      sample->sample,
                      true,
                      &sample->channel);

            if (res!= FMOD_OK) return false;

            FMOD_Channel_SetLoopCount(sample->channel, -1);
            FMOD_Channel_SetPaused(sample->channel, false);

        } catch (...) {
            return false;
        }
    }

    return true;
}
Esempio n. 3
0
void AudioManager::Play( const AudioManager::AudioType Type,
                         const string& ID,
                         const float Volume,
                         const float Pitch,
                         const float Pan,
                         const int32_t LoopCount,
                         const int32_t Priority,
                         const FMOD_CHANNELINDEX ChannelIndex )
{
	// Create local variables.

		float Frequency = Null;
		FMOD_CHANNEL* Channel = nullptr;
		unordered_map< string, SoundData >::iterator AudioMapIterator;

	// Check arguments.

		if( Type == MaxAudioTypes )
			throw exception();

	// Playback specified audio sample or stream.

		if( Initialized )
		{
			AudioMapIterator = AudioMaps[ Type ].Instance.find( ID );

			if( AudioMapIterator == AudioMaps[ Type ].Instance.end() )
				throw exception();

			if( FMOD_System_PlaySound( SystemInstance, ChannelIndex, AudioMapIterator->second.Instance, true, &Channel ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_SetChannelGroup( Channel, AudioMapIterator->second.Group ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_SetLoopCount( Channel, LoopCount ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_SetPriority( Channel, Priority ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_SetPan( Channel, Pan ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_GetFrequency( Channel, &Frequency ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_SetFrequency( Channel, ( Frequency * Pitch ) ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_SetVolume( Channel, Volume ) != FMOD_OK )
				throw exception();

			if( FMOD_Channel_SetPaused( Channel, false ) != FMOD_OK )
				throw exception();
		}
}
Esempio n. 4
0
void Sound::Play(bool bLoop)
{
	// Check if we have a sound loaded
	if (!mLoaded)
	{
		return;
	}

	// Stop any previous sound first
	Stop();

	// Check if we are already playing
	FMOD_System_PlaySound(FMODBridge::Get()->FMODSystem(), FMOD_CHANNEL_FREE, mpSound, true, &mpChannel);
	FMOD_Channel_SetLoopCount(mpChannel, bLoop ? -1 : 0);
	FMOD_Channel_SetVolume(mpChannel, mVolume);
	FMOD_Channel_SetPaused(mpChannel, false);
}
Esempio n. 5
0
 void sound::loop(int num)
 {
     FMOD_Channel_SetLoopCount(_chan, num);
 }
Esempio n. 6
0
FMOD_RESULT bmx_FMOD_Channel_SetLoopCount(MAX_FMOD_CHANNEL *channel, int loopcount) {
    return FMOD_Channel_SetLoopCount(channel->channel, loopcount);
}