/****************************************************************************** * * Update volume and separation (panning) of 2D source * *****************************************************************************/ EXPORT void HWRAPI (Update2DSoundParms) (INT32 chan, INT32 vol, INT32 sep) { FSOUND_SAMPLE *fmsample; if (chan < 0) return; fmsample = FSOUND_GetCurrentSample(chan); if (fmsample) { if (!FSOUND_Sample_GetMode(fmsample) & FSOUND_2D) { DBG_Printf("FMOD(Update2DSoundParms,Main): 2D Vol/Pan on 3D channel %i?\n",chan); //return; } } else return; if (!FSOUND_SetPaused(chan, true)) DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPaused, Pause, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); if (!FSOUND_SetVolume(chan,vol)) DBG_Printf("FMOD(Update2DSoundParms, , channel %i to volume %i): %s\n", chan,vol,FMOD_ErrorString(FSOUND_GetError())); if (!FSOUND_SetPan(chan, sep == NORMAL_SEP ? FSOUND_STEREOPAN : sep)) DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPan, channel %i to sep %i): %s\n", chan,sep,FMOD_ErrorString(FSOUND_GetError())); if (!FSOUND_SetPaused(chan, false)) DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPaused, Resume, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); }
void LecteurAudio::appuiLecture(bool etatBouton) { // Le bouton vient d'etre enfonce if (etatBouton) { // On (re)met en lecture les lecteurs des joueurs emettreCommande(lectureMorceau); // L'etat passe a Lecture etatActuel = lecture; // Si le bouton pause etait enfonce il s'agit d'une reprise de pause if (actionPause->isChecked()) { // On relache le bouton pause actionPause->setChecked(false); // On reprend la lecture du titre FSOUND_SetPaused(canalAudio, false); } // Sinon il s'agit d'une premiere lecture else { // On rend inoperant le passage sur un tag : sans cela un tag peut deplacer le curseur de temps entre // le lancement de la lecture et le repositionnement dans le temps repriseDeLecture = true; // On initialise le canal audio en commencant la lecture canalAudio = FSOUND_Stream_Play(FSOUND_FREE, fluxAudio); // On se positionne a l'endroit choisi par l'utilisateur FSOUND_Stream_SetTime(fluxAudio, positionTemps->value()); // On regle le volume FSOUND_SetVolume(canalAudio, niveauVolume->value()); // Le passage sur un tag est a nouveau operationnel repriseDeLecture = false; } } // Le bouton vient d'etre relache else { // Le lecteur etait dans l'etat Lecture if (etatActuel == lecture) { // On met en pause les lecteurs des joueurs emettreCommande(pauseMorceau); // On met le lecteur en Pause etatActuel = pause; // On enfonce le bouton pause actionPause->setChecked(true); // On met la lecture en pause FSOUND_SetPaused(canalAudio, true); } // Dans les autres cas il y a un probleme else { qWarning("Le bouton lecture etait enfonce alors que le lecteur n'etait pas en en train de lire (appuiLecture - LecteurAudio.cpp)"); return; } } }
bool FMODEngine::SetPlayState( MUSIKEngine::PlayState state) { switch (state ) { case MUSIKEngine::Paused: return FSOUND_SetPaused(FSOUND_ALL, 1) != 0; case MUSIKEngine::Playing: return FSOUND_SetPaused(FSOUND_ALL, 0) != 0; case MUSIKEngine::Stopped: return FSOUND_SetPaused(FSOUND_ALL, 1) != 0; } return false; }
void CSoundSourceFMod::SetLooping( BOOL loop ) { if(_Loop!=loop) { _Loop = loop; if(_FModChannel!=-1) { //首先暂停 FSOUND_SetPaused(_FModChannel, true); FSOUND_SetLoopMode(_FModChannel, _Loop?FSOUND_LOOP_NORMAL:FSOUND_LOOP_OFF); FSOUND_SetPaused(_FModChannel, false); } } }
bool FMODStreamOut::SetPlayState( MUSIKEngine::PlayState state) { switch (state ) { case MUSIKEngine::Paused: return FSOUND_SetPaused(FMODChannel, 1) != 0; case MUSIKEngine::Playing: return FSOUND_SetPaused(FMODChannel, 0) != 0; case MUSIKEngine::Stopped: return FSOUND_SetPaused(FMODChannel, 1) != 0; default: break; } return false; }
static inline VOID M_ResumeMusic(VOID) { if (mod && FMUSIC_GetPaused(mod)) FMUSIC_SetPaused(mod, FALSE); if (fsoundchannel != -1 && FSOUND_GetPaused(fsoundchannel)) FSOUND_SetPaused(fsoundchannel, FALSE); }
bool CMusicChannelFMod::playStream() { if (FSOUND_Stream_GetOpenState(_MusicStream) == -3) { nlwarning("NLSOUND FMod Driver: stream failed to open. (file not found, out of memory or other error)"); FSOUND_Stream_Close(_MusicStream); _MusicStream = NULL; return false; } // Start playing if ((_MusicChannel = FSOUND_Stream_PlayEx(FSOUND_FREE, _MusicStream, NULL, true)) == -1) return false; // stereo pan (as reccomended) FSOUND_SetPan(_MusicChannel, FSOUND_STEREOPAN); // update volume int vol255 = (int)(_Gain * 255.0f); FSOUND_SetVolumeAbsolute(_MusicChannel, vol255); // Set a callback to know if stream has ended _CallBackEnded = false; FSOUND_Stream_SetEndCallback(_MusicStream, streamEndCallBack, static_cast<void *>(this)); // unpause FSOUND_SetPaused(_MusicChannel, false); return true; }
VOID CSoundSourceFMod::Play(VOID) { //停止 Stop(); //播放 if(_Sample) { CSoundBufferFMod* bufFMod= static_cast<CSoundBufferFMod*>(_Sample); _State= source_playing; //以暂停模式开始播放声音 if(bufFMod->m_pFModSample) _FModChannel= FSOUND_PlaySoundEx(FSOUND_FREE, bufFMod->m_pFModSample, NULL, true); //在Channel播放 if(_FModChannel!=-1) { FSOUND_SetLoopMode(_FModChannel, _Loop?FSOUND_LOOP_NORMAL:FSOUND_LOOP_OFF); //音量 UpdateVolume(); //开始播放 FSOUND_SetPaused(_FModChannel, false); } } }
void LecteurAudio::joueurLectureMorceau() { // Si aucun fichier audio n'est actuellement ouvert, on quitte la fonction if (!fluxAudio) { qWarning("Demande de lecture alors qu'aucun fichier n'est ouvert (joueurLectureMorceau - LecteurAudio.cpp)"); return; } // Si le lecteur etait a l'arret if (etatActuel == arret) { // L'etat passe a Lecture etatActuel = lecture; // On initialise le canal audio en commencant la lecture canalAudio = FSOUND_Stream_Play(FSOUND_FREE, fluxAudio); // On se positionne a l'endroit indique par le MJ FSOUND_Stream_SetTime(fluxAudio, joueurPositionTemps); // On regle le volume FSOUND_SetVolume(canalAudio, niveauVolume->value()); } // Si le lecteur etait en pause else if (etatActuel == pause) { // L'etat passe a Lecture etatActuel = lecture; // On reprend la lecture du titre FSOUND_SetPaused(canalAudio, false); } // Dans tous les autres cas il s'agit d'une erreur else qWarning("Demande de lecture d'un titre alors que le lecteur n'est ni en pause, ni a l'arret (joueurLectureMorceau - LecteurAudio.cpp)"); }
EXPORT void HWRAPI (StopSource) (INT32 chan) { FSOUND_SAMPLE *fmsample; if (chan < 0) return; fmsample = FSOUND_GetCurrentSample(chan); if (!fmsample) return; if (!FSOUND_GetPaused(relcheckup(chan))) { if (!FSOUND_SetPaused(relcheckup(chan),true)) { DBG_Printf("FMOD(StopSource,FSOUND_SetPaused, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); } else if (relstack(chan) != -1) { relarray[relstack(chan)].pos.active = false; } } #ifdef MORESTUFF else DBG_Printf("FMOD(StopSource,FSOUND_GetPaused): Channel %i is stopped already\n",chan); #endif }
static inline VOID M_PauseMusic(VOID) { if (mod && !FMUSIC_GetPaused(mod)) FMUSIC_SetPaused(mod, TRUE); if (fsoundchannel != -1 && FSOUND_IsPlaying(fsoundchannel)) FSOUND_SetPaused(fsoundchannel, TRUE); }
void LLAudioEngine_FMOD::stopInternetStream() { if (mInternetStreamChannel != -1) { FSOUND_SetPaused(mInternetStreamChannel, true); FSOUND_SetPriority(mInternetStreamChannel, 0); mInternetStreamChannel = -1; } if (mCurrentInternetStreamp) { llinfos << "Stopping internet stream: " << mCurrentInternetStreamp->getURL() << llendl; if (mCurrentInternetStreamp->stopStream()) { delete mCurrentInternetStreamp; } else { llwarns << "Pushing stream to dead list: " << mCurrentInternetStreamp->getURL() << llendl; mDeadStreams.push_back(mCurrentInternetStreamp); } mCurrentInternetStreamp = NULL; //mInternetStreamURL.clear(); } }
//set listener static void relset(INT32 which) { INT32 i; if (which == -2 || which == -1) { which = -which; memset(&rellistener[which-1], 0, sizeof (rellistener_s_t)); //Delete me for (i = 0; i <= STATIC_SOURCES_NUM; i++) { if (relarray[i].pos.active && relarray[i].listener == which) { FSOUND_SetPaused(relarray[i].chan,true); relarray[i].pos.active = false; } } return; } else if (which == 1 || which ==2) { float pos[3], vel[3]; // Temp bin which -= 1; //Hello! //Get update FSOUND_3D_Listener_GetAttributes(&pos[0],&vel[0],NULL,NULL,NULL,NULL,NULL,NULL); memcpy(&rellistener[which].pos[0],&pos[0],sizeof (pos)); memcpy(&rellistener[which].vel[0],&vel[0],sizeof (vel)); if (!rellistener[which].active) for (i = 0; i <= STATIC_SOURCES_NUM; i++) { if (!relarray[i].pos.active && relarray[i].listener == which) { FSOUND_SetPaused(relarray[i].chan,false); relarray[i].pos.active = true; } } rellistener[which].active = which; } else { memset(&rellistener[0], 0, sizeof (rellistener_s_t)); memset(&rellistener[1], 0, sizeof (rellistener_s_t)); } }
void LecteurAudio::appuiPause(bool etatBouton) { // Le bouton vient d'etre enfonce if (etatBouton) { // Le lecture etait en train de lire un titre : on met en pause if (etatActuel == lecture) { // On met en pause les lecteurs des joueurs emettreCommande(pauseMorceau); // On passe l'etat en pause etatActuel = pause; // On relache le bouton Lecture actionLecture->setChecked(false); // On met la lecture en pause FSOUND_SetPaused(canalAudio, true); } // Dans tous les autres etats, on relache le bouton de pause else actionPause->setChecked(false); } // Le bouton vient d'etre relache else { // Le lecture etait en pause : on reprend la lecture if (etatActuel == pause) { // On remet en lecture les lecteurs des joueurs emettreCommande(lectureMorceau); // Nouvel etat : lecture etatActuel = lecture; // On enfonce le bouton Lecture actionLecture->setChecked(true); // On reprend la lecture du titre FSOUND_SetPaused(canalAudio, false); } // Dans les autres cas il y a un probleme else { qWarning("Le bouton pause etait enfonce alors que le lecteur n'etait pas en pause (appuiPause - LecteurAudio.cpp)"); return; } } }
void wsay(char *dafilename, long dafreq, long volume1, long volume2) { unsigned char ch1, ch2; long i, j, bad, free=-1, oldest=0; unsigned int oldestpos=0; int chan; if (fmod_inited == 0) return; i = numwaves-1; do { bad = 0; j = 0; while ((dafilename[j] > 0) && (j < 16)) { ch1 = dafilename[j]; if ((ch1 >= 97) && (ch1 <= 123)) ch1 -= 32; ch2 = instname[i][j]; if ((ch2 >= 97) && (ch2 <= 123)) ch2 -= 32; if (ch1 != ch2) {bad = 1; break;} j++; } if (bad == 0) { #if 0 for (j=0; j<NUMCHANNELS; j++) { if (!FSOUND_IsPlaying(channels[j])) { free = j; break; } if (j==0) continue; if (FSOUND_GetCurrentPosition(channels[j]) > oldestpos) { oldest = j; oldestpos = FSOUND_GetCurrentPosition(channels[j]); } } if (free < 0) { FSOUND_StopSound(channels[oldest]); free = oldest; } chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[i], NULL, 1); if (chan == -1) return; FSOUND_SetFrequency(chan, dafreq*11025/4096); FSOUND_SetVolume(chan, (volume1*volume2)>>1); // set pan FSOUND_SetPaused(chan, 0); #endif channels[free] = chan; return; } i--; } while (i >= 0); }
bool FMODStreamOut::Start() { FMODChannel = FSOUND_Stream_PlayEx(FSOUND_FREE, StreamPointer, NULL, 1); SetVolume(m_Volume); FSOUND_SetPaused(FMODChannel, 0); return FMODChannel != -1; }
void Source::Pause() { // Is the source currently playing? if (IsPlaying()) { // Pause now FSOUND_SetPaused(m_nChannel, 1); } }
void CAudioManager::UnPauseAll(){ if(m_bValidAudio == false) return; for(int i = 0; i < m_AudioClip.size(); i++){ if(FSOUND_GetPaused(m_AudioClip[i].channelPlaying) == true) FSOUND_SetPaused(m_AudioClip[i].channelPlaying, false); } }
//=========================================================================== // DM_FModExtPause //=========================================================================== void DM_FModExtPause(int pause) { if(!ext_inited) return; //ext_playing = !pause; if(module) FMUSIC_SetPaused(module, pause != 0); if(stream) FSOUND_SetPaused(stream_channel, pause != 0); }
void LLAudioChannelFMOD::play() { if (!mChannelID) { llwarns << "Playing without a channelID, aborting" << llendl; return; } if (!FSOUND_SetPaused(mChannelID, false)) { llwarns << "LLAudioChannelFMOD::play error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; } getSource()->setPlayedOnce(true); }
void PlayStereoFrequency( short player, short which, short freq ) { if( soundOn ) { #ifdef UseSDLMixer Mix_PlayChannel(-1, sound[which], 0); // Mix_SetPanning(chanHandle, 0, 0); #else // FMod int chanHandle = FSOUND_PlaySoundEx( FSOUND_FREE, sound[which], NULL, true ); FSOUND_SetPan( chanHandle, player? 255: 0 ); FSOUND_SetFrequency( chanHandle, (FSOUND_GetFrequency(chanHandle) * (16 + freq)) / 16 ); FSOUND_SetPaused( chanHandle, false ); #endif } }
bool Source::Play(bool bRestart) { // Is a buffer loaded? Buffer *pBuffer = static_cast<Buffer*>(GetBuffer()); if (!pBuffer) return false; // Error! // Paused? if (IsPaused() && !bRestart) { FSOUND_SetPaused(m_nChannel, 0); } else { // Play if (IsPlaying()) { if (!bRestart) return true; // Done Stop(); } m_nChannel = pBuffer->Play(); // Add source to sound manager static_cast<SoundManager&>(GetSoundManager()).AddActiveSource(*this); // Get frequency and setup pitch m_nFrequency = FSOUND_GetFrequency(m_nChannel); float fPitch = m_fPitch; m_fPitch = -1.0f; SetPitch(fPitch); // Set volume pBuffer->SetVolume(m_nChannel, m_fVolume); // [HACK] HW sound: We have to pause the playback if we want to change the looping mode... // FSOUND_SetPaused(m_nChannel, 1); pBuffer->SetLooping(m_nChannel, m_bLooping); // FSOUND_SetPaused(m_nChannel, 0); // Set attributes SetAttribute(Position, m_vAttributes[Position]); SetAttribute(Velocity, m_vAttributes[Velocity]); } // Done return true; }
void LecteurAudio::joueurPauseMorceau() { // Si aucun fichier audio n'est actuellement ouvert, on quitte la fonction if (!fluxAudio) { qWarning("Demande de mise en pause alors qu'aucun fichier n'est ouvert (joueurPauseMorceau - LecteurAudio.cpp)"); return; } // Si le lecteur etait en train de lire if (etatActuel == lecture) { // On met le lecteur en Pause etatActuel = pause; // On met la lecture en pause FSOUND_SetPaused(canalAudio, true); } // Dans tous les autres cas il s'agit d'une erreur else qWarning("Demande de mis en pause du lecteur alors qu'il n'etait pas en lecture (joueurPauseMorceau - LecteurAudio.cpp)"); }
EXPORT INT32 HWRAPI (StartSource) (INT32 chan) { FSOUND_SAMPLE *fmsample; if (chan < 0) return -1; fmsample = FSOUND_GetCurrentSample(chan); if (!fmsample) return -1; #ifdef MORESTUFF if (FSOUND_Sample_GetMode(fmsample) & FSOUND_2D) { DBG_Printf("FMOD(StartSource,Main): Starting 2D channel %i?\n",chan); //return -1; } else { DBG_Printf("FMOD(StartSource,Main): Starting 3D Channel %i?\n",chan); //return -1; } #endif if (FSOUND_GetPaused(relcheckup(chan))) { if (!FSOUND_SetPaused(relcheckup(chan), false)) DBG_Printf("FMOD(StartSource,FSOUND_SetPaused, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); else if (relstack(chan) != -1) relarray[relstack(chan)].pos.active = false; } else DBG_Printf("FMOD(StartSource,FSOUND_GetPaused): Channel %i is playing already",chan); return chan; }
void LLAudioEngine_FMOD::updateInternetStream() { // Kill dead internet streams, if possible std::list<LLAudioStreamFMOD *>::iterator iter; for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) { LLAudioStreamFMOD *streamp = *iter; if (streamp->stopStream()) { llinfos << "Closed dead stream" << llendl; delete streamp; mDeadStreams.erase(iter++); } else { iter++; } } // Don't do anything if there are no streams playing if (!mCurrentInternetStreamp) { return; } int open_state = mCurrentInternetStreamp->getOpenState(); if (!open_state) { // Stream is live // start the stream if it's ready if (mInternetStreamChannel < 0) { mInternetStreamChannel = mCurrentInternetStreamp->startStream(); if (mInternetStreamChannel != -1) { // Reset volume to previously set volume setInternetStreamGain(mInternetStreamGain); FSOUND_SetPaused(mInternetStreamChannel, false); //FSOUND_Stream_Net_SetMetadataCallback(mInternetStream, callbackMetaData, this); } } } switch(open_state) { default: case 0: // success break; case -1: // stream handle is invalid llwarns << "InternetStream - invalid handle" << llendl; stopInternetStream(); return; case -2: // opening //strlcpy(mInternetStreamArtist, "Opening", 256); break; case -3: // failed to open, file not found, perhaps llwarns << "InternetSteam - failed to open" << llendl; stopInternetStream(); return; case -4: // connecting //strlcpy(mInternetStreamArtist, "Connecting", 256); break; case -5: // buffering //strlcpy(mInternetStreamArtist, "Buffering", 256); break; } }
/** Pauses a stream * * @param pause Whether to pause the stream or not * * @returns If the stream paused, return true, otherwise false */ bool FMODStreamBuffer::Pause(bool pause) { if(IsPlaying() == true && FSOUND_SetPaused(m_channel,pause) == 1) return true; return false; }
void wsayfollow(char *dafilename, long dafreq, long davol, long *daxplc, long *dayplc, char followstat) { /* dafilename: filename dafreq: 4096 = Middle C 8192 = +1 8ve davol: 0-256 = volume daxplc: dayplc: followstat: 0 = sound emination origin (fixed) followstat: 1 = pointer to sprite coordinates (dynamic) followstat: 0 = position is fixed in space 1 = position follows an object */ unsigned char ch1, ch2; long i, wavnum, bad, oldest=0, free=-1, ox, oy, x, y, vo; unsigned int oldestpos=0; int chan; if (fmod_inited == 0) return; for (wavnum=numwaves-1;wavnum>=0;wavnum--) { bad = 0; i = 0; while ((dafilename[i] > 0) && (i < 16)) { ch1 = dafilename[i]; if ((ch1 >= 97) && (ch1 <= 123)) ch1 -= 32; ch2 = instname[wavnum][i]; if ((ch2 >= 97) && (ch2 <= 123)) ch2 -= 32; if (ch1 != ch2) {bad = 1; break;} i++; } if (bad != 0) continue; #if 0 for (i=0; i<NUMCHANNELS; i++) { if (!FSOUND_IsPlaying(channels[i])) { free = i; break; } if (i==0) continue; if (FSOUND_GetCurrentPosition(channels[i]) > oldestpos) { oldest = i; oldestpos = FSOUND_GetCurrentPosition(channels[i]); } } if (free < 0) { FSOUND_StopSound(channels[oldest]); free = oldest; } chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[wavnum], NULL, 1); if (chan == -1) return; FSOUND_SetFrequency(chan, dafreq*11025/4096); FSOUND_SetVolume(chan, davol); FSOUND_SetPaused(chan, 0); #endif channels[free] = chan; return; } }
glui32 glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) { FILE *file; long pos, len; glui32 type; char *buf; int offset = 0; int i; if (!chan) { gli_strict_warning("schannel_play_ext: invalid id."); return 0; } /* stop previous noise */ glk_schannel_stop(chan); if (repeats == 0) return 1; /* load sound resource into memory */ if (!giblorb_is_resource_map()) { char name[1024]; sprintf(name, "%s/SND%ld", gli_workdir, snd); file = fopen(name, "rb"); if (!file) return 0; fseek(file, 0, SEEK_END); len = ftell(file); buf = malloc(len); if (!buf) { fclose(file); return 0; } fseek(file, 0, 0); fread(buf, 1, len, file); fclose(file); /* identify by file magic the two types that fmod can do... */ type = 0; /* unidentified */ /* AIFF */ if (len > 4 && !memcmp(buf, "FORM", 4)) type = giblorb_ID_FORM; /* WAVE */ if (len > 4 && !memcmp(buf, "WAVE", 4)) type = giblorb_ID_WAVE; /* MIDI */ if (len > 4 && !memcmp(buf, "MThd", 4)) type = giblorb_ID_MIDI; /* Ogg Vorbis */ if (len > 4 && !memcmp(buf, "OggS", 4)) type = giblorb_ID_OGG; /* s3m */ if (len > 0x30 && !memcmp(buf + 0x2c, "SCRM", 4)) type = giblorb_ID_MOD; /* XM */ if (len > 20 && !memcmp(buf, "Extended Module: ", 17)) type = giblorb_ID_MOD; /* MOD */ if (len > 1084) { char resname[4]; memcpy(resname, buf + 1080, 4); if (!strcmp(resname+1, "CHN") || /* 4CHN, 6CHN, 8CHN */ !strcmp(resname+2, "CN") || /* 16CN, 32CN */ !strcmp(resname, "M.K.") || !strcmp(resname, "M!K!") || !strcmp(resname, "FLT4") || !strcmp(resname, "CD81") || !strcmp(resname, "OKTA") || !strcmp(resname, " ")) type = giblorb_ID_MOD; } if (!memcmp(buf, "\377\372", 2)) /* mp3 */ type = giblorb_ID_MP3; /* look for RIFF (future boy has broken resources...?) */ if (len > 128 && type == 0) for (i = 0; i < 124; i++) if (!memcmp(buf+i, "RIFF", 4)) { offset = i; type = giblorb_ID_WAVE; break; } if (type == 0) type = giblorb_ID_MP3; } else { giblorb_get_resource(giblorb_ID_Snd, snd, &file, &pos, &len, &type); if (!file) return 0; buf = malloc(len); if (!buf) return 0; fseek(file, pos, 0); fread(buf, 1, len, file); } switch (type) { case giblorb_ID_FORM: case giblorb_ID_WAVE: case giblorb_ID_MP3: chan->sample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buf + offset, FSOUND_NORMAL|FSOUND_LOADMEMORY, 0, len); if (!chan->sample) { free(buf); return 0; } if (repeats != 1) FSOUND_Sample_SetMode(chan->sample, FSOUND_LOOP_NORMAL); else FSOUND_Sample_SetMode(chan->sample, FSOUND_LOOP_OFF); chan->channel = FSOUND_PlaySound(FSOUND_FREE, chan->sample); FSOUND_SetVolume(chan->channel, chan->volume / 256); FSOUND_SetPaused(chan->channel, 0); break; case giblorb_ID_MOD: case giblorb_ID_MIDI: chan->module = FMUSIC_LoadSongEx(buf, 0, len, FSOUND_LOADMEMORY, 0, 0); if (!chan->module) { free(buf); return 0; } if (repeats != 1) FMUSIC_SetLooping(chan->module, 1); else FMUSIC_SetLooping(chan->module, 0); FMUSIC_SetMasterVolume(chan->module, chan->volume / 256); FMUSIC_PlaySong(chan->module); break; default: gli_strict_warning("schannel_play_ext: unknown resource type."); } free(buf); return 1; }
/* [ [DESCRIPTION] [PARAMETERS] [RETURN_VALUE] [REMARKS] [SEE_ALSO] ] */ int main(int argc, char *argv[]) { FSOUND_STREAM *stream; int read_percent = 0, i, driver = 0, channel = -1, status = 0, openstate, bitrate; unsigned int flags; char s[256] = ""; char key; if (FSOUND_GetVersion() < FMOD_VERSION) { printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); return 1; } if ((argc < 2) || (strnicmp(argv[1], "http:", 5))) { printf("-------------------------------------------------------------\n"); printf("FMOD netstream example.\n"); printf("Copyright (c) Firelight Technologies Pty, Ltd, 1999-2004.\n"); printf("-------------------------------------------------------------\n"); printf("Syntax: netstream <url>\n"); printf("Example: netstream http://www.fmod.org/stream.mp3\n\n"); return 1; } #if defined(WIN32) || defined(_WIN64) || defined(__CYGWIN32__) || defined(__WATCOMC__) FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND); #elif defined(__linux__) FSOUND_SetOutput(FSOUND_OUTPUT_OSS); #endif // ========================================================================================== // SELECT DRIVER // ========================================================================================== printf("---------------------------------------------------------\n"); switch (FSOUND_GetOutput()) { case FSOUND_OUTPUT_NOSOUND: printf("NoSound"); break; case FSOUND_OUTPUT_WINMM: printf("Windows Multimedia Waveout"); break; case FSOUND_OUTPUT_DSOUND: printf("Direct Sound"); break; case FSOUND_OUTPUT_A3D: printf("A3D"); break; case FSOUND_OUTPUT_OSS: printf("Open Sound System"); break; case FSOUND_OUTPUT_ESD: printf("Enlightenment Sound Daemon"); break; case FSOUND_OUTPUT_ALSA: printf("ALSA"); break; }; printf(" Driver list\n"); printf("---------------------------------------------------------\n"); for (i=0; i < FSOUND_GetNumDrivers(); i++) { printf("%d - %s\n", i+1, FSOUND_GetDriverName(i)); } printf("---------------------------------------------------------\n"); printf("Press a corresponding number or ESC to quit\n"); do { key = getch(); if (key == 27) exit(0); driver = key - '1'; } while (driver < 0 || driver >= FSOUND_GetNumDrivers()); FSOUND_SetDriver(driver); // ========================================================================================== // INITIALIZE // ========================================================================================== if (!FSOUND_Init(44100, 32, 0)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return 1; } /* Internet streams can work with a much smaller stream buffer than normal streams because they use another level of buffering on top of the stream buffer. */ FSOUND_Stream_SetBufferSize(100); /* Here's where we set the size of the network buffer and some buffering parameters. In this case we want a network buffer of 64k, we want it to prebuffer 60% of that when we first connect, and we want it to rebuffer 80% of that whenever we encounter a buffer underrun. */ FSOUND_Stream_Net_SetBufferProperties(64000, 60, 80); /* Open the stream using FSOUND_NONBLOCKING because the connect/buffer process might take a long time */ stream = FSOUND_Stream_Open(argv[1], FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0); if (!stream) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return 1; } printf("\nPress ESC to quit...\n\n"); key = 0; do { if (kbhit()) { key = getch(); } /* Play the stream if it's not already playing */ if (channel < 0) { channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE); FSOUND_SetPaused(channel, FALSE); if (channel != -1) { FSOUND_Stream_Net_SetMetadataCallback(stream, metacallback, 0); } } openstate = FSOUND_Stream_GetOpenState(stream); if ((openstate == -1) || (openstate == -3)) { printf("\nERROR: failed to open stream!\n"); printf("SERVER: %s\n", FSOUND_Stream_Net_GetLastServerStatus()); break; } FSOUND_Stream_Net_GetStatus(stream, &status, &read_percent, &bitrate, &flags); /* Show how much of the net buffer is used and what the status is */ if (metanum) { printf("%s - %s\n", artist, title); metanum = 0; } s[0] = 0; strncat(s, bar, (read_percent >> 1) + (read_percent & 1)); strncat(s, nobar, (100 - read_percent) >> 1); printf("|%s| %d%% %s\r", s, read_percent, status_str[status]); Sleep(16); } while (key != 27); printf("\n"); FSOUND_Stream_Close(stream); FSOUND_Close(); return 0; }
/* [ [DESCRIPTION] [PARAMETERS] [RETURN_VALUE] [REMARKS] [SEE_ALSO] ] */ int main() { FSOUND_SAMPLE *samp1 = 0, *samp2 = 0; int key; int eqid1,eqid2; if (FSOUND_GetVersion() < FMOD_VERSION) { printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); return 1; } /* INITIALIZE */ FSOUND_SetBufferSize(100); /* This is nescessary to get FX to work on output buffer */ if (!FSOUND_Init(44100, 32, FSOUND_INIT_ENABLESYSTEMCHANNELFX)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } /* LOAD SAMPLES */ /* PCM,44,100 Hz, 8 Bit, Mono */ samp1 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/drumloop.wav", FSOUND_2D, 0, 0); if (!samp1) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } FSOUND_Sample_SetMode(samp1, FSOUND_LOOP_OFF); /* PCM,44,100 Hz, 16 Bit, Stereo */ samp2 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/jules.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0); if (!samp2) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } /* DISPLAY HELP */ printf("FSOUND Output Method : "); switch (FSOUND_GetOutput()) { case FSOUND_OUTPUT_NOSOUND: printf("FSOUND_OUTPUT_NOSOUND\n"); break; case FSOUND_OUTPUT_WINMM: printf("FSOUND_OUTPUT_WINMM\n"); break; case FSOUND_OUTPUT_DSOUND: printf("FSOUND_OUTPUT_DSOUND\n"); break; case FSOUND_OUTPUT_ASIO: printf("FSOUND_OUTPUT_ASIO\n"); break; case FSOUND_OUTPUT_OSS: printf("FSOUND_OUTPUT_OSS\n"); break; case FSOUND_OUTPUT_ALSA: printf("FSOUND_OUTPUT_ALSA\n"); break; case FSOUND_OUTPUT_ESD: printf("FSOUND_OUTPUT_ESD\n"); break; }; printf("FSOUND Mixer : "); switch (FSOUND_GetMixer()) { case FSOUND_MIXER_QUALITY_FPU: printf("FSOUND_MIXER_QUALITY_FPU\n"); break; case FSOUND_MIXER_QUALITY_MMXP5: printf("FSOUND_MIXER_QUALITY_MMXP5\n"); break; case FSOUND_MIXER_QUALITY_MMXP6: printf("FSOUND_MIXER_QUALITY_MMXP6\n"); break; }; printf("FSOUND Driver : %s\n", FSOUND_GetDriverName(FSOUND_GetDriver())); printf("=========================================================================\n"); printf("Press 1 Play SOFTWARE sound affected by following reverb dsp unit (wet)\n"); printf(" 2 Play SOFTWARE sound unaffected by following reverb dsp unit (dry)\n"); if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND) { printf(" 3 Play HARDWARE FX enabled sound using Direct X 8 (echo+flange)\n"); printf(" 4 Set EQ on global software output to be affect by DX8 FX\n"); printf(" Press 1 or 2 to hear the effect (3 is unaffected)\n"); printf(" 5 Turn off EQ on global software output\n"); } printf(" ESC Quit\n"); printf("=========================================================================\n"); /* SET UP DSPS! */ SetupReverb(); /* Note if we are using a dsp unit for playing sounds, callback and parameter are ignored! */ DrySFXUnit = FSOUND_DSP_Create(NULL, FSOUND_DSP_DEFAULTPRIORITY_USER+100, 0); FSOUND_DSP_SetActive(DrySFXUnit, TRUE); /* You must pause the software output before getting the FX handle on it. */ if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND) { FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, TRUE); eqid1 = FSOUND_FX_Enable(FSOUND_SYSTEMCHANNEL, FSOUND_FX_PARAMEQ); eqid2 = FSOUND_FX_Enable(FSOUND_SYSTEMCHANNEL, FSOUND_FX_PARAMEQ); FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, FALSE); } /* START PLAYING! */ do { key = 0; printf("channels playing = %d cpu usage = %.02f%%\r", FSOUND_GetChannelsPlaying(), FSOUND_GetCPUUsage()); if (kbhit()) { key = getch(); if (key == '1') { int channel = FSOUND_PlaySound(FSOUND_FREE, samp1); } if (key == '2') { FSOUND_PlaySoundEx(FSOUND_FREE, samp1, DrySFXUnit, FALSE); } if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND) { if (key == '3') { static int fxchannel = FSOUND_FREE; static int echoid = -1, echoid2 = -1,flangeid = -1, firsttime; if (fxchannel == FSOUND_FREE) { firsttime = TRUE; } else { firsttime = FALSE; } fxchannel = FSOUND_PlaySoundEx(fxchannel, samp2, DrySFXUnit, TRUE); /* NOTE! Even though it is for hardware FX, set it to a DrySFXUnit just in case a non hardware output mode has been selected (such as WINMM/Linux etc) and it actually drops back to 100% software */ FSOUND_SetVolume(fxchannel, 120); /* turn it down a bit! */ if (firsttime) { echoid = FSOUND_FX_Enable(fxchannel, FSOUND_FX_ECHO); echoid2 = FSOUND_FX_Enable(fxchannel, FSOUND_FX_ECHO); flangeid = FSOUND_FX_Enable(fxchannel, FSOUND_FX_FLANGER); } FSOUND_SetPaused(fxchannel, FALSE); FSOUND_FX_SetEcho(echoid, 80.0f, 70.0f, 100.0f, 100.0f, TRUE); FSOUND_FX_SetEcho(echoid2, 100, 70.0f, 10, 10, FALSE); } if (key == '4') { FSOUND_FX_SetParamEQ(eqid1, 8000, 36, -15); FSOUND_FX_SetParamEQ(eqid2, 16000, 36, -15); } if (key == '5') { FSOUND_FX_SetParamEQ(eqid1, 8000, 15, 0); FSOUND_FX_SetParamEQ(eqid2, 8000, 15, 0); } } } Sleep(10); } while (key != 27); printf("\n"); /* CLEANUP AND SHUTDOWN */ FSOUND_DSP_Free(DrySFXUnit); CloseReverb(); FSOUND_Sample_Free(samp1); FSOUND_Sample_Free(samp2); FSOUND_Close(); return 0; }