void SoundEngine::togglePauseChannel(unsigned int channel)
{
    FMOD_BOOL etat;
    FMOD_CHANNEL *canal=getChannel(channel);
    FMOD_Channel_GetPaused(canal, &etat);

    if (etat == 1) // Si la chanson est en pause
        FMOD_Channel_SetPaused(canal, 0); // On enlève la pause
    else // Sinon, elle est en cours de lecture
        FMOD_Channel_SetPaused(canal, 1); // On met en pause
}
	void ModuleIrisAudio::FadeBgmThreadProc(int duration){
		bgmIsFading = true;
		int time = duration;
		while (time >= 0){
			float v;
			FMOD_Channel_SetPaused(bgmChannel, true);
			FMOD_Channel_GetVolume(bgmChannel, &v);
			FMOD_Channel_SetVolume(bgmChannel, v - v / (duration / 1000));
			time -= 1000;
			FMOD_Channel_SetPaused(bgmChannel, false);
			Sleep(1000);
		}
		FMOD_Channel_Stop(bgmChannel);
		bgmIsFading = false;
	}
	bool ModuleIrisAudio::MePlay(wstring filePath, int volume, int rate){
		string sfilepath = WStringToString(filePath);
		const char* fpath = sfilepath.c_str();

		if (channels == 0){
			if (meChannel != NULL){
				BOOL isPlaying;
				FMOD_Channel_IsPlaying(meChannel, &isPlaying);
				if (isPlaying)
					FMOD_Channel_Stop(meChannel);
			}
		}

		FMOD_RESULT result;

		result = FMOD_System_CreateStream(fmodSystem, fpath, FMOD_DEFAULT, 0, &me);
		if (result != FMOD_OK)
			return false;

		result = FMOD_System_PlaySound(fmodSystem, FMOD_CHANNEL_FREE, me, true, &meChannel);
		if (result != FMOD_OK)
			return false;

		FMOD_Channel_SetMode(meChannel, FMOD_LOOP_NORMAL);
		FMOD_Channel_SetVolume(meChannel, volume / 100.0f);

		float frequancy;

		FMOD_Channel_GetFrequency(meChannel, &frequancy);
		FMOD_Channel_SetFrequency(meChannel, frequancy * (rate / 100.0));
		FMOD_Channel_SetPaused(meChannel, FALSE);

		return true;
	}
Example #4
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;
}
// ----------------------------------------------------------------------------
void ofxSoundPlayerFMOD::setPaused(bool bP)
{
	if (getIsPlaying() == true){
		FMOD_Channel_SetPaused(channel,bP);
		bPaused = bP;
	}
}
Example #6
0
// toggles pause/unpause
void Sound::togglePause(void)
{
  FMOD_BOOL p;

  FMOD_Channel_GetPaused(channel, &p);
  FMOD_Channel_SetPaused(channel, !p);
}
Example #7
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;
}
Example #8
0
INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority)
{
	FMOD_SOUND *sound;
	FMOD_CHANNEL *chan;
	INT32 i;
	float frequency;

	sound = (FMOD_SOUND *)S_sfx[id].data;
	I_Assert(sound != NULL);

	FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, sound, true, &chan));

	if (sep == 0)
		sep = 1;

	FMR(FMOD_Channel_SetVolume(chan, (vol / 255.0) * (sfx_volume / 31.0)));
	FMR(FMOD_Channel_SetPan(chan, (sep - 128) / 127.0));

	FMR(FMOD_Sound_GetDefaults(sound, &frequency, NULL, NULL, NULL));
	FMR(FMOD_Channel_SetFrequency(chan, (pitch / 128.0) * frequency));

	FMR(FMOD_Channel_SetPriority(chan, priority));
	//UNREFERENCED_PARAMETER(priority);
	//FMR(FMOD_Channel_SetPriority(chan, 1 + ((0xff-vol)>>1))); // automatic priority 1 - 128 based on volume (priority 0 is music)

	FMR(FMOD_Channel_GetIndex(chan, &i));
	FMR(FMOD_Channel_SetPaused(chan, false));
	return i;
}
Example #9
0
void whitgl_sound_play(int id, float adjust)
{
	int index = -1;
	int i;
	for(i=0; i<num_sounds; i++)
	{
		if(sounds[i].id == id)
		{
			index = i;
			continue;
		}
	}
	if(index == -1)
	{
		WHITGL_LOG("ERR Cannot find sound %d", id);
		return;
	}

	FMOD_RESULT result = FMOD_System_PlaySound(fmodSystem, FMOD_CHANNEL_FREE, sounds[index].sound, true, &sounds[index].channel);
	_whitgl_sound_errcheck("FMOD_System_PlaySound", result);

	float defaultFrequency;
	result = FMOD_Sound_GetDefaults(sounds[index].sound, &defaultFrequency, NULL, NULL, NULL);
	_whitgl_sound_errcheck("FMOD_Sound_GetDefaults", result);
	result = FMOD_Channel_SetFrequency(sounds[index].channel, defaultFrequency*adjust);
	_whitgl_sound_errcheck("FMOD_Channel_SetFrequency", result);
	result = FMOD_Channel_SetPaused(sounds[index].channel, false);
	_whitgl_sound_errcheck("FMOD_Channel_SetPaused", result);
}
Example #10
0
void sound_toggle_pause(void)
{
    if (loaded) {
        FMOD_BOOL p;
        FMOD_Channel_GetPaused(_channel,&p);
        FMOD_Channel_SetPaused (_channel,!p);
    }
}
Example #11
0
bool	Sound::unpauseSound()
{
  if (this->_channel)
    {
      FMOD_Channel_SetPaused(this->_channel, false);
      return (true);
    }
  return (false);
}
Example #12
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();
		}
}
Example #13
0
void Audio::pauseMusique() {
	if(!_canalMusique)
		return;
	
	FMOD_BOOL pause;
	FMOD_Channel_GetPaused(_canalMusique, &pause);
	
	FMOD_Channel_SetPaused(_canalMusique, !pause);
}
Example #14
0
void Sound::load() {
    if (loaded) {
        FMOD_Sound_Release(audio);
    }
    char *path = &location[0u];
    FMOD_System_CreateSound(system, path, FMOD_SOFTWARE, 0, &audio);
    FMOD_Channel_SetChannelGroup(channel, channelGroup);
    FMOD_Channel_SetPaused(channel, true);
    loaded = true;
}
Example #15
0
void set_paused(FMOD_CHANNEL **channel, int paused)
{
    FMOD_RESULT result;
    unsigned int blocksize;
    
    result = FMOD_System_GetDSPBufferSize(gSystem, &blocksize, 0);
    ERRCHECK(result);

    if (!paused)
    {
        unsigned int pausestart_hi = 0, pausestart_lo = 0;

        FMOD_System_GetDSPClock(gSystem, &pausestart_hi, &pausestart_lo);
        
        FMOD_64BIT_ADD(pausestart_hi, pausestart_lo, 0, blocksize * 2);   /* Into the future by 2 mixer blocks. */
        printf("\npause BOTH at %d \n", pausestart_lo);
       
        /* Make them both pause at exactly the same tick.  Mute them both to avoid a click as well. */
        FMOD_Channel_SetMute(channel[0], TRUE);
        FMOD_Channel_SetDelay(channel[0], FMOD_DELAYTYPE_DSPCLOCK_PAUSE, pausestart_hi, pausestart_lo);
        FMOD_Channel_SetMute(channel[1], TRUE);
        FMOD_Channel_SetDelay(channel[1], FMOD_DELAYTYPE_DSPCLOCK_PAUSE, pausestart_hi, pausestart_lo);
    }
    else
    {
        unsigned int syshi, syslo;
        int count;

        FMOD_System_GetDSPClock(gSystem, &syshi, &syslo);

        printf("\nunpause BOTH at %d\n", syslo);
        
        for (count = 0; count < 2; count++)
        { 
            unsigned int starttime_hi, starttime_lo; 
            unsigned int pausetime_hi = 0, pausetime_lo = 0;
            unsigned int hi = syshi, lo = syslo;
            
            FMOD_Channel_GetDelay(channel[count], FMOD_DELAYTYPE_DSPCLOCK_PAUSE, &pausetime_hi, &pausetime_lo);
            FMOD_Channel_GetDelay(channel[count], FMOD_DELAYTYPE_DSPCLOCK_START, &starttime_hi, &starttime_lo);

            FMOD_64BIT_ADD(hi, lo, 0, blocksize * 2);                   /* Push operation into the future by 2 mixer blocks so it doesnt conflict with mixer. */
            if (starttime_lo > pausetime_lo)                            /* Was already playing, unpause immediately. */
            {
                FMOD_64BIT_ADD(hi, lo, starttime_hi, starttime_lo);     /* Push forward the delayed start by the gap between starting and pausing */
                FMOD_64BIT_SUB(hi, lo, pausetime_hi, pausetime_lo);     /* Push forward the delayed start by the gap between starting and pausing */
            }
            printf("restart %d at %d\n", count, lo);
            FMOD_Channel_SetDelay(channel[count], FMOD_DELAYTYPE_DSPCLOCK_PAUSE, 0, 0);
            FMOD_Channel_SetDelay(channel[count], FMOD_DELAYTYPE_DSPCLOCK_START, hi, lo);
            FMOD_Channel_SetMute(channel[count], FALSE);
            FMOD_Channel_SetPaused(channel[count], FALSE);
        }
    }
}
Example #16
0
void Java_org_fmod_realtimestitching_Example_cPause(JNIEnv *env, jobject thiz)
{
	FMOD_RESULT result = FMOD_OK;
	FMOD_BOOL paused = 0;

	result = FMOD_Channel_GetPaused(gChannel, &paused);
	CHECK_RESULT(result);

	result = FMOD_Channel_SetPaused(gChannel, !paused);
	CHECK_RESULT(result);
}
Example #17
0
void pause_fiend_music(void)
{
	FMOD_BOOL paused;
	if(!sound_is_on)return;
	if(strcmp(current_music,"none")==0)return;
	
	FMOD_Channel_GetPaused(fmod_music_channel, &paused);
	if(!paused)
	{
		FMOD_Channel_SetPaused(fmod_music_channel, TRUE);
	}
}
Example #18
0
void MOD_Resume (void)
{
	if(SND_Initialised == false || SND_MusicChannel.inuse == false)
		return;

	if(SND_MusicChannel.paused == true)
	{
		result = FMOD_Channel_SetPaused(SND_MusicChannel.channel, false);
		FMOD_ERROR(result, true, false);

		SND_MusicChannel.paused = false;
	}
}
Example #19
0
void CSound::Resume(void) {
	// Check if we have a sound loaded
	if (!mLoaded) {
		return;
	}
#if __ENABLE_CFMOD
	// Check if we have a valid channel
	if (0 != mpChannel) {
		// Resume the channel that is playing the sound
		FMOD_Channel_SetPaused(mpChannel, 0);
	}
#endif
}
Example #20
0
void        FMODSound::play(void)
{
  if (this->_channel)
    {
      FMOD_Channel_GetPaused(this->_channel, &(this->_tmp));
    }
  if (this->_tmp == true)
    FMOD_Channel_SetPaused(this->_channel, false);
  else
    FMOD_System_PlaySound(this->_system, FMOD_CHANNEL_FREE,
			  this->_sound, 0, &(this->_channel));
  FMOD_Channel_SetVolume(this->_channel, this->_volume);
}
Example #21
0
/*
---------------------------------------
    暂停播放
---------------------------------------
*/
static bool_t
iXMM_FMOD_pause (
  __CR_IN__ iXMMEDIA*   that
    )
{
    iXMM_FMOD*  real;
    FMOD_RESULT result;

    real = (iXMM_FMOD*)that;
    result = FMOD_Channel_SetPaused(real->m_chn, TRUE);
    if (result != FMOD_OK)
        return (FALSE);
    return (TRUE);
}
Example #22
0
Sound::Sound(const Sound &_sound)
{
	//FMOD_SOUND *temp = *&_sound.sound;
	this->sound = *&_sound.sound;
	f_pos = _sound.f_pos;
	f_vel = _sound.f_vel;
	*result = FMOD_Channel_Set3DAttributes(channel,&f_pos,&f_vel);
	ERRCHECK();
	*result = FMOD_Channel_SetPaused(channel, true);
	ERRCHECK();

	pos = new Vector(_sound.pos->X_Y_Z[0],_sound.pos->X_Y_Z[1],_sound.pos->X_Y_Z[2]);
	vel = new Vector(_sound.vel->X_Y_Z[0],_sound.vel->X_Y_Z[1],_sound.vel->X_Y_Z[2]);
}
	/// starts or continue playing, true if successfull
	virtual const bool Play(){
		if(IsPlaying())return true;
		if(IsPaused()){
			// unpause sound
			if(mpChannel){
				result = FMOD_Channel_SetPaused(mpChannel,false);
				ERRCHECK(result);
			}
		} else {
			// start playing
			mpChannel = 0;
			// alloc channel
			if(mpSound && mSoundSystem && mSoundSystem->mpSystem){
				result = FMOD_System_PlaySound(mSoundSystem->mpSystem, FMOD_CHANNEL_FREE, mpSound, true, &mpChannel);
				ERRCHECK(result);
			}
			
			// channel free and working?
			if(mpChannel){
				
				if(mb3D){
					// set 3d position and velocity data
					result = FMOD_Channel_Set3DAttributes(mpChannel, &mlPos, &mlVel);
					ERRCHECK(result);
					// set currently set minmax distances
					SetMinMaxDistance(mfMinDistance,mfMaxDistance);
				} 
				
				result = FMOD_Channel_SetPaused(mpChannel,false);
				ERRCHECK(result);
				
				return true;
			} else return false;
		}
		return false;
	}
Example #24
0
void Sound::Resume()
{
	// Check if we have a sound loaded
	if (!mLoaded)
	{
		return;
	}

	// Check if we have a valid channel
	if (0 != mpChannel)
	{
		// Resume the channel that is playing the sound
		FMOD_Channel_SetPaused(mpChannel, 0);		
	}
}
Example #25
0
void resume_all_sounds(void)
{
	int i;

	if(!sound_is_on)return;
	
	for(i=0;i<MAX_SOUNDS_PLAYING;i++)
	{
		if(sound_data[i].used)
		{
			FMOD_Channel_SetPaused(sound_data[i].voice_num,FALSE);
			sound_data[i].used=0;
		}
	}

}
Example #26
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);
}
Example #27
0
void CDA_Resume (void)
{
#ifdef UQE_FMOD_CDAUDIO

	if(SND_InitialisedCD == false || SND_MusicChannel.inuse == false)
		return;

	if(SND_MusicChannel.paused == true)
	{
		result = FMOD_Channel_SetPaused(SND_MusicChannel.channel, false);
		FMOD_ERROR(result, true, false);

		SND_MusicChannel.paused = false;
	}
#else
	CDAudio_Resume();
#endif
}
Example #28
0
Sound::Sound(const char *file, int _mode,Vector &_pos, Vector&_vel, FMOD_SYSTEM *_system, FMOD_RESULT &_result)
{
	system = _system;
	result = &_result;
	if(_mode > 1)
	{
		mode =_mode = 0;
	}else
	{
		mode = _mode;
	}
	
	switch(_mode)
	{
	case SOUND:
		*result = FMOD_System_CreateSound(system, file, FMOD_DEFAULT, 0, &sound);
		this->setSoundMode(FMOD_LOOP_OFF);
		break;
	case STREAM:
		*result =  FMOD_System_CreateStream(system, file, FMOD_DEFAULT, 0,&sound);
		this->setSoundMode(FMOD_LOOP_NORMAL);
		break;
	}
	ERRCHECK();

	pos = &_pos;
	vel = &_vel;

	f_pos.x = pos->X_Y_Z[0];
	f_pos.y = pos->X_Y_Z[1];
	f_pos.z = pos->X_Y_Z[2];

	f_vel.x = vel->X_Y_Z[0];
	f_vel.y = vel->X_Y_Z[1];
	f_vel.z = vel->X_Y_Z[2];

	//*result = channel->set3DAttributes(&f_pos,&f_vel);
	*result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, true, &channel);
	ERRCHECK();
	*result = FMOD_Channel_Set3DAttributes(channel,&f_pos,&f_vel);
	ERRCHECK();
	*result = FMOD_Channel_SetPaused(channel, true);
	ERRCHECK();
}
Example #29
0
void PlayStereoFrequency( short player, short which, short freq )
{
	if( soundOn )
	{
		float oldFreq;
		FMOD_System_PlaySound( fmodSystem, FMOD_CHANNEL_FREE, sound[which], true, &soundChannel[player] );
		// SetPan pans the sound from -1 (full left) to 1 (full right).
		// which means player 0 should be -1 and player 1 should be 1.
		// Except hard panning sounds kind of bad so player 0 should be
		// -0.75 and player 1 should be 0.75.
		if( playerWindowVisible[1] ) {
			FMOD_Channel_SetPan( soundChannel[player], -0.75f + 1.5f * player );
		} else {
			FMOD_Channel_SetPan( soundChannel[player], 0.0f );
		}
		FMOD_Channel_GetFrequency( soundChannel[player], &oldFreq );
		FMOD_Channel_SetFrequency( soundChannel[player], oldFreq * (16 + freq)/ 16 );
		FMOD_Channel_SetPaused( soundChannel[player], false );
	}
}
Example #30
0
int main(int argc, char **argv)
{
	setup_ui(&argc, &argv);

	FMOD_SOUND *soundtrack;
	FMOD_CHANNEL *channel1;

	FMOD_VECTOR position = { 0, 0, 0 };
	FMOD_VECTOR velocity = { 0, 0, 0 };
	FMOD_VECTOR forward = { 0, 0, 1 };
	FMOD_VECTOR up = { 0, 1, 0 };

	FMOD_System_Create(&fsystem);
	FMOD_System_Init(fsystem, 100, FMOD_INIT_NORMAL, NULL);
	FMOD_System_Set3DSettings(fsystem, 1.0f, 1.0f, 1.0f);

	FMOD_System_CreateSound(fsystem, argc < 2 ? "../sounds/blast.wav" : argv[1], FMOD_3D | FMOD_LOOP_NORMAL, 0, &soundtrack);
	FMOD_System_PlaySound(fsystem, soundtrack, NULL, 1, &channel1);
	FMOD_Channel_Set3DAttributes(channel1, &position, &velocity, NULL);
	FMOD_Channel_SetPaused(channel1, 0);

	FMOD_System_Set3DListenerAttributes(fsystem, 0, &position, &velocity, &forward, &up);
	FMOD_System_Update(fsystem);

	gtk_main();

	/*int i = 0;
	while (i < 500) {
		i++;
		FMOD_System_Update(fsystem);

		struct timespec sleepTime = { 0, 50 * 1000 * 1000 };
		nanosleep(&sleepTime, NULL);
	}*/

	FMOD_Sound_Release(soundtrack);
	FMOD_System_Close(fsystem);
	FMOD_System_Release(fsystem);
}