|
|
| version 1.5, 2003/11/06 03:22:41 | version 1.9, 2004/01/23 17:37:39 |
|---|---|
| Line 6 | Line 6 |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "sound.h" | #include "sound.h" |
| #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) |
| #include "vermouth.h" | #include "commng.h" |
| #include "cmver.h" | |
| #endif | #endif |
| #include "soundrecording.h" | #include "soundrecording.h" |
| #include "np2opening.h" | |
| #define SOUNDBUFFERS 2 | #define SOUNDBUFFERS 2 |
| Line 19 typedef struct { | Line 21 typedef struct { |
| UINT rate; | UINT rate; |
| UINT samples; | UINT samples; |
| UINT buffersize; | UINT buffersize; |
| #if defined(SOUNDMNG_USEBUFFERING) | #if !defined(SOUND_CRITICAL) |
| SINT16 *indata; | SINT16 *indata; |
| SINT16 *extendbuffer; | SINT16 *extendbuffer; |
| #endif | #endif |
| Line 32 static BOOL QS_Avail = FALSE; | Line 34 static BOOL QS_Avail = FALSE; |
| static _QSOUND QSound; | static _QSOUND QSound; |
| static BOOL QSound_Playing = FALSE; | static BOOL QSound_Playing = FALSE; |
| #if defined(VERMOUTH_LIB) | |
| MIDIMOD vermouth_module = NULL; | |
| #endif | |
| static void (PARTSCALL *fnmix)(SINT16 *dst, | static void (PARTSCALL *fnmix)(SINT16 *dst, |
| const SINT32 *src, UINT size); | const SINT32 *src, UINT size); |
| Line 45 static pascal void QSoundCallback(SndCha | Line 43 static pascal void QSoundCallback(SndCha |
| QSOUND qs; | QSOUND qs; |
| int nextbuf; | int nextbuf; |
| void *dst; | void *dst; |
| #if !defined(SOUNDMNG_USEBUFFERING) | #if defined(SOUND_CRITICAL) |
| const SINT32 *src; | const SINT32 *src; |
| #endif | #endif |
| Line 53 const SINT32 *src; | Line 51 const SINT32 *src; |
| qs = &QSound; | qs = &QSound; |
| nextbuf = inCommand->param1; | nextbuf = inCommand->param1; |
| dst = qs->buf[nextbuf]->sampleArea; | dst = qs->buf[nextbuf]->sampleArea; |
| #if defined(SOUNDMNG_USEBUFFERING) | #if !defined(SOUND_CRITICAL) |
| if (qs->indata) { | if (qs->indata) { |
| CopyMemory((SINT16 *)dst, qs->indata, qs->buffersize); | CopyMemory((SINT16 *)dst, qs->indata, qs->buffersize); |
| qs->indata = NULL; | qs->indata = NULL; |
| Line 137 static BOOL SoundBuffer_Init(UINT rate, | Line 135 static BOOL SoundBuffer_Init(UINT rate, |
| drate = rate; | drate = rate; |
| dtox80(&drate, &extFreq); | dtox80(&drate, &extFreq); |
| #if defined(SOUNDMNG_USEBUFFERING) | #if !defined(SOUND_CRITICAL) |
| qs->extendbuffer = (SINT16 *)_MALLOC(buffersize, "Extend buffer"); | qs->extendbuffer = (SINT16 *)_MALLOC(buffersize, "Extend buffer"); |
| if (qs->extendbuffer == NULL) { | if (qs->extendbuffer == NULL) { |
| goto sbinit_err; | goto sbinit_err; |
| Line 188 static void SoundBuffer_Term(void) { | Line 186 static void SoundBuffer_Term(void) { |
| buf[i] = NULL; | buf[i] = NULL; |
| } | } |
| } | } |
| #if defined(SOUNDMNG_USEBUFFERING) | #if !defined(SOUND_CRITICAL) |
| qs->indata = NULL; | qs->indata = NULL; |
| if (qs->extendbuffer) { | if (qs->extendbuffer) { |
| _MFREE(qs->extendbuffer); | _MFREE(qs->extendbuffer); |
| Line 200 static void SoundBuffer_Term(void) { | Line 198 static void SoundBuffer_Term(void) { |
| UINT soundmng_create(UINT rate, UINT ms) { | UINT soundmng_create(UINT rate, UINT ms) { |
| UINT samples; | UINT samples; |
| #if defined(VERMOUTH_LIB) | |
| UINT num; | |
| #endif | |
| QSound_Playing = FALSE; | QSound_Playing = FALSE; |
| Line 216 UINT soundmng_create(UINT rate, UINT ms) | Line 211 UINT soundmng_create(UINT rate, UINT ms) |
| if (SoundChannel_Init()) { | if (SoundChannel_Init()) { |
| goto qsinit_err; | goto qsinit_err; |
| } | } |
| #if defined(SOUNDMNG_USEBUFFERING) | #if !defined(SOUND_CRITICAL) |
| samples = rate * ms / (SOUNDBUFFERS * 1000); | samples = rate * ms / (SOUNDBUFFERS * 1000); |
| samples = (samples + 3) & (~3); | samples = (samples + 3) & (~3); |
| #else | #else |
| Line 227 UINT soundmng_create(UINT rate, UINT ms) | Line 222 UINT soundmng_create(UINT rate, UINT ms) |
| goto qsinit_err; | goto qsinit_err; |
| } | } |
| #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) |
| vermouth_module = midimod_create(rate); | cmvermouth_load(rate); |
| for (num=0; num<128; num++) { | |
| midimod_loadprogram(vermouth_module, num); | |
| midimod_loadrhythm(vermouth_module, num); | |
| } | |
| #endif | #endif |
| return(samples); | return(samples); |
| Line 247 void soundmng_destroy(void) { | Line 238 void soundmng_destroy(void) { |
| SoundBuffer_Term(); | SoundBuffer_Term(); |
| SoundChannel_Term(); | SoundChannel_Term(); |
| #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) |
| midimod_destroy(vermouth_module); | cmvermouth_unload(); |
| vermouth_module = NULL; | |
| #endif | #endif |
| } | } |
| } | } |
| Line 273 void soundmng_setreverse(BOOL reverse) { | Line 263 void soundmng_setreverse(BOOL reverse) { |
| } | } |
| } | } |
| #if defined(SOUNDMNG_USEBUFFERING) | #if !defined(SOUND_CRITICAL) |
| void soundmng_sync(void) { | void soundmng_sync(void) { |
| QSOUND qs; | QSOUND qs; |
| Line 293 const SINT32 *src; | Line 283 const SINT32 *src; |
| } | } |
| #endif | #endif |
| #ifndef SUPPORT_WAVEMIX | |
| // -------------------------------------------------------------------------- | // -------------------------------------------------------------------------- |
| #include <QuickTime/Movies.h> | #include <QuickTime/Movies.h> |
| #include "np2.h" | #include "np2.h" |
| Line 306 static Movie setupWAV(const char* name) | Line 297 static Movie setupWAV(const char* name) |
| short resID = 0; | short resID = 0; |
| Movie wav = NULL; | Movie wav = NULL; |
| char path[MAX_PATH]; | if (!getResourceFile(name, &fs)) { |
| Str255 fname; | char path[MAX_PATH]; |
| Str255 fname; | |
| file_cpyname(path, file_getcd(name), MAX_PATH); | |
| mkstr255(fname, path); | |
| FSMakeFSSpec(0, 0, fname, &fs); | |
| } | |
| file_cpyname(path, file_getcd(name), MAX_PATH); | |
| mkstr255(fname, path); | |
| FSMakeFSSpec(0, 0, fname, &fs); | |
| if (OpenMovieFile( &fs, &movieRefNum, fsRdPerm ) == noErr) { | if (OpenMovieFile( &fs, &movieRefNum, fsRdPerm ) == noErr) { |
| if (NewMovieFromFile(&wav,movieRefNum, &resID, NULL, newMovieActive, NULL) != noErr) { | if (NewMovieFromFile(&wav,movieRefNum, &resID, NULL, newMovieActive, NULL) != noErr) { |
| return NULL; | return NULL; |
| Line 330 void soundmng_deinitialize(void) { | Line 324 void soundmng_deinitialize(void) { |
| BOOL soundmng_initialize(void) { | BOOL soundmng_initialize(void) { |
| EnterMovies(); | EnterMovies(); |
| seekWAV[0] = setupWAV("Fddseek.wav"); | seekWAV[0] = setupWAV("fddseek.wav"); |
| seekWAV[1] = setupWAV("Fddseek1.wav"); | seekWAV[1] = setupWAV("fddseek1.wav"); |
| if (seekWAV[0] == NULL || seekWAV[1] == NULL) { | if (seekWAV[0] == NULL || seekWAV[1] == NULL) { |
| return false; | return false; |
| } | } |
| Line 359 void soundmng_pcmstop(UINT num) { | Line 353 void soundmng_pcmstop(UINT num) { |
| } | } |
| } | } |
| #endif |