Skip to content
Permalink
Browse files
Allow user and application volume adjustments to both apply
Comment from ripsaw8080 (2019-11-10 @ 08:03):

It's important to consider features/functionality when looking for ways
to reduce processing. The MSCDEX-based volume control was made separate
of the DOSBox mixer for two reasons: 1) the SB mixer interface CD volume
control is tied to the DOSBox mixer by default (can be disabled with
sbmixer=false) and the two methods would be in conflict; 2) the user can
adjust the mixer volume on top of what the game does with the MSCDEX
volume, in other words a relative adjustment rather than an override.
  • Loading branch information
krcroft committed Nov 10, 2019
1 parent a243d3b commit a335427b2eabc19e498b6050771830cb9f2dd59c
Showing with 14 additions and 6 deletions.
  1. +2 −1 include/mixer.h
  2. +1 −1 src/dos/cdrom_image.cpp
  3. +11 −4 src/hardware/mixer.cpp
@@ -48,6 +48,7 @@ class MixerChannel {
public:
void SetVolume(float _left,float _right);
void SetScale( float f );
void SetScale( float _left, float _right_);
void UpdateVolume(void);
void SetFreq(Bitu _freq);
void Mix(Bitu _needed);
@@ -79,7 +80,7 @@ class MixerChannel {
void Enable(bool _yesno);
MIXER_Handler handler;
float volmain[2];
float scale;
float scale[2];
Bit32s volmul[2];

//This gets added the frequency counter each mixer step
@@ -538,7 +538,7 @@ void CDROM_Interface_Image::ChannelControl(TCtrl ctrl)
if (player.ctrlUsed && player.channel != NULL) {
const float leftVolumePercent = static_cast<float>(player.ctrlData.vol[0] / 255.0);
const float rightVolumePercent = static_cast<float>(player.ctrlData.vol[1] / 255.0);
player.channel->SetVolume(leftVolumePercent, rightVolumePercent);
player.channel->SetScale(leftVolumePercent, rightVolumePercent);
#ifdef DEBUG
LOG_MSG("%s CDROM: Game set the left and right volume to %3.0f%% and %3.0f%%, respectively",
get_time(), leftVolumePercent * 100, rightVolumePercent * 100);
@@ -92,11 +92,11 @@ Bit8u MixTemp[MIXER_BUFSIZE];

MixerChannel * MIXER_AddChannel(MIXER_Handler handler,Bitu freq,const char * name) {
MixerChannel * chan=new MixerChannel();
chan->scale = 1.0;
chan->handler=handler;
chan->name=name;
chan->SetFreq(freq);
chan->next=mixer.channels;
chan->SetScale(1.0);
chan->SetVolume(1,1);
chan->enabled=false;
chan->interpolate = false;
@@ -128,8 +128,8 @@ void MIXER_DelChannel(MixerChannel* delchan) {
}

void MixerChannel::UpdateVolume(void) {
volmul[0]=(Bits)((1 << MIXER_VOLSHIFT)*scale*volmain[0]*mixer.mastervol[0]);
volmul[1]=(Bits)((1 << MIXER_VOLSHIFT)*scale*volmain[1]*mixer.mastervol[1]);
volmul[0]=(Bits)((1 << MIXER_VOLSHIFT)*scale[0]*volmain[0]*mixer.mastervol[0]);
volmul[1]=(Bits)((1 << MIXER_VOLSHIFT)*scale[1]*volmain[1]*mixer.mastervol[1]);
}

void MixerChannel::SetVolume(float _left,float _right) {
@@ -139,7 +139,14 @@ void MixerChannel::SetVolume(float _left,float _right) {
}

void MixerChannel::SetScale( float f ) {
scale = f;
scale[0] = f;
scale[1] = f;
UpdateVolume();
}

void MixerChannel::SetScale( float _left, float _right) {
scale[0] = _left;
scale[1] = _right;
UpdateVolume();
}

0 comments on commit a335427

Please sign in to comment.