some bugfixes, and got a nice bass going

master
vampirefrog 6 years ago
parent 693332aa07
commit 60af68fb58

@ -46,8 +46,8 @@ void filter_set_resonance(struct Filter *filter, float resonance) {
float filter_sample(struct Filter *filter, float input) {
if(++filter->last_calc >= 16) {
filter->last_calc = 0;
filter->cutoff_calc = pow (0.5, 8.5 - (filter->cutoff)*8 );
filter->resonance_calc = filter->resonance;
filter->cutoff_calc = pow(0.5, 8.5 - filter->cutoff * 8);
filter->resonance_calc = pow(0.5, (1.0 - filter->resonance) * 4.5);
}
float cutoff = filter->cutoff_calc;
float resonance = filter->resonance_calc;

@ -245,19 +245,19 @@ int main(int argc, char **argv) {
sr = jack_get_sample_rate(client);
synth_init(&synth);
synth.osc_env.attack = 2;
synth.osc_env.decay = 200;
synth.osc_env.attack = 1;
synth.osc_env.decay = 0;
synth.osc_env.sustain = 100;
synth.osc_env.release = 100;
synth.filter_env.attack = 150;
synth.filter_env.decay = 100;
synth.filter_env.sustain = 100;
synth.filter_env.release = 100;
synth.filter_eg_intensity = .8;
synth.filter_env.attack = 1;
synth.filter_env.decay = 300;
synth.filter_env.sustain = 0;
synth.filter_env.release = 0;
synth.filter_eg_intensity = .9;
synth.filter_kbd_track = .5;
sine_osc_set_freq(&synth.lfo_osc, 6);
synth.pitch_bend_range = 12; // semitones
// synth.monophonic = 1;
synth.monophonic = 1;
if (jack_activate(client)) {
fprintf (stderr, "cannot activate client");

@ -9,7 +9,7 @@
#include "tables.inc"
void synth_init(struct Synth *synth) {
synth_set_cutoff_freq(synth, 127);
synth_set_cutoff_freq(synth, 0);
synth_set_resonance(synth, 0);
srandom(1234);
synth->key_stack_size = 0;
@ -133,11 +133,6 @@ void synth_note_off(struct Synth *synth, uint8_t note, uint8_t velocity) {
voice_stop(&synth->voices[i]);
}
}
printf("voices: ");
for(int i = 0; i < SYNTH_NUM_VOICES; i++) {
printf("%d%d ", synth->voices[i].osc_env.state, synth->voices[i].filter_env.state);
}
printf("\n");
}
}
@ -175,11 +170,11 @@ void synth_set_resonance(struct Synth *synth, uint8_t f) {
}
void synth_set_unison_spread(struct Synth *synth, uint8_t w) {
synth->unison_spread = w;
synth->unison_spread = w / 127.0;
}
void synth_set_stereo_spread(struct Synth *synth, uint8_t w) {
synth->stereo_spread = w;
synth->stereo_spread = w / 127.0;
}
void synth_set_volume(struct Synth *s, uint8_t vol) {

@ -20,8 +20,8 @@ struct Key {
struct Synth {
struct Voice voices[SYNTH_NUM_VOICES];
struct Envelope osc_env, filter_env;
uint8_t unison_spread;
uint8_t stereo_spread;
float unison_spread;
float stereo_spread;
uint8_t monophonic;
float tuning; // 440.0Hz

@ -8,8 +8,8 @@ void voice_render_sample(struct Voice *v, float *out) {
float s = oscillator_render_sample(&v->osc);
filter_set_cutoff(&v->filter, v->synth->cutoff + cutoff * v->synth->filter_eg_intensity);
float f = filter_sample(&v->filter, v->volume * amplitude * s / 32768.0);
out[0] = (127 + v->pan) * f / 255.0;
out[1] = (127 - v->pan) * f / 255.0;
out[0] = (1 + v->pan) * f / 2;
out[1] = (1 - v->pan) * f / 2;
v->time++;
}

@ -13,7 +13,7 @@ struct Voice {
uint8_t note;
float detune;
float volume;
int8_t pan;
float pan;
uint32_t time;
struct Envelope osc_env, filter_env;

Loading…
Cancel
Save