summaryrefslogtreecommitdiff
path: root/synth/in_synth_cli.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2011-01-14 13:38:54 +0100
committerFlorian Jung <flo@thinkpad.(none)>2011-01-14 13:38:54 +0100
commitb2d0c97e0ca7b7eb0a7195ddbf263b9953171e66 (patch)
tree00ecb19be6f349196b8c14085ff3325b074677c2 /synth/in_synth_cli.cpp
parenta43a4e27a2ba3c34bac5a215ce49175b22913bd4 (diff)
Moved lfos and sample-and-hold in own source file
Diffstat (limited to 'synth/in_synth_cli.cpp')
-rw-r--r--synth/in_synth_cli.cpp40
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;