From 65fe359eb034d8e4a4a7f4d673af6f473ef27ff8 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 9 Jan 2011 13:06:58 +0100 Subject: envelope_update_frames can now be set via CLI and config file --- TODO | 2 +- synth/cli.cpp | 10 ++++++++++ synth/defines.h | 1 + synth/globals.cpp | 6 ++++-- synth/globals.h | 2 ++ synth/load.cpp | 7 +++++++ synth/main.cpp | 5 ++++- synth/note.cpp | 8 +++----- 8 files changed, 32 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index 1dfd844..c77e94a 100644 --- a/TODO +++ b/TODO @@ -54,4 +54,4 @@ TODO für den synth TODO fürs CLI - x ... + x envelope_update_frames per CLI setzen 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"< #include @@ -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=ENV_NTH_FRAME) + if (env_frame_counter>=envelope_update_frames) { env_frame_counter=0; for (i=0;i