void I_UpdateSoundParams(int channel, int vol, int sep, int pitch) { // proff 07/04/98: Added for CYGWIN32 compatibility #ifdef HAVE_LIBDSOUND int DSB_Status; if (noDSound == true) return; // proff 07/26/98: Added volume check if (vol==0) { IDirectSoundBuffer_Stop(lpSecondaryDSB[channel]); return; } IDirectSoundBuffer_SetVolume(lpSecondaryDSB[channel],VOL(vol)); IDirectSoundBuffer_SetPan(lpSecondaryDSB[channel],SEP(sep)); IDirectSoundBuffer_SetFrequency (lpSecondaryDSB[channel], ChannelInfo[channel].samplerate+PITCH(pitch)); if (ChannelInfo[channel].playing == true) { IDirectSoundBuffer_GetStatus(lpSecondaryDSB[channel], &DSB_Status); if ((DSB_Status & DSBSTATUS_PLAYING) == 0) IDirectSoundBuffer_Play(lpSecondaryDSB[channel], 0, 0, 0); } #endif // HAVE_LIBDSOUND }
/* Ac97 Volume Volume has been divided into 8 levels to correspond to 8 leds \param[in] Xuint32 volume */ void audio_set_volume(Xuint32 address, int volume) { Xuint32 v = 0; #define VOL(val, def) case val: v = def; break; switch(volume) { VOL(0, AC97_VOL_ATTN_44_5_DB); VOL(1, AC97_VOL_ATTN_41_5_DB); VOL(2, AC97_VOL_ATTN_35_5_DB); VOL(3, AC97_VOL_ATTN_29_5_DB); VOL(4, AC97_VOL_ATTN_23_5_DB); VOL(5, AC97_VOL_ATTN_17_5_DB); VOL(6, AC97_VOL_ATTN_11_5_DB); VOL(7, AC97_VOL_ATTN_6_0_DB); VOL(8, AC97_VOL_ATTN_0_DB); default: break; } XAC97_WriteReg(address, AC97_PCMOutVol, v); XAC97_WriteReg(address, AC97_MasterVol, AC97_VOL_MAX ); XAC97_WriteReg(address, AC97_AuxOutVol, AC97_VOL_MAX); XAC97_WriteReg(address, AC97_MasterVolMono, AC97_VOL_MAX); }
int I_StartSound(sfxinfo_t *sound, int vol, int sep, int pitch, int pri) { int channel=0; // proff 07/04/98: Added for CYGWIN32 compatibility #ifdef HAVE_LIBDSOUND HRESULT error; char *snddata; int sndlength; if (noDSound == true) return channel; // load sound data if we have not already I_CacheSound(sound); // find a free channel channel = I_GetFreeChannel(); // proff 07/26/98: Added volume check // proff 10/31/98: Added Stop before updating sound-data error = IDirectSoundBuffer_Stop(lpSecondaryDSB[channel]); ChannelInfo[channel].playing = false; if (vol==0) return channel; snddata = sound->data; ChannelInfo[channel].samplerate = (snddata[3] << 8) + snddata[2]; // proff 10/31/98: Use accurate time for this one ChannelInfo[channel].endtime = I_GetTime_RealTime() + (sound->length * 35) / ChannelInfo[channel].samplerate + 1; // skip past header snddata += 8; sndlength = sound->length - 8; error = IDirectSoundBuffer_SetCurrentPosition(lpSecondaryDSB[channel],0); // proff 11/09/98: Added for a slight speedup if (sound != ChannelInfo[channel].sfx) { DWORD *hand1,*hand2; DWORD len1,len2; ChannelInfo[channel].sfx = sound; error = IDirectSoundBuffer_Lock(lpSecondaryDSB[channel],0,65535, &hand1,&len1,&hand2,&len2, DSBLOCK_FROMWRITECURSOR); if (len1 >= sndlength) { memset(hand1, 128, len1); memcpy(hand1, snddata , sndlength); memset(hand2, 128, len2); } else { memcpy(hand1, snddata, len1); memcpy(hand2, &((char *)snddata)[len1], sndlength-len1); } error = IDirectSoundBuffer_Unlock (lpSecondaryDSB[channel], hand1, len1, hand2, len2); } IDirectSoundBuffer_SetVolume(lpSecondaryDSB[channel], VOL(vol)); IDirectSoundBuffer_SetPan(lpSecondaryDSB[channel], SEP(sep)); IDirectSoundBuffer_SetFrequency(lpSecondaryDSB[channel], ChannelInfo[channel].samplerate+PITCH(pitch)); error = IDirectSoundBuffer_Play(lpSecondaryDSB[channel], 0, 0, 0); ChannelInfo[channel].playing = true; #endif // HAVE_LIBDSOUND return channel; }