static void _postAudioBuffer(struct GBAAVStream* stream, struct GBAAudio* audio) { UNUSED(stream); int16_t samples[SAMPLES * 2]; #if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF blip_read_samples(audio->left, samples, SAMPLES, true); blip_read_samples(audio->right, samples + 1, SAMPLES, true); #else int16_t samplesR[SAMPLES]; GBAAudioCopy(audio, &samples[SAMPLES], samplesR, SAMPLES); size_t i; for (i = 0; i < SAMPLES; ++i) { samples[i * 2] = samples[SAMPLES + i]; samples[i * 2 + 1] = samplesR[i]; } #endif audioCallback(samples, SAMPLES); }
static void _postAudioBuffer(struct GBAAVStream* stream, struct GBAAudio* audio) { UNUSED(stream); memset(audioLeft, 0, AUDIO_SAMPLES * sizeof(int16_t)); memset(audioRight, 0, AUDIO_SAMPLES * sizeof(int16_t)); #if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF blip_read_samples(audio->left, audioLeft, AUDIO_SAMPLES, false); blip_read_samples(audio->right, audioRight, AUDIO_SAMPLES, false); #elif RESAMPLE_LIBRARY == RESAMPLE_NN GBAAudioCopy(audio, audioLeft, audioRight, AUDIO_SAMPLES); #endif GSPGPU_FlushDataCache(0, (void*) audioLeft, AUDIO_SAMPLES * sizeof(int16_t)); GSPGPU_FlushDataCache(0, (void*) audioRight, AUDIO_SAMPLES * sizeof(int16_t)); csndPlaySound(0x8, SOUND_ONE_SHOT | SOUND_FORMAT_16BIT, 0x8000, 1.0, -1.0, audioLeft, audioLeft, AUDIO_SAMPLES * sizeof(int16_t)); csndPlaySound(0x9, SOUND_ONE_SHOT | SOUND_FORMAT_16BIT, 0x8000, 1.0, 1.0, audioRight, audioRight, AUDIO_SAMPLES * sizeof(int16_t)); CSND_SetPlayState(0x8, 1); CSND_SetPlayState(0x9, 1); csndExecCmds(false); }