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; }
bool isPalying(){ if(channel == NULL) return false; FMOD_BOOL is_playing = false; FMOD_Channel_IsPlaying(channel, &is_playing); return is_playing; }
bool Sound::isPlaying() { if(!this->ch)return false; FMOD_BOOL val; FMOD_RESULT r; r = FMOD_Channel_IsPlaying( this->ch, &val ); if( r != FMOD_OK ) return false; return val; }
//------------------------------------------------------------ bool ofFmodSoundPlayer::getIsPlaying(){ if (!bLoadedOk) return false; int playing = 0; FMOD_Channel_IsPlaying(channel, &playing); return (playing != 0 ? true : false); }
QSP_BOOL QSPCallBacks::IsPlay(QSPString file) { FMOD_BOOL playing = FALSE; QSPSounds::iterator elem = m_sounds.find(wxFileName(wxString(file.Str, file.End), wxPATH_DOS).GetFullPath().Upper()); if (elem != m_sounds.end()) FMOD_Channel_IsPlaying(((QSPSound *)(&elem->second))->Channel, &playing); return (playing == TRUE); }
bool isPlaying() const { FMOD_BOOL playing = false; if (NULL != m_channel) { FMOD_Channel_IsPlaying(m_channel, &playing); } return playing; }
/// is this source playing at the moment? (paused is playing, isplaying=false => sound completly played or unplayable) virtual const bool IsPlaying(){ FMOD_BOOL b; if(mpChannel == 0)return false; else { FMOD_Channel_IsPlaying(mpChannel,&b); if(b)return true; else return false; } }
//! Is Playing u1 teSound::IsPlaying() { FMOD_BOOL isPlaying = false; if(channel) teSoundManager::CheckResult(FMOD_Channel_IsPlaying(channel, &isPlaying)); return isPlaying ? true : false; }
void StopAudio() /* Stop the sound if is playing.*/ { if (systemFMOD != NULL) { BOOL isPlaying = FALSE; FMOD_Channel_IsPlaying(channel, &isPlaying); if (isPlaying) FMOD_Channel_Stop(channel); } }
bool FMCSound::isFinished() const { FMOD_System_Update(m_fmod_system); if (m_fmod_channel == 0) return true; int playing = 0; FMOD_RESULT result = FMOD_Channel_IsPlaying(m_fmod_channel, &playing); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { MYASSERT(result != FMOD_OK); } return playing == 0; }
void Systems::SoundSystem::Update(double dt) { FMOD_System_Update(m_System); //Delete sounds. Not until it's done playing std::map<EntityID, FMOD_CHANNEL*>::iterator it; for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();) { FMOD_Channel_IsPlaying(it->second, &m_isPlaying); if(m_isPlaying) { it++; } else { // FMOD_Sound_Release(m_DeleteSounds[it->first]); m_DeleteSounds.erase(it->first); it = m_DeleteChannels.erase(it); } } //LOG_INFO("Antal emitters i listan: %i", m_Channels.size()); for(it = m_Channels.begin(); it != m_Channels.end();) { FMOD_Channel_IsPlaying(it->second, &m_isPlaying); if(!m_isPlaying) { it = m_Channels.erase(it); } else { it++; } } }
bool CSound::IsPlaying(void) const { // Check if we have a sound loaded if (!mLoaded) { return false; } #if __ENABLE_CFMOD // Check if we have a valid channel FMOD_BOOL bPlaying = 0; if (0 != mpChannel) { FMOD_Channel_IsPlaying(mpChannel, &bPlaying); } return (bPlaying != 0); #else return false; #endif }
jboolean Java_org_fmod_playsound_Example_cGetPlaying(JNIEnv *env, jobject thiz) { FMOD_RESULT result = FMOD_OK; FMOD_BOOL playing = 0; if (gChannel) { result = FMOD_Channel_IsPlaying(gChannel, &playing); if (result != FMOD_ERR_INVALID_HANDLE && result != FMOD_ERR_CHANNEL_STOLEN) { CHECK_RESULT(result); } } return playing; }
void AudioPlayer::update( unsigned time ) { FMOD_CHECK( FMOD_System_Update( mFmodSys ) ); for( unsigned i = 0 ; i < MaxNumChannel ; ++i ) { if ( mChannels[ i ] == NULL ) continue; FMOD_BOOL isPlaying; if ( FMOD_Channel_IsPlaying( mChannels[i] , &isPlaying ) == FMOD_OK ) { if ( !isPlaying ) mChannels[i] = NULL; } } }
bool Sound::IsPlaying() const { // Check if we have a sound loaded if (!mLoaded) { return false; } // Check if we have a valid channel FMOD_BOOL bPlaying = 0; if (0 != mpChannel) { FMOD_Channel_IsPlaying(mpChannel, &bPlaying); } return (bPlaying != 0); }
/* --------------------------------------- 播放是否结束 --------------------------------------- */ static bool_t iXMM_FMOD_is_over ( __CR_IN__ iXMMEDIA* that, __CR_OT__ bool_t* over ) { FMOD_BOOL retc; iXMM_FMOD* real; FMOD_RESULT result; real = (iXMM_FMOD*)that; result = FMOD_Channel_IsPlaying(real->m_chn, &retc); if (result != FMOD_OK) return (FALSE); *over = retc ? FALSE : TRUE; return (TRUE); }
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); } }
void QSPCallBacks::UpdateSounds() { QSPSound *snd; FMOD_BOOL playing = FALSE; QSPSounds::iterator i = m_sounds.begin(); while (i != m_sounds.end()) { snd = (QSPSound *)&i->second; FMOD_Channel_IsPlaying(snd->Channel, &playing); if (playing) ++i; else { snd->Free(); m_sounds.erase(i++); } } }
int find_free_channel(void) { FMOD_BOOL is_playing; FMOD_RESULT result; int i; for (i = 0; i < NUM_CHANNELS; i++) { if (channel[i] == NULL) { return i; }; result = FMOD_Channel_IsPlaying(channel[i], &is_playing); ERRCHECK(result); if (!is_playing) { return i; } } return -1; }
boolean I_SoundIsPlaying(INT32 handle) { FMOD_CHANNEL *chan; FMOD_BOOL playing; FMOD_RESULT e; FMR(FMOD_System_GetChannel(fsys, handle, &chan)); if (music_stream && chan == music_channel) return false; e = FMOD_Channel_IsPlaying(chan, &playing); switch(e) { case FMOD_ERR_INVALID_HANDLE: // Sound effect finished. case FMOD_ERR_CHANNEL_STOLEN: // Sound effect interrupted. -- technically impossible due to GetChannel by handle. :( return false; // therefore, it's not playing anymore. default: FMR(e); break; } return (boolean)playing; }
void musicHandler (void) { int playing = 0; unsigned int ms = 0; unsigned int lenms = 0; if (chan) { result = FMOD_Channel_IsPlaying(chan, &playing); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } if (playing) { return; } FMOD_SOUND *currentsound = 0; result = FMOD_Channel_GetPosition(chan, &ms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } FMOD_Channel_GetCurrentSound(chan, ¤tsound); if (currentsound) { result = FMOD_Sound_GetLength(currentsound, &lenms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } } } current_track = (current_track + 1) % SCNT; playMusic(current_track); }
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); } } } }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system; FMOD_SOUND *cdsound; FMOD_CHANNEL *channel = 0; FMOD_RESULT result; int key; unsigned int numtracks, currenttrack = 0; unsigned int version; printf("==================================================================\n"); printf("CDPlayer Example. Copyright (c) Firelight Technologies 2004-2014.\n"); printf("==================================================================\n\n"); /* Create a System object and initialize. */ result = FMOD_System_Create(&system); ERRCHECK(result); result = FMOD_System_GetVersion(system, &version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL); ERRCHECK(result); /* Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium. */ result = FMOD_System_SetStreamBufferSize(system, 64*1024, FMOD_TIMEUNIT_RAWBYTES); ERRCHECK(result); /* Try a few drive letters. */ result = FMOD_System_CreateStream(system, "d:", FMOD_OPENONLY, 0, &cdsound); if (result != FMOD_OK) { result = FMOD_System_CreateStream(system, "e:", FMOD_OPENONLY, 0, &cdsound); if (result != FMOD_OK) { result = FMOD_System_CreateStream(system, "f:", FMOD_OPENONLY, 0, &cdsound); ERRCHECK(result); } } result = FMOD_Sound_GetNumSubSounds(cdsound, &numtracks); ERRCHECK(result); for (;;) { FMOD_TAG tag; if (FMOD_Sound_GetTag(cdsound, 0, -1, &tag) != FMOD_OK) { break; } if (tag.datatype == FMOD_TAGDATATYPE_CDTOC) { dump_cddb_query((FMOD_CDTOC *)tag.data); } } printf("\n========================================\n"); printf("Press SPACE to pause\n"); printf(" n to skip to next track\n"); printf(" < re-wind 10 seconds\n"); printf(" > fast-forward 10 seconds\n"); printf(" ESC to exit\n"); printf("========================================\n\n"); /* Print out length of entire CD. Did you know you can also play 'cdsound' and it will play the whole CD without gaps? */ { unsigned int lenms; result = FMOD_Sound_GetLength(cdsound, &lenms, FMOD_TIMEUNIT_MS); ERRCHECK(result); printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100); } /* Play whole CD */ result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, cdsound, FALSE, &channel); ERRCHECK(result); /* Main loop */ do { if (_kbhit()) { key = _getch(); switch (key) { case ' ' : { int paused; FMOD_Channel_GetPaused(channel, &paused); FMOD_Channel_SetPaused(channel, !paused); break; } case '<' : { unsigned int ms; FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_SENTENCE_MS); if (ms >= 10000) { ms -= 10000; } else { ms = 0; } FMOD_Channel_SetPosition(channel, ms, FMOD_TIMEUNIT_SENTENCE_MS); break; } case '>' : { unsigned int ms; FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_SENTENCE_MS); ms += 10000; FMOD_Channel_SetPosition(channel, ms, FMOD_TIMEUNIT_SENTENCE_MS); break; } case 'n' : { FMOD_Channel_GetPosition(channel, ¤ttrack, FMOD_TIMEUNIT_SENTENCE_SUBSOUND); currenttrack++; if (currenttrack >= numtracks) { currenttrack = 0; } FMOD_Channel_SetPosition(channel, currenttrack, FMOD_TIMEUNIT_SENTENCE_SUBSOUND); break; } } } FMOD_System_Update(system); if (channel) { unsigned int ms; unsigned int lenms; FMOD_BOOL playing; FMOD_BOOL paused; int busy; result = FMOD_Channel_GetPaused(channel, &paused); ERRCHECK(result); result = FMOD_Channel_IsPlaying(channel, &playing); ERRCHECK(result); result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_SENTENCE_MS); ERRCHECK(result); result = FMOD_Sound_GetLength(cdsound, &lenms, FMOD_TIMEUNIT_SENTENCE_MS); ERRCHECK(result); result = FMOD_File_GetDiskBusy(&busy); ERRCHECK(result); printf("Track %d/%d : %02d:%02d:%02d/%02d:%02d:%02d : %s (%s)\r", currenttrack + 1, numtracks, ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", busy ? "*" : " "); } Sleep(50); } while (key != 27); printf("\n"); /* Shut down */ result = FMOD_Sound_Release(cdsound); ERRCHECK(result); result = FMOD_System_Close(system); ERRCHECK(result); result = FMOD_System_Release(system); ERRCHECK(result); return 0; }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system; FMOD_SOUND *sound; FMOD_CHANNEL *channel = 0; FMOD_RESULT result; int key; unsigned int version; printf("===================================================================\n"); printf("NetStream Example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("===================================================================\n\n"); if (argc < 2) { printf("Usage: netstream <url>\n"); printf("Example: netstream http://www.fmod.org/stream.mp3\n\n"); return -1; } /* Create a System object and initialize. */ result = FMOD_System_Create(&system); ERRCHECK(result); result = FMOD_System_GetVersion(system,&version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, 0); ERRCHECK(result); /* Bump up the file buffer size a little bit for netstreams (to account for lag). */ result = FMOD_System_SetStreamBufferSize(system, 64*1024, FMOD_TIMEUNIT_RAWBYTES); ERRCHECK(result); result = FMOD_System_CreateSound(system, argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound); ERRCHECK(result); printf("Press space to pause, Esc to quit\n\n"); /* Main loop */ do { unsigned int ms = 0, percent = 0; int playing = FALSE; int paused = FALSE; int starving = FALSE; FMOD_OPENSTATE openstate; if (!channel) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel); } if (_kbhit()) { key = _getch(); switch (key) { case ' ' : { if (channel) { int paused; FMOD_Channel_GetPaused(channel, &paused); FMOD_Channel_SetPaused(channel, !paused); } break; } } } FMOD_System_Update(system); for (;;) { FMOD_TAG tag; if (FMOD_Sound_GetTag(sound, 0, -1, &tag) != FMOD_OK) { break; } if (tag.datatype == FMOD_TAGDATATYPE_STRING) { printf("%s = %s (%d bytes) \n", tag.name, tag.data, tag.datalen); } else if (tag.type == FMOD_TAGTYPE_FMOD) { if (!strcmp(tag.name, "Sample Rate Change")) { FMOD_Channel_SetFrequency(channel, *((float *)tag.data)); } } } result = FMOD_Sound_GetOpenState(sound, &openstate, &percent, &starving, 0); ERRCHECK(result); if (channel) { result = FMOD_Channel_GetPaused(channel, &paused); ERRCHECK(result); result = FMOD_Channel_IsPlaying(channel, &playing); ERRCHECK(result); result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS); ERRCHECK(result); result = FMOD_Channel_SetMute(channel, starving); ERRCHECK(result); } printf("Time %02d:%02d:%02d : %s : (%3d%%%) %s \r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, openstate == FMOD_OPENSTATE_BUFFERING ? "Buffering..." : openstate == FMOD_OPENSTATE_CONNECTING ? "Connecting..." : paused ? "Paused " : playing ? "Playing " : "Stopped ", percent, starving ? "STARVING" : " "); Sleep(10); } while (key != 27); printf("\n"); printf("Shutting down.\n"); if (channel) { result = FMOD_Channel_Stop(channel); ERRCHECK(result); } /* If we pressed escape before it is ready, wait for it to finish opening before we release it. */ do { FMOD_OPENSTATE openstate; result = FMOD_Sound_GetOpenState(sound, &openstate, 0, 0, 0); ERRCHECK(result); if (openstate == FMOD_OPENSTATE_READY) { break; } printf("Waiting for sound to finish opening before trying to release it....\r"); Sleep(10); } while (1); /* Shut down */ result = FMOD_Sound_Release(sound); ERRCHECK(result); result = FMOD_System_Close(system); ERRCHECK(result); result = FMOD_System_Release(system); ERRCHECK(result); return 0; }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system; FMOD_SOUND *sound; FMOD_CHANNEL *channel = 0; FMOD_RESULT result; int key; unsigned int version; memset(gCurrentTrackArtist, 0, 256); memset(gCurrentTrackTitle, 0, 256); strcpy(gOutputFileName, "output.mp3"); /* Start off like this then rename if a title tag comes along */ printf("======================================================================\n"); printf("RipNetStream Example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("======================================================================\n\n"); if (argc < 2) { printf("Usage: ripnetstream <url>\n"); return -1; } /* Create a System object and initialize. */ result = FMOD_System_Create(&system); ERRCHECK(result); result = FMOD_System_GetVersion(system, &version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } result = FMOD_System_Init(system, 100, FMOD_INIT_NORMAL, NULL); ERRCHECK(result); result = FMOD_System_SetStreamBufferSize(system, gFileBufferSize, FMOD_TIMEUNIT_RAWBYTES); ERRCHECK(result); result = FMOD_System_AttachFileSystem(system, myopen, myclose, myread, 0); ERRCHECK(result); printf("Buffering...\n\n"); result = FMOD_System_CreateSound(system, argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound); ERRCHECK(result); /* Main loop */ do { if (sound && !channel) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel); } if (kbhit()) { key = getch(); switch (key) { case ' ' : { if (channel) { int paused; FMOD_Channel_GetPaused(channel, &paused); FMOD_Channel_SetPaused(channel, !paused); } break; } case 'm' : case 'M' : { if (channel) { int mute; FMOD_Channel_GetMute(channel, &mute); FMOD_Channel_SetMute(channel, !mute); } break; } } } FMOD_System_Update(system); if (channel) { unsigned int ms = 0; int playing = FALSE; int paused = FALSE; int tagsupdated = 0; FMOD_Sound_GetNumTags(sound, 0, &tagsupdated); if (tagsupdated) { printf("\n"); printf("\n"); for (;;) { FMOD_TAG tag; if (FMOD_Sound_GetTag(sound, 0, -1, &tag) != FMOD_OK) { break; } if (tag.datatype == FMOD_TAGDATATYPE_STRING) { printf("[%-11s] %s (%d bytes)\n", tag.name, (char *)tag.data, tag.datalen); FMOD_Sound_GetFormat(sound, &gSoundType, 0, 0, 0); if (!strcmp(tag.name, "ARTIST")) { if (strncmp(gCurrentTrackArtist, (const char *)tag.data, 256)) { strncpy(gCurrentTrackArtist, (const char *)tag.data, 256); gUpdateFileName = TRUE; } } if (!strcmp(tag.name, "TITLE")) { if (strncmp(gCurrentTrackTitle, (const char *)tag.data, 256)) { strncpy(gCurrentTrackTitle, (const char *)tag.data, 256); gUpdateFileName = TRUE; } } } } printf("\n"); } result = FMOD_Channel_IsPlaying(channel, &playing); if (result != FMOD_OK || !playing) { FMOD_Sound_Release(sound); sound = 0; channel = 0; } else { result = FMOD_Channel_GetPaused(channel, &paused); result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS); printf("\rTime %02d:%02d:%02d : %s : Press SPACE to pause. 'm' to mute. ESC to quit.", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped"); fflush(stdout); } } if (sound) { FMOD_OPENSTATE openstate = FMOD_OPENSTATE_READY; FMOD_Sound_GetOpenState(sound, &openstate, 0, 0, 0); if (openstate == FMOD_OPENSTATE_ERROR) { FMOD_Sound_Release(sound); sound = 0; channel = 0; } } if (!sound) { printf("\n"); printf("Error occurred or stream ended. Restarting stream..\n"); result = FMOD_System_CreateSound(system, argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound); ERRCHECK(result); Sleep(1000); } Sleep(10); } while (key != 27); printf("\n"); /* Shut down */ result = FMOD_Sound_Release(sound); ERRCHECK(result); result = FMOD_System_Close(system); ERRCHECK(result); result = FMOD_System_Release(system); ERRCHECK(result); return 0; }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system; FMOD_SOUND *sound1, *sound2; FMOD_CHANNEL *channel = 0; FMOD_RESULT result; FMOD_SPEAKERMODE speakermode; int key; unsigned int version; /* Create a System object and initialize. */ result = FMOD_System_Create(&system); ERRCHECK(result); result = FMOD_System_GetVersion(system, &version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } /* Choose the speaker mode selected by the Windows control panel. */ result = FMOD_System_GetDriverCaps(system, 0, 0, 0, &speakermode); ERRCHECK(result); result = FMOD_System_SetSpeakerMode(system, speakermode); ERRCHECK(result); result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE | FMOD_2D, 0, &sound1); ERRCHECK(result); result = FMOD_Sound_SetMode(sound1, FMOD_LOOP_OFF); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/stereo.ogg", FMOD_SOFTWARE | FMOD_2D, 0, &sound2); ERRCHECK(result); printf("==============================================================================\n"); printf("Multi Speaker Output Example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("==============================================================================\n"); printf("\n"); switch (speakermode) { case FMOD_SPEAKERMODE_MONO : { printf("Using control panel speaker mode : MONO.\n"); printf("\n"); printf("Note! This output mode is very limited in its capability.\n"); printf("Most functionality of this demo is only realized with at least FMOD_SPEAKERMODE_QUAD\n"); printf("and above.\n"); break; } case FMOD_SPEAKERMODE_STEREO : { printf("Using control panel speaker mode : STEREO.\n"); printf("\n"); printf("Note! This output mode is very limited in its capability.\n"); printf("Most functionality of this demo is only realized with FMOD_SPEAKERMODE_QUAD\n"); printf("and above.\n"); break; } case FMOD_SPEAKERMODE_QUAD : { printf("Using control panel speaker mode : QUAD.\n"); printf("Side left, side right, center and subwoofer mix will be disabled.\n"); break; } case FMOD_SPEAKERMODE_SURROUND : { printf("Using control panel speaker mode : SURROUND.\n"); printf("Side left, side right, and subwoofer mix will be disabled.\n"); break; } case FMOD_SPEAKERMODE_5POINT1 : { printf("Using control panel speaker mode : 5.1 surround.\n"); printf("Side left and right mix will be disabled..\n"); break; } case FMOD_SPEAKERMODE_7POINT1 : { printf("Using control panel speaker mode : 7.1 surround.\n"); printf("Full capability.\n"); break; } }; printf("\n"); printf("Press '1' to play a mono sound on the FRONT LEFT speaker.\n"); printf("Press '2' to play a mono sound on the FRONT RIGHT speaker.\n"); if (speakermode >= FMOD_SPEAKERMODE_SURROUND) { printf("Press '3' to play a mono sound on the CENTER speaker.\n"); } else { printf("- CENTER Disabled\n"); } if (speakermode >= FMOD_SPEAKERMODE_QUAD) { printf("Press '4' to play a mono sound on the REAR LEFT speaker.\n"); printf("Press '5' to play a mono sound on the REAR RIGHT speaker.\n"); } else { printf("- REAR LEFT Disabled\n"); printf("- REAR RIGHT Disabled\n"); } if (speakermode >= FMOD_SPEAKERMODE_7POINT1) { printf("Press '6' to play a mono sound on the SIDE LEFT speaker.\n"); printf("Press '7' to play a mono sound on the SIDE RIGHT speaker.\n"); } else { printf("- SIDE LEFT Disabled\n"); printf("- SIDE RIGHT Disabled\n"); } printf("\n"); printf("Press '8' to play a stereo sound on the front speakers.\n"); printf("Press '9' to play a stereo sound on the front speakers but channel swapped.\n"); if (speakermode >= FMOD_SPEAKERMODE_SURROUND) { printf("Press '0' to play the right part of a stereo sound on the CENTER speaker.\n"); } printf("Press 'Esc' to quit\n"); printf("\n"); /* Main loop. */ do { if (_kbhit()) { key = _getch(); switch (key) { case '1' : { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel); ERRCHECK(result); result = FMOD_Channel_SetSpeakerMix(channel, 1.0f, 0, 0, 0, 0, 0, 0, 0); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); break; } case '2' : { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel); ERRCHECK(result); result = FMOD_Channel_SetSpeakerMix(channel, 0, 1.0f, 0, 0, 0, 0, 0, 0); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); break; } case '3' : { if (speakermode >= FMOD_SPEAKERMODE_QUAD) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel); ERRCHECK(result); result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 1.0f, 0, 0, 0, 0, 0); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); } break; } case '4' : { if (speakermode >= FMOD_SPEAKERMODE_QUAD) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel); ERRCHECK(result); result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 1.0f, 0, 0, 0); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); } break; } case '5' : { if (speakermode >= FMOD_SPEAKERMODE_QUAD) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel); ERRCHECK(result); result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 1.0f, 0, 0); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); } break; } case '6' : { if (speakermode >= FMOD_SPEAKERMODE_7POINT1) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel); ERRCHECK(result); result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 1.0f, 0); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); } break; } case '7' : { if (speakermode >= FMOD_SPEAKERMODE_7POINT1) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel); ERRCHECK(result); result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 0, 1.0f); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); } break; } case '8' : { float levels[2] = { 0, 1.0f }; result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &channel); ERRCHECK(result); /* By default a stereo sound would play in all right and all left speakers, so this forces it to just the front. */ result = FMOD_Channel_SetSpeakerMix(channel, 1.0f, 1.0f, 0, 0, 0, 0, 0, 0); ERRCHECK(result); result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); break; } case '9' : { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &channel); ERRCHECK(result); /* Clear out all speakers first. */ result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 0, 0); ERRCHECK(result); /* Put the left channel of the sound in the right speaker. */ { float levels[2] = { 0, 1.0f }; /* This array represents the source stereo sound. l/r */ result = FMOD_Channel_SetSpeakerLevels(channel, FMOD_SPEAKER_FRONT_LEFT, levels, 2); ERRCHECK(result); } /* Put the right channel of the sound in the left speaker. */ { float levels[2] = { 1.0f, 0 }; /* This array represents the source stereo sound. l/r */ result = FMOD_Channel_SetSpeakerLevels(channel, FMOD_SPEAKER_FRONT_RIGHT, levels, 2); ERRCHECK(result); } result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); break; } case '0' : { if (speakermode >= FMOD_SPEAKERMODE_SURROUND) /* All formats that have a center speaker. */ { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &channel); ERRCHECK(result); /* Clear out all speakers first. */ result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 0, 0); ERRCHECK(result); /* Put the right channel of the sound in the center speaker. */ { float levels[2] = { 0, 1.0f }; /* This array represents the source stereo sound. l/r */ result = FMOD_Channel_SetSpeakerLevels(channel, FMOD_SPEAKER_FRONT_CENTER, levels, 2); ERRCHECK(result); } result = FMOD_Channel_SetPaused(channel, FALSE); ERRCHECK(result); } break; } } } FMOD_System_Update(system); { unsigned int ms = 0; unsigned int lenms = 0; int playing = FALSE; int paused = FALSE; int channelsplaying = 0; if (channel) { FMOD_SOUND *currentsound = 0; result = FMOD_Channel_IsPlaying(channel, &playing); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = FMOD_Channel_GetPaused(channel, &paused); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } FMOD_Channel_GetCurrentSound(channel, ¤tsound); if (currentsound) { result = FMOD_Sound_GetLength(currentsound, &lenms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } } } FMOD_System_GetChannelsPlaying(system, &channelsplaying); printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying); } Sleep(10); } while (key != 27); printf("\n"); /* Shut down */ result = FMOD_Sound_Release(sound1); ERRCHECK(result); result = FMOD_Sound_Release(sound2); ERRCHECK(result); result = FMOD_System_Close(system); ERRCHECK(result); result = FMOD_System_Release(system); ERRCHECK(result); return 0; }
bool Sound::Is_Playing() const { FMOD_BOOL isPlaying; FMOD_Channel_IsPlaying(channel, &isPlaying); return isPlaying != 0; }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system; FMOD_SOUND *cdsound; FMOD_SOUND *sound; FMOD_CHANNEL *channel = 0; FMOD_RESULT result; int key, numtracks, currenttrack = 0; unsigned int version; if (argc < 2) { printf("Usage: cdplayer <volumename>\n"); printf("Example: cdplayer \"Audio CD\"\n"); exit(-1); } printf("==================================================================\n"); printf("CDPlayer Example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("==================================================================\n\n"); /* Create a System object and initialize. */ result = FMOD_System_Create(&system); ERRCHECK(result); result = FMOD_System_GetVersion(system, &version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL); ERRCHECK(result); /* Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium. */ result = FMOD_System_SetStreamBufferSize(system, 64*1024, FMOD_TIMEUNIT_RAWBYTES); ERRCHECK(result); result = FMOD_System_CreateStream(system, argv[1], FMOD_OPENONLY, 0, &cdsound); ERRCHECK(result); result = FMOD_Sound_GetNumSubSounds(cdsound, &numtracks); ERRCHECK(result); result = FMOD_Sound_GetSubSound(cdsound, currenttrack, &sound); ERRCHECK(result); for (;;) { FMOD_TAG tag; if (FMOD_Sound_GetTag(cdsound, 0, -1, &tag) != FMOD_OK) { break; } if (tag.datatype == FMOD_TAGDATATYPE_CDTOC) { dump_cddb_query((FMOD_CDTOC *)tag.data); } } printf("\n========================================\n"); printf("Press SPACE to pause\n"); printf(" n to skip to next track\n"); printf(" ESC to exit\n"); printf("========================================\n\n"); /* Print out length of entire CD. Did you know you can also play 'cdsound' and it will play the whole CD without gaps? */ { unsigned int lenms; result = FMOD_Sound_GetLength(cdsound, &lenms, FMOD_TIMEUNIT_MS); ERRCHECK(result); printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100); } /* Play a CD track */ result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel); ERRCHECK(result); /* Main loop */ do { if (kbhit()) { key = getch(); switch (key) { case ' ' : { int paused; FMOD_Channel_GetPaused(channel, &paused); FMOD_Channel_SetPaused(channel, !paused); break; } case 'n' : { currenttrack++; if (currenttrack >= numtracks) { currenttrack = 0; } result = FMOD_Sound_GetSubSound(cdsound, currenttrack, &sound); ERRCHECK(result); result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel); ERRCHECK(result); break; } } } FMOD_System_Update(system); if (channel) { unsigned int ms, lenms, percent = 0; FMOD_BOOL playing; FMOD_BOOL paused; result = FMOD_Channel_GetPaused(channel, &paused); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = FMOD_Channel_IsPlaying(channel, &playing); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = FMOD_Sound_GetLength(sound, &lenms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } printf("\rTrack %d/%d : %02d:%02d:%02d/%02d:%02d:%02d : %s", currenttrack + 1, numtracks, ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped"); fflush(stdout); } Sleep(10); } while (key != 27); printf("\n"); /* Shut down */ result = FMOD_Sound_Release(cdsound); ERRCHECK(result); result = FMOD_System_Close(system); ERRCHECK(result); result = FMOD_System_Release(system); ERRCHECK(result); return 0; }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system = 0; FMOD_SOUND *sound = 0; FMOD_CHANNEL *channel = 0; FMOD_RESULT result; FMOD_CREATESOUNDEXINFO exinfo; int key, driver, recorddriver, numdrivers, count; unsigned int version; /* Create a System object and initialize. */ result = FMOD_System_Create(&system); ERRCHECK(result); result = FMOD_System_GetVersion(system, &version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } /* System initialization */ printf("---------------------------------------------------------\n"); printf("Select OUTPUT type\n"); printf("---------------------------------------------------------\n"); printf("1 : OSS - Open Sound System\n"); printf("2 : ALSA - Advanced Linux Sound Architecture\n"); printf("3 : ESD - Enlightenment Sound Daemon\n"); printf("---------------------------------------------------------\n"); printf("Press a corresponding number or ESC to quit\n"); do { key = getch(); } while (key != 27 && key < '1' && key > '5'); switch (key) { case '1' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_OSS); break; case '2' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_ALSA); break; case '3' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_ESD); break; default : return 1; } ERRCHECK(result); /* Enumerate playback devices */ result = FMOD_System_GetNumDrivers(system, &numdrivers); ERRCHECK(result); printf("---------------------------------------------------------\n"); printf("Choose a PLAYBACK driver\n"); printf("---------------------------------------------------------\n"); for (count=0; count < numdrivers; count++) { char name[256]; result = FMOD_System_GetDriverInfo(system, count, name, 256, 0); ERRCHECK(result); printf("%d : %s\n", count + 1, name); } printf("---------------------------------------------------------\n"); printf("Press a corresponding number or ESC to quit\n"); do { key = getch(); if (key == 27) { return 0; } driver = key - '1'; } while (driver < 0 || driver >= numdrivers); result = FMOD_System_SetDriver(system, driver); ERRCHECK(result); /* Enumerate record devices */ result = FMOD_System_GetRecordNumDrivers(system, &numdrivers); ERRCHECK(result); printf("---------------------------------------------------------\n"); printf("Choose a RECORD driver\n"); printf("---------------------------------------------------------\n"); for (count=0; count < numdrivers; count++) { char name[256]; result = FMOD_System_GetRecordDriverInfo(system, count, name, 256, 0); ERRCHECK(result); printf("%d : %s\n", count + 1, name); } printf("---------------------------------------------------------\n"); printf("Press a corresponding number or ESC to quit\n"); recorddriver = 0; do { key = getch(); if (key == 27) { return 0; } recorddriver = key - '1'; } while (recorddriver < 0 || recorddriver >= numdrivers); printf("\n"); result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL); ERRCHECK(result); memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.numchannels = 1; exinfo.format = FMOD_SOUND_FORMAT_PCM16; exinfo.defaultfrequency = 44100; exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5; result = FMOD_System_CreateSound(system, 0, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &exinfo, &sound); ERRCHECK(result); printf("===================================================================\n"); printf("Recording example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("===================================================================\n"); printf("\n"); printf("Press 'r' to record a 5 second segment of audio and write it to a wav file.\n"); printf("Press 'p' to play the 5 second segment of audio.\n"); printf("Press 'l' to turn looping on/off.\n"); printf("Press 's' to stop recording and playback.\n"); printf("Press 'w' to save the 5 second segment to a wav file.\n"); printf("Press 'Esc' to quit\n"); printf("\n"); /* Main loop. */ do { static FMOD_CHANNEL *channel = 0; static int looping = 0; int recording = 0; int playing = 0; unsigned int recordpos = 0; unsigned int playpos = 0; unsigned int length; if (kbhit()) { key = getch(); switch (key) { case 'r' : case 'R' : { result = FMOD_System_RecordStart(system, recorddriver, sound, looping); ERRCHECK(result); break; } case 'p' : case 'P' : { if (looping) { FMOD_Sound_SetMode(sound, FMOD_LOOP_NORMAL); } else { FMOD_Sound_SetMode(sound, FMOD_LOOP_OFF); } ERRCHECK(result); result = FMOD_System_PlaySound(system, FMOD_CHANNEL_REUSE, sound, 0, &channel); ERRCHECK(result); break; } case 'l' : case 'L' : { looping = !looping; break; } case 's' : case 'S' : { result = FMOD_System_RecordStop(system, recorddriver); if (channel) { FMOD_Channel_Stop(channel); channel = 0; } break; } case 'w' : case 'W' : { printf("Writing to record.wav ... \r"); SaveToWav(sound); Sleep(500); break; } } } FMOD_Sound_GetLength(sound, &length, FMOD_TIMEUNIT_PCM); ERRCHECK(result); FMOD_System_IsRecording(system, recorddriver, &recording); ERRCHECK(result); FMOD_System_GetRecordPosition(system, recorddriver, &recordpos); ERRCHECK(result); if (channel) { FMOD_Channel_IsPlaying(channel, &playing); ERRCHECK(result); FMOD_Channel_GetPosition(channel, &playpos, FMOD_TIMEUNIT_PCM); ERRCHECK(result); } printf("State: %-19s. Record pos = %6d : Play pos = %6d : Loop %-3s\r", recording ? playing ? "Recording / playing" : "Recording" : playing ? "Playing" : "Idle", recordpos, playpos, looping ? "On" : "Off"); fflush(stdout); FMOD_System_Update(system); Sleep(10); } while (key != 27); printf("\n"); /* Shut down */ result = FMOD_Sound_Release(sound); ERRCHECK(result); result = FMOD_System_Release(system); ERRCHECK(result); return 0; }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system; FMOD_CHANNEL *channel = 0; FMOD_DSP *dsp = 0; FMOD_RESULT result; int key; unsigned int version; /* Create a System object and initialize. */ result = FMOD_System_Create(&system); ERRCHECK(result); result = FMOD_System_GetVersion(system, &version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); getch(); return 0; } result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL); ERRCHECK(result); /* Create DSP units for each type of noise we want. */ result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_OSCILLATOR, &dsp); ERRCHECK(result); result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_RATE, 440.0f); ERRCHECK(result); printf("======================================================================\n"); printf("GenerateTone Example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("======================================================================\n\n"); printf("\n"); printf("Press '1' to play a sine wave\n"); printf("Press '2' to play a square wave\n"); printf("Press '3' to play a triangle wave\n"); printf("Press '4' to play a saw wave\n"); printf("Press '5' to play a white noise\n"); printf("Press 's' to stop channel\n"); printf("\n"); printf("Press 'v'/'V' to change channel volume\n"); printf("Press 'f'/'F' to change channel frequency\n"); printf("Press '['/']' to change channel pan\n"); printf("Press 'Esc' to quit\n"); printf("\n"); /* Main loop */ do { if (kbhit()) { key = getch(); switch (key) { case '1' : { result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel); FMOD_Channel_SetVolume(channel, 0.5f); result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 0); ERRCHECK(result); FMOD_Channel_SetPaused(channel, FALSE); break; } case '2' : { result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel); FMOD_Channel_SetVolume(channel, 0.125f); result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 1); ERRCHECK(result); FMOD_Channel_SetPaused(channel, FALSE); break; } case '3' : { result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel); FMOD_Channel_SetVolume(channel, 0.5f); result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 2); ERRCHECK(result); FMOD_Channel_SetPaused(channel, FALSE); break; } case '4' : { result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel); FMOD_Channel_SetVolume(channel, 0.125f); result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 4); ERRCHECK(result); FMOD_Channel_SetPaused(channel, FALSE); break; } case '5' : { result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel); FMOD_Channel_SetVolume(channel, 0.25f); result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 5); ERRCHECK(result); FMOD_Channel_SetPaused(channel, FALSE); break; } case 's' : { FMOD_Channel_Stop(channel); break; } case 'v' : { float volume; FMOD_Channel_GetVolume(channel, &volume); volume -= 0.1f; FMOD_Channel_SetVolume(channel, volume); break; } case 'V' : { float volume; FMOD_Channel_GetVolume(channel, &volume); volume += 0.1f; FMOD_Channel_SetVolume(channel, volume); break; } case 'f' : { float frequency; FMOD_Channel_GetFrequency(channel, &frequency); frequency -= 500.0f; FMOD_Channel_SetFrequency(channel, frequency); break; } case 'F' : { float frequency; FMOD_Channel_GetFrequency(channel, &frequency); frequency += 500.0f; FMOD_Channel_SetFrequency(channel, frequency); break; } case '[' : { float pan; FMOD_Channel_GetPan(channel, &pan); pan -= 0.1f; FMOD_Channel_SetPan(channel, pan); break; } case ']' : { float pan; FMOD_Channel_GetPan(channel, &pan); pan += 0.1f; FMOD_Channel_SetPan(channel, pan); break; } } } FMOD_System_Update(system); { float frequency = 0, volume = 0, pan = 0; int playing = FALSE; if (channel) { FMOD_Channel_GetFrequency(channel, &frequency); FMOD_Channel_GetVolume(channel, &volume); FMOD_Channel_GetPan(channel, &pan); FMOD_Channel_IsPlaying(channel, &playing); } printf("Channel %s : Frequency %.1f Volume %.1f Pan %.1f \r", playing ? "playing" : "stopped", frequency, volume, pan); fflush(stdout); } Sleep(10); } while (key != 27); printf("\n"); /* Shut down */ result = FMOD_DSP_Release(dsp); ERRCHECK(result); result = FMOD_System_Close(system); ERRCHECK(result); result = FMOD_System_Release(system); ERRCHECK(result); return 0; }