done for gur day, removed markov stuff, started on Grain struct

master
bx 2022-02-10 21:02:29 +00:00
parent 141636d742
commit 89f385011c
2 changed files with 25 additions and 13 deletions

View File

@ -3,7 +3,6 @@
#include "ampler.h"
#include "random.c"
#include "markov.c"
#include "audio.c"
#include "draw.c"
@ -42,10 +41,10 @@ Ampler_state *init() {
puts(SDL_GetError());
// TODO: iterate a directory to load samples
load_sample(state, "./mix.wav");
//load_sample(state, "./mix.wav");
//load_sample(state, "./haunted.wav");
//load_sample(state, "./loop2.wav");
//load_sample(state, "./loop.wav");
load_sample(state, "./loop.wav");
//load_sample(state, "./chord.wav");
puts("init.");

View File

@ -38,8 +38,12 @@ for ; N##_i < arraylen(ARRAY); N##_i += 1, N = &((ARRAY)[N##_i]) do
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SAMPLE_RATE (44100)
#define CHANNELS (2)
#define CHANNELS (1)
#define FRAME_SAMPLES (SAMPLE_RATE / 60)
#define GRAIN_SAMPLES (SAMPLE_RATE / 36)
#define GRID_WIDTH (36)
#define GRID_HEIGHT (36)
typedef struct Sound_src Sound_src;
struct Sound_src {
@ -54,19 +58,21 @@ struct Sound_src {
enum { SND_FREE = 0, SND_STOPPED, SND_PLAYING, SND_LOOPING, } state;
};
typedef struct Grain Grain;
struct Grain {
s8 samples[GRAIN_SAMPLES];
// not sure what else to store here?
// maybe file origin?
// speed multiplier?
// ending?
};
typedef struct Udp_msg Udp_msg;
struct Udp_msg {
s8 text[32]; // includes null terminator
enum { MSG_FREE = 0, MSG_TRIGGER, } state;
};
typedef struct Markov_4 Markov_4;
struct Markov_4 {
u8 start;
u8 chain[256][256];
u8 lens[256];
};
typedef struct Ampler_state Ampler_state;
struct Ampler_state {
u32 size; // in bytes, off this struct
@ -77,8 +83,7 @@ struct Ampler_state {
Udp_msg messages[64];
s8 frame_mix[CHANNELS][FRAME_SAMPLES];
s8 frame_rec[CHANNELS][FRAME_SAMPLES];
Markov_4 markov;
Grain grains[GRID_WIDTH][GRID_HEIGHT];
};
@ -86,4 +91,12 @@ void udp_init(Ampler_state *);
void udp_frame(Ampler_state *);
void udp_quit(Ampler_state *);
/*
typedef struct Markov_4 Markov_4;
struct Markov_4 {
u8 start;
u8 chain[256][256];
u8 lens[256];
};
*/