summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/synth_engine.h2
-rw-r--r--src/synth_engine_v2.c23
-rw-r--r--src/synth_gui.c9
3 files changed, 26 insertions, 8 deletions
diff --git a/src/synth_engine.h b/src/synth_engine.h
index d9932d6..dafff90 100644
--- a/src/synth_engine.h
+++ b/src/synth_engine.h
@@ -149,6 +149,8 @@ typedef struct {
struct midi_t *midi;
+ char * patch_name;
+
synth_gui gui;
} synth_t;
diff --git a/src/synth_engine_v2.c b/src/synth_engine_v2.c
index ac248b3..95ed61b 100644
--- a/src/synth_engine_v2.c
+++ b/src/synth_engine_v2.c
@@ -219,6 +219,12 @@ float Q_rsqrt(float number)
return conv.f;
}
+float
+make_single_sample(synth_t *synth, float freq, midi_note_t * note, unsigned int sample_rate)
+{
+ return synth->gen[synth->geni](freq, note, synth->x, sample_rate);
+}
+
/**
* @brief generate a sample from the currently selected generator
*
@@ -267,10 +273,10 @@ make_sample(synth_t * synth, unsigned int sample_rate, int frame)
note->lfo_index = osc_sin_next(CC_GET(lfo_freq), note->lfo_index);
- sample += rms * note->velocity * adsr * synth->gen[synth->geni](targ_freq,
- note,
- synth->x,
- sample_rate);
+ sample += rms * note->velocity * adsr * make_single_sample(synth,
+ targ_freq,
+ note,
+ sample_rate);
}
/* filter */
@@ -599,10 +605,10 @@ init_synth(void)
synth->viz.rate_divider = 15;
synth->viz.y_divider = 1;
-// for (int i = 0; i < RING_SIZE; i++) synth->viz.wave_buffer_data[i] = 0;
+ // for (int i = 0; i < RING_SIZE; i++) synth->viz.wave_buffer_data[i] = 0;
synth->viz.wave_buffer_data = (float *)calloc(sizeof(float), RING_SIZE);
PaUtil_InitializeRingBuffer(&synth->viz.wave_buffer, sizeof(float), RING_SIZE, synth->viz.wave_buffer_data);
-// for (int i = 0; i < RING_SIZE; i++) synth->viz.fft_buffer_data[i] = 0;
+ // for (int i = 0; i < RING_SIZE; i++) synth->viz.fft_buffer_data[i] = 0;
synth->viz.fft_buffer_data = (float *)calloc(sizeof(float), RING_SIZE);
PaUtil_InitializeRingBuffer(&synth->viz.fft_buffer, sizeof(float), RING_SIZE, synth->viz.fft_buffer_data);
@@ -621,7 +627,6 @@ init_synth(void)
synth->viz.tmp_index = 0;
synth->wvt_pos = 0;
-
synth->sound_active = 0;
strcpy(synth->soundcard.name, "default");
@@ -634,6 +639,8 @@ init_synth(void)
synth->gui.screen = SCREEN_MAIN;
synth->gui.audiomidi_initialized = 0;
+ synth->patch_name = NULL;
+
return synth;
}
@@ -657,6 +664,8 @@ free_synth(synth_t * synth)
free_bw_band_stop(synth->fff2);
free(synth->del);
+
+ if (synth->patch_name) free(synth->patch_name);
free(synth);
}
diff --git a/src/synth_gui.c b/src/synth_gui.c
index f96cccb..f7a541f 100644
--- a/src/synth_gui.c
+++ b/src/synth_gui.c
@@ -861,7 +861,7 @@ void draw_load_patch(synth_t *synth) {
static bool save_name_edit = false;
static char save_text[1024] = ""; // TODO default to current patch name
- GuiPanel((Rectangle){ WIDTH / 2.0 - 200, HEIGHT / 2.0 - 140, 400, 280 }, "Save patch");
+ GuiPanel((Rectangle){ WIDTH / 2.0 - 200, HEIGHT / 2.0 - 140, 400, 280 }, "Load patch");
if (GuiButton(
(Rectangle){WIDTH / 2.0 - 50 - 50 - 3, HEIGHT / 2.0 - 12, 100, 24},
"load")) {
@@ -870,6 +870,7 @@ void draw_load_patch(synth_t *synth) {
fprintf(stderr, "Can't load %s\n", save_text);
return;
}
+ synth->patch_name = strdup(save_text);
synth->gui.popup = POPUP_NONE;
}
}
@@ -1262,6 +1263,12 @@ draw_main(synth_t *synth)
synth->gui.popup = POPUP_LOAD_PATCH;
}
+ if ( GuiButton((Rectangle){ WIDTH - 100 - 50, 50 + 24 + 6 + 24 + 6 + 24 + 6 + 24 + 6 + 24 + 6 + 24 + 6 + 24 + 6, 100, 24 }, "reLOAD!")) {
+ if (synth->patch_name && load_synth(synth, synth->patch_name)) {
+ fprintf(stderr, "Can't load %s\n", synth->patch_name);
+ }
+ }
+
// signals
draw_signals(synth, 20, 390, WIDTH - 2*20, 200);