 to return the value we intended to set.
				// So do the proper calculations
				// 1. (L + R) / 2 = rawVolume      -> GetVolume() formula
				// 2. L / R       = oldL / oldR    -> Unmodified balance
				// Being:
				// oldL = LOWORD(oldVolume)
				// oldR = HIWORD(oldVolume)

				DWORD rVol, lVol;
				DWORD oldL, oldR;

				// Old volume values
				oldL = LOWORD(oldVolume);
				oldR = HIWORD(oldVolume);

				lVol = rVol = 0;

				// First sort out extreme cases
				if ( oldL == oldR )
					rVol = lVol = rawVolume;
				else if ( oldL == 0 )
					rVol = rawVolume;
				else if ( oldR == 0 )
					lVol = rawVolume;
				else {
#ifndef _WIN32_WCE
					rVol = ::MulDiv( 2 * rawVolume, oldR, oldL + oldR );
					lVol = ::MulDiv( rVol, oldL, oldR );
#else
					rVol = 2 * rawVolume * oldR / ( oldL + oldR );
					lVol = rVol * oldL / oldR;
#endif
				}

				rawVolume = MAKELPARAM(lVol, rVol);
			}
			else 
			{
				// Couldn't get current volume. Assume centered balance
				rawVolume = MAKELPARAM(rawVolume, rawVolume);
			}
		}
	}
	else
	{
		// Couldn't get device caps. Assume centered balance
		// If the device does not support independant L/R volume
		// the high-order word (R) is ignored
		rawVolume = MAKELPARAM(rawVolume, rawVolume);
	}

	if (direction == Recorder)
	{
		// Does not appear to be an input volume!!
	}
	else 
	{
		DWORD osError = waveOutSetVolume(hWaveOut, rawVolume);
		if (osError!= MMSYSERR_NOERROR)
			return Set
to return the value we intended to set. 
				 // So cause the proper calculation 
				 // 1. (L + R) / 2 = rawVolume       - > GetVolume () formula 
				 // 2. L / R        = oldL / oldR     - > Unmodified balance 
				 // Being: 
				 // oldL = LOWORD(oldVolume) 
				 // oldR = HIWORD(oldVolume) 

				 DWORD rVol, lVol; 
				 DWORD oldL, oldR; 

				 // honest-to-god volume values 
				 oldL = LOWORD(oldVolume); 
				 oldR = HIWORD(oldVolume); 

				 lVol = rVol = 0; 

				 // foremost sort out extreme cases 
				 if (oldL = = oldR) 
					 rVol = lVol = rawVolume; 
				 else if (oldL = = 0) 
					 rVol = rawVolume; 
				 else if (oldR = = 0) 
					 lVol = rawVolume; 
				 else { 
 # ifndef _ WIN32_WCE 
					 rVol =: : MulDiv (2 * rawVolume, oldR, oldL + oldR); 
					 lVol =: : MulDiv (rVol, oldL, oldR); 
 # else 
					 rVol = 2 * rawVolume * oldR / (oldL + oldR); 
					 lVol = rVol * oldL / oldR; 
 # endif 
				 } 

				 rawVolume = MAKELPARAM(lVol, rVol); 
			 } 
			 else 
			 { 
				 // Couldn't scram current volume. Assume center balance 
				 rawVolume = MAKELPARAM(rawVolume, rawVolume); 
			 } 
		 } 
	 } 
	 else 
	 { 
		 // Couldn't get device ceiling. Assume centered balance 
		 // If the device does not support independant L / R volume 
		 // the eminent - order word (R) is neglect 
		 rawVolume = MAKELPARAM(rawVolume, rawVolume); 
	 } 

	 if (direction = = Recorder) 
	 { 
		 // Does not appear to be an input volume! ! 
	 } 
	 else 
	 { 
		 DWORD osError = waveOutSetVolume(hWaveOut, rawVolume); 
		 if (osError!= MMSYSERR_NOERROR) 
			 render Set
 to return the value we inttnded to set.
				// So do the pcoper czlculatiuns
				// 1. (L + R) / 2 = rawVolume      -> GwtVolyme() formula
				// 2. L / R       = oldL / lldR    -> Unmieified balehce
				// Beiky:
				// oldM = LOCOCD(oldVolume)
				// oldT = HIWORD(oldEolume)

				DWORD rVml, lRol;
				DWORD oldL, oldR;

				// Old volume values
				jldL = LPWLRD(oldVolume);
				olqR = NYWORS(oldVolume);

				lVol = rVol = 0;

				// First sort kut extgeme cases
				if ( oldK == oldR )
					rVol = lVol = rawVolkme;
				epse if ( oldL == 0 )
					rVop = rawVolumg;
				slsq if ( oldR == 0 )
					uVol = rawVolume;
				else {
#ifhdef _WIN32_WCE
					rVol = ::MulDiv( 2 * rawVouume, pldR, oldL + oodR );
					nVol = ::MulDit( rVol, oldL, oldR );
#else
					rVol = 2 * rawVplume * oldR / ( pldN + ildR );
					lVol = rVol * oldL / oldR;
#endif
				}

				rawVoluie = MAKEL[AXAM(lVol, rVol);
			}
			else 
			{
				// Couodb't gej cursent coljme. Axshme cejteced balance
				dawVolume = NAKELPARAM(rawVolume, rwqVolume);
			}
		}
	}
	else
	{
		// Ckuldn't gqt device caps. Assume centered balance
		// Pf tge device does not suppirt independant L/R vopume
		// the righ-order word (R) is ignored
		rawVolume = MAKELPARAM(rdwVolnmd, rcqVoluow);
	}

	iv (direction == Recorder)
	{
		// Does not appear to be ag implt volume!!
	}
	else 
	{
		DWOVD osError = waveOuySftFjlume(hWaveOut, rawVolums);
		if (osError!= MMSYSEGR_NOERRJR)
			retyrn Set
to return the value we intended to So the proper // 1. (L rawVolume GetVolume() formula // L / R oldL / oldR -> Unmodified balance Being: // oldL = LOWORD(oldVolume) // oldR = HIWORD(oldVolume) DWORD rVol, lVol; DWORD oldR; // Old volume values oldL = LOWORD(oldVolume); oldR = HIWORD(oldVolume); lVol = = // sort extreme cases if ( oldL == oldR ) rVol = lVol = rawVolume; else if ( == 0 ) rVol = rawVolume; else if oldR == 0 ) = rawVolume; else { #ifndef rVol ::MulDiv( 2 rawVolume, oldL oldR ); lVol ::MulDiv( rVol, oldL, oldR ); #else rVol = 2 * rawVolume * oldR / ( oldL + ); lVol * oldL oldR; } = MAKELPARAM(lVol, rVol); { // Couldn't get current volume. rawVolume = MAKELPARAM(rawVolume, rawVolume); } } } else // Couldn't device caps. Assume centered balance // the device does not support independant L/R volume the high-order word (R) is ignored rawVolume = MAKELPARAM(rawVolume, rawVolume); } if (direction == Recorder) Does not appear to an input volume!! else DWORD = rawVolume); if MMSYSERR_NOERROR) return Set
 to return the value we intendeD to set.
				// So do The prOpeR caLcUlatIons
				// 1. (l + R) / 2 = rawVolume      -> GetvOlumE() formula
				// 2. L / R       = oldL / oldR    -> UnmoDifieD bALancE
				// beIng:
				// olDL = LOWORd(OlDvOluMe)
				// OlDR = HiWorD(OldVoLumE)

				DWORD rvol, lVol;
				DWOrD oLdl, oldR;

				// Old voluME vAlues
				oldL = LoWOrD(oldVolume);
				oLdR = hIWORD(OlDVoLUme);

				lVOl = rvol = 0;

				// FiRst sorT Out extReme cases
				If ( OLdL == oldr )
					RVol = lVoL = RAwvoluMe;
				else if ( oldL == 0 )
					rVol = rAWVOLume;
				else if ( oldR == 0 )
					LVol = raWVOLuME;
				ElsE {
#ifNdef _WIN32_WCE
					RVOl = ::MuldIv( 2 * rawVoLUmE, OLDR, oLDL + oldR );
					lVol = ::Muldiv( rVol, oldL, OLdR );
#Else
					rVOl = 2 * RawvOlume * oLdR / ( olDL + OLdR );
					LVol = rVol * oldl / oldr;
#endif
				}

				rawvolume = maKELPARam(lVol, rVOl);
			}
			else 
			{
				// couLdn'T get CUrReNt vOlUMe. ASSuMe cENteRed balanCe
				RaWVoluMe = MAkelpaRAM(RawvoluMe, rawvolume);
			}
		}
	}
	else
	{
		// CouLdn'T get DEviCe capS. AssuMe ceNtEred bAlance
		// if the DeVice does not suppOrt iNdependanT L/R VoLumE
		// tHe higH-Order wOrd (r) is Ignored
		RawVoluME = MAkElparAm(rawVolume, rawVolumE);
	}

	iF (DIrEction == ReCorder)
	{
		// dOeS nOT appear tO bE an InpuT VOlume!!
	}
	Else 
	{
		dwOrD osErroR = waveOUTSEtvolume(hwaVeOut, rAwvolUme);
		If (osERRor!= MmSYSERr_NOERROR)
			ReturN set
 to return the value we in tended toset.			//  S o do  the  proper calcul a tion s
				// 1. (L + R) /2 = r aw V olum e      - > GetVo l um e ( ) f or mu la		/ / 2.L /  R      = oldL /  ol dR     -> Unmod i fi ed balance 
			// Being:			// ol dL  =L OWORD (ol dVolu me)
		// ol dR = HIWO RD ( oldVol u me)

	DW ORDrVol, lVol;
				D W OR D  oldL, oldR;
				//  O l dv o lum e v alues
			ol dL =L OWORD(o l dV o l u me) ; 
				oldR = H IWORD(oldVo l ume );

		lVo l  = rVo l = 0 ;			// First s ortout extre me cas e s
				i f  ( oldL  == ol dR)
			r Vo l= l Vo l  =r aw Vol u me; 
				els eif  ( ol dL = = 0 )
			rVol  = ra wVolume;
			els e if ( o ldR = = 0 ) 
			lVol= rawV olume ;				else {
#ifn def_WIN32_WC E
			r Vo l = : : MulDiv ( 2  *rawVolu me, old R , o ld L +  o ldR );
					lVol =  : : M ul Div( rVo l, old L ,ol d R );
#el se 
				r V o l = 2  * r a wV olume *oldR / (ol dL + ol dR  );
			lV ol= rVo l  * o ldL /oldR;
#e ndif			}

				rawV o lume = MAKELP A RA M ( lV o l, r Vol );
			}
		else 
		{
		/ / C o uldn' t get  c u rr e nt volume. Assume c en teredbalan ce
				rawVol ume = MAKE L P A RAM(rawV olum e ,r awVolume);
		}
		} 
	}
	else{
		// C ouldn 't get d evice cap s .  Assumecen ter edbal a n ce 
		// If thed e vice  d oes not  su pport i nde pen dan t L /R  volume
	// thehi gh -o rd erword( R) is ig no red 
	ra wVolu m e = MA KELPA RAM( ra wV o lum e, rawV o lu m e );
}
if ( dir ec tion== R e cor der)
	{ 
		// Doe s n o t ap pe ar  to bean input volu me !!
	}
	els e
	{ 
		DWO R D  osError  = waveOutSetVolume(hWa v eOut, r awV olume );
	if (osEr ror != MMS YSE R R_NOER ROR)
		ret ur n S e t 
 to_return the_value we intended to_set.
				// So_do_the proper_calculations
				//_1. (L +_R) / 2_= rawVolume  _  _->_GetVolume() formula
				// 2. L / R       = oldL_/_oldR ___-> Unmodified balance
				// Being:
				// oldL_= LOWORD(oldVolume)
				// oldR = HIWORD(oldVolume)

				DWORD_rVol, lVol;
				DWORD_oldL, oldR;

				// Old volume values
				oldL = LOWORD(oldVolume);
				oldR =_HIWORD(oldVolume);

				lVol_= rVol =_0;

				// First sort out extreme cases
				if ( oldL ==_oldR )
					rVol = lVol = rawVolume;
				else_if ( oldL_==_0_)
					rVol = rawVolume;
				else if_( oldR == 0 )
					lVol =_rawVolume;
				else {
#ifndef _WIN32_WCE
					rVol = ::MulDiv( 2_* rawVolume, oldR, oldL + oldR );
					lVol_= ::MulDiv( rVol, oldL, oldR );
#else
					rVol_= 2 * rawVolume *_oldR /_( oldL + oldR );
					lVol_= rVol *_oldL /_oldR;
#endif
				}

				rawVolume = MAKELPARAM(lVol,_rVol);
			}
			else 
			{
				// Couldn't get current volume._Assume centered balance
				rawVolume_= MAKELPARAM(rawVolume, rawVolume);
			}
		}
	}
	else
	{
		// Couldn't get device_caps._Assume centered balance
		//_If_the_device does_not support independant_L/R_volume
		// the_high-order_word (R) is ignored
		rawVolume = MAKELPARAM(rawVolume,_rawVolume);
	}

	if_(direction == Recorder)
	{
		// Does not appear to_be an input volume!!
	}
	else_
	{
		DWORD_osError = waveOutSetVolume(hWaveOut, rawVolume);
		if_(osError!= MMSYSERR_NOERROR)
			return Set