Skip to content

Commit c4acfad

Browse files
committed
misc
1 parent 924f97b commit c4acfad

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
A modular synthesizer application written in C, using SDL2 for graphics and audio, and supporting MIDI input via libremidi. The GUI is resizable and features oscilloscope and spectrum displays, keyboard input, and real-time control of oscillators, effects, mixer, and arpeggiator.
22

3+
![sdl2-synth screenshot](screenshot.png)
4+
35
![GitHub last commit](https://img.shields.io/github/last-commit/koppi/sdl2-synth)
46
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/koppi/sdl2-synth)
57
[![OS](https://github.com/koppi/sdl2-synth/actions/workflows/os.yml/badge.svg)](https://github.com/koppi/sdl2-synth/actions/workflows/os.yml)
68
[![Web](https://github.com/koppi/sdl2-synth/actions/workflows/web.yml/badge.svg)](https://github.com/koppi/sdl2-synth/actions/workflows/web.yml)
79
[![GitHub issues](https://img.shields.io/github/issues/koppi/sdl2-synth)](https://github.com/koppi/sdl2-synth/issues)
810

9-
![sdl2-synth screenshot](screenshot.png)
10-
1111
## Features
1212

1313
- **4-oscillator synth**: Each with independent waveform, pitch, detune, gain, phase, pulse width, and unison controls.

src/synth.c

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,37 +452,91 @@ char* synth_save_preset_json(const Synth *synth) {
452452
cJSON_AddNumberToObject(osc, "pitch", synth->osc[i].pitch);
453453
cJSON_AddNumberToObject(osc, "detune", synth->osc[i].detune);
454454
cJSON_AddNumberToObject(osc, "gain", synth->osc[i].gain);
455+
cJSON_AddNumberToObject(osc, "pan", synth->osc[i].pan);
456+
cJSON_AddNumberToObject(osc, "pulse_width", synth->osc[i].pulse_width);
457+
cJSON_AddNumberToObject(osc, "unison_voices", synth->osc[i].unison_voices);
458+
cJSON_AddNumberToObject(osc, "unison_detune", synth->osc[i].unison_detune);
455459
cJSON_AddItemToArray(oscillators, osc);
456460
}
457-
cJSON_AddItemToObject(root, "oscillators", oscillators);
461+
cJSON_AddItemToObject(root, "oscillators", oscillators);
462+
463+
// Save ADSR Envelope parameters
464+
cJSON *adsr = cJSON_CreateObject();
465+
cJSON_AddNumberToObject(adsr, "attack", synth->adsr.attack);
466+
cJSON_AddNumberToObject(adsr, "decay", synth->adsr.decay);
467+
cJSON_AddNumberToObject(adsr, "sustain", synth->adsr.sustain);
468+
cJSON_AddNumberToObject(adsr, "release", synth->adsr.release);
469+
cJSON_AddItemToObject(root, "adsr", adsr);
470+
471+
// Save LFO parameters
472+
cJSON *lfos = cJSON_CreateArray();
473+
for (int i = 0; i < 3; ++i) {
474+
cJSON *lfo = cJSON_CreateObject();
475+
cJSON_AddNumberToObject(lfo, "waveform", synth->lfos[i].waveform);
476+
cJSON_AddNumberToObject(lfo, "frequency", synth->lfos[i].frequency);
477+
cJSON_AddNumberToObject(lfo, "depth", synth->lfos[i].depth);
478+
cJSON_AddNumberToObject(lfo, "phase", synth->lfos[i].phase);
479+
cJSON_AddNumberToObject(lfo, "gain", synth->lfos[i].gain);
480+
cJSON_AddNumberToObject(lfo, "target", synth->lfos[i].target);
481+
cJSON_AddNumberToObject(lfo, "sync", synth->lfos[i].sync);
482+
cJSON_AddBoolToObject(lfo, "enabled", synth->lfos[i].enabled);
483+
cJSON_AddItemToArray(lfos, lfo);
484+
}
485+
cJSON_AddItemToObject(root, "lfos", lfos);
458486

459487
// Save Mixer parameters
460488
cJSON *mixer = cJSON_CreateObject();
461489
cJSON_AddNumberToObject(mixer, "master_gain", synth->mixer.master);
490+
cJSON_AddNumberToObject(mixer, "master_pan", synth->mixer.master_pan);
491+
cJSON_AddNumberToObject(mixer, "master_width", synth->mixer.master_width);
462492
cJSON *osc_gains = cJSON_CreateArray();
463-
for (int i = 0; i < 4; ++i) {
493+
for (int i = 0; i < 6; ++i) {
464494
cJSON_AddItemToArray(osc_gains, cJSON_CreateNumber(synth->mixer.osc_gain[i]));
465495
}
466496
cJSON_AddItemToObject(mixer, "osc_gains", osc_gains);
467497
// Add compressor parameters
498+
cJSON_AddNumberToObject(mixer, "comp_enabled", synth->mixer.comp_enabled);
468499
cJSON_AddNumberToObject(mixer, "comp_threshold", synth->mixer.comp_threshold);
469500
cJSON_AddNumberToObject(mixer, "comp_ratio", synth->mixer.comp_ratio);
470501
cJSON_AddNumberToObject(mixer, "comp_attack", synth->mixer.comp_attack);
471502
cJSON_AddNumberToObject(mixer, "comp_release", synth->mixer.comp_release);
472503
cJSON_AddNumberToObject(mixer, "comp_makeup_gain", synth->mixer.comp_makeup_gain);
504+
cJSON_AddNumberToObject(mixer, "dc_filter_enabled", synth->mixer.dc_filter_enabled);
505+
cJSON_AddNumberToObject(mixer, "dc_filter_freq", synth->mixer.dc_filter_freq);
506+
cJSON_AddNumberToObject(mixer, "soft_clip_enabled", synth->mixer.soft_clip_enabled);
507+
cJSON_AddNumberToObject(mixer, "soft_clip_threshold", synth->mixer.soft_clip_threshold);
508+
cJSON_AddNumberToObject(mixer, "soft_clip_ratio", synth->mixer.soft_clip_ratio);
509+
cJSON_AddNumberToObject(mixer, "auto_gain_enabled", synth->mixer.auto_gain_enabled);
510+
cJSON_AddNumberToObject(mixer, "auto_gain_target", synth->mixer.auto_gain_target);
473511
cJSON_AddItemToObject(root, "mixer", mixer);
474512

475513
// Save FX parameters
476514
cJSON *fx = cJSON_CreateObject();
515+
cJSON_AddNumberToObject(fx, "filter_enabled", synth->fx.filter_enabled);
516+
cJSON_AddNumberToObject(fx, "filter_type", synth->fx.filter_type);
517+
cJSON_AddNumberToObject(fx, "filter_cutoff", synth->fx.filter_cutoff);
518+
cJSON_AddNumberToObject(fx, "filter_resonance", synth->fx.filter_resonance);
519+
cJSON_AddNumberToObject(fx, "filter_drive", synth->fx.filter_drive);
520+
cJSON_AddNumberToObject(fx, "filter_mix", synth->fx.filter_mix);
521+
cJSON_AddNumberToObject(fx, "filter_oversampling", synth->fx.filter_oversampling);
477522
cJSON_AddNumberToObject(fx, "flanger_depth", synth->fx.flanger_depth);
478523
cJSON_AddNumberToObject(fx, "flanger_rate", synth->fx.flanger_rate);
479524
cJSON_AddNumberToObject(fx, "flanger_feedback", synth->fx.flanger_feedback);
480525
cJSON_AddNumberToObject(fx, "delay_time", synth->fx.delay_time);
481526
cJSON_AddNumberToObject(fx, "delay_feedback", synth->fx.delay_feedback);
482527
cJSON_AddNumberToObject(fx, "delay_mix", synth->fx.delay_mix);
528+
cJSON_AddNumberToObject(fx, "multitap_enabled", synth->fx.multitap_enabled);
529+
cJSON_AddNumberToObject(fx, "multitap_tap0", synth->fx.multitap_taps[0]);
530+
cJSON_AddNumberToObject(fx, "multitap_tap0_level", synth->fx.multitap_levels[0]);
531+
cJSON_AddNumberToObject(fx, "multitap_tap1", synth->fx.multitap_taps[1]);
532+
cJSON_AddNumberToObject(fx, "multitap_tap1_level", synth->fx.multitap_levels[1]);
533+
cJSON_AddNumberToObject(fx, "multitap_tap2", synth->fx.multitap_taps[2]);
534+
cJSON_AddNumberToObject(fx, "multitap_tap2_level", synth->fx.multitap_levels[2]);
535+
cJSON_AddNumberToObject(fx, "multitap_tap3", synth->fx.multitap_taps[3]);
536+
cJSON_AddNumberToObject(fx, "multitap_tap3_level", synth->fx.multitap_levels[3]);
483537
cJSON_AddNumberToObject(fx, "reverb_size", synth->fx.reverb_size);
484-
cJSON_AddNumberToObject(fx, "reverb_damping", synth->fx.reverb_damping);
485-
cJSON_AddNumberToObject(fx, "reverb_mix", synth->fx.reverb_mix);
538+
cJSON_AddNumberToObject(fx, "reverb_mix", synth->fx.reverb_damping);
539+
cJSON_AddNumberToObject(fx, "reverb_damping", synth->fx.reverb_mix);
486540
cJSON_AddItemToObject(root, "fx", fx);
487541

488542
// Save Ring Modulator parameters

0 commit comments

Comments
 (0)