int PlatChangeCDDAVolume(int volume) { MMRESULT mmres; unsigned int newVolume; /* check the cdDeviceId */ if(cdDeviceID==NO_DEVICE) return SOUND_PLATFORMERROR; /* check the mixer device id */ if(cdAuxDeviceID==NO_DEVICE) return SOUND_PLATFORMERROR; /* scale and set the new volume */ { int channelVolume; channelVolume = VOLUME_CDDA_MINPLAT + WideMulNarrowDiv(volume, (VOLUME_CDDA_MAXPLAT-VOLUME_CDDA_MINPLAT), (CDDA_VOLUME_MAX-CDDA_VOLUME_MIN)); if(channelVolume < VOLUME_CDDA_MINPLAT) channelVolume = VOLUME_CDDA_MINPLAT; if(channelVolume > VOLUME_CDDA_MAXPLAT) channelVolume = VOLUME_CDDA_MAXPLAT; /* set left and right channels (if there is only one channel, should still work ok)*/ newVolume = channelVolume|(channelVolume<<16); } PlatGetCDDAVolumeControl(); mmres = auxSetVolume((UINT)cdAuxDeviceID,(DWORD)newVolume); if(mmres==MMSYSERR_NOERROR) return 1; else return SOUND_PLATFORMERROR; }
bool Win32RedBookDevice::setVolume(F32 volume) { if(!mAcquired) { setLastError("Device has not been acquired"); return(false); } if(!mVolumeInitialized) { setLastError("Volume failed to initialize"); return(false); } // move into a U32 - left/right U16 volumes U32 vol = U32(volume * 65536.f); if(vol > 0xffff) vol = 0xffff; if(mUsingMixer) { mMixerVolumeValue.dwValue = vol; mixerSetControlDetails(mVolumeDeviceId, &mMixerVolumeDetails, MIXER_SETCONTROLDETAILSF_VALUE); } else { vol |= vol << 16; auxSetVolume(mAuxVolumeDeviceId, vol); } setLastError(""); return(true); }
/*------------------------------------------------------------------------ * * PROTOTYPE : void DriverSampleSetVolume(float volume) * * DESCRIPTION : Master volume controle * */ static void SetVolume(float volume) { LPDIRECTSOUNDBUFFER pDS = g_lpPrimaryBuffer; if (!pDS) return; SYS_DXTRACE(pDS->SetVolume(GetVol(volume))); int v = (int)(volume*255.f); auxSetVolume(0, v|(v<<8)|(v<<16)|(v<<24)); }
void CDAudio_Shutdown(void) { if (!initialized) return; if (playing) // Manoel Kasimier CDAudio_Stop(); if (CD_ID != -1) // Manoel Kasimier auxSetVolume(CD_ID,CD_OrigVolume); // Manoel Kasimier if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD)NULL)) Con_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n"); }
void Win32RedBookDevice::closeVolume() { setLastError(""); if(!mVolumeInitialized) return; if(mUsingMixer) { mMixerVolumeValue.dwValue = mOriginalVolume; mixerSetControlDetails(mVolumeDeviceId, &mMixerVolumeDetails, MIXER_SETCONTROLDETAILSF_VALUE); mixerClose((HMIXER)mVolumeDeviceId); } else auxSetVolume(mAuxVolumeDeviceId, mOriginalVolume); mVolumeInitialized = false; }
void CD_SetVolume(unsigned long Volume) { if (CD_ID != -1) auxSetVolume(CD_ID,(Volume<<16)+Volume); }