From f6def87e3434607d3a7a9600d8a2601d96156398 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Tue, 28 Apr 2009 21:48:24 +0000 Subject: [PATCH] Include an extra scale factor in the mixer volume to be set by a device Set the adlib device scale at 2.0 Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3377 --- include/mixer.h | 4 +++- src/hardware/adlib.cpp | 3 ++- src/hardware/mixer.cpp | 26 +++++++++----------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/include/mixer.h b/include/mixer.h index d8585a35..a31b5493 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: mixer.h,v 1.18 2009-04-25 16:25:03 harekiet Exp $ */ +/* $Id: mixer.h,v 1.19 2009-04-28 21:48:24 harekiet Exp $ */ #ifndef DOSBOX_MIXER_H #define DOSBOX_MIXER_H @@ -48,6 +48,7 @@ extern Bit8u MixTemp[MIXER_BUFSIZE]; class MixerChannel { public: void SetVolume(float _left,float _right); + void SetScale( float f ); void UpdateVolume(void); void SetFreq(Bitu _freq); void Mix(Bitu _needed); @@ -78,6 +79,7 @@ public: void Enable(bool _yesno); MIXER_Handler handler; float volmain[2]; + float scale; Bit32s volmul[2]; Bitu freq_add,freq_index; Bitu done,needed; diff --git a/src/hardware/adlib.cpp b/src/hardware/adlib.cpp index 8ab83109..d2e3bf94 100644 --- a/src/hardware/adlib.cpp +++ b/src/hardware/adlib.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: adlib.cpp,v 1.37 2009-04-26 18:24:36 qbix79 Exp $ */ +/* $Id: adlib.cpp,v 1.38 2009-04-28 21:48:24 harekiet Exp $ */ #include #include @@ -732,6 +732,7 @@ Module::Module( Section* configuration ) : Module_base(configuration) { std::string oplemu( section->Get_string( "oplemu" ) ); mixerChan = mixerObject.Install(OPL_CallBack,rate,"FM"); + mixerChan->SetScale( 2.0 ); if (oplemu == "old") { if ( oplmode == OPL_opl2 ) { handler = new old_OPL2::Handler(); diff --git a/src/hardware/mixer.cpp b/src/hardware/mixer.cpp index 81955e60..6999ba7d 100644 --- a/src/hardware/mixer.cpp +++ b/src/hardware/mixer.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: mixer.cpp,v 1.52 2009-04-26 18:24:36 qbix79 Exp $ */ +/* $Id: mixer.cpp,v 1.53 2009-04-28 21:48:24 harekiet Exp $ */ /* Remove the sdl code from here and have it handeld in the sdlmain. @@ -62,20 +62,6 @@ static INLINE Bit16s MIXER_CLIP(Bits SAMP) { } else return MAX_AUDIO; } -struct MIXER_Channel { - double vol_main[2]; - Bits vol_mul[2]; - Bit8u mode; - Bitu freq; - char * name; - MIXER_MixHandler handler; - Bitu sample_add; - Bitu sample_left; - Bitu remain; - bool playing; - MIXER_Channel * next; -}; - static struct { Bit32s work[MIXER_BUFSIZE][2]; Bitu pos,done; @@ -92,6 +78,7 @@ 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); @@ -126,8 +113,8 @@ void MIXER_DelChannel(MixerChannel* delchan) { } void MixerChannel::UpdateVolume(void) { - volmul[0]=(Bits)((1 << MIXER_VOLSHIFT)*volmain[0]*mixer.mastervol[0]); - volmul[1]=(Bits)((1 << MIXER_VOLSHIFT)*volmain[1]*mixer.mastervol[1]); + volmul[0]=(Bits)((1 << MIXER_VOLSHIFT)*scale*volmain[0]*mixer.mastervol[0]); + volmul[1]=(Bits)((1 << MIXER_VOLSHIFT)*scale*volmain[1]*mixer.mastervol[1]); } void MixerChannel::SetVolume(float _left,float _right) { @@ -136,6 +123,11 @@ void MixerChannel::SetVolume(float _left,float _right) { UpdateVolume(); } +void MixerChannel::SetScale( float f ) { + scale = f; + UpdateVolume(); +} + void MixerChannel::Enable(bool _yesno) { if (_yesno==enabled) return; enabled=_yesno;