/* [ [DESCRIPTION] [PARAMETERS] [RETURN_VALUE] [REMARKS] [SEE_ALSO] ] */ void SetupReverb() { /* REVERB SETUP */ /* something to fiddle with. */ int delay[REVERB_NUMTAPS] = { 131, 149, 173, 211, 281, 401, 457}; /* prime numbers make it sound cool! */ int volume[REVERB_NUMTAPS] = { 120, 100, 95, 90, 80, 60, 50}; int pan[REVERB_NUMTAPS] = { 100, 128, 128, 152, 128, 100, 152}; int count; for (count=0; count< REVERB_NUMTAPS; count++) { DSP_ReverbTap[count].delayms = delay[count]; DSP_ReverbTap[count].volume = volume[count]; DSP_ReverbTap[count].pan = pan[count]; DSP_ReverbTap[count].historyoffset = 0; DSP_ReverbTap[count].historylen = (DSP_ReverbTap[count].delayms * 44100 / 1000); if (DSP_ReverbTap[count].historylen < FSOUND_DSP_GetBufferLength()) { DSP_ReverbTap[count].historylen = FSOUND_DSP_GetBufferLength(); /* just in case our calc is not the same. */ } DSP_ReverbTap[count].historybuff = (char *)calloc(DSP_ReverbTap[count].historylen, 4); /* * 4 is for 16bit stereo (mmx only) */ DSP_ReverbTap[count].workarea = NULL; DSP_ReverbTap[count].Unit = FSOUND_DSP_Create(&DSP_ReverbCallback, FSOUND_DSP_DEFAULTPRIORITY_USER+20+(count*2), &DSP_ReverbTap[count]); FSOUND_DSP_SetActive(DSP_ReverbTap[count].Unit, TRUE); } }
void CMusikPlayer::InitDSP() { if ( !m_DSP ) m_DSP = FSOUND_DSP_Create( &dspcallback, FSOUND_DSP_DEFAULTPRIORITY_USER, 0 ); if ( m_DSP ) FSOUND_DSP_SetActive( m_DSP, wxGetApp().Prefs.bUseEQ ); }
bool LLAudioEngine_FMOD::initWind() { if (!mWindGen) { bool enable; switch (FSOUND_GetMixer()) { case FSOUND_MIXER_MMXP5: case FSOUND_MIXER_MMXP6: case FSOUND_MIXER_QUALITY_MMXP5: case FSOUND_MIXER_QUALITY_MMXP6: enable = (typeid(MIXBUFFERFORMAT) == typeid(S16)); break; case FSOUND_MIXER_BLENDMODE: enable = (typeid(MIXBUFFERFORMAT) == typeid(S32)); break; case FSOUND_MIXER_QUALITY_FPU: enable = (typeid(MIXBUFFERFORMAT) == typeid(F32)); break; default: // FSOUND_GetMixer() does not return a valid mixer type on Darwin LL_INFOS("AppInit") << "Unknown FMOD mixer type, assuming default" << LL_ENDL; enable = true; break; } if (enable) { mWindGen = new LLWindGen<MIXBUFFERFORMAT>(FSOUND_GetOutputRate()); } else { LL_WARNS("AppInit") << "Incompatible FMOD mixer type, wind noise disabled" << LL_ENDL; } } mNextWindUpdate = 0.0; if (mWindGen && !mWindDSP) { mWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, mWindGen); } if (mWindDSP) { FSOUND_DSP_SetActive(mWindDSP, true); return true; } return false; }
void LLAudioEngine_FMOD::initWind() { mWindGen = new LLWindGen<MIXBUFFERFORMAT>; if (!gWindDSP) { gWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, mWindGen); } if (gWindDSP) { FSOUND_DSP_SetActive(gWindDSP, true); } mNextWindUpdate = 0.0; }
void SetupReverb() { /* REVERB SETUP */ /* something to fiddle with. */ int delay[REVERB_NUMTAPS] = { 131, 149, 173, 211, 281, 401, 457}; /* prime numbers make it sound good! */ int volume[REVERB_NUMTAPS] = { 120, 100, 95, 90, 80, 60, 50}; int pan[REVERB_NUMTAPS] = { 100, 128, 128, 152, 128, 100, 152}; int count; for (count=0; count< REVERB_NUMTAPS; count++) { DSP_ReverbTap[count].delayms = delay[count]; DSP_ReverbTap[count].volume = volume[count]; DSP_ReverbTap[count].pan = pan[count]; DSP_ReverbTap[count].historyoffset = 0; DSP_ReverbTap[count].historylen = (DSP_ReverbTap[count].delayms * 44100 / 1000); if (DSP_ReverbTap[count].historylen < FSOUND_DSP_GetBufferLength()) DSP_ReverbTap[count].historylen = FSOUND_DSP_GetBufferLength(); /* just in case our calc is not the same. */ #ifdef __MACH__ DSP_ReverbTap[count].historybuff = (char *)calloc(DSP_ReverbTap[count].historylen, 4); #else if (MPLibraryIsLoaded()) { DSP_ReverbTap[count].historybuff = (char *)MPAllocateAligned(DSP_ReverbTap[count].historylen * 4, kMPAllocateDefaultAligned, kMPAllocateClearMask); /* * 4 is for 16bit stereo (mmx only) */ } if (!DSP_ReverbTap[count].historybuff) { printf("Memory not allocated!"); exit (EXIT_FAILURE); } #endif DSP_ReverbTap[count].workarea = NULL; DSP_ReverbTap[count].Unit = FSOUND_DSP_Create(&DSP_ReverbCallback, FSOUND_DSP_DEFAULTPRIORITY_USER+20+(count*2), (void *)&DSP_ReverbTap[count]); FSOUND_DSP_SetActive(DSP_ReverbTap[count].Unit, TRUE); } }
/* [ [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; }
void CMusikPlayer::InitDSP() { if ( !m_DSP ) m_DSP = FSOUND_DSP_Create( &dspcallback, FSOUND_DSP_DEFAULTPRIORITY_USER, 0 ); ActivateDSP(); }
/* [ [DESCRIPTION] [PARAMETERS] [RETURN_VALUE] [REMARKS] [SEE_ALSO] ] */ int main() { FSOUND_SAMPLE *samp1 = 0, *samp2 = 0; int 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; } /* INITIALIZE */ if (!FSOUND_Init(44100, 32, 0)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } /* LOAD SAMPLES */ /* PCM,44,100 Hz, 8 Bit, Mono */ #if defined(__MACH__) || defined(WIN32) samp1 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/drumloop.wav", FSOUND_2D, 0, 0); #else samp1 = FSOUND_Sample_Load(FSOUND_FREE, ":::media:drumloop.wav", FSOUND_2D, 0, 0); #endif 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 */ #if defined(__MACH__) || defined(WIN32) samp2 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/jules.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0); #else samp2 = FSOUND_Sample_Load(FSOUND_FREE, ":::media:jules.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0); #endif 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; case FSOUND_OUTPUT_MAC: printf("FSOUND_OUTPUT_MAC\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"); 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); /* 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); } } 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; }