From 141636d7427552722a2e6091368f45b11c96d841 Mon Sep 17 00:00:00 2001 From: bx Date: Thu, 10 Feb 2022 20:16:11 +0000 Subject: [PATCH] disabled markov stuffs, switched to mono --- ampler.c | 4 ++-- audio.c | 20 ++++++-------------- draw.c | 8 ++++---- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/ampler.c b/ampler.c index 0c4f920..b971798 100644 --- a/ampler.c +++ b/ampler.c @@ -42,8 +42,8 @@ Ampler_state *init() { puts(SDL_GetError()); // TODO: iterate a directory to load samples - //load_sample(state, "./mix.wav"); - load_sample(state, "./haunted.wav"); + load_sample(state, "./mix.wav"); + //load_sample(state, "./haunted.wav"); //load_sample(state, "./loop2.wav"); //load_sample(state, "./loop.wav"); //load_sample(state, "./chord.wav"); diff --git a/audio.c b/audio.c index 2c77954..6e07d76 100644 --- a/audio.c +++ b/audio.c @@ -95,24 +95,14 @@ int audio_frame(Ampler_state *state) { // TODO: We should use CHANNELS here // static s8 mix_l[FRAME_SAMPLES] = { 0 }, mix_r[FRAME_SAMPLES] = { 0 }; - s8 *mix_l = state->frame_mix[0], *mix_r = state->frame_mix[1]; + s8 *mix_l = state->frame_mix[0]; // s8 *mix_l = state->frame_mix[0], *mix_r = state->frame_mix[1]; SDL_memset(mix_l, 0, FRAME_SAMPLES / sizeof (s8)); - SDL_memset(mix_r, 0, FRAME_SAMPLES / sizeof (s8)); + //SDL_memset(mix_r, 0, FRAME_SAMPLES / sizeof (s8)); - s8 *mix[] = { mix_l, mix_r }; + s8 *mix[] = { mix_l }; //s8 *mix[] = { mix_l, mix_r }; foreach_ptr(Sound_src, snd, state -> sounds) sound_src_frame(snd, mix); - // MARKOV TEST - SDL_memset(&(state->markov), 0, sizeof state->markov); - markov_gen(&(state->markov), mix_l); - markov_synth(&(state->markov), mix_l); - for int i = 0; i < FRAME_SAMPLES; i += 1 do - mix_r[i] = mix_l[i]; - // MARKOV TEST - - - const int vol = 100; static s16 frame[FRAME_SAMPLES * CHANNELS] = { 0 }; for int i = 0; i < FRAME_SAMPLES; i += 1 do @@ -178,8 +168,10 @@ void load_sample(Ampler_state *state, const char *file_name) { puts("fffuuuck"); for int i = 0; i < snd -> track_len; i += 1 do - for int t = 0; t < chans; t += 1 do + for int t = 0; t < chans; t += 1 do { + if t >= CHANNELS do continue; // THIS GETS US MONO snd -> tracks[t][i] = (s8) (buffer[i * chans + t] >> 8); + } SDL_FreeWAV((void *) buffer); diff --git a/draw.c b/draw.c index 9c8c770..2b7d62e 100644 --- a/draw.c +++ b/draw.c @@ -38,11 +38,12 @@ void draw_frame(SDL_Window *w, SDL_Renderer *r, Ampler_state *state) { // SDL_RenderClear(r); //markov_draw(&(state->markov), r); - SDL_memset(&(state->markov), 0, sizeof state->markov); - markov_gen(&(state->markov), state->frame_mix[1]); - markov_draw(&(state->markov), r); + //SDL_memset(&(state->markov), 0, sizeof state->markov); + //markov_gen(&(state->markov), state->frame_mix[1]); + //markov_draw(&(state->markov), r); SDL_RenderPresent(r); +} /* for int x = 0; x < 256; x += 1 do @@ -96,4 +97,3 @@ void draw_frame(SDL_Window *w, SDL_Renderer *r, Ampler_state *state) { } } */ -}