Skip to content

Commit 8cca5b8

Browse files
committed
misc
1 parent 6ad2112 commit 8cca5b8

File tree

7 files changed

+20
-42
lines changed

7 files changed

+20
-42
lines changed

src/gui.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <SDL2/SDL.h>
1111
#include <SDL_ttf.h>
1212
#include <SDL_opengl.h>
13-
// #include <GL/gl.h>
14-
// #include <OpenGL/gl.h>
1513

1614
// Global pointers to app state for GUI access
1715
static int *g_chord_prog_enabled = NULL;
@@ -199,8 +197,8 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context,
199197

200198
// Oscillators
201199
if (ImGui::CollapsingHeader("Oscillators", ImGuiTreeNodeFlags_DefaultOpen)) {
202-
ImGui::Columns(3, "osc_columns", true);
203-
for (int i = 0; i < 6; ++i) {
200+
ImGui::Columns(2, "osc_columns", true);
201+
for (int i = 0; i < 4; ++i) {
204202
ImGui::PushID(i);
205203
char title[32];
206204
sprintf(title, "OSC %d", i + 1);
@@ -240,7 +238,7 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context,
240238
}
241239

242240
// Individual oscillator randomization buttons
243-
ImGui::Columns(6, "random_buttons", true);
241+
ImGui::Columns(4, "random_buttons", true);
244242

245243
if (ImGui::Button("Randomize OSC 1")) {
246244
synth_randomize_oscillator(synth, 0);
@@ -256,14 +254,6 @@ void gui_draw(Synth *synth, SDL_Window *window, SDL_GLContext gl_context,
256254
ImGui::NextColumn();
257255
if (ImGui::Button("Randomize OSC 4")) {
258256
synth_randomize_oscillator(synth, 3);
259-
}
260-
ImGui::NextColumn();
261-
if (ImGui::Button("Randomize OSC 5")) {
262-
synth_randomize_oscillator(synth, 4);
263-
}
264-
ImGui::NextColumn();
265-
if (ImGui::Button("Randomize OSC 6")) {
266-
synth_randomize_oscillator(synth, 5);
267257
}
268258
ImGui::Columns(1, "", false);
269259
}

src/midi.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ const CCMapping cc_map[] = {
3030
{15, "osc3.waveform", 0.0f, 4.0f}, // CC 15: (Undefined/Unused) → OSC 3 Waveform Select
3131
{16, "osc4.pitch", -24.0f, 24.0f}, // CC 16: General Purpose Controller 1 → OSC 4 Pitch Bend
3232
{17, "osc4.detune", -1.0f, 1.0f}, // CC 17: General Purpose Controller 2 → OSC 4 Detune
33-
{18, "osc5.gain", 0.0f, 1.0f}, // CC 18: General Purpose Controller 3 → OSC 5 Gain
34-
{19, "osc6.gain", 0.0f, 1.0f}, // CC 19: General Purpose Controller 4 → OSC 6 Gain
33+
3534

3635
// OSCILLATOR PARAMETER BLOCK (CC 20-31)
3736
{20, "mixer.master", 0.0f, 2.0f}, // CC 20: (Undefined) → Master Volume
@@ -47,8 +46,7 @@ const CCMapping cc_map[] = {
4746
{30, "fx.delay.mix", 0.0f, 1.0f}, // CC 30: (Undefined) → Delay Mix
4847

4948
// STANDARD MIDI CONTROLLERS (CC 32-63)
50-
{33, "osc6.waveform", 0.0f, 4.0f}, // CC 33: LSB of Bank Select → OSC 6 Waveform
51-
{34, "osc5.waveform", 0.0f, 4.0f}, // CC 34: LSB of Bank Select → OSC 5 Waveform
49+
{34, "osc4.waveform", 0.0f, 4.0f}, // CC 34: LSB of Bank Select → OSC 4 Waveform
5250
{35, "osc4.waveform", 0.0f, 4.0f}, // CC 35: LSB of Bank Select → OSC 4 Waveform
5351
{36, "osc3.waveform", 0.0f, 4.0f}, // CC 36: LSB of Bank Select → OSC 3 Waveform
5452
{37, "osc2.waveform", 0.0f, 4.0f}, // CC 37: LSB of Bank Select → OSC 2 Waveform
@@ -61,8 +59,7 @@ const CCMapping cc_map[] = {
6159
{44, "fx.filter_drive", 1.0f, 10.0f}, // CC 44: LSB of Bank Select → Filter Drive
6260
{45, "fx.filter_resonance", 0.1f, 10.0f}, // CC 45: LSB of Bank Select → Filter Resonance
6361
{46, "fx.filter_mix", 0.0f, 1.0f}, // CC 46: LSB of Bank Select → Filter Mix
64-
{47, "osc6.unison_voices", 1.0f, 8.0f}, // CC 47: LSB of Bank Select → OSC 6 Unison Voices
65-
{48, "osc5.unison_voices", 1.0f, 8.0f}, // CC 48: LSB of Bank Select → OSC 5 Unison Voices
62+
{48, "osc4.unison_voices", 1.0f, 8.0f}, // CC 48: LSB of Bank Select → OSC 4 Unison Voices
6663
{49, "osc4.unison_voices", 1.0f, 8.0f}, // CC 49: LSB of Bank Select → OSC 4 Unison Voices
6764
{50, "osc3.unison_voices", 1.0f, 8.0f}, // CC 50: LSB of Bank Select → OSC 3 Unison Voices
6865
{51, "osc2.unison_voices", 1.0f, 8.0f}, // CC 51: LSB of Bank Select → OSC 2 Unison Voices

src/mixer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ void mixer_init(Mixer *mixer) {
8282
mixer->osc_gain[1] = 0.0f; // OSC 2 - muted
8383
mixer->osc_gain[2] = 0.0f; // OSC 3 - muted
8484
mixer->osc_gain[3] = 0.0f; // OSC 4 - muted
85-
mixer->osc_gain[4] = 0.0f; // OSC 5 - muted
86-
mixer->osc_gain[5] = 0.0f; // OSC 6 - muted
8785

8886
mixer->master = 0.25f; // Reduced from 1.0f to 0.25f
8987
mixer->master_pan = 0.0f; // Center pan by default

src/synth.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ int synth_init(Synth *synth, int samplerate, int buffer_size, int voices) {
192192
// synth_play_startup_melody(synth); // Start the melody at startup
193193

194194
char param_name[16];
195-
for (int i = 0; i < 6; ++i) { // Loop for all 6 oscillators
195+
for (int i = 0; i < 4; ++i) { // Loop for all 4 oscillators
196196
osc_init(&synth->osc[i], samplerate);
197197

198198
// Default parameters for main oscillators (0-3)
@@ -218,14 +218,7 @@ int synth_init(Synth *synth, int samplerate, int buffer_size, int voices) {
218218
}
219219

220220
// Specific default parameters for Bass (osc[4])
221-
synth_set_param(synth, "osc5.waveform", 1.0f); // Saw wave for bass
222-
synth_set_param(synth, "osc5.pitch", -12.0f); // One octave down
223-
synth_set_param(synth, "osc5.gain", 0.7f);
224-
225-
// Specific default parameters for Percussion (osc[5])
226-
synth_set_param(synth, "osc6.waveform", 4.0f); // Noise for percussion
227-
synth_set_param(synth, "osc6.gain", 0.5f);
228-
// For percussion, we might want a very short envelope, but that's handled by voice/envelope, not directly by osc params.
221+
229222

230223
synth_set_param(synth, "osc1.waveform", 0.0f);
231224
synth_set_param(synth, "osc2.waveform", 0.0f);
@@ -331,7 +324,7 @@ void synth_handle_cc(Synth *synth, int cc, int value) {
331324
void synth_set_param(Synth *synth, const char *param, float value) {
332325
if (strncmp(param, "osc", 3) == 0) {
333326
int i = param[3] - '1';
334-
if (i >= 0 && i < 6) // Changed from i < 4 to i < 6
327+
if (i >= 0 && i < 4)
335328
osc_set_param(&synth->osc[i], param + 5, value);
336329
} else if (strncmp(param, "fx.", 3) == 0) {
337330
fx_set_param(&synth->fx, param + 3, value);
@@ -446,7 +439,7 @@ char* synth_save_preset_json(const Synth *synth) {
446439

447440
// Save Oscillator parameters
448441
cJSON *oscillators = cJSON_CreateArray();
449-
for (int i = 0; i < 6; ++i) {
442+
for (int i = 0; i < 4; ++i) {
450443
cJSON *osc = cJSON_CreateObject();
451444
cJSON_AddNumberToObject(osc, "waveform", synth->osc[i].waveform);
452445
cJSON_AddNumberToObject(osc, "pitch", synth->osc[i].pitch);
@@ -588,7 +581,7 @@ void synth_load_preset_json(Synth *synth, const char *json_string) {
588581
cJSON *oscillators = cJSON_GetObjectItemCaseSensitive(root, "oscillators");
589582
if (cJSON_IsArray(oscillators)) {
590583
int num_oscillators = cJSON_GetArraySize(oscillators);
591-
for (int i = 0; i < num_oscillators && i < 6; ++i) { // Limit to 6 oscillators
584+
for (int i = 0; i < num_oscillators && i < 4; ++i) { // Limit to 4 oscillators
592585
cJSON *osc = cJSON_GetArrayItem(oscillators, i);
593586
if (cJSON_IsObject(osc)) {
594587
cJSON *waveform = cJSON_GetObjectItemCaseSensitive(osc, "waveform");
@@ -845,8 +838,8 @@ void synth_load_default_config(Synth *synth) {
845838
void synth_randomize_parameters(Synth *synth) {
846839
char param_name[32];
847840

848-
// Randomize all oscillators (0-5)
849-
for (int i = 0; i < 6; i++) {
841+
// Randomize all oscillators (0-3)
842+
for (int i = 0; i < 4; i++) {
850843
// Randomize waveform (0-4: SINE, SAW, SQUARE, TRI, NOISE)
851844
float random_waveform = (float)(rand() % 5);
852845
snprintf(param_name, sizeof(param_name), "osc%d.waveform", i + 1);
@@ -885,7 +878,7 @@ void synth_randomize_parameters(Synth *synth) {
885878
}
886879

887880
void synth_randomize_oscillator(Synth *synth, int osc_index) {
888-
if (osc_index < 0 || osc_index >= 6) return;
881+
if (osc_index < 0 || osc_index >= 4) return;
889882

890883
char param_name[32];
891884

src/synth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ typedef struct {
2323
} ChordProgression;
2424

2525
typedef struct Synth {
26-
Oscillator osc[6]; // osc[0-3] for main, osc[4] for bass, osc[5] for percussion
26+
Oscillator osc[4]; // osc[0-3] for main oscillators
2727
LFO lfos[3]; // lfos[0] for pitch, lfos[1] for volume, lfos[2] for filter
2828
Mixer mixer;
2929
FX fx;

src/voice.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void voice_render(Voice *v, const Oscillator *osc, const LFO *lfo, const float *
4545
float filter_mod = lfo[2].enabled ? lfo_get_modulation_value((LFO*)&lfo[2]) : 0.0f;
4646

4747
// Process each oscillator with gain and panning
48-
for (int o = 0; o < 6; ++o) {
48+
for (int o = 0; o < 4; ++o) {
4949
float modified_note = v->note;
5050

5151
// Apply pitch LFO (only to main oscillators 0-3)
@@ -63,7 +63,7 @@ void voice_render(Voice *v, const Oscillator *osc, const LFO *lfo, const float *
6363
osc_output *= osc_gains[o];
6464

6565
// Apply oscillator panning
66-
float pan = (o < 6) ? osc[o].pan : 0.0f; // All oscillators support pan
66+
float pan = (o < 4) ? osc[o].pan : 0.0f; // All oscillators support pan
6767
float left_gain = (pan <= 0.0f) ? 1.0f : 1.0f - pan;
6868
float right_gain = (pan >= 0.0f) ? 1.0f : 1.0f + pan;
6969

@@ -76,8 +76,8 @@ void voice_render(Voice *v, const Oscillator *osc, const LFO *lfo, const float *
7676
right *= v->velocity * adsr_value;
7777

7878
// Average across oscillators and add to stereo buffer
79-
stereo[n * 2 + 0] += left * (1.0f / 6.0f); // Left channel
80-
stereo[n * 2 + 1] += right * (1.0f / 6.0f); // Right channel
79+
stereo[n * 2 + 0] += left * (1.0f / 4.0f); // Left channel
80+
stereo[n * 2 + 1] += right * (1.0f / 4.0f); // Right channel
8181
}
8282
}
8383

src/voice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ typedef struct Voice {
88
float note;
99
float velocity;
1010
unsigned long long timestamp;
11-
float phase_acc[6];
11+
float phase_acc[4];
1212
AdsrEnvelope adsr;
1313
} Voice;
1414

0 commit comments

Comments
 (0)