summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/filter.h98
-rw-r--r--src/synth.c2
-rw-r--r--src/synth_engine.c210
-rw-r--r--src/synth_engine.h8
-rw-r--r--src/synth_gui.c10
5 files changed, 133 insertions, 195 deletions
diff --git a/src/filter.h b/src/filter.h
index e72d384..2e2839c 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -28,33 +28,33 @@ extern "C"{
#endif
#endif
-typedef struct {
+ typedef struct {
int n;
- FTR_PRECISION *A;
+ FTR_PRECISION *A;
FTR_PRECISION *d1;
FTR_PRECISION *d2;
FTR_PRECISION *w0;
FTR_PRECISION *w1;
FTR_PRECISION *w2;
-} BWLowPass;
-// BWHighPass uses exactly the same struct
-typedef BWLowPass BWHighPass;
+ } BWLowPass;
+ // BWHighPass uses exactly the same struct
+ typedef BWLowPass BWHighPass;
-typedef struct {
+ typedef struct {
int m;
FTR_PRECISION ep;
- FTR_PRECISION *A;
+ FTR_PRECISION *A;
FTR_PRECISION *d1;
FTR_PRECISION *d2;
FTR_PRECISION *w0;
FTR_PRECISION *w1;
FTR_PRECISION *w2;
-} CHELowPass;
-typedef CHELowPass CHEHighPass;
+ } CHELowPass;
+ typedef CHELowPass CHEHighPass;
-typedef struct {
+ typedef struct {
int n;
- FTR_PRECISION *A;
+ FTR_PRECISION *A;
FTR_PRECISION *d1;
FTR_PRECISION *d2;
FTR_PRECISION *d3;
@@ -64,12 +64,12 @@ typedef struct {
FTR_PRECISION *w2;
FTR_PRECISION *w3;
FTR_PRECISION *w4;
-} BWBandPass;
+ } BWBandPass;
-typedef struct {
+ typedef struct {
int m;
FTR_PRECISION ep;
- FTR_PRECISION *A;
+ FTR_PRECISION *A;
FTR_PRECISION *d1;
FTR_PRECISION *d2;
FTR_PRECISION *d3;
@@ -79,13 +79,13 @@ typedef struct {
FTR_PRECISION *w2;
FTR_PRECISION *w3;
FTR_PRECISION *w4;
-} CHEBandPass;
+ } CHEBandPass;
-typedef struct {
+ typedef struct {
int n;
FTR_PRECISION r;
FTR_PRECISION s;
- FTR_PRECISION *A;
+ FTR_PRECISION *A;
FTR_PRECISION *d1;
FTR_PRECISION *d2;
FTR_PRECISION *d3;
@@ -95,14 +95,14 @@ typedef struct {
FTR_PRECISION *w2;
FTR_PRECISION *w3;
FTR_PRECISION *w4;
-} BWBandStop;
+ } BWBandStop;
-typedef struct {
+ typedef struct {
int m;
FTR_PRECISION ep;
FTR_PRECISION r;
FTR_PRECISION s;
- FTR_PRECISION *A;
+ FTR_PRECISION *A;
FTR_PRECISION *d1;
FTR_PRECISION *d2;
FTR_PRECISION *d3;
@@ -112,46 +112,46 @@ typedef struct {
FTR_PRECISION *w2;
FTR_PRECISION *w3;
FTR_PRECISION *w4;
-} CHEBandStop;
+ } CHEBandStop;
-void update_bw_low_pass_filter(BWLowPass* filter, FTR_PRECISION s, FTR_PRECISION f, FTR_PRECISION q);
+ void update_bw_low_pass_filter(BWLowPass* filter, FTR_PRECISION s, FTR_PRECISION f, FTR_PRECISION q);
-BWLowPass* create_bw_low_pass_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
-BWHighPass* create_bw_high_pass_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
-BWBandPass* create_bw_band_pass_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
-BWBandStop* create_bw_band_stop_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
+ BWLowPass* create_bw_low_pass_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
+ BWHighPass* create_bw_high_pass_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
+ BWBandPass* create_bw_band_pass_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
+ BWBandStop* create_bw_band_stop_filter(int order, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
-CHELowPass* create_che_low_pass_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
-CHEHighPass* create_che_high_pass_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
-CHEBandPass* create_che_band_pass_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
-CHEBandStop* create_che_band_stop_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
+ CHELowPass* create_che_low_pass_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
+ CHEHighPass* create_che_high_pass_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION half_power_frequency);
+ CHEBandPass* create_che_band_pass_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
+ CHEBandStop* create_che_band_stop_filter(int order, FTR_PRECISION epsilon, FTR_PRECISION sampling_frequency, FTR_PRECISION lower_half_power_frequency, FTR_PRECISION upper_half_power_frequency);
-void free_bw_low_pass(BWLowPass* filter);
-void free_bw_high_pass(BWHighPass* filter);
-void free_bw_band_pass(BWBandPass* filter);
-void free_bw_band_stop(BWBandStop* filter);
+ void free_bw_low_pass(BWLowPass* filter);
+ void free_bw_high_pass(BWHighPass* filter);
+ void free_bw_band_pass(BWBandPass* filter);
+ void free_bw_band_stop(BWBandStop* filter);
-void free_che_low_pass(CHELowPass* filter);
-void free_che_high_pass(CHEHighPass* filter);
-void free_che_band_pass(CHEBandPass* filter);
-void free_che_band_stop(CHEBandStop* filter);
+ void free_che_low_pass(CHELowPass* filter);
+ void free_che_high_pass(CHEHighPass* filter);
+ void free_che_band_pass(CHEBandPass* filter);
+ void free_che_band_stop(CHEBandStop* filter);
-FTR_PRECISION bw_low_pass(BWLowPass* filter, FTR_PRECISION input);
-FTR_PRECISION bw_high_pass(BWHighPass* filter, FTR_PRECISION input);
-FTR_PRECISION bw_band_pass(BWBandPass* filter, FTR_PRECISION input);
-FTR_PRECISION bw_band_stop(BWBandStop* filter, FTR_PRECISION input);
+ FTR_PRECISION bw_low_pass(BWLowPass* filter, FTR_PRECISION input);
+ FTR_PRECISION bw_high_pass(BWHighPass* filter, FTR_PRECISION input);
+ FTR_PRECISION bw_band_pass(BWBandPass* filter, FTR_PRECISION input);
+ FTR_PRECISION bw_band_stop(BWBandStop* filter, FTR_PRECISION input);
-FTR_PRECISION che_low_pass(CHELowPass* filter, FTR_PRECISION input);
-FTR_PRECISION che_high_pass(CHEHighPass* filter, FTR_PRECISION input);
-FTR_PRECISION che_band_pass(CHEBandPass* filter, FTR_PRECISION input);
-FTR_PRECISION che_band_stop(CHEBandStop* filter, FTR_PRECISION input);
+ FTR_PRECISION che_low_pass(CHELowPass* filter, FTR_PRECISION input);
+ FTR_PRECISION che_high_pass(CHEHighPass* filter, FTR_PRECISION input);
+ FTR_PRECISION che_band_pass(CHEBandPass* filter, FTR_PRECISION input);
+ FTR_PRECISION che_band_stop(CHEBandStop* filter, FTR_PRECISION input);
-FTR_PRECISION softmax(FTR_PRECISION* data, int size, int target_ind);
+ FTR_PRECISION softmax(FTR_PRECISION* data, int size, int target_ind);
-// Output should be pre-allocated which has the same(or larger) size as the input.
-void spike_filter_upward(FTR_PRECISION * input, int size, FTR_PRECISION * output, FTR_PRECISION strength);
+ // Output should be pre-allocated which has the same(or larger) size as the input.
+ void spike_filter_upward(FTR_PRECISION * input, int size, FTR_PRECISION * output, FTR_PRECISION strength);
#if __cplusplus
}
diff --git a/src/synth.c b/src/synth.c
index 5a08e4f..5ce932f 100644
--- a/src/synth.c
+++ b/src/synth.c
@@ -61,8 +61,8 @@ main(void) {
for( i=0; i< Pa_GetDeviceCount(); i++ ) {
deviceInfo = Pa_GetDeviceInfo( i );
//if (!strcmp("HyperX Cloud II Wireless: USB Audio (hw:0,0)", deviceInfo->name)) break;
- if (!strcmp("HDA Intel PCH: ALC1220 Analog (hw:1,0)", deviceInfo->name)) break;
printf("dev: %s || %f\n", deviceInfo->name, deviceInfo->defaultSampleRate);
+ if (!strcmp("HDA Intel PCH: ALC1220 Analog (hw:0,0)", deviceInfo->name)) break;
}
diff --git a/src/synth_engine.c b/src/synth_engine.c
index 57ec29b..41756c7 100644
--- a/src/synth_engine.c
+++ b/src/synth_engine.c
@@ -2,6 +2,23 @@
#include "lowpass.h"
#include "filter.h"
+/* 1d convolution */
+void
+convole(float *signal, float *filter, size_t signal_size, size_t filter_size, float *out) {
+ for (size_t i = 0; i < filter_size + signal_size; i++) {
+ size_t kmin, kmax, k;
+ out[i] = 0;
+ /* find overlap */
+ kmin = (i >= filter_size - 1) ? i - (filter_size - 1) : 0;
+ kmax = (i < signal_size - 1) ? i : signal_size - 1;
+
+ /* Add the overlaping values */
+ for (k = kmin; k <= kmax; k++) {
+ out[i] += signal[k] * filter[i - k];
+ }
+ }
+}
+
float
adsr_amplitude(void *synthData, unsigned long long elapsed)
{
@@ -14,20 +31,20 @@ adsr_amplitude(void *synthData, unsigned long long elapsed)
float dLifeTime = (elapsed * (1.0 / (float)SAMPLE_RATE));
if (synth->n.noteOn != 0 && synth->n.noteOff == 0) {
- if (dLifeTime <= synth->adsr.a)
+ if (dLifeTime < synth->adsr.a)
dAmplitude = (dLifeTime / synth->adsr.a)*(dLifeTime / synth->adsr.a) * dStartAmplitude;
- if (dLifeTime > synth->adsr.a && dLifeTime <= ( synth->adsr.a + synth->adsr.d))
+ if (dLifeTime >= synth->adsr.a && dLifeTime <= ( synth->adsr.a + synth->adsr.d))
dAmplitude = ((dLifeTime - synth->adsr.a) / synth->adsr.d) * (synth->adsr.s - dStartAmplitude) + dStartAmplitude;
if (dLifeTime > (synth->adsr.a + synth->adsr.d))
dAmplitude = synth->adsr.s;
}
else { // Note is off
- if (dLifeTime <= synth->adsr.a)
+ if (dLifeTime < synth->adsr.a)
dReleaseAmplitude = (dLifeTime / synth->adsr.a)*(dLifeTime / synth->adsr.a) * dStartAmplitude;
- if (dLifeTime > synth->adsr.a && dLifeTime <= (synth->adsr.a + synth->adsr.d))
+ if (dLifeTime >= synth->adsr.a && dLifeTime <= (synth->adsr.a + synth->adsr.d))
dReleaseAmplitude = ((dLifeTime - synth->adsr.a) / synth->adsr.d) * (synth->adsr.s - dStartAmplitude) + dStartAmplitude;
if (dLifeTime > (synth->adsr.a + synth->adsr.d))
@@ -38,7 +55,7 @@ adsr_amplitude(void *synthData, unsigned long long elapsed)
if (synth->adsr.r < 0) {
dAmplitude = synth->adsr.s;
}
-}
+ }
// Amplitude should not be negative
if (dAmplitude <= 0.000)
dAmplitude = 0.0;
@@ -118,91 +135,45 @@ gen3(float f, unsigned long long phase, float x, unsigned int sample_rate)
/* + sqr_sample(0.2, f * x, 0.2 * x * x, phase, sample_rate); */
}
-
-
-/* 1d convolution */
-void
-convole(float *signal, float *filter, size_t signal_size, size_t filter_size, float *out) {
- for (size_t i = 0; i < filter_size + signal_size; i++) {
- size_t kmin, kmax, k;
- out[i] = 0;
- /* find overlap */
- kmin = (i >= filter_size - 1) ? i - (filter_size - 1) : 0;
- kmax = (i < signal_size - 1) ? i : signal_size - 1;
-
- /* Add the overlaping values */
- for (k = kmin; k <= kmax; k++) {
- out[i] += signal[k] * filter[i - k];
- }
- }
-}
-
-void
-low_pass_filter(float* signal, int length, float cutoff, float resonance, float* out) {
- float c = 1.0f / tanf(M_PI * cutoff); // calculate filter constant
- float a1 = 1.0f / (1.0f + resonance * c + c * c); // calculate filter coefficients
- float a2 = 2.0f * a1;
- float a3 = a1;
- float b1 = 2.0f * (1.0f - c * c) * a1;
- float b2 = (1.0f - resonance * c + c * c) * a1;
- float prev_input = 0.0f, prev_output = 0.0f; // initialize previous input and output to zero
- for (int i = 0; i < length; i++) {
- float input = signal[i];
- float output = a1 * input + a2 * prev_input + a3 * prev_output - (i >= 1 ? b1 * out[i-1] : 0.0f) - (i >= 2 ? b2 * out[i-2] : 0.0f);
- out[i] = output;
- prev_input = input;
- prev_output = output;
- }
+float
+clamp(float f)
+{
+ if (f <= -1) return -0.9999;
+ if (f >= 1) return 0.9999;
}
-
float
make_sample(unsigned long long phase, void *synthData, unsigned int sample_rate, int viz)
{
synth_t *synth = (synth_t*)synthData;
float sample = 0;
-
+ //LFO!
+ //if (synth->adsr.elapsed > SAMPLE_RATE / 2) synth->adsr.elapsed = 0;
+
int n = 1;
- if (1 /* !synth->filter */) {
- for (int i = 0; i < n; i++) {
- sample += (1.0 / n) * synth->gen[synth->geni](synth->n.freq + synth->freq_offset, phase, synth->x, sample_rate);
- }
-
- if (!viz && synth->filter) {
- // ALLL THE FILTERS
- LowPass_Update(synth->resonance, (adsr_amplitude(synth, synth->adsr.elapsed) + 0.1) * synth->cutoff + 1, sample_rate);
- sample = LowPass_Filter(sample);
+ for (int i = 0; i < n; i++) {
+ sample += (1.0 / n) * synth->gen[synth->geni](synth->n.freq + synth->freq_offset, phase, synth->x, sample_rate);
+ }
- update_bw_low_pass_filter(synth->fff, SAMPLE_RATE, (adsr_amplitude(synth, synth->adsr.elapsed) + 0.1) * synth->cutoff, synth->resonance);
- sample = bw_low_pass(synth->fff, sample);
- }
+ if (!viz && synth->filter) {
+ // ALLL THE FILTERS
+ LowPass_Update(synth->resonance, (adsr_amplitude(synth, synth->adsr.elapsed) + 0.1) * round(synth->cutoff) + 1, sample_rate);
+ sample = LowPass_Filter(sample);
- sample = synth->gain * adsr_amplitude(synth, synth->adsr.elapsed) *
- sample; //synth->gen[synth->geni](synth->n.freq + synth->freq_offset, phase, synth->x);
-
- if (synth->clamp && sample >= 1) sample = 0.99;
- if (synth->clamp && sample <= -1) sample = -0.99;
- } else {
- // get sample array s[]
- int samples = 30;
- float s[samples];
-
- if (synth->adsr.elapsed < samples) {
- for (int i = 0; i < samples; i++) {
- s[i] = synth->gain * adsr_amplitude(synth, i) * synth->gen[synth->geni](synth->n.freq + synth->freq_offset, i, synth->x, sample_rate);
- }
- } else {
- for (int i = 0; i < samples; i++) {
- s[i] = synth->gain * adsr_amplitude(synth, synth->adsr.elapsed - 50 + i) * synth->gen[synth->geni](synth->n.freq + synth->freq_offset, phase - 50 + i, synth->x, sample_rate);
- }
- }
+ update_bw_low_pass_filter(synth->fff, SAMPLE_RATE, (adsr_amplitude(synth, synth->adsr.elapsed) + 0.1) * synth->cutoff, synth->resonance);
+ sample = bw_low_pass(synth->fff, sample);
+ }
- // process s[]
+ sample = synth->gain * adsr_amplitude(synth, synth->adsr.elapsed) * sample;
+
+ // band stop for high freqs
+ if (!viz)
+ sample = bw_band_stop(synth->fff2, sample);
- // return s[50]
- }
+
+ if (synth->clamp) sample = clamp(sample);
return sample;
}
@@ -221,70 +192,30 @@ sound_gen(const void *inputBuffer, void *outputBuffer,
(void) statusFlags;
(void) inputBuffer;
- if (1) {
- float s;
- for( unsigned long i=0; i<framesPerBuffer; i++ ) {
- //get_portaudio_frame(outputBuffer, synth);
- s = make_sample(synth->n.elapsed, synth, SAMPLE_RATE, 0);
- *out++ = s;
- *out++ = s;
- synth->adsr.elapsed++;
- synth->n.elapsed++;
- if (!synth->multi) {
- if (synth->n.elapsed >= (1.0 / synth->n.freq) * SAMPLE_RATE) synth->n.elapsed = 0;
- } else {
-
- }
- }
- } else {
- float s[FRAMES_PER_BUFFER * 5];
-
- if (synth->adsr.elapsed < framesPerBuffer * 5) {
- for (unsigned long long i = 0; i < framesPerBuffer * 5; i++) {
- s[i] = make_sample(i, synth, SAMPLE_RATE, 0);
- synth->adsr.elapsed++;
- synth->n.elapsed++;
- if (!synth->multi) {
- if (synth->n.elapsed >= (1.0 / synth->n.freq) * SAMPLE_RATE) synth->n.elapsed = 0;
- } else {
- }
- }
- } else {
- for (unsigned long long i = 0; i < framesPerBuffer * 5; i++) {
- s[i] = make_sample(synth->n.elapsed - framesPerBuffer * 2 + i, synth, SAMPLE_RATE, 0);
- synth->adsr.elapsed++;
- synth->n.elapsed++;
- if (!synth->multi) {
- if (synth->n.elapsed >= (1.0 / synth->n.freq) * SAMPLE_RATE) synth->n.elapsed = 0;
- } else {
- }
- }
+ float s;
+ for( unsigned long i=0; i<framesPerBuffer; i++ ) {
+ //get_portaudio_frame(outputBuffer, synth);
+ if (!synth->active) {
+ *out++ = 0.0f;
+ *out++ = 0.0f;
+ continue;
}
-
- // filter
-
- // output
-
- if (synth->adsr.elapsed < framesPerBuffer * 5) {
- for( unsigned long i=0; i<framesPerBuffer; i++ ) {
- *out++ = s[i];
- *out++ = s[i];
- }
- } else {
- for( unsigned long i=0; i<framesPerBuffer; i++ ) {
- *out++ = s[i + (2 * framesPerBuffer)];
- *out++ = s[i + (2 * framesPerBuffer)];
- }
+ if (adsr_amplitude(synth, synth->adsr.elapsed) == 0 && synth->n.noteOff != 0) {
+ printf("SYNTH OPFF\n");
+ synth->active = 0;
+ *out++ = 0.0f;
+ *out++ = 0.0f;
+ continue;
}
- synth->adsr.elapsed-= 4*framesPerBuffer;
-
+ s = make_sample(synth->n.elapsed, synth, SAMPLE_RATE, 0);
+ *out++ = s;
+ *out++ = s;
+ synth->adsr.elapsed++;
+ synth->n.elapsed++;
if (!synth->multi) {
- for (int i = 0; i < framesPerBuffer * 4; i++) {
- synth->n.elapsed--;
- if (synth->n.elapsed == 0) synth->n.elapsed = (int)(SAMPLE_RATE / synth->n.freq);
- }
+ if (synth->n.elapsed >= (1.0 / synth->n.freq) * SAMPLE_RATE) synth->n.elapsed = 0;
} else {
- synth->n.elapsed-= 4*framesPerBuffer;
+
}
}
@@ -305,7 +236,7 @@ init_synth(synth_t * synth)
synth->n.elapsed = 0;
- synth->adsr.a = 0.001;
+ synth->adsr.a = 0.0;
synth->adsr.d = 0.3;
synth->adsr.s = 0.7;
synth->adsr.r = 0.4;
@@ -317,7 +248,7 @@ init_synth(synth_t * synth)
synth->filter = 0;
synth->cutoff = 22000.0f;
synth->resonance = 1.0f;
- synth->clamp = 0;
+ synth->clamp = 1;
synth->gen[0] = gen0;
synth->gen[1] = gen1;
@@ -325,8 +256,11 @@ init_synth(synth_t * synth)
synth->gen[3] = gen3;
synth->geni = 0;
+ synth->active = 0;
+
synth->viz.sample_rate_divider = 1;
LowPass_Init();
synth->fff = create_bw_low_pass_filter(2, SAMPLE_RATE, 400);
+ synth->fff2 = create_bw_band_stop_filter(8, SAMPLE_RATE, 15000, 22000);
}
diff --git a/src/synth_engine.h b/src/synth_engine.h
index e35e8fb..674a11e 100644
--- a/src/synth_engine.h
+++ b/src/synth_engine.h
@@ -53,15 +53,19 @@ typedef struct {
int multi;
int filter;
- float cutoff;
- float resonance;
int clamp;
float (*gen[4]) (float freq, unsigned long long phase, float x, unsigned int sample_rate);
int geni;
+ float cutoff;
+ float resonance;
+
BWLowPass* fff;
+ BWBandStop* fff2;
+ int active;
+
viz_t viz;
} synth_t;
diff --git a/src/synth_gui.c b/src/synth_gui.c
index 3cfde6f..f92c853 100644
--- a/src/synth_gui.c
+++ b/src/synth_gui.c
@@ -15,6 +15,7 @@ set_note(void *synthData, float note, PaTime time, int key)
synth->n.noteOff = 0;
synth->n.elapsed = 0;
synth->adsr.elapsed = 0;
+ synth->active = 1;
}
@@ -53,7 +54,7 @@ draw_adsr_sliders(synth_t * synth, int x, int y, int width, int height, int offs
int count = 0;
snprintf(buf, sizeof buf, "%.3f", synth->adsr.a);
- synth->adsr.a = GuiSliderBar((Rectangle){ x, y + count++ * (height + offset), width, height }, "A: ", buf, synth->adsr.a , 0.001f, 2.0f);
+ synth->adsr.a = GuiSliderBar((Rectangle){ x, y + count++ * (height + offset), width, height }, "A: ", buf, synth->adsr.a , 0.0f, 2.0f);
snprintf(buf, sizeof buf, "%.3f", synth->adsr.d);
synth->adsr.d = GuiSliderBar((Rectangle){ x, y + count++ * (height + offset), width, height }, "D: ", buf, synth->adsr.d , 0.001f, 2.0f);
snprintf(buf, sizeof buf, "%.3f", synth->adsr.s);
@@ -82,7 +83,6 @@ draw_signals(synth_t * synth, int x, int y, int width, int height)
}
} else {
for (int i = x; i < WIDTH - x; i++) {
- //DrawCircle((WIDTH - (1 / (synth->n.freq + 1)) * SAMPLE_RATE) / 2 + i , (HEIGHT / 2) + floor(50 * make_sample(i % period, synth, SAMPLE_RATE)), point_radius, RED);
DrawCircle(i , y + height / 2 + floor(50 * make_sample((i - x) % period, synth, SAMPLE_RATE / synth->viz.sample_rate_divider, 1)), point_radius, RED);
}
}
@@ -129,19 +129,19 @@ rayrun(void *synthData, PaStream *stream)
synth->freq_offset = 0;
}
snprintf(buf, sizeof buf, "%.1f", synth->freq_offset);
- synth->freq_offset = GuiSliderBar((Rectangle){ WIDTH / 2 - 108, 150 - 42, 216, 24 }, "fine", buf, synth->freq_offset , -20.0f, 20.0f);
+ synth->freq_offset = GuiSlider((Rectangle){ WIDTH / 2 - 108, 150 - 42, 216, 24 }, "fine", buf, synth->freq_offset , -20.0f, 20.0f);
if ( GuiButton((Rectangle){ WIDTH / 2 - 108, 150 - 6 - 6, 216, 6 }, "")) {
synth->gain = 1;
}
snprintf(buf, sizeof buf, "%.1f", synth->gain);
- synth->gain = GuiSliderBar((Rectangle){ WIDTH / 2 - 108, 150, 216, 24 }, "gain", buf, synth->gain , 0.0f, 2.0f);
+ synth->gain = GuiSlider((Rectangle){ WIDTH / 2 - 108, 150, 216, 24 }, "gain", buf, synth->gain , 0.0f, 2.0f);
if ( GuiButton((Rectangle){ WIDTH / 2 - 108, 150 - 6 - 6 + 42, 216, 6 }, "")) {
synth->x = 1;
}
snprintf(buf, sizeof buf, "%.1f", synth->x);
- synth->x = GuiSliderBar((Rectangle){ WIDTH / 2 - 108, 150 + 42, 216, 24 }, "x", buf, synth->x , 0.0f, 2.0f);
+ synth->x = GuiSlider((Rectangle){ WIDTH / 2 - 108, 150 + 42, 216, 24 }, "x", buf, synth->x , 0.0f, 2.0f);
synth->multi = GuiToggle((Rectangle){ WIDTH - 100 - 50 - 100 - 50 , 50, 100, 24 }, "!MULTI!", synth->multi);
synth->filter = GuiToggle((Rectangle){ WIDTH - 100 - 50 - 100 - 50 , 50 + 24 + 6, 100, 24 }, "FILTER", synth->filter);