void msdos_shutdown_sound(void) { if (Machine->sample_rate != 0) { int chip,n; for(chip=0;chip<num_used_opl;chip++) { /* silence the OPL */ for (n = 0x40;n <= 0x55;n++) { osd_opl_control(chip,n); osd_opl_write(chip,0x3f); } for (n = 0x60;n <= 0x95;n++) { osd_opl_control(chip,n); osd_opl_write(chip,0xff); } for (n = 0xa0;n <= 0xb0;n++) { osd_opl_control(chip,n); osd_opl_write(chip,0); } } #ifdef USE_SEAL ACloseVoices(); ACloseAudio(); #endif } }
static int close_alib(audio_output_t *ao) { close(ao->fn); ASetCloseDownMode( audioServer, AKeepTransactions, NULL ); ACloseAudio( audioServer, NULL ); audioServer = (Audio *) NULL; return 0; }
int main(void) { AUDIOINFO info; AUDIOCAPS caps; UINT rc, nDevId; /* initialize audio library */ AInitialize(); /* show registered device drivers */ printf("List of registered devices:\n"); for (nDevId = 0; nDevId < AGetAudioNumDevs(); nDevId++) { AGetAudioDevCaps(nDevId, &caps); printf(" %2d. %s\n", nDevId, caps.szProductName); } printf("\n"); /* * NOTE: Here we can use any of the above devices, or we can * use the virtual device AUDIO_DEVICE_MAPPER for detection. */ /* open audio device */ info.nDeviceId = AUDIO_DEVICE_MAPPER; info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO; info.nSampleRate = 44100; if ((rc = AOpenAudio(&info)) != AUDIO_ERROR_NONE) { CHAR szText[80]; AGetErrorText(rc, szText, sizeof(szText) - 1); printf("ERROR: %s\n", szText); exit(1); } /* * NOTE: Since the audio device may not support the playback * format and sampling frequency, the audio system uses the * closest configuration which is then returned to the user * in the AUDIOINFO structure. * */ /* print information */ AGetAudioDevCaps(info.nDeviceId, &caps); printf("%s at %d-bit %s %u Hz detected\n", caps.szProductName, info.wFormat & AUDIO_FORMAT_16BITS ? 16 : 8, info.wFormat & AUDIO_FORMAT_STEREO ? "stereo" : "mono", info.nSampleRate); /* close audio device */ ACloseAudio(); return 0; }
void msdos_shutdown_sound(void) { if (seal_sample_rate != 0) { int n; /* stop and release voices */ for (n = 0; n < NUMVOICES; n++) { AStopVoice(hVoice[n]); ADestroyAudioVoice(hVoice[n]); if (lpWave[n]) { ADestroyAudioData(lpWave[n]); free(lpWave[n]); lpWave[n] = 0; } } ACloseVoices(); ACloseAudio(); } }
int main(void) { AUDIOINFO info; LPAUDIOMODULE lpModule; LPAUDIOWAVE lpWave; HAC hVoice; BOOL stopped; /* initialize audio library */ AInitialize(); /* open audio device */ info.nDeviceId = AUDIO_DEVICE_MAPPER; info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO; info.nSampleRate = 44100; AOpenAudio(&info); /* load module and waveform file */ ALoadModuleFile("test.s3m", &lpModule, 0); ALoadWaveFile("test.wav", &lpWave, 0); /* open voices for module and waveform */ AOpenVoices(lpModule->nTracks + 1); /* play the module file */ APlayModule(lpModule); ASetModuleVolume(64); /* play the waveform through a voice */ ACreateAudioVoice(&hVoice); APlayVoice(hVoice, lpWave); ASetVoiceVolume(hVoice, 48); ASetVoicePanning(hVoice, 128); /* program main execution loop */ printf("Playing module and waveform, press any key to stop.\n"); while (!kbhit()) { /* update audio system */ AUpdateAudio(); /* restart waveform if stopped */ AGetVoiceStatus(hVoice, &stopped); if (stopped) APlayVoice(hVoice, lpWave); /* check if the module is stopped */ AGetModuleStatus(&stopped); if (stopped) break; } /* stop playing the waveform */ AStopVoice(hVoice); ADestroyAudioVoice(hVoice); /* stop playing the module */ AStopModule(); ACloseVoices(); /* release the waveform & module */ AFreeWaveFile(lpWave); AFreeModuleFile(lpModule); /* close audio device */ ACloseAudio(); return 0; }
int main(void) { AUDIOINFO info; LPAUDIOWAVE lpWave; HAC hVoice[NUMVOICES]; BOOL stopped; UINT n, m; /* initialize audio library */ AInitialize(); /* open audio device */ info.nDeviceId = AUDIO_DEVICE_MAPPER; info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO; info.nSampleRate = 44100; AOpenAudio(&info); /* load waveform file */ ALoadWaveFile("test.wav", &lpWave, 0); /* open and allocate voices */ AOpenVoices(NUMVOICES); for (n = 0; n < NUMVOICES; n++) { ACreateAudioVoice(&hVoice[n]); ASetVoiceVolume(hVoice[n], 64); ASetVoicePanning(hVoice[n], n & 1 ? 0 : 255); } /* program main execution loop */ printf("Playing waveform, press any key to stop.\n"); for (n = m = 0; !kbhit() && n < 48 - 7; n++) { /* play chord C-E-G */ APlayVoice(hVoice[m+0], lpWave); APlayVoice(hVoice[m+1], lpWave); APlayVoice(hVoice[m+2], lpWave); ASetVoiceFrequency(hVoice[m+0], FREQ(aPeriodTable[n+0])); ASetVoiceFrequency(hVoice[m+1], FREQ(aPeriodTable[n+4])); ASetVoiceFrequency(hVoice[m+2], FREQ(aPeriodTable[n+7])); m = (m + 3) % NUMVOICES; /* wait until note finishes */ do { /* update audio system */ AUpdateAudio(); AGetVoiceStatus(hVoice[0], &stopped); } while (!stopped); } /* stop and release voices */ for (n = 0; n < NUMVOICES; n++) { AStopVoice(hVoice[n]); ADestroyAudioVoice(hVoice[n]); } ACloseVoices(); /* release the waveform file */ AFreeWaveFile(lpWave); /* close audio device */ ACloseAudio(); return 0; }