Exemplo n.º 1
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;
}
Exemplo n.º 2
0
void Audio::Stop(std::string name)
{
    if (!IsPlaying(name)) return;

    Sample *sample = FindSample(name);
    if (sample == NULL) return;

    FMOD_Channel_Stop(sample->channel);
}
Exemplo n.º 3
0
bool Audio::IsPlaying(std::string name)
{
    Sample *samp = FindSample(name);
    if (samp == NULL) return false;

    int index;
    FMOD_Channel_GetIndex(samp->channel, &index);

    // FMOD returns 99 if sample is playing, 0 if not
    return (index > 0);

}
Exemplo n.º 4
0
	bool Audio::SetVolume(std::string filename, float level) {
		Sample *sample = FindSample(filename);
//***BUG
		if (!sample) return false;
		
		if (sample->sample != NULL) {
			try {
				FMOD_Channel_SetVolume(sample->channel,level);
			} catch (...) {
				return false;
			}
		}
	
		return true;
	}