diff --git a/src/devices/audio.c b/src/devices/audio.c index c2d02dd..19860f4 100644 --- a/src/devices/audio.c +++ b/src/devices/audio.c @@ -15,7 +15,6 @@ WITH REGARD TO THIS SOFTWARE. */ #define SOUND_TIMER (AUDIO_BUFSIZE / SAMPLE_FREQUENCY * 1000.0f) -#define N_CHANNELS 4 #define XFADE_SAMPLES 100 #define INTERPOL_METHOD 1 @@ -54,7 +53,7 @@ typedef struct AudioChannel { float vol_r; } AudioChannel; -AudioChannel channel[N_CHANNELS]; +AudioChannel channel[POLYPHONY]; const float tuning[109] = { 0.00058853f, 0.00062352f, 0.00066060f, 0.00069988f, 0.00074150f, @@ -117,10 +116,10 @@ note_on(AudioChannel *channel, Uint16 duration, Uint8 *data, Uint16 len, Uint8 v sample.data = data; sample.len = len; sample.pos = 0; - sample.env.a = attack * 62.0f; - sample.env.d = decay * 62.0f; + sample.env.a = attack * 64.0f; + sample.env.d = decay * 64.0f; sample.env.s = sustain / 16.0f; - sample.env.r = release * 62.0f; + sample.env.r = release * 64.0f; if (loop) { sample.loop = len; } else { @@ -238,7 +237,7 @@ audio_handler(void *ctx, Uint8 *out_stream, int len) { memset(stream, 0x00, len); int n; - for (n = 0; n < N_CHANNELS; n++) { + for (n = 0; n < POLYPHONY; n++) { Uint8 device = (3 + n) << 4; Uxn *u = (Uxn *)ctx; Uint8 *addr = &u->dev[device]; diff --git a/src/uxnemu.c b/src/uxnemu.c index 9d8e009..df3765b 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -90,6 +90,7 @@ audio_deo(int instance, Uint8 *d, Uint8 port, Uxn *u) SDL_LockAudioDevice(audio_id); audio_start(instance, d, u); SDL_UnlockAudioDevice(audio_id); + SDL_PauseAudioDevice(audio_id, 0); } } @@ -266,7 +267,7 @@ emu_init(Uxn *u) deadline_interval = ms_interval * TIMEOUT_MS; exec_deadline = SDL_GetPerformanceCounter() + deadline_interval; screen_resize(WIDTH, HEIGHT); - SDL_PauseAudioDevice(audio_id, 0); + SDL_PauseAudioDevice(audio_id, 1); return 1; }