From f6efcdd98b32f1cd0d5a4a52abb333437c04b44f Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 15 Jan 2024 16:06:05 +0100 Subject: [WIP] Add decay control and attack/decay params on ch3 --- src/patterns.c | 105 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 61 insertions(+), 44 deletions(-) (limited to 'src/patterns.c') diff --git a/src/patterns.c b/src/patterns.c index a1f8f24..8dd0f5c 100644 --- a/src/patterns.c +++ b/src/patterns.c @@ -7,7 +7,7 @@ typedef struct TriggerNote { Note note; } TriggerNote; -typedef struct ChannelSquareParams { +typedef struct ChannelSquare1Params { u8 env_volume; u8 env_time; u8 env_direction; @@ -17,7 +17,16 @@ typedef struct ChannelSquareParams { u8 sweep_direction; u8 prob; s8 pan; -} ChannelSquareParams; +} ChannelSquare1Params; + +typedef struct ChannelSquare2Params { + u8 env_volume; + u8 env_time; + u8 env_direction; + u8 duty_cycle; + u8 prob; + s8 pan; +} ChannelSquare2Params; typedef struct ChannelWaveParams { u8 wave_volume; @@ -26,6 +35,8 @@ typedef struct ChannelWaveParams { u8 type_a; u8 shape_b; u8 type_b; + u8 wave_attack; + u8 wave_decay; u8 prob; s8 pan; } ChannelWaveParams; @@ -39,11 +50,17 @@ typedef struct ChannelNoiseParams { s8 pan; } ChannelNoiseParams; -typedef struct ChannelSquare { +typedef struct ChannelSquare1 { bool active; TriggerNote notes[16]; - ChannelSquareParams params[16]; -} ChannelSquare; + ChannelSquare1Params params[16]; +} ChannelSquare1; + +typedef struct ChannelSquare2 { + bool active; + TriggerNote notes[16]; + ChannelSquare2Params params[16]; +} ChannelSquare2; typedef struct ChannelWave { bool active; @@ -58,8 +75,8 @@ typedef struct ChannelNoise { } ChannelNoise; typedef struct Pattern { - ChannelSquare ch1; - ChannelSquare ch2; + ChannelSquare1 ch1; + ChannelSquare2 ch2; ChannelWave ch3; ChannelNoise ch4; int bpm; @@ -71,7 +88,7 @@ typedef struct Pattern { // Defaults. // -const ChannelSquare default_ch1 = { +const ChannelSquare1 default_ch1 = { .notes = { {true, NOTE_C_4}, {true, NOTE_D_SHARP_4}, @@ -111,7 +128,7 @@ const ChannelSquare default_ch1 = { .active = true, }; -const ChannelSquare default_ch2 = { +const ChannelSquare2 default_ch2 = { .notes = { {true, NOTE_C_3}, {true, NOTE_C_3}, @@ -131,22 +148,22 @@ const ChannelSquare default_ch2 = { {true, NOTE_C_3}, }, .params = { - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, - {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, + {8, 4, 0, 2, PROB_100, 0}, }, .active = true, }; @@ -171,22 +188,22 @@ const ChannelWave default_ch3 = { {true, NOTE_G_5}, }, .params = { - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, - {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, + {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, }, .active = true, }; @@ -244,7 +261,7 @@ static Pattern patterns[8] = { {default_ch1, default_ch2, default_ch3, default_ch4, default_bpm, 0, true}, }; -static ChannelSquareParams ch1_params = {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}; -static ChannelSquareParams ch2_params = {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}; -static ChannelWaveParams ch3_params = {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}; +static ChannelSquare1Params ch1_params = {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}; +static ChannelSquare2Params ch2_params = {8, 4, 0, 2, PROB_100, 0}; +static ChannelWaveParams ch3_params = {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}; static ChannelNoiseParams ch4_params = {0xF, 0x2, 0, 0, PROB_100, 0}; -- cgit v1.2.1