summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--p/TEST.cfg32
-rw-r--r--p/mario.preset36
-rw-r--r--p/pad.cfg32
-rw-r--r--p/wierdfilter.preset36
-rw-r--r--src/archive/gtk.c (renamed from src/gtk.c)0
-rw-r--r--src/gui_functions.c23
-rw-r--r--src/synth_engine.h4
-rw-r--r--src/synth_engine_v2.c33
-rw-r--r--src/synth_gui.c22
-rw-r--r--tmpl/index.html1
10 files changed, 182 insertions, 37 deletions
diff --git a/p/TEST.cfg b/p/TEST.cfg
new file mode 100644
index 0000000..d214300
--- /dev/null
+++ b/p/TEST.cfg
@@ -0,0 +1,32 @@
+synth :
+{
+ name = "example synth name";
+ generator = 4;
+ adsr :
+ {
+ a = 0.0;
+ peak = 1.0;
+ d = 0.3;
+ s = 0.7;
+ r = 0.2;
+ };
+ delay :
+ {
+ enable = 1;
+ time = 0.285;
+ feedback = 0.5;
+ };
+ filter :
+ {
+ enable = 0;
+ cutoff = 907.421875;
+ resonance = 0.946563;
+ };
+ lfo :
+ {
+ freq = 1.0;
+ amp = 0.0;
+ };
+ autogain = 0;
+ gain = 0.295;
+};
diff --git a/p/mario.preset b/p/mario.preset
new file mode 100644
index 0000000..f25dbab
--- /dev/null
+++ b/p/mario.preset
@@ -0,0 +1,36 @@
+synth :
+{
+ name = "mario.preset";
+ generator = 4;
+ adsr :
+ {
+ a = 0.0;
+ peak = 1.0;
+ d = 0.3;
+ s = 0.7;
+ r = 0.2;
+ };
+ delay :
+ {
+ enable = 1;
+ time = 0.285;
+ feedback = 0.5;
+ };
+ biquad :
+ {
+ enable = 1;
+ };
+ filter :
+ {
+ enable = 0;
+ cutoff = 907.421875;
+ resonance = 0.946563;
+ };
+ lfo :
+ {
+ freq = 1.0;
+ amp = 0.0;
+ };
+ autogain = 0;
+ gain = 0.295;
+};
diff --git a/p/pad.cfg b/p/pad.cfg
new file mode 100644
index 0000000..54e43a6
--- /dev/null
+++ b/p/pad.cfg
@@ -0,0 +1,32 @@
+synth :
+{
+ name = "example synth name";
+ generator = 4;
+ adsr :
+ {
+ a = 0.9;
+ peak = 0.59;
+ d = 0.53;
+ s = 0.48;
+ r = 3.15;
+ };
+ delay :
+ {
+ enable = 1;
+ time = 0.21;
+ feedback = 0.795;
+ };
+ filter :
+ {
+ enable = 1;
+ cutoff = 1593.359375;
+ resonance = 1.0;
+ };
+ lfo :
+ {
+ freq = 0.5;
+ amp = 0.005;
+ };
+ autogain = 1;
+ gain = 0.458319;
+};
diff --git a/p/wierdfilter.preset b/p/wierdfilter.preset
new file mode 100644
index 0000000..bfc92d4
--- /dev/null
+++ b/p/wierdfilter.preset
@@ -0,0 +1,36 @@
+synth :
+{
+ name = "wierdfilter.preset";
+ generator = 3;
+ adsr :
+ {
+ a = 0.0;
+ peak = 1.0;
+ d = 0.3;
+ s = 0.7;
+ r = 5.0;
+ };
+ delay :
+ {
+ enable = 0;
+ time = 0.5;
+ feedback = 0.5;
+ };
+ biquad :
+ {
+ enable = 1;
+ };
+ filter :
+ {
+ enable = 1;
+ cutoff = 8024.023438;
+ resonance = 5.941563;
+ };
+ lfo :
+ {
+ freq = 1.0;
+ amp = 0.0;
+ };
+ autogain = 0;
+ gain = 0.18;
+};
diff --git a/src/gtk.c b/src/archive/gtk.c
index 2b91b94..2b91b94 100644
--- a/src/gtk.c
+++ b/src/archive/gtk.c
diff --git a/src/gui_functions.c b/src/gui_functions.c
new file mode 100644
index 0000000..b024368
--- /dev/null
+++ b/src/gui_functions.c
@@ -0,0 +1,23 @@
+/*
+ * Header library for gui functions
+ */
+#ifndef SYNTH_GUI_H_
+#define SYNTH_GUI_H_
+
+#include "control.h"
+#include <raylib.h>
+
+void frequencyToColor(float frequency, int *red, int *green, int *blue);
+float generic_vbar(float val, float def, float min, float max, int x, int y, int width, int height);
+float generic_hbar(float val, float def, float min, float max, int x, int y, int width, int height);
+
+void draw_cc_circle(cc_t * cc, int x, int y, int width, int height);
+void draw_cc_hbar(cc_t * cc, int x, int y, int width, int height);
+void draw_cc_vbar(cc_t * cc, int x, int y, int width, int height);
+
+int gui_string_spinner(Rectangle rect, char * text, int * index);
+
+#endif // SYNTH_GUI_H_
+#ifdef SYNTH_GUI_IMPLEMENTATION
+
+#endif // SYNTH_GUI_IMPLEMENTATION
diff --git a/src/synth_engine.h b/src/synth_engine.h
index dafff90..a29c389 100644
--- a/src/synth_engine.h
+++ b/src/synth_engine.h
@@ -103,8 +103,6 @@ typedef struct {
int autogain;
- float x;
-
midi_note_t midi_note[MIDI_NOTES];
midi_note_t * midi_active[MIDI_NOTES];
int midi_active_n;
@@ -133,7 +131,7 @@ typedef struct {
int modifiers[16];
int modi;
- float (*gen[7]) (float freq, midi_note_t * midi_note, float x, unsigned int sample_rate);
+ float (*gen[7]) (float freq, midi_note_t * midi_note);
int geni;
BWLowPass* fff;
diff --git a/src/synth_engine_v2.c b/src/synth_engine_v2.c
index 95ed61b..e15df85 100644
--- a/src/synth_engine_v2.c
+++ b/src/synth_engine_v2.c
@@ -1,7 +1,6 @@
#include "synth_engine.h"
#include "synth_math.h"
#include "lowpass.h"
-#include "filter.h"
#include "control.h"
#include "sound.h"
#include "midi.h"
@@ -12,63 +11,56 @@
#include <time.h>
float
-gen0(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
+gen0(float f, midi_note_t * midi_note)
{
- (void)x; (void)sample_rate;
float sample = osc_sin(midi_note->wvt_index);
midi_note->wvt_index = osc_sin_next(f, midi_note->wvt_index);
return sample;
}
float
-gen1(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
+gen1(float f, midi_note_t * midi_note)
{
- (void)x; (void)sample_rate;
float sample = osc_saw(midi_note->wvt_index);
midi_note->wvt_index = osc_saw_next(f, midi_note->wvt_index);
return sample;
}
float
-gen2(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
+gen2(float f, midi_note_t * midi_note)
{
- (void)x; (void)sample_rate;
float sample = osc_weird(midi_note->wvt_index);
midi_note->wvt_index = osc_weird_next(f, midi_note->wvt_index);
return sample;
}
float
-gen3(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
+gen3(float f, midi_note_t * midi_note)
{
- (void)x; (void)sample_rate;
float sample = osc_tri(midi_note->wvt_index);
midi_note->wvt_index = osc_tri_next(f, midi_note->wvt_index);
return sample;
}
float
-gen4(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
+gen4(float f, midi_note_t * midi_note)
{
- (void)x; (void)sample_rate;
float sample = osc_sound(midi_note->wvt_index);
midi_note->wvt_index = osc_sound_next(f, midi_note->wvt_index);
return sample;
}
float
-gen5(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
+gen5(float f, midi_note_t * midi_note)
{
- (void)x; (void)sample_rate;
float sample = osc_digisaw(midi_note->wvt_index);
midi_note->wvt_index = osc_digisaw_next(f, midi_note->wvt_index);
return sample;
}
float
-gen6(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
+gen6(float f, midi_note_t * midi_note)
{
- (void)x; (void)sample_rate;
float sample = osc_sqr(midi_note->wvt_index);
midi_note->wvt_index = osc_sqr_next(f, midi_note->wvt_index);
return sample;
@@ -196,7 +188,7 @@ get_max_sample(synth_t *synth, int test_size)
note_dup.adsr = note->adsr;
note_dup.active = note->active;
for (int i = 0; i < test_size; i++) {
- osc_wave[i] += synth->gen[synth->geni](note_dup.freq * 3, &note_dup, synth->x, SAMPLE_RATE);
+ osc_wave[i] += synth->gen[synth->geni](note_dup.freq * 3, &note_dup);
}
}
@@ -220,9 +212,9 @@ float Q_rsqrt(float number)
}
float
-make_single_sample(synth_t *synth, float freq, midi_note_t * note, unsigned int sample_rate)
+make_single_sample(synth_t *synth, float freq, midi_note_t * note)
{
- return synth->gen[synth->geni](freq, note, synth->x, sample_rate);
+ return synth->gen[synth->geni](freq, note);
}
/**
@@ -275,8 +267,7 @@ make_sample(synth_t * synth, unsigned int sample_rate, int frame)
sample += rms * note->velocity * adsr * make_single_sample(synth,
targ_freq,
- note,
- sample_rate);
+ note);
}
/* filter */
@@ -540,8 +531,6 @@ init_synth(void)
// synth->modi = 0;
synth->autogain = 1;
- synth->x = 1;
-
synth->adsr.a = 0.00001f;
synth->adsr.peak = 1.0f;
synth->adsr.d = 0.3;
diff --git a/src/synth_gui.c b/src/synth_gui.c
index 77e1876..db37bf7 100644
--- a/src/synth_gui.c
+++ b/src/synth_gui.c
@@ -369,7 +369,7 @@ draw_osc(synth_t * synth, int x, int y, int width, int height)
midi_note_t note_dup = {0};
for (int i = 0; i < width; i++) {
float freq = SAMPLE_RATE/(float)width;
- osc_wave[i] += synth->gen[synth->geni](freq, &note_dup, synth->x, SAMPLE_RATE);
+ osc_wave[i] += synth->gen[synth->geni](freq, &note_dup);
}
for (int i = 0; i < width; i++) {
@@ -645,9 +645,10 @@ draw_signals(synth_t * synth, int x, int y, int width, int height)
DrawRectangleLines(x, y, width, height, WHITE);
if (synth->viz.wave_enabled || synth->viz.spectrum_enabled) {
- synth->viz.rate_divider =
- GuiSlider((Rectangle){x + (width / 2.0) / 2, y - 12, width / 2.0, 12},
- "", NULL, synth->viz.rate_divider, 1, 150);
+ synth->viz.rate_divider = generic_hbar(synth->viz.rate_divider, 15, 1, 150, x + (width / 2.0) / 2, y - 12, width / 2.0, 12);
+ /* synth->viz.rate_divider = */
+ /* GuiSlider((Rectangle){x + (width / 2.0) / 2, y - 12, width / 2.0, 12}, */
+ /* "", NULL, synth->viz.rate_divider, 1, 150); */
synth->viz.y_divider = generic_vbar(synth->viz.y_divider, 1.0, 0.5, 3.0, x - 10, y, 10, height);
/* /\* GuiSlider((Rectangle){x - 10, y, 10, height}, "", NULL, *\/ */
/* /\* synth->viz.y_divider, 0.5, 3); *\/ */
@@ -1254,11 +1255,12 @@ draw_main(synth_t *synth)
draw_osc(synth, WIDTH / 2 + 180, 140, 80, 80);
}
- if ( GuiButton((Rectangle){ WIDTH / 2.0 - 108, 150 - 6 - 6 + 42, 216, 6 }, "")) {
- synth->x = 1;
- }
- snprintf(buf, sizeof buf, "%.1f", synth->x);
- synth->x = GuiSlider((Rectangle){ WIDTH / 2.0 - 108, 150 + 42, 216, 24 }, "x", buf, synth->x , 0.0f, 2.0f);
+ // x variable
+ /* if ( GuiButton((Rectangle){ WIDTH / 2.0 - 108, 150 - 6 - 6 + 42, 216, 6 }, "")) { */
+ /* synth->x = 1; */
+ /* } */
+ /* snprintf(buf, sizeof buf, "%.1f", synth->x); */
+ /* synth->x = GuiSlider((Rectangle){ WIDTH / 2.0 - 108, 150 + 42, 216, 24 }, "x", buf, synth->x , 0.0f, 2.0f); */
synth->filter = GuiToggle((Rectangle){ WIDTH - 100 - 50 - 100 - 50 , 50 , 46, 24 }, "LP", synth->filter);
synth->biquad = GuiToggle((Rectangle){ WIDTH - 100 - 50 - 100 - 50 + 46 + 8 , 50 , 46, 24 }, "bq", synth->biquad);
@@ -1341,8 +1343,6 @@ rayrun(synth_t *synth){
ws_send_message(b);
sprintf(b, "autogain:%d", synth->autogain);
ws_send_message(b);
- sprintf(b, "x:%f", synth->x);
- ws_send_message(b);
sprintf(b, "midi_active_n:%d", synth->midi_active_n);
ws_send_message(b);
sprintf(b, "octave:%d", synth->octave);
diff --git a/tmpl/index.html b/tmpl/index.html
index a6ae38b..071f2a2 100644
--- a/tmpl/index.html
+++ b/tmpl/index.html
@@ -24,7 +24,6 @@
<span id="wvt_pos" class="int">wvt_pos: $INT( synth->wvt_pos )$</span>
<span id="cci" class="int">cci: $INT( synth->cci )$</span>
<span id="autogain" class="int">autogain: $INT( synth->autogain )$</span>
- <span id="x" class="float">x: $FLOAT( synth->x )$</span>
<span id="midi_active_n" class="int">midi_active_n: $INT( synth->midi_active_n )$</span>
<span id="octave" class="int">octave: $INT( synth->octave )$</span>
<span id="delay" class="int">delay: $INT( synth->delay )$</span>