From d4e928c4eecdcb12ebc96054c92cfc7b701c9a83 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sat, 12 Feb 2011 16:02:01 +0100 Subject: Sawtooth and pulse-waves have now variable phases for sawtooth, the ratio rising:falling phase is adjustable for pulse, the ratio high:low is adjustable --- TODO | 4 --- TODO.done | 4 +++ synth/defines.h | 29 +++++++++++++++++++++- synth/main.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++--------- synth/waveforms.txt | 67 +++++++++++++++++++++++++++++++++++++++----------- 5 files changed, 143 insertions(+), 32 deletions(-) diff --git a/TODO b/TODO index cb13c19..d81ad27 100644 --- a/TODO +++ b/TODO @@ -5,10 +5,6 @@ wenn man danach die noten spielen will. nicht reproduzierbar TODO für den synth - o square- und sawtooth mit einstellbarer pulsweite - -> invers-saw (0,1) = saw(1,0) - -> dreieck = saw(0.5,0.5) - o invertierter pulse-sin o file-watcher ist unsauber: inotify_map_mutex und prog_load_mutex werden eigentlich zu spät erstellt; bei EXTREM schnellen events könnte ein noch nicht existenter mutex gelockt werden diff --git a/TODO.done b/TODO.done index 56f7ed0..edd8294 100644 --- a/TODO.done +++ b/TODO.done @@ -82,6 +82,10 @@ TODO für den synth (o)bei filter-envelopes: ksr/ksl? nää. (o)resonanz-tremolo bei tiefpass? nää. * RAM aufräumen? [keine leaks, und linux macht das schon] + x square- und sawtooth mit einstellbarer pulsweite + -> invers-saw (0,1) = saw(1,0) + -> dreieck = saw(0.5,0.5) + x invertierter pulse-sin TODO fürs CLI diff --git a/synth/defines.h b/synth/defines.h index fb1d63b..1ec5b18 100644 --- a/synth/defines.h +++ b/synth/defines.h @@ -56,7 +56,34 @@ extern float LFO_FREQ_HZ[]; #define WAVE_RES 44100 -#define N_WAVEFORMS 8 + + +// saw_start must be >= n_normal +// pulse_start must be > saw_end +// holes are allowed + +// 0..6 different stuff +// 10..19 saw +// 20..29 square is allowed, for example + +//SAW_N and PULSE_N should be odd numbers, otherwise you won't +//get equal ratios for falling/rising or high/low +//in english: you won't get a "normal" triangle wave or a "normal" +// square wave then +#define N_NORMAL_WAVEFORMS 6 +#define WAVE_SAW_START 100 +#define WAVE_SAW_N 201 +#define WAVE_PULSE_START 400 +#define WAVE_PULSE_N 201 + +#if ( (WAVE_SAW_START < N_NORMAL_WAVEFORMS) || \ + (WAVE_PULSE_START < WAVE_SAW_START+WAVE_SAW_N) ) + #error NORMAL WAVEFORMS, SAW- AND PULSE-WAVES MAY NOT OVERLAP! +#endif + +#define N_WAVEFORMS (WAVE_PULSE_START+WAVE_PULSE_N) + + #define NO_CONT 128 diff --git a/synth/main.cpp b/synth/main.cpp index 32b2b84..f9f1e57 100644 --- a/synth/main.cpp +++ b/synth/main.cpp @@ -96,22 +96,69 @@ int main(int argc, char** argv) load_program(programfile[i],program_settings[i]); } + fixed_t* temp=new fixed_t[WAVE_RES]; + for (i=0;i