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 --- synth/defines.h | 29 +++++++++++++++++++++- synth/main.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++--------- synth/waveforms.txt | 67 +++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 139 insertions(+), 28 deletions(-) (limited to 'synth') 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