diff options
Diffstat (limited to 'synth/in_synth_cli.cpp')
-rw-r--r-- | synth/in_synth_cli.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/synth/in_synth_cli.cpp b/synth/in_synth_cli.cpp index dd9260f..ece806b 100644 --- a/synth/in_synth_cli.cpp +++ b/synth/in_synth_cli.cpp @@ -9,6 +9,7 @@ #include "communication.h" #include "globals.h" #include "load.h" +#include "lfos.h" using namespace std; @@ -64,6 +65,18 @@ void lock_and_load_program(int prg_no, string file) do_request(prg_no, false); } +void lock_and_change_lfo(int lfo_no, float freq) +{ + do_request(-1, true); + + uninit_lfo(lfo_no); + lfo_freq_hz[lfo_no]=freq; + init_lfo(lfo_no); + + do_request(-1, false); +} + + void do_in_synth_cli() { string input; @@ -470,6 +483,33 @@ void do_in_synth_cli() cout << "error: channel-number must be one of 0.."<<N_CHANNELS-1<<endl; } } + else if ((command=="change_lfo") || (command=="lfo") || (command=="set_lfo")) + { + string freqstr, lfostr; + lfostr=trim_spaces(str_before(params,' ',params)); + freqstr=trim_spaces(str_after(params,' ',"")); + + if ((!isnum(lfostr)) || (lfostr=="")) + cout << "error: expected lfo-number, found '"<<lfostr<<"'"<<endl; + else if (! (isfloat(freqstr)&&freqstr!="")) + cout << "error: expected frequency, found '"<<freqstr<<"'"<<endl; + else + { + num=atoi(lfostr.c_str()); + if ((num>=0) && (num<N_LFOS)) + { + float freq; + freq=atof(freqstr.c_str()); + + if (freq>0) + lock_and_change_lfo(num,freq); + else + cout << "error: frequency must be a positive number"<<endl; + } + else + cout << "error: lfo-number must be one of 0.."<<N_LFOS-1<<endl; + } + } else if (command!="") { cout << "error: unrecognized command '"<<command<<"'"<<endl; |