void FX_SetVolume ( int volume ) { int status; #ifdef PLAT_DOS switch( FX_SoundDevice ) { case SoundBlaster : case Awe32 : if ( BLASTER_CardHasMixer() ) { BLASTER_SetVoiceVolume( volume ); } else { MV_SetVolume( volume ); } break; case ProAudioSpectrum : case SoundMan16 : status = PAS_SetPCMVolume( volume ); if ( status != PAS_Ok ) { MV_SetVolume( volume ); } break; case GenMidi : case SoundCanvas : case WaveBlaster : break; case SoundScape : MV_SetVolume( volume ); break; case UltraSound : GUSWAVE_SetVolume( volume ); break; case SoundSource : case TandySoundSource : MV_SetVolume( volume ); break; } #else MV_SetVolume( volume ); #endif }
void FX_SetVolume ( int volume ) { MV_SetVolume( volume ); }
int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels, void *initdata) { if (MV_Installed) MV_Shutdown(); MV_SetErrorCode(MV_Ok); // MV_TotalMemory + 2: FIXME, see valgrind_errors.log int const totalmem = Voices * sizeof(VoiceNode) + MV_TOTALBUFFERSIZE + 2; #ifdef _3DS char *ptr = (char *) linearAlloc( totalmem); #else char *ptr = (char *) Xaligned_alloc(16, totalmem); #endif if (!ptr) { MV_SetErrorCode(MV_NoMem); return MV_Error; } Bmemset(ptr, 0, totalmem); MV_Voices = (VoiceNode *)ptr; ptr += Voices * sizeof(VoiceNode); // Set number of voices before calculating volume table MV_MaxVoices = Voices; LL_Reset((VoiceNode*) &VoiceList, next, prev); LL_Reset((VoiceNode*) &VoicePool, next, prev); for (int index = 0; index < Voices; index++) { LL_Add((VoiceNode*) &VoicePool, &MV_Voices[ index ], next, prev); } MV_SetReverseStereo(FALSE); ASS_SoundDriver = soundcard; // Initialize the sound card if (SoundDriver_Init(&MixRate, &numchannels, initdata) != MV_Ok) MV_SetErrorCode(MV_DriverError); if (MV_ErrorCode != MV_Ok) { ALIGNED_FREE_AND_NULL(MV_Voices); return MV_Error; } MV_Installed = TRUE; MV_CallBackFunc = NULL; MV_ReverbLevel = 0; MV_ReverbTable = NULL; // Set the sampling rate MV_MixRate = MixRate; // Set Mixer to play stereo digitized sound MV_SetMixMode(numchannels); MV_ReverbDelay = MV_BufferSize * 3; // Make sure we don't cross a physical page MV_MixBuffer[ MV_NumberOfBuffers ] = ptr; for (int buffer = 0; buffer < MV_NumberOfBuffers; buffer++) { MV_MixBuffer[ buffer ] = ptr; ptr += MV_BufferSize; } // Calculate pan table MV_CalcPanTable(); MV_SetVolume(MV_MAXTOTALVOLUME); // Start the playback engine if (MV_StartPlayback() != MV_Ok) { // Preserve error code while we shutdown. int status = MV_ErrorCode; MV_Shutdown(); MV_SetErrorCode(status); return MV_Error; } return MV_Ok; }