diff options
author | Florian Jung <flo@thinkpad.(none)> | 2011-01-09 13:06:58 +0100 |
---|---|---|
committer | Florian Jung <flo@thinkpad.(none)> | 2011-01-09 13:22:20 +0100 |
commit | 65fe359eb034d8e4a4a7f4d673af6f473ef27ff8 (patch) | |
tree | 97c71e37ff314cd1a244b85c914809ae544e2fd8 /synth | |
parent | 918f4c99f37b9ca2ae2bbd6c906b7e0f994af014 (diff) |
envelope_update_frames can now be set via CLI and config file
Diffstat (limited to 'synth')
-rw-r--r-- | synth/cli.cpp | 10 | ||||
-rw-r--r-- | synth/defines.h | 1 | ||||
-rw-r--r-- | synth/globals.cpp | 6 | ||||
-rw-r--r-- | synth/globals.h | 2 | ||||
-rw-r--r-- | synth/load.cpp | 7 | ||||
-rw-r--r-- | synth/main.cpp | 5 | ||||
-rw-r--r-- | synth/note.cpp | 8 |
7 files changed, 31 insertions, 8 deletions
diff --git a/synth/cli.cpp b/synth/cli.cpp index 376edc3..eb52c95 100644 --- a/synth/cli.cpp +++ b/synth/cli.cpp @@ -44,6 +44,8 @@ void parse_args(int argc, char** argv) {"max-portamento-time", required_argument, 0, 303}, {"filter-update-freq", required_argument, 0, 305}, {"lfo-update-freq", required_argument, 0, 306}, + {"env-update-freq", required_argument, 0, 307}, + {"envelope-update-freq", required_argument, 0, 307}, {"no-connect-audio-out", no_argument, 0, 'a'}, {"no-connect-audio", no_argument, 0, 'a'}, {"dont-connect-audio-out", no_argument, 0, 'a'}, @@ -164,6 +166,14 @@ void parse_args(int argc, char** argv) else output_warning("WARNING: not a number in --lfo-update-freq option. ignoring it..."); break; + case 307: if (isfloat(optarg)) + if (atoi(optarg)<=0) + output_warning("WARNING: envelope-update-freq must be positive. ignoring it..."); + else + envelope_update_freq_hz=atof(optarg); + else + output_warning("WARNING: not a number in --envelope-update-freq option. ignoring it..."); + break; default: cout << "ERROR: invalid command line options. try the --help switch" << endl; exit(1); diff --git a/synth/defines.h b/synth/defines.h index 4a2e929..34d745e 100644 --- a/synth/defines.h +++ b/synth/defines.h @@ -11,6 +11,7 @@ #define FILTER_UPDATE_FREQ_HZ 250 #define LFO_UPDATE_FREQ_HZ 500 +#define ENVELOPE_UPDATE_FREQ_HZ 50 //when changing this, also change code marked with FINDLFO! #define N_LFOS 3 diff --git a/synth/globals.cpp b/synth/globals.cpp index 5b256b3..e932fcb 100644 --- a/synth/globals.cpp +++ b/synth/globals.cpp @@ -23,11 +23,13 @@ float cleanup_interval_sec=0; float snh_freq_hz=0; float max_port_time_sec=0; -float filter_update_freq_hz; -float lfo_update_freq_hz; +float filter_update_freq_hz=0; +float lfo_update_freq_hz=0; +float envelope_update_freq_hz=0; int filter_update_frames; int lfo_update_frames; +int envelope_update_frames; float xrun_time=0; int xrun_n=0; diff --git a/synth/globals.h b/synth/globals.h index b7c9109..efbbe72 100644 --- a/synth/globals.h +++ b/synth/globals.h @@ -36,9 +36,11 @@ extern float max_port_time_sec; extern float filter_update_freq_hz; extern float lfo_update_freq_hz; +extern float envelope_update_freq_hz; extern int filter_update_frames; extern int lfo_update_frames; +extern int envelope_update_frames; extern float xrun_time; extern int xrun_n; diff --git a/synth/load.cpp b/synth/load.cpp index d88ec3e..9b80106 100644 --- a/synth/load.cpp +++ b/synth/load.cpp @@ -176,6 +176,13 @@ void read_config(const char *cfg, bool complain=true) else output_verbose("NOTE: ignoring value for filter_update_freq, another setting overrides this."); } + else if ((var=="envelope_update_freq") || (var=="env_update_freq")) + { + if (envelope_update_freq_hz==0) + envelope_update_freq_hz=valf; + else + output_verbose("NOTE: ignoring value for envelope_update_freq, another setting overrides this."); + } else output_warning("WARNING: unknown variable '"+var+"'. ignoring it..."); } diff --git a/synth/main.cpp b/synth/main.cpp index ae2e0d8..95444cb 100644 --- a/synth/main.cpp +++ b/synth/main.cpp @@ -41,6 +41,7 @@ int main(int argc, char** argv) if (max_port_time_sec<=0) max_port_time_sec=MAX_PORTAMENTO_TIME; if (filter_update_freq_hz<=0) filter_update_freq_hz=FILTER_UPDATE_FREQ_HZ; if (lfo_update_freq_hz<=0) lfo_update_freq_hz=LFO_UPDATE_FREQ_HZ; + if (envelope_update_freq_hz<=0) envelope_update_freq_hz=ENVELOPE_UPDATE_FREQ_HZ; if (xrun_n<=0) xrun_n=XRUN_N; if (xrun_time<=0) xrun_time=XRUN_TIME; @@ -62,9 +63,10 @@ int main(int argc, char** argv) filter_update_frames=samp_rate/filter_update_freq_hz; lfo_update_frames=samp_rate/lfo_update_freq_hz; + envelope_update_frames=samp_rate/envelope_update_freq_hz; if (filter_update_frames<1) filter_update_frames=1; if (lfo_update_frames<1) lfo_update_frames=1; - + if (envelope_update_frames<1) envelope_update_frames=1; int i,j; @@ -184,5 +186,6 @@ void dump_options() cout << "xrun n/time:\t\t"<<xrun_n<<"/"<<xrun_time<<"s"<<endl; cout << "lfo update freq:\t"<<lfo_update_freq_hz<<endl; cout << "filter update freq:\t"<<filter_update_freq_hz<<endl; + cout << "envelope update freq:\t"<<envelope_update_freq_hz<<endl; } diff --git a/synth/note.cpp b/synth/note.cpp index b8028bc..a9a5a42 100644 --- a/synth/note.cpp +++ b/synth/note.cpp @@ -1,5 +1,3 @@ -#define ENV_NTH_FRAME 50 - #include <string> #include <cmath> @@ -39,7 +37,7 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr envelope=new Envelope*[n_oscillators]; for (int i=0;i<n_oscillators;i++) - envelope[i]=new Envelope(prg.env_settings[i], ENV_NTH_FRAME); + envelope[i]=new Envelope(prg.env_settings[i], envelope_update_frames); oscillator=new oscillator_t[n_oscillators]; orig.oscillator=new oscillator_t[n_oscillators]; @@ -85,7 +83,7 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr filter_update_counter=filter_update_frames; } - env_frame_counter=ENV_NTH_FRAME; //force update in first frame + env_frame_counter=envelope_update_frames; //force update in first frame sync_factor=prg.sync_factor; @@ -385,7 +383,7 @@ fixed_t Note::get_sample() env_frame_counter++; - if (env_frame_counter>=ENV_NTH_FRAME) + if (env_frame_counter>=envelope_update_frames) { env_frame_counter=0; for (i=0;i<n_oscillators;i++) |