diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/archive/gtk.c (renamed from src/gtk.c) | 0 | ||||
| -rw-r--r-- | src/gui_functions.c | 23 | ||||
| -rw-r--r-- | src/synth_engine.h | 4 | ||||
| -rw-r--r-- | src/synth_engine_v2.c | 33 | ||||
| -rw-r--r-- | src/synth_gui.c | 22 |
5 files changed, 46 insertions, 36 deletions
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, ¬e_dup, synth->x, SAMPLE_RATE); + osc_wave[i] += synth->gen[synth->geni](note_dup.freq * 3, ¬e_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, ¬e_dup, synth->x, SAMPLE_RATE); + osc_wave[i] += synth->gen[synth->geni](freq, ¬e_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); |
