|
|
| version 1.10, 2005/02/16 09:31:55 | version 1.14, 2007/01/08 06:58:02 |
|---|---|
| Line 10 | Line 10 |
| #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) |
| #include "vermouth.h" | #include "vermouth.h" |
| #endif | #endif |
| #if defined(MT32SOUND_DLL) | |
| #include "mt32snd.h" | |
| #endif | |
| #if defined(_M_IA64) || defined(_M_AMD64) | |
| #define SOUNDBUFFERALIGN (1 << 3) | |
| #else | |
| #define SOUNDBUFFERALIGN (1 << 2) | |
| #endif | |
| #if !defined(_WIN64) | |
| #ifdef __cplusplus | #ifdef __cplusplus |
| extern "C" { | extern "C" { |
| #endif | #endif |
| Line 18 void __fastcall satuation_s16mmx(SINT16 | Line 28 void __fastcall satuation_s16mmx(SINT16 |
| #ifdef __cplusplus | #ifdef __cplusplus |
| } | } |
| #endif | #endif |
| #endif | |
| #if 1 | #if 1 |
| Line 75 UINT soundmng_create(UINT rate, UINT ms) | Line 86 UINT soundmng_create(UINT rate, UINT ms) |
| UINT samples; | UINT samples; |
| DSBUFFERDESC dsbdesc; | DSBUFFERDESC dsbdesc; |
| PCMWAVEFORMAT pcmwf; | PCMWAVEFORMAT pcmwf; |
| int i; | |
| if ((pDSound == NULL) || | if ((pDSound == NULL) || |
| (rate != 11025) && (rate != 22050) && (rate != 44100)) { | (rate != 11025) && (rate != 22050) && (rate != 44100)) { |
| Line 91 UINT soundmng_create(UINT rate, UINT ms) | Line 103 UINT soundmng_create(UINT rate, UINT ms) |
| // keydispr_delayinit((UINT8)((ms * 10 + 563) / 564)); | // keydispr_delayinit((UINT8)((ms * 10 + 563) / 564)); |
| samples = (rate * ms) / 2000; | samples = (rate * ms) / 2000; |
| samples = (samples + 3) & (~3); | samples = (samples + SOUNDBUFFERALIGN - 1) & (~(SOUNDBUFFERALIGN - 1)); |
| dsstreambytes = samples * 2 * sizeof(SINT16); | dsstreambytes = samples * 2 * sizeof(SINT16); |
| soundmng_setreverse(FALSE); | soundmng_setreverse(FALSE); |
| Line 103 UINT soundmng_create(UINT rate, UINT ms) | Line 115 UINT soundmng_create(UINT rate, UINT ms) |
| pcmwf.wf.nBlockAlign = 2 * sizeof(SINT16); | pcmwf.wf.nBlockAlign = 2 * sizeof(SINT16); |
| pcmwf.wf.nAvgBytesPerSec = rate * 2 * sizeof(SINT16); | pcmwf.wf.nAvgBytesPerSec = rate * 2 * sizeof(SINT16); |
| ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); | for (i=0; i<2; i++) { |
| dsbdesc.dwSize = DSBUFFERDESC_SIZE; | ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); |
| dsbdesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | | dsbdesc.dwSize = i ? sizeof(dsbdesc) : DSBUFFERDESC_SIZE; |
| dsbdesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | | |
| DSBCAPS_CTRLFREQUENCY | | DSBCAPS_CTRLFREQUENCY | |
| DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; |
| dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; | dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; |
| dsbdesc.dwBufferBytes = dsstreambytes * 2; | dsbdesc.dwBufferBytes = dsstreambytes * 2; |
| if (FAILED(pDSound->CreateSoundBuffer(&dsbdesc, &pDSData3, NULL))) { | if (SUCCEEDED(pDSound->CreateSoundBuffer(&dsbdesc, &pDSData3, NULL))) { |
| break; | |
| } | |
| } | |
| if (i >= 2) { | |
| goto stcre_err2; | goto stcre_err2; |
| } | } |
| Line 118 UINT soundmng_create(UINT rate, UINT ms) | Line 135 UINT soundmng_create(UINT rate, UINT ms) |
| vermouth_module = midimod_create(rate); | vermouth_module = midimod_create(rate); |
| midimod_loadall(vermouth_module); | midimod_loadall(vermouth_module); |
| #endif | #endif |
| #if defined(MT32SOUND_DLL) | |
| mt32sound_setrate(rate); | |
| #endif | |
| dsstreamevent = (UINT8)-1; | dsstreamevent = (UINT8)-1; |
| soundmng_reset(); | |
| return(samples); | return(samples); |
| stcre_err2: | stcre_err2: |
| Line 157 void soundmng_destroy(void) { | Line 176 void soundmng_destroy(void) { |
| midimod_destroy(vermouth_module); | midimod_destroy(vermouth_module); |
| vermouth_module = NULL; | vermouth_module = NULL; |
| #endif | #endif |
| #if defined(MT32SOUND_DLL) | |
| mt32sound_setrate(0); | |
| #endif | |
| pDSData3->Stop(); | pDSData3->Stop(); |
| pDSData3->Release(); | pDSData3->Release(); |
| pDSData3 = NULL; | pDSData3 = NULL; |
| Line 247 void soundmng_sync(void) { | Line 269 void soundmng_sync(void) { |
| void soundmng_setreverse(BOOL reverse) { | void soundmng_setreverse(BOOL reverse) { |
| if (!reverse) { | if (!reverse) { |
| #if !defined(_WIN64) | |
| if (mmxflag) { | if (mmxflag) { |
| fnmix = satuation_s16; | fnmix = satuation_s16; |
| } | } |
| else { | else { |
| fnmix = satuation_s16mmx; | fnmix = satuation_s16mmx; |
| } | } |
| #else | |
| fnmix = satuation_s16; | |
| #endif | |
| } | } |
| else { | else { |
| fnmix = satuation_s16x; | fnmix = satuation_s16x; |
| Line 444 BRESULT soundmng_initialize(void) { | Line 470 BRESULT soundmng_initialize(void) { |
| goto smcre_err; | goto smcre_err; |
| } | } |
| pcmcreate(); | pcmcreate(); |
| #if defined(MT32SOUND_DLL) | |
| mt32sound_initialize(); | |
| #endif | |
| return(SUCCESS); | return(SUCCESS); |
| smcre_err: | smcre_err: |
| Line 453 smcre_err: | Line 482 smcre_err: |
| void soundmng_deinitialize(void) { | void soundmng_deinitialize(void) { |
| #if defined(MT32SOUND_DLL) | |
| mt32sound_deinitialize(); | |
| #endif | |
| pcmdestroy(); | pcmdestroy(); |
| soundmng_destroy(); | soundmng_destroy(); |
| RELEASE(pDSound); | RELEASE(pDSound); |