- [NEW] Minim makefile

- [NEW] Sound stops while debugging
- [CHG] Now all sound related code is in the zx_ula module
This commit is contained in:
2024-04-17 22:41:29 +02:00
parent 9f67286779
commit e80de06d2c
5 changed files with 46 additions and 28 deletions

View File

@@ -97,4 +97,39 @@ namespace zx_ula
uint8_t get_border_color() { return border_color; }
uint8_t get_ear() { return ear; }
SDL_AudioDeviceID sdlAudioDevice;
uint8_t sound_buffer[1024];
uint16_t sound_pos;
void audioCallback(void * userdata, uint8_t * stream, int len)
{
const uint16_t top = sound_pos < len ? sound_pos : len;
memcpy(stream, sound_buffer, top);
sound_pos=0;
}
void sound_init()
{
SDL_AudioSpec audioSpec{11025, AUDIO_U8, 1, 0, 220, 0, 0, &audioCallback, NULL};
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
}
void sound_enable()
{
SDL_PauseAudioDevice(sdlAudioDevice, 0);
}
void sound_disable()
{
SDL_PauseAudioDevice(sdlAudioDevice, 1);
}
void sound_update()
{
sound_buffer[sound_pos++] = ear*128;
}
}