- Timestamp:
- Mar 9, 2000, 5:18:00 PM (25 years ago)
- Location:
- trunk/src/dsound/new
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dsound/new/OS2SNDBUFFER.CPP
r3047 r3050 1 /* $Id: OS2SNDBUFFER.CPP,v 1. 3 2000-03-08 20:44:09mike Exp $ */1 /* $Id: OS2SNDBUFFER.CPP,v 1.4 2000-03-09 16:18:00 mike Exp $ */ 2 2 3 3 /* … … 20 20 #include <stdlib.h> 21 21 #include <string.h> 22 #include <math.h>23 22 24 23 #define INITGUID … … 33 32 #include <misc.h> 34 33 34 #include "DSVolume.h" 35 35 36 36 WAVEFORMATEX wfxDefaultPrimaryBuf = { WAVE_FORMAT_PCM, … … 518 518 519 519 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufSetVolume (%d, buf=%X)", lVolume, me)); 520 if (me == NULL) { 521 return DSERR_INVALIDPARAM; 522 } 520 if (me == NULL || lVolume < -10000) { 521 return DSERR_INVALIDPARAM; 522 } 523 // some apps pass positive values in lVolume, that's wrong right?!? 523 524 me->DSvolume = (lVolume > 0) ? 0 : lVolume; 524 525 525 526 /* = (10 ^ (1/10)) = 1dB - but the formula below gives results _very_ similar */ 526 527 /* to 'real' DirectSound, indistinguishable for all practical purposes */ 527 me->volume = 255.0 * pow(4, me->DSvolume / 1000.0); 528 //me->volume = 255.0 * pow(4, me->DSvolume / 1000.0); 529 530 /* Note: for some strange reason the above code sometimes gives erroneous */ 531 /* results, hence we now use a simple conversion table (in steps of 4/100 dB) */ 532 533 if (me->DSvolume < -4000) 534 me->volume = 0; 535 else 536 me->volume = VolTable[-me->DSvolume / 4]; 537 528 538 dprintf((" New volume: %d", me->volume)); 529 539 … … 537 547 538 548 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufSetPan (%d, buf=%X)", lPan, me)); 539 if (me == NULL ) {549 if (me == NULL || lPan < -10000 || lPan > 10000) { 540 550 return DSERR_INVALIDPARAM; 541 551 } … … 546 556 } 547 557 548 /* Note: the formula below is not necessarily mathematically correct but is */ 549 /* experimentally proven to give very good results */ 550 me->pan = 255.0 * pow(4, -abs(lPan) / 1000.0); 551 me->pan = 255 - me->pan; 558 /* Note: we use very similar code as for volume above */ 552 559 if (lPan < 0) 553 me->pan = -me->pan; 560 if (lPan < -4000) 561 me->pan = -255; 562 else 563 me->pan = VolTable[-lPan / 4] - 255; 564 else 565 if (lPan > 4000) 566 me->pan = 255; 567 else 568 me->pan = 255 - VolTable[lPan / 4]; 569 570 dprintf((" New pan: %d", me->pan)); 554 571 555 572 return DS_OK; -
trunk/src/dsound/new/dsmixer.cpp
r3027 r3050 57 57 else 58 58 vol2 = inBuf->volume * (256 + inBuf->pan) / 256; 59 59 60 len = inBuf->bufferdesc.dwBufferBytes / bytespersample * 1024; 60 61 if ((inBuf->lpfxFormat->nChannels == 2) && (inBuf->lpfxFormat->wBitsPerSample == 16)) {
Note:
See TracChangeset
for help on using the changeset viewer.