Skip to content

Commit 6d9b68a

Browse files
committed
misc
1 parent 0f0d680 commit 6d9b68a

File tree

2 files changed

+83
-12
lines changed

2 files changed

+83
-12
lines changed

src/arpeggiator.h

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,40 @@
44
struct Synth; // Forward declaration
55

66
typedef enum {
7+
ARP_OFF,
8+
ARP_CHORD,
79
ARP_UP,
810
ARP_DOWN,
9-
ARP_ORDER,
11+
ARP_UP_DOWN,
12+
ARP_PENDULUM,
13+
ARP_CONVERGE,
14+
ARP_DIVERGE,
15+
ARP_LEAPFROG,
16+
ARP_THUMB_UP,
17+
ARP_THUMB_DOWN,
18+
ARP_PINKY_UP,
19+
ARP_PINKY_DOWN,
20+
ARP_REPEAT,
1021
ARP_RANDOM,
22+
ARP_RANDOM_WALK,
23+
ARP_SHUFFLE,
24+
ARP_ORDER, // Legacy mode for backward compatibility
1125
} ArpMode;
1226

27+
typedef enum {
28+
RATE_QUARTER = 0, // 1/4 notes
29+
RATE_EIGHTH = 1, // 1/8 notes (default)
30+
RATE_SIXTEENTH = 2, // 1/16 notes
31+
RATE_THIRTYSECOND = 3, // 1/32 notes
32+
} ArpRate;
33+
34+
typedef enum {
35+
CHORD_MAJOR = 0,
36+
CHORD_MINOR = 1,
37+
CHORD_SUS = 2,
38+
CHORD_DIM = 3,
39+
} ChordType;
40+
1341
#define ARP_PATTERN_LEN 16
1442

1543
// Structure to track active arpeggiated notes
@@ -25,6 +53,7 @@ typedef struct {
2553
int pattern[ARP_PATTERN_LEN];
2654
int step;
2755
float tempo;
56+
ArpRate rate;
2857
float step_phase;
2958
int held_count;
3059
int held_notes[16];
@@ -33,12 +62,24 @@ typedef struct {
3362
int hold; // Hold flag to sustain notes after key release
3463
int octave; // Octave control for keyboard input (0-4 = octaves 1-5)
3564
int octaves; // Number of octaves to spread chords across (1-6)
65+
66+
// Chord generation parameters
67+
ChordType chord_type;
68+
int add_6; // Add 6th extension
69+
int add_m7; // Add minor 7th extension
70+
int add_M7; // Add major 7th extension
71+
int add_9; // Add 9th extension
72+
int voicing; // Voicing/inversion level (0-16)
73+
3674
ActiveArpeggiatedNote active_arpeggiated_notes[16]; // Max 16 notes in a polyphonic step
3775
} Arpeggiator;
3876

3977
void arpeggiator_init(Arpeggiator *arp);
4078
void arpeggiator_set_param(Arpeggiator *arp, const char *param, float value, struct Synth *synth);
4179
const char *arpeggiator_mode_str(const Arpeggiator *arp);
80+
const char *arpeggiator_rate_str(const Arpeggiator *arp);
81+
const char *arpeggiator_chord_str(const Arpeggiator *arp);
82+
int arpeggiator_generate_chord(const Arpeggiator *arp, int root_note, int *chord_notes, int max_notes);
4283
void arpeggiator_note_on(Arpeggiator *arp, int note);
4384
void arpeggiator_note_off(Arpeggiator *arp, int note);
4485
void arpeggiator_clear_notes(Arpeggiator *arp);

src/gui.cpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -562,17 +562,45 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context) {
562562
// Arpeggiator
563563
if (ImGui::CollapsingHeader("Arpeggiator", ImGuiTreeNodeFlags_DefaultOpen)) {
564564
ImGui::Checkbox("Enabled##arp", (bool*)&synth->arp.enabled);
565-
const char* arp_modes[] = { "UP", "DOWN", "ORDER", "RANDOM" };
565+
const char* arp_modes[] = {
566+
"OFF", "CHORD", "UP", "DOWN", "UP/DOWN", "PENDULUM",
567+
"CONVERGE", "DIVERGE", "LEAPFROG", "THUMB-UP", "THUMB-DOWN",
568+
"PINKY-UP", "PINKY-DOWN", "REPEAT", "RANDOM", "RANDOM WALK", "SHUFFLE", "ORDER"
569+
};
566570
int current_arp_mode = (int)synth->arp.mode;
567-
if (ImGui::Combo("Mode", &current_arp_mode, "UP\0DOWN\0ORDER\0RANDOM\0\0", 4)) {
571+
if (ImGui::Combo("Mode", &current_arp_mode, arp_modes, 18)) {
568572
synth->arp.mode = (ArpMode)current_arp_mode;
569573
}
570574
ImGui::SliderFloat("Tempo", &synth->arp.tempo, 30.0f, 240.0f, "%.2f", 0);
575+
const char* arp_rates[] = { "1/4", "1/8", "1/16", "1/32" };
576+
int current_arp_rate = (int)synth->arp.rate;
577+
if (ImGui::Combo("Rate", &current_arp_rate, arp_rates, 4)) {
578+
synth->arp.rate = (ArpRate)current_arp_rate;
579+
}
571580
ImGui::SliderInt("Octave", &synth->arp.octave, 0, 4, "%d");
572581
ImGui::SliderInt("Octaves", &synth->arp.octaves, 1, 6, "%d");
573582
ImGui::Checkbox("Polyphonic", (bool*)&synth->arp.polyphonic);
574583
ImGui::Checkbox("Hold", (bool*)&synth->arp.hold);
575584

585+
ImGui::Separator();
586+
ImGui::Text("Chord Generation:");
587+
588+
// Chord Type
589+
const char* chord_types[] = {"MAJOR", "MINOR", "SUS", "DIM"};
590+
int current_chord_type = (int)synth->arp.chord_type;
591+
if (ImGui::Combo("Chord Type", &current_chord_type, chord_types, 4)) {
592+
synth->arp.chord_type = (ChordType)current_chord_type;
593+
}
594+
595+
// Chord Extensions
596+
ImGui::Checkbox("Add 6th", (bool*)&synth->arp.add_6);
597+
ImGui::Checkbox("Add m7", (bool*)&synth->arp.add_m7);
598+
ImGui::Checkbox("Add Maj7", (bool*)&synth->arp.add_M7);
599+
ImGui::Checkbox("Add 9th", (bool*)&synth->arp.add_9);
600+
601+
// Voicing
602+
ImGui::SliderInt("Voicing", &synth->arp.voicing, 0, 16, "%d");
603+
576604
ImGui::Separator();
577605
ImGui::Text("Presets:");
578606
ImGui::Columns(4, "arp_presets", true);
@@ -618,6 +646,7 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context) {
618646
if (ImGui::Button("Trance Gate")) {
619647
synth->arp.mode = ARP_UP;
620648
synth->arp.tempo = 140.0f;
649+
synth->arp.rate = RATE_SIXTEENTH;
621650
synth->arp.octaves = 4;
622651
synth->arp.polyphonic = 1;
623652
synth->arp.hold = 1;
@@ -642,14 +671,14 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context) {
642671
}
643672
ImGui::SameLine(); ImGui::Text("Progressive");
644673

645-
if (ImGui::Button("Ambient Pad")) {
646-
synth->arp.mode = ARP_UP;
674+
if (ImGui::Button("Sustained Chord")) {
675+
synth->arp.mode = ARP_CHORD;
647676
synth->arp.tempo = 60.0f;
648-
synth->arp.octaves = 3;
677+
synth->arp.octaves = 1;
649678
synth->arp.polyphonic = 1;
650679
synth->arp.hold = 1;
651680
}
652-
ImGui::SameLine(); ImGui::Text("Slow & wide");
681+
ImGui::SameLine(); ImGui::Text("Chordal");
653682

654683
ImGui::NextColumn();
655684

@@ -674,6 +703,7 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context) {
674703
if (ImGui::Button("DnB Roll")) {
675704
synth->arp.mode = ARP_RANDOM;
676705
synth->arp.tempo = 174.0f;
706+
synth->arp.rate = RATE_THIRTYSECOND;
677707
synth->arp.octaves = 2;
678708
synth->arp.polyphonic = 1;
679709
synth->arp.hold = 0;
@@ -718,14 +748,14 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context) {
718748
}
719749
ImGui::SameLine(); ImGui::Text("Harsh");
720750

721-
if (ImGui::Button("Jazz Walker")) {
722-
synth->arp.mode = ARP_ORDER;
723-
synth->arp.tempo = 140.0f;
751+
if (ImGui::Button("Pendulum")) {
752+
synth->arp.mode = ARP_PENDULUM;
753+
synth->arp.tempo = 120.0f;
724754
synth->arp.octaves = 2;
725-
synth->arp.polyphonic = 1;
755+
synth->arp.polyphonic = 0;
726756
synth->arp.hold = 0;
727757
}
728-
ImGui::SameLine(); ImGui::Text("Walking");
758+
ImGui::SameLine(); ImGui::Text("Bouncing");
729759

730760
ImGui::Columns(1, "", false);
731761
}

0 commit comments

Comments
 (0)