// ---------------------------------------------------------------------------- void ofxSoundPlayerFMOD::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); //fmod update() should be called every frame - according to the docs. //we have been using fmod without calling it at all which resulted in channels not being able //to be reused. we should have some sort of global update function but putting it here //solves the channel bug FMOD_System_Update(sys); }
void Java_org_fmod_playsound_Example_cUpdate(JNIEnv *env, jobject thiz) { FMOD_RESULT result = FMOD_OK; result = FMOD_System_Update(gSystem); CHECK_RESULT(result); }
void CDA_Update (void) { #ifdef UQE_FMOD_CDAUDIO 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) CDA_Pause(); else CDA_Resume(); #else CDAudio_Update(); #endif }
void stop() { if (NULL != m_channel) { FMOD_Channel_Stop(m_channel); FMOD_System_Update(System); m_channel = NULL; } }
void playMusic(const int & n) { result = FMOD_System_PlaySound(sys, FMOD_CHANNEL_FREE, sounds[n], 0, &chan); ERRCHECK(result); FMOD_System_Update(sys); return; }
void FMCSound::stop() { m_has_played = false; FMOD_System_Update(m_fmod_system); if (m_fmod_channel == 0) return; FMOD_Channel_Stop(m_fmod_channel); }
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); } } }
void play(bool loop = false) { if (loop) { FMOD_Sound_SetMode(m_sound, FMOD_LOOP_NORMAL); } FMOD_System_PlaySound(System, FMOD_CHANNEL_FREE, m_sound, false, &m_channel); FMOD_System_Update(System); }
void Update() { FMOD_RESULT result = FMOD_OK; if (gSystem) { result = FMOD_System_Update(gSystem); CHECK_RESULT(result); } }
void AudioManager::Update() { // Update the audio system. if( Initialized ) { if( FMOD_System_Update( SystemInstance ) != FMOD_OK ) throw exception(); } }
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); } } }
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); } }
void Sound::Update() { FMOD_System_Update(fmodSystem); for(int i = 0; i < MAX_SOUNDS; i++) { Sound* sound = sounds[i]; if(sound == nullptr) continue; if(sound->onlyPlayOnce && !sound->Is_Playing()) Destroy_Sound(sound); } }
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); }
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 Java_org_fmod_realtimestitching_Example_cUpdate(JNIEnv *env, jobject thiz) { FMOD_RESULT result = FMOD_OK; /* Replace the subsound that just finished with a new subsound, to create endless seamless stitching! Note that this polls the currently playing subsound using the FMOD_TIMEUNIT_BUFFERED flag. Remember streams are decoded / buffered ahead in advance! Don't use the 'audible time' which is FMOD_TIMEUNIT_SENTENCE_SUBSOUND by itself. When streaming, sound is processed ahead of time, and things like stream buffer / sentence manipulation (as done below) is required to be in 'buffered time', or else there will be synchronization problems and you might end up releasing a sub-sound that is still playing! */ result = FMOD_Channel_GetPosition(gChannel, &gCurrentSubSoundID, (FMOD_TIMEUNIT)(FMOD_TIMEUNIT_SENTENCE_SUBSOUND | FMOD_TIMEUNIT_BUFFERED)); CHECK_RESULT(result); if (gCurrentSubSoundID != gSubSoundID) { /* Release the sound that isn't playing any more. */ result = FMOD_Sound_Release(gSubSound[gSubSoundID]); CHECK_RESULT(result); /* Replace it with a new sound in our list. */ result = FMOD_System_CreateStream(gSystem, gSoundName[gSentenceID], FMOD_DEFAULT, 0, &gSubSound[gSubSoundID]); CHECK_RESULT(result); result = FMOD_Sound_SetSubSound(gSound, gSubSoundID, gSubSound[gSubSoundID]); CHECK_RESULT(result); sprintf(s, "Replacing subsound %d / 2 with sound %d / %d\n", gSubSoundID, gSentenceID, NUMSOUNDS); __android_log_write(ANDROID_LOG_INFO, "fmod_realtimestitching", s); gSentenceID++; if (gSentenceID >= NUMSOUNDS) { gSentenceID = 0; } gSubSoundID = gCurrentSubSoundID; } result = FMOD_System_Update(gSystem); CHECK_RESULT(result); }
explicit Sound(const QString &fileName, bool backgroundMusic = false) : m_sound(NULL), m_channel(NULL) { FMOD_MODE mode = FMOD_DEFAULT; FMOD_SOUNDGROUP *soundGroup = EffectGroup; if (backgroundMusic) { mode |= FMOD_CREATESTREAM; soundGroup = BackgroundMusicGroup; } FMOD_System_CreateSound(System, fileName.toLatin1(), mode, NULL, &m_sound); FMOD_Sound_SetSoundGroup(m_sound, soundGroup); FMOD_System_Update(System); }
void SSVisualizer::UpdateUserLayer( const float deltaTime ) { // Perform non-simulation update logic here (Don't forget to set update order priority!) FMOD_System_Update(m_SoundSystem); //Get spectrum data PROFILE(AutoProfiler memAllocProfiler("VisualizerAllocation", Profiler::PROFILER_CATEGORY_STANDARD, true, true)); #ifdef USE_STACK_ALLOC float* leftSpectrum = (float*)m_Allocator->Allocate(sizeof(float) * SPECTRUM_SIZE); float* rightSpectrum = (float*)m_Allocator->Allocate(sizeof(float) * SPECTRUM_SIZE); Particle2* particles = (Particle2*)m_Allocator->Allocate(sizeof(Particle2) * SPECTRUM_SIZE); #else float* leftSpectrum = (float*)malloc(sizeof(float) * SPECTRUM_SIZE); float* rightSpectrum = (float*)malloc(sizeof(float) * SPECTRUM_SIZE); Particle2* particles = (Particle2*)malloc(sizeof(Particle2) * SPECTRUM_SIZE); #endif PROFILE(memAllocProfiler.Stop()); FMOD_Channel_GetSpectrum(m_Channel, leftSpectrum, SPECTRUM_SIZE, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE); FMOD_Channel_GetSpectrum(m_Channel, rightSpectrum, SPECTRUM_SIZE, 1, FMOD_DSP_FFT_WINDOW_TRIANGLE); int res = 8; float maxH; for (int i = 0; i < SPECTRUM_SIZE / res; ++i) { float h = -0.5f + glm::max((rightSpectrum[i] + rightSpectrum[i]) * 5.0f - 0.04f, 0.0f) + 0.015f; maxH = glm::max(h + 0.5f, maxH); for (int k = 0; k < res; k++) { int index = i * res + k; particles[index].Pos = glm::vec4((index / (float)SPECTRUM_SIZE) * 2.0f - 1.0f, h, 0.1f, 1); particles[index].Color = m_Color; } } maxH = glm::max(maxH, 0.0f); m_Color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f) * maxH + glm::vec4(0.0f, 0.0f, 1.0f, 1.0f) * (1.0f - maxH); glBindBuffer(GL_ARRAY_BUFFER, m_VBO); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Particle2) * SPECTRUM_SIZE, particles); m_RenderProgram.Apply(); glBindBuffer(GL_ARRAY_BUFFER, m_VBO); glBindVertexArray(m_VAO); glDrawArrays(GL_LINE_STRIP, 0, SPECTRUM_SIZE); PROFILE(AutoProfiler memDellocProfiler("VisualizerDeallocation", Profiler::PROFILER_CATEGORY_STANDARD, true, true)); #ifdef USE_STACK_ALLOC m_Allocator->Unwind(m_Marker); #else free(leftSpectrum); free(rightSpectrum); free(particles); #endif PROFILE(memDellocProfiler.Stop()); }
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; } } }
/* runGameLoop - This is the game loop management method. It runs continuously while the game is active. Once per frame it instructs the major game objects to get user input, record user input, update the GUI state, update the sprites' states using AI and input, perform collision detection and resolution (physics), render the screen, etc. This loop is timed such that everything is kept to a consistent framerate, thus the game should run consistently on all machines. */ void Game::runGameLoop() { // FIRST PROFILE? bool firstTimeThroughLoop = true; // LET'S START THE TIMER FROM SCRATCH timer->resetTimer(); playMusic ("data\\music\\planetarium.mp3"); // KEEP RENDERING UNTIL SOMEONE PULLS THE PLUG while(gsm->isAppActive()) { // MOVE ALONG WINDOWS MESSAGES, THIS ALLOWS // US TO GET USER INPUT os->processOSMessages(); //Update FMOD system FMOD_System_Update (system); // GET USER INPUT AND UPDATE GAME, GUI, OR PLAYER // STATE OR WHATEVER IS NECESSARY input->processInput(this); // IT IS POSSIBLE THE USER REQUESTED A SHUTDOWN // OF THE APP, SO WE NEED TO CHECK AGAIN if (gsm->isAppActive()) { // USE THE INPUT TO UPDATE THE GAME processGameData(); // AND RENDER THE GAME if(black <= 0) graphics->renderGame(this); else{ graphics->getWorldRenderList()->clear(); black--; } } } }
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(); }
void Audio::stop() { if (System == NULL) return; int n; FMOD_System_GetChannelsPlaying(System, &n); QList<FMOD_CHANNEL *> channels; for (int i = 0; i < n; i++) { FMOD_CHANNEL *channel; FMOD_RESULT result = FMOD_System_GetChannel(System, i, &channel); if (result == FMOD_OK) channels << channel; } foreach (FMOD_CHANNEL * const &channel, channels) FMOD_Channel_Stop(channel); stopBGM(); FMOD_System_Update(System); }
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); }
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++; } } }
int main(int argc, char *argv[]) { FMOD_SYSTEM *system = 0; FMOD_SOUND *sound = 0; FMOD_RESULT result; FMOD_CREATESOUNDEXINFO exinfo; int key, recorddriver, numdrivers, count; unsigned int version; FILE *fp; unsigned int datalength = 0, soundlength; /* 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 : DirectSound\n"); printf("2 : Windows Multimedia WaveOut\n"); printf("3 : ASIO\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_DSOUND); break; case '2' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_WINMM); break; case '3' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_ASIO); break; default : return 1; } 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, 0); ERRCHECK(result); memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.numchannels = 2; exinfo.format = FMOD_SOUND_FORMAT_PCM16; exinfo.defaultfrequency = 44100; exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 2; result = FMOD_System_CreateSound(system, 0, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &exinfo, &sound); ERRCHECK(result); printf("========================================================================\n"); printf("Record to disk example. Copyright (c) Firelight Technologies 2004-2014.\n"); printf("========================================================================\n"); printf("\n"); printf("Press a key to start recording to record.wav\n"); printf("\n"); _getch(); result = FMOD_System_RecordStart(system, recorddriver, sound, TRUE); ERRCHECK(result); printf("Press 'Esc' to quit\n"); printf("\n"); fp = fopen("record.wav", "wb"); if (!fp) { printf("ERROR : could not open record.wav for writing.\n"); return 1; } /* Write out the wav header. As we don't know the length yet it will be 0. */ WriteWavHeader(fp, sound, datalength); result = FMOD_Sound_GetLength(sound, &soundlength, FMOD_TIMEUNIT_PCM); ERRCHECK(result); /* Main loop. */ do { static unsigned int lastrecordpos = 0; unsigned int recordpos = 0; if (_kbhit()) { key = _getch(); } FMOD_System_GetRecordPosition(system, recorddriver, &recordpos); ERRCHECK(result); if (recordpos != lastrecordpos) { void *ptr1, *ptr2; int blocklength; unsigned int len1, len2; blocklength = (int)recordpos - (int)lastrecordpos; if (blocklength < 0) { blocklength += soundlength; } /* Lock the sound to get access to the raw data. */ FMOD_Sound_Lock(sound, lastrecordpos * exinfo.numchannels * 2, blocklength * exinfo.numchannels * 2, &ptr1, &ptr2, &len1, &len2); /* * exinfo.numchannels * 2 = stereo 16bit. 1 sample = 4 bytes. */ /* Write it to disk. */ if (ptr1 && len1) { datalength += fwrite(ptr1, 1, len1, fp); } if (ptr2 && len2) { datalength += fwrite(ptr2, 1, len2, fp); } /* Unlock the sound to allow FMOD to use it again. */ FMOD_Sound_Unlock(sound, ptr1, ptr2, len1, len2); } lastrecordpos = recordpos; printf("%-23s. Record buffer pos = %6d : Record time = %02d:%02d\r", (timeGetTime() / 500) & 1 ? "Recording to record.wav" : "", recordpos, datalength / exinfo.defaultfrequency / exinfo.numchannels / 2 / 60, (datalength / exinfo.defaultfrequency / exinfo.numchannels / 2) % 60); FMOD_System_Update(system); Sleep(10); } while (key != 27); printf("\n"); /* Write back the wav header now that we know its length. */ WriteWavHeader(fp, sound, datalength); fclose(fp); /* 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_SOUND *sound[6]; FMOD_CHANNEL *channel[6]; FMOD_CHANNELGROUP *groupA, *groupB, *masterGroup; FMOD_RESULT result; int key, 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; } result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_LOOP_NORMAL, 0, &sound[0]); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/jaguar.wav", FMOD_LOOP_NORMAL, 0, &sound[1]); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/swish.wav", FMOD_LOOP_NORMAL, 0, &sound[2]); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/c.ogg", FMOD_LOOP_NORMAL, 0, &sound[3]); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/d.ogg", FMOD_LOOP_NORMAL, 0, &sound[4]); ERRCHECK(result); result = FMOD_System_CreateSound(system, "../media/e.ogg", FMOD_LOOP_NORMAL, 0, &sound[5]); ERRCHECK(result); result = FMOD_System_CreateChannelGroup(system, "Group A", &groupA); ERRCHECK(result); result = FMOD_System_CreateChannelGroup(system, "Group B", &groupB); ERRCHECK(result); result = FMOD_System_GetMasterChannelGroup(system, &masterGroup); ERRCHECK(result); printf("=======================================================================\n"); printf("ChannelGroups Example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("=======================================================================\n"); printf("\n"); printf("Group A : drumloop.wav, jaguar.wav, swish.wav\n"); printf("Group B : c.ogg, d.ogg, e.ogg\n"); printf("\n"); printf("Press 'A' to mute/unmute group A\n"); printf("Press 'B' to mute/unmute group B\n"); printf("Press 'C' to mute/unmute group A and B (master group)\n"); printf("Press 'Esc' to quit\n"); printf("\n"); /* Instead of being independent, set the group A and B to be children of the master group. */ result = FMOD_ChannelGroup_AddGroup(masterGroup, groupA); ERRCHECK(result); result = FMOD_ChannelGroup_AddGroup(masterGroup, groupB); ERRCHECK(result); /* Start all the sounds! */ for (count = 0; count < 6; count++) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound[count], TRUE, &channel[count]); ERRCHECK(result); if (count < 3) { result = FMOD_Channel_SetChannelGroup(channel[count], groupA); } else { result = FMOD_Channel_SetChannelGroup(channel[count], groupB); } ERRCHECK(result); result = FMOD_Channel_SetPaused(channel[count], FALSE); ERRCHECK(result); } /* Change the volume of each group, just because we can! (And makes it less of a loud noise). */ result = FMOD_ChannelGroup_SetVolume(groupA, 0.5f); ERRCHECK(result); result = FMOD_ChannelGroup_SetVolume(groupB, 0.5f); ERRCHECK(result); /* Main loop. */ do { if (_kbhit()) { key = _getch(); switch (key) { case 'a' : case 'A' : { static int mute = TRUE; FMOD_ChannelGroup_SetMute(groupA, mute); mute = !mute; break; } case 'b' : case 'B' : { static int mute = TRUE; FMOD_ChannelGroup_SetMute(groupB, mute); mute = !mute; break; } case 'c' : case 'C' : { static int mute = TRUE; FMOD_ChannelGroup_SetMute(masterGroup, mute); mute = !mute; break; } } } FMOD_System_Update(system); { int channelsplaying = 0; FMOD_System_GetChannelsPlaying(system, &channelsplaying); printf("Channels Playing %2d\r", channelsplaying); } Sleep(10); } while (key != 27); printf("\n"); /* A little fade out. (over 2 seconds) */ printf("Goodbye!\n"); { float pitch = 1.0f; float vol = 1.0f; for (count = 0; count < 200; count++) { FMOD_ChannelGroup_SetPitch(masterGroup, pitch); FMOD_ChannelGroup_SetVolume(masterGroup, vol); vol -= (1.0f / 200.0f); pitch -= (0.5f / 200.0f); Sleep(10); } } /* Shut down */ for (count = 0; count < 6; count++) { result = FMOD_Sound_Release(sound[count]); ERRCHECK(result); } result = FMOD_ChannelGroup_Release(groupA); ERRCHECK(result); result = FMOD_ChannelGroup_Release(groupB); 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 *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; }