void Sound::Init(int _channels)
{
	s_result = FMOD_System_Create(&s_fmod_system);
	assert(s_result == FMOD_OK);
	//Initializes the system with 1 channel
	s_result = FMOD_System_Init(s_fmod_system, _channels, FMOD_INIT_NORMAL, 0);
	assert(s_result == FMOD_OK);
	FMOD_Channel_SetVolume(s_channel, 0.0f);
}
Beispiel #2
0
bool QSPCallBacks::SetVolume(QSPString file, int volume)
{
    if (!IsPlay(file)) return false;
    QSPSounds::iterator elem = m_sounds.find(wxFileName(wxString(file.Str, file.End), wxPATH_DOS).GetFullPath().Upper());
    QSPSound *snd = (QSPSound *)&elem->second;
    snd->Volume = volume;
    FMOD_Channel_SetVolume(snd->Channel, (float)(m_volumeCoeff * volume) / 100);
    return true;
}
Beispiel #3
0
    void play(){
        if(sound){
            FMOD_RESULT result = FMOD_System_PlaySound(System, FMOD_CHANNEL_FREE, sound, false, &channel);

            if(result == FMOD_OK){
                FMOD_Channel_SetVolume(channel, Config.EffectVolume);
                FMOD_System_Update(System);
            }
        }
    }
Beispiel #4
0
void Sound::init() {
  //create the sound system. If fails, sound is set to impossible
  result = FMOD_System_Create(&fmodsystem);
  if (result != FMOD_OK) possible = false;
  //if initialise the sound system. If fails, sound is set to impossible
  if (possible) result = FMOD_System_Init(fmodsystem, 2, FMOD_INIT_NORMAL, 0);
  if (result != FMOD_OK) possible = false;
  //sets initial sound volume (mute)
  if (possible) {FMOD_Channel_SetVolume(channel, 0.0f); printf("sadsad\n");}
}
Beispiel #5
0
void Systems::SoundSystem::PlaySound(FMOD_CHANNEL** channel, FMOD_SOUND* sound, float volume, bool loop)
{
	FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, sound, false, channel);
	FMOD_Channel_SetVolume(*channel, volume);
	if(loop)
	{
		FMOD_Channel_SetMode(*channel, FMOD_LOOP_NORMAL);
		FMOD_Sound_SetLoopCount(sound, -1);
	}
}
    void play(const bool doubleVolume = false)
    {
        if (sound) {
            FMOD_RESULT result = FMOD_System_PlaySound(System, FMOD_CHANNEL_FREE, sound, false, &channel);

            if (result == FMOD_OK) {
                FMOD_Channel_SetVolume(channel, (doubleVolume ? 2 : 1) * Config.EffectVolume);
                FMOD_System_Update(System);
            }
        }
    }
Beispiel #7
0
void Sound::play(float vol){
	if(vol==0)return;
	FMOD_RESULT r;
	if( !this->ch ){
		r = FMOD_System_PlaySound( parent->sys, FMOD_CHANNEL_FREE, sound, 0, & this->ch );
	} else {
		r = FMOD_System_PlaySound( parent->sys, FMOD_CHANNEL_REUSE, sound, 0, & this->ch );            
	}
	FMOD_ERRCHECK(r);
	FMOD_Channel_SetVolume(ch, default_volume * vol );
}
void Audio::playBGM(const QString &filename)
{
    FMOD_RESULT result = FMOD_System_CreateStream(System, filename.toLocal8Bit(), FMOD_LOOP_NORMAL, NULL, &BGM);

    if (result == FMOD_OK) {
        FMOD_Sound_SetLoopCount(BGM, -1);
        FMOD_System_PlaySound(System, FMOD_CHANNEL_FREE, BGM, false, &BGMChannel);

        FMOD_Channel_SetVolume(BGMChannel, Config.BGMVolume);
        FMOD_System_Update(System);
    }
}
Beispiel #9
0
boolean I_PlaySong(INT32 handle, boolean looping)
{
	if (1337 == handle)
	{
		midimode = true;
		if (looping)
			FMR(FMOD_Sound_SetMode(music_stream, FMOD_LOOP_NORMAL));
		FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel));
		FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0));
		FMR_MUSIC(FMOD_Channel_SetPriority(music_channel, 0));
	}
	return true;
}
Beispiel #10
0
bool 	Sound::setVolume(float value)
{
  if (this->_channel)
    {
      if (FMOD_Channel_SetVolume(this->_channel, value))
	{
	  //std::cerr << "Error on setting volume sound " + this->_name << std::endl;
	  return (false);
	}
      return (true);
    }
  return (false);
}
Beispiel #11
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);
}
Beispiel #12
0
void		sound_play(eSound snd, float vol, float pan, float freq)
{
    static Sound*	s;

    if (!s)
        s = &((Data*)SDLazy_GetData())->sound;

    FMOD_System_PlaySound(s->system, FMOD_CHANNEL_FREE, s->mp3[snd], 0, &s->chan);
    FMOD_Channel_SetVolume(s->chan, vol);
    FMOD_Channel_SetPan(s->chan, pan);
    FMOD_Channel_SetFrequency(s->chan, freq);

    FMOD_System_Update(s->system);
}
	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;
	}
Beispiel #14
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;
	}
Beispiel #15
0
	SoundID AudioPlayer::playSound( ResID id , float volume , bool beLoop )
	{
		SoundRes* res = getSound( id );
		if ( res == NULL )
			return ERROR_SOUND_ID;

		FMOD_CHANNEL* channel;
		FMOD_System_PlaySound( mFmodSys , FMOD_CHANNEL_FREE , res->sound , false , &channel );
		FMOD_Channel_SetVolume( channel , volume * res->volume * mSoundVolume );
		FMOD_Channel_SetCallback( channel ,ChannelCallBack );

		if ( beLoop )
			FMOD_Channel_SetMode( channel ,FMOD_LOOP_NORMAL );

		return registerChannel( channel );
	}
Beispiel #16
0
// seems to never be called on an invalid channel (calls I_SoundIsPlaying first?)
// so I'm not gonna worry about it.
void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch)
{
	FMOD_CHANNEL *chan;
	FMOD_SOUND *sound;
	float frequency;

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

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

	//FMR(FMOD_Channel_SetPriority(chan, 1 + ((0xff-vol)>>1))); // automatic priority 1 - 128 based on volume (priority 0 is music)
}
bool ClientActionToneMelody::runAction()
{
    FMOD_RESULT result;
    if (!system) {
        channel = 0;
        result = FMOD_System_Create(&system);
        ERRCHECK(result);
        FMOD_System_SetDSPBufferSize(system, 64, 1);
        result = FMOD_System_Init(system, 2, FMOD_INIT_STREAM_FROM_UPDATE | FMOD_INIT_MIX_FROM_UPDATE, NULL);
        ERRCHECK(result);
        result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_OSCILLATOR, &dsp);
        ERRCHECK(result);
    }

    if (channel) {
        result = FMOD_Channel_Stop(channel);
        ERRCHECK(result);
        channel = 0;
    }

    if (tone_frequency) {

        result = FMOD_DSP_SetParameterFloat(dsp, FMOD_DSP_OSCILLATOR_RATE, (float) tone_frequency);
        ERRCHECK(result);
        result = FMOD_System_PlayDSP(system, dsp, 0, true, &channel);
        ERRCHECK(result);
        result = FMOD_Channel_SetVolume(channel, 1.0f);
        ERRCHECK(result);

        result = FMOD_DSP_SetParameterInt(dsp,FMOD_DSP_OSCILLATOR_TYPE, 1);
        ERRCHECK(result);
        StartMelodyTone(settings->value("MELODY"));

        updateTimer->start();
        settings->insert("ACTIVE", "1");
    } else {
        updateTimer->stop();
        periodicToneTimer->stop();
        prog_led_tone_control = false;
        tone_state = false;
        tone_periodic = false;
        tone_period = 0;
        settings->insert("ACTIVE", "0");
    }

    return true;
}
Beispiel #18
0
void Audio::jouerSon(audio_t son, bool boucle) throw(Audio::Exc_Son) {
	if(boucle)
		FMOD_Sound_SetLoopCount(son, -1);
	else
		FMOD_Sound_SetLoopCount(son, 0);

	FMOD_CHANNEL *c = 0;
	resultat = FMOD_System_PlaySound(_systeme, FMOD_CHANNEL_FREE, son, false, &c);
	erreur(resultat, 7);
	
	int nb;
	FMOD_Channel_GetIndex(c, &nb);
	_canaux[nb] = c;
	
	FMOD_Channel_SetCallback(c, &sonStoppe);
	FMOD_Channel_SetVolume(c, Parametres::volumeEffets());
}
Beispiel #19
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);
}
Beispiel #20
0
void Audio::jouerMusique() throw(Audio::Exc_Son) {
	if(_canalMusique) {
		FMOD_BOOL pause;
		FMOD_Channel_GetPaused(_canalMusique, &pause);
		if(!pause)
			return;
	}
	
	resultat = FMOD_System_PlaySound(_systeme, FMOD_CHANNEL_FREE, _musique, false, &_canalMusique);
	erreur(resultat, 8);
	
	int nb;
	FMOD_Channel_GetIndex(_canalMusique, &nb);
	_canaux[nb] = _canalMusique;
		
	FMOD_Channel_SetVolume(_canalMusique, Parametres::volumeMusique());
}
Beispiel #21
0
void QSPCallBacks::SetOverallVolume(float coeff)
{
	QSPSound *snd;
	FMOD_BOOL playing = FALSE;
	if (coeff < 0.0)
		coeff = 0.0;
	else if (coeff > 1.0)
		coeff = 1.0;
	m_volumeCoeff = coeff;
	for (QSPSounds::iterator i = m_sounds.begin(); i != m_sounds.end(); ++i)
	{
		snd = (QSPSound *)&i->second;
		FMOD_Channel_IsPlaying(snd->Channel, &playing);
		if (playing)
			FMOD_Channel_SetVolume(snd->Channel, (float)(m_volumeCoeff * snd->Volume) / 100);
	}
}
Beispiel #22
0
void Sound::AddToVolume(float fVolume)
{
	// Check if we have a sound loaded
	if (!mLoaded)
	{
		return;
	}

	// Cache the volume
	mVolume += fVolume;

	if (mVolume> 1.0f) mVolume = 1.0f;
	else if (mVolume <0.0f) mVolume = 0.0f;

	// Check if we have a valid channel
	if (0 != mpChannel)
	{
		FMOD_Channel_SetVolume(mpChannel, mVolume);
	}
}
Beispiel #23
0
void CSound::SetVolume(float fVolume) {
	// Check if we have a sound loaded
	if (!mLoaded) {
		return;
	}

	// Cache the volume
	mVolume = fVolume;

	if (mVolume > 1.0f)
		mVolume = 1.0f;
	else if (mVolume < 0.0f)
		mVolume = 0.0f;
#if __ENABLE_CFMOD
	// Check if we have a valid channel
	if (0 != mpChannel) {
		FMOD_Channel_SetVolume(mpChannel, mVolume);
	}
#endif
}
Beispiel #24
0
void MOD_Update (void)
{
	if(SND_Initialised == false || SND_MusicChannel.inuse == false)
		return;

	FMOD_System_Update(fmod_system);
	SND_MusicChannel.volume = bgmvolume.value;

	if(SND_MusicChannel.volume < 0.0f)
		SND_MusicChannel.volume = 0.0f;

	if(SND_MusicChannel.volume > 1.0f)
		SND_MusicChannel.volume = 1.0f;

	FMOD_Channel_SetVolume(SND_MusicChannel.channel, SND_MusicChannel.volume);

	if(SND_MusicChannel.volume == 0.0f | cl.paused == true)
		MOD_Pause();
	else
		MOD_Resume();
}
Beispiel #25
0
void whitgl_loop_volume(int id, float volume)
{
	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_Channel_SetVolume(sounds[index].channel, volume);
	_whitgl_sound_errcheck("FMOD_Channel_SetVolume", result);
}
Beispiel #26
0
/*
---------------------------------------
    设置音量
---------------------------------------
*/
static bool_t
iXMM_FMOD_set_volume (
  __CR_IO__ iXMMEDIA*   that,
  __CR_IN__ sint_t      percent
    )
{
    float       vols;
    iXMM_FMOD*  real;
    FMOD_RESULT result;

    real = (iXMM_FMOD*)that;
    if (percent < 0)
        percent = 0;
    else
    if (percent > 100)
        percent = 100;
    vols = ((float)percent) / 100.0f;
    result = FMOD_Channel_SetVolume(real->m_chn, vols);
    if (result != FMOD_OK)
        return (FALSE);
    that->__volume__ = percent;
    return (TRUE);
}
Beispiel #27
0
void whitgl_loop_add(int id, const char* filename)
{
	WHITGL_LOG("Adding loop: %s", filename);
	if(num_sounds >= WHITGL_SOUND_MAX)
	{
		WHITGL_LOG("ERR Too many sounds");
		return;
	}
	sounds[num_sounds].id = id;
	FMOD_RESULT result = FMOD_System_CreateSound(fmodSystem, filename, FMOD_HARDWARE | FMOD_2D | FMOD_LOOP_NORMAL, 0, &sounds[num_sounds].sound);
	_whitgl_sound_errcheck("FMOD_System_CreateSound", result);

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

	result = FMOD_Channel_SetVolume(sounds[num_sounds].channel, 0);
	_whitgl_sound_errcheck("FMOD_Channel_SetVolume", result);

	result = FMOD_Channel_SetPaused(sounds[num_sounds].channel, false);
	_whitgl_sound_errcheck("FMOD_Channel_SetPaused", result);

	num_sounds++;
}
// ---------------------------------------------------------------------------- 
void ofSoundPlayer::play(){
	
	// if it's a looping sound, we should try to kill it, no?
	// or else people will have orphan channels that are looping
	if (bLoop == true){
		FMOD_Channel_Stop(channel);
	}
	
	// if the sound is not set to multiplay, then stop the current,
	// before we start another
	if (!bMultiPlay){
		FMOD_Channel_Stop(channel);
	}
	
	FMOD_System_PlaySound(sys, FMOD_CHANNEL_FREE, sound, bPaused, &channel);

	FMOD_Channel_GetFrequency(channel, &internalFreq);
	FMOD_Channel_SetVolume(channel,volume);
	FMOD_Channel_SetPan(channel,pan);
	FMOD_Channel_SetFrequency(channel, internalFreq * speed);
	FMOD_Channel_SetMode(channel,  (bLoop == true) ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
		
}
Beispiel #29
0
void update_sound(void)
{
	int i;
	int vol, pan;
	
	if(!sound_is_on)return;
	
	for(i=0;i<MAX_SOUNDS_PLAYING;i++)
	{
		if(sound_data[i].used)
		{
			FMOD_BOOL is_playing;
			FMOD_Channel_IsPlaying(sound_data[i].voice_num, &is_playing);
			if(is_playing==FALSE)
			{
				FMOD_Channel_Stop(sound_data[i].voice_num);
				sound_data[i].used=0;
			}
			else
			{
				if(!sound_data[i].lower_at_dist)
				{
					vol = sound_data[i].vol;
					pan = 128;
				}
				else
					calc_sound_prop(sound_data[i].x,sound_data[i].y,&vol, &pan, sound_info[sound_data[i].sound_num].volume);
				
								
				FMOD_Channel_SetVolume(sound_data[i].voice_num, ((float)vol)/256);
				FMOD_Channel_SetPan(sound_data[i].voice_num, pan);

			}

		}
	}
}
Beispiel #30
0
void Game::loadRessources()
{
	blockImage.LoadFromFile(BLOCK_IMG);
	bgImage.LoadFromFile(BG_IMG);
	gameOverImage.LoadFromFile(GAME_OVER_IMG);
	digital.LoadFromFile(DIGITAL_FONT);
	vador.LoadFromFile(VADOR_FONT);
	myriad.LoadFromFile(MYRIAD_FONT);
	
	FMOD_System_Create(&system);
	
	FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
	
	FMOD_System_CreateSound(system, MOVE_SOUND.c_str(), FMOD_DEFAULT, 0, &move);
	FMOD_System_CreateSound(system, HOLD_SOUND.c_str(), FMOD_DEFAULT, 0, &hold);
	FMOD_System_CreateSound(system, DROP_SOUND.c_str(), FMOD_DEFAULT, 0, &drop);
	FMOD_System_CreateSound(system, DELETE_SOUND.c_str(), FMOD_DEFAULT, 0, &deletion);
	
	FMOD_System_CreateSound(system, MARATHON_MUSIC.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &marathonMusic);
	FMOD_System_CreateSound(system, SPRINT_MUSIC.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &sprintMusic);
	FMOD_System_CreateSound(system, ULTRA_MUSIC.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &ultraMusic);
	
	FMOD_Channel_SetVolume(musicChannel, 0.5);
}