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:06:58 +0100 |
commit | 216f7933c5b4b65f7f45d3c459ead10f160d124b (patch) | |
tree | 7d7e0c6a7af1723a4d536bd4d12c50572db77896 | |
parent | 8320af55e716f352f2720801fcd73913f2e7d19c (diff) |
envelope_update_frames can now be set via CLI and config file
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | synth/Makefile | 2 | ||||
-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 |
9 files changed, 33 insertions, 10 deletions
@@ -66,4 +66,4 @@ TODO für den synth TODO fürs CLI - x ... + x envelope_update_frames per CLI setzen diff --git a/synth/Makefile b/synth/Makefile index 7ddccd7..c1d6dab 100644 --- a/synth/Makefile +++ b/synth/Makefile @@ -1,5 +1,5 @@ CXX=g++ -CFLAGS=-Wall -pg +CFLAGS=-Wall -O2 CXXFLAGS=$(CFLAGS) LDFLAGS=-lm `pkg-config --cflags --libs jack` 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 d6af5f2..6a84353 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 ad921c2..ffc1de5 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 56c47b9..646e371 100644 --- a/synth/main.cpp +++ b/synth/main.cpp @@ -42,6 +42,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; @@ -63,9 +64,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; @@ -205,5 +207,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 8479153..b6bfa22 100644 --- a/synth/note.cpp +++ b/synth/note.cpp @@ -1,5 +1,3 @@ -#define ENV_NTH_FRAME 50 - #include <cmath> #include "note.h" @@ -42,7 +40,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]; @@ -79,7 +77,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; @@ -343,7 +341,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++) |