Change sdl audio to not play until the first pitch is sent
This commit is contained in:
parent
1d7c96dd3d
commit
9c8ae94825
|
@ -15,7 +15,6 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SOUND_TIMER (AUDIO_BUFSIZE / SAMPLE_FREQUENCY * 1000.0f)
|
#define SOUND_TIMER (AUDIO_BUFSIZE / SAMPLE_FREQUENCY * 1000.0f)
|
||||||
#define N_CHANNELS 4
|
|
||||||
#define XFADE_SAMPLES 100
|
#define XFADE_SAMPLES 100
|
||||||
#define INTERPOL_METHOD 1
|
#define INTERPOL_METHOD 1
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ typedef struct AudioChannel {
|
||||||
float vol_r;
|
float vol_r;
|
||||||
} AudioChannel;
|
} AudioChannel;
|
||||||
|
|
||||||
AudioChannel channel[N_CHANNELS];
|
AudioChannel channel[POLYPHONY];
|
||||||
|
|
||||||
const float tuning[109] = {
|
const float tuning[109] = {
|
||||||
0.00058853f, 0.00062352f, 0.00066060f, 0.00069988f, 0.00074150f,
|
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.data = data;
|
||||||
sample.len = len;
|
sample.len = len;
|
||||||
sample.pos = 0;
|
sample.pos = 0;
|
||||||
sample.env.a = attack * 62.0f;
|
sample.env.a = attack * 64.0f;
|
||||||
sample.env.d = decay * 62.0f;
|
sample.env.d = decay * 64.0f;
|
||||||
sample.env.s = sustain / 16.0f;
|
sample.env.s = sustain / 16.0f;
|
||||||
sample.env.r = release * 62.0f;
|
sample.env.r = release * 64.0f;
|
||||||
if (loop) {
|
if (loop) {
|
||||||
sample.loop = len;
|
sample.loop = len;
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,7 +237,7 @@ audio_handler(void *ctx, Uint8 *out_stream, int len) {
|
||||||
memset(stream, 0x00, len);
|
memset(stream, 0x00, len);
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
for (n = 0; n < N_CHANNELS; n++) {
|
for (n = 0; n < POLYPHONY; n++) {
|
||||||
Uint8 device = (3 + n) << 4;
|
Uint8 device = (3 + n) << 4;
|
||||||
Uxn *u = (Uxn *)ctx;
|
Uxn *u = (Uxn *)ctx;
|
||||||
Uint8 *addr = &u->dev[device];
|
Uint8 *addr = &u->dev[device];
|
||||||
|
|
|
@ -90,6 +90,7 @@ audio_deo(int instance, Uint8 *d, Uint8 port, Uxn *u)
|
||||||
SDL_LockAudioDevice(audio_id);
|
SDL_LockAudioDevice(audio_id);
|
||||||
audio_start(instance, d, u);
|
audio_start(instance, d, u);
|
||||||
SDL_UnlockAudioDevice(audio_id);
|
SDL_UnlockAudioDevice(audio_id);
|
||||||
|
SDL_PauseAudioDevice(audio_id, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +267,7 @@ emu_init(Uxn *u)
|
||||||
deadline_interval = ms_interval * TIMEOUT_MS;
|
deadline_interval = ms_interval * TIMEOUT_MS;
|
||||||
exec_deadline = SDL_GetPerformanceCounter() + deadline_interval;
|
exec_deadline = SDL_GetPerformanceCounter() + deadline_interval;
|
||||||
screen_resize(WIDTH, HEIGHT);
|
screen_resize(WIDTH, HEIGHT);
|
||||||
SDL_PauseAudioDevice(audio_id, 0);
|
SDL_PauseAudioDevice(audio_id, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue