void cmvermouth_load(UINT rate) { MIDIMOD vermouth; if (rate == 0) { return; } if (cmver.rate != rate) { midimod_destroy(cmver.vermouth); cmver.rate = rate; vermouth = midimod_create(rate); cmver.vermouth = vermouth; midimod_loadall(vermouth); } }
UINT soundmng_create(UINT rate, UINT ms) { UINT samples; DSBUFFERDESC dsbdesc; PCMWAVEFORMAT pcmwf; int i; if ((pDSound == NULL) || (rate != 11025) && (rate != 22050) && (rate != 44100)) { goto stcre_err1; } if (ms < 40) { ms = 40; } else if (ms > 1000) { ms = 1000; } // キーボード表示のディレイ設定 // keydispr_delayinit((UINT8)((ms * 10 + 563) / 564)); samples = (rate * ms) / 2000; samples = (samples + SOUNDBUFFERALIGN - 1) & (~(SOUNDBUFFERALIGN - 1)); dsstreambytes = samples * 2 * sizeof(SINT16); soundmng_setreverse(FALSE); ZeroMemory(&pcmwf, sizeof(PCMWAVEFORMAT)); pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = 2; pcmwf.wf.nSamplesPerSec = rate; pcmwf.wBitsPerSample = 16; pcmwf.wf.nBlockAlign = 2 * sizeof(SINT16); pcmwf.wf.nAvgBytesPerSec = rate * 2 * sizeof(SINT16); for (i=0; i<2; i++) { ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); dsbdesc.dwSize = i ? sizeof(dsbdesc) : DSBUFFERDESC_SIZE; dsbdesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; dsbdesc.dwBufferBytes = dsstreambytes * 2; if (SUCCEEDED(pDSound->CreateSoundBuffer(&dsbdesc, &pDSData3, NULL))) { break; } } if (i >= 2) { goto stcre_err2; } #if defined(VERMOUTH_LIB) vermouth_module = midimod_create(rate); midimod_loadall(vermouth_module); #endif #if defined(MT32SOUND_DLL) mt32sound_setrate(rate); #endif dsstreamevent = (UINT8)-1; return(samples); stcre_err2: RELEASE(pDSData3); stcre_err1: return(0); }