summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO33
-rw-r--r--TODO.done6
-rw-r--r--synth/Makefile2
-rw-r--r--synth/OPTIMIZATIONS6
-rw-r--r--synth/channel.cpp34
-rw-r--r--synth/defines.h2
-rw-r--r--synth/envelope.cpp2
-rw-r--r--synth/in_synth_cli.cpp10
-rw-r--r--synth/jack.cpp52
-rw-r--r--synth/lfos.cpp14
-rw-r--r--synth/main.cpp42
-rw-r--r--synth/note.cpp44
-rw-r--r--synth/parser.cpp32
-rw-r--r--synth/programs.cpp8
-rw-r--r--synth/readwave.cpp2
-rw-r--r--synth/shared_object_manager.cpp6
-rw-r--r--synth/util.cpp8
17 files changed, 159 insertions, 144 deletions
diff --git a/TODO b/TODO
index d6704c7..6de4cb8 100644
--- a/TODO
+++ b/TODO
@@ -2,25 +2,12 @@
wenn man danach die noten spielen will. nicht reproduzierbar
TODO für den synth
-!! o im in-synth-cli auch die snh-freq setzen!!!
-
- o freq-envelopes und pfactor dafür auch für compiled_notes implementieren!
- o envelopes nur alle N frames updaten auch bei compiled notes implementieren!
-
- o optimierung: foo++ durch ++foo ersetzen
- o optimierung: bei allen iterationen: foo.end() cachen!
-
- o zu testen: funktionieren no-release-envs auch in compilierten noten?
+ o frameskip vlt nicht ++en?
+ o seltener cleanup rufen, stattdessen als inaktiv markieren
+ -> effekt: noten können wiederverwendet werden, seltenere ctor-aufrufe
o RAM aufräumen?
- o beide parser: envelopes von oscs mit out=0 standardmäßig deaktivieren
- o envelope, filter, ggf. auch alles aus program.o im hauptprogramm
- lassen? d.h. via init funktionspointer übergeben oder virtuelle
- interfaceklassen benutzen (für envelope/filter z.B.)
-
- (o)bei program change vielleicht nicht _ALLE_ controller resetten?
-
o KSL mit powf und floats statt mit double umschreiben
o statt lfo-nummer direkten zugriff auf curr_lfo angeben?
o bei tremolo (und vibrato?): eventuell nicht prüfen, obs aktiviert
@@ -29,7 +16,6 @@ TODO für den synth
o jedes programm eigene LFOs?
o andere wellenformen bei LFOs?
- o mehr wellen für wave[]
o parser: sehr redundante funktionen zusammenführen
o parser: direkt in result schreiben?
@@ -46,11 +32,24 @@ TODO für den synth
per RPN, NRPN
o nur auf bestimmte channels reagieren
+ (o)bei program change vielleicht nicht _ALLE_ controller resetten?
+
(o)fehlerklassen für fatale fehler (von string abgeleitet)
(o)bei filter-envelopes: ksr/ksl? nää.
(o)resonanz-tremolo bei tiefpass? nää.
+TODO für den compiler
+ o freq-envelopes und pfactor dafür auch für compiled_notes implementieren!
+ o envelopes nur alle N frames updaten auch bei compiled notes implementieren!
+ o zu testen: funktionieren no-release-envs auch in compilierten noten?
+ o envelopes von oscs mit out=0 standardmäßig deaktivieren
+ o envelope, filter, ggf. auch alles aus program.o im hauptprogramm
+ lassen? d.h. via init funktionspointer übergeben oder virtuelle
+ interfaceklassen benutzen (für envelope/filter z.B.)
+
+
+
TODO fürs CLI
x ...
diff --git a/TODO.done b/TODO.done
index a83b6ed..26e7e06 100644
--- a/TODO.done
+++ b/TODO.done
@@ -69,7 +69,11 @@ TODO für den synth
x im cli dürfen warnungen nicht mehr fatal sein
x on-the-fly die LFOs ändern
x funktioniert Channel::release_all bei gedrücktem HOLD oder SOSTENUTO? [ja]
- x freq-envelopes:
+ x freq-envelopes
+ x im in-synth-cli auch die snh-freq setzen!!!
+ x optimierung: foo++ durch ++foo ersetzen
+ x optimierung: den relevanten iterationen: foo.end() cachen!
+ x mehr wellen für wave[]
TODO fürs CLI
diff --git a/synth/Makefile b/synth/Makefile
index 0db09da..6258697 100644
--- a/synth/Makefile
+++ b/synth/Makefile
@@ -1,5 +1,5 @@
CXX=g++
-CFLAGS=-Wall -g
+CFLAGS=-Wall -O2
CXXFLAGS=$(CFLAGS)
LDFLAGS=-lm `pkg-config --cflags --libs jack`
diff --git a/synth/OPTIMIZATIONS b/synth/OPTIMIZATIONS
index b8bfe0d..07cbcff 100644
--- a/synth/OPTIMIZATIONS
+++ b/synth/OPTIMIZATIONS
@@ -8,6 +8,12 @@ Mögliche Optimierungen
und filter-offset aus orig berechnen
o 2% beim filter: evtl nur mit floats statt mit doubles rechnen?
o <2% in note::get_sample u.a.: pitch-bending effizienter lösen?
+ o ??? Note's ctor kopiert viel unnötiges. besser:
+ channels bekommen je. eine kopie aller programme
+ noten bekommen nur noch pointer auf channeleigene kopie
+ note->set_param wird unnötig
+ pfactor-zeuch läuft extra: wird kopiert, und bei jeder
+ pfactor-änderung mit dem pfactor verrechnet
x 0% beim channel::get_sample: pro note immer mehrere samples auf
einmal holen (iterator braucht recht viel leistung)
wird von g++ automatisch wegoptimiert -> ok
diff --git a/synth/channel.cpp b/synth/channel.cpp
index c2d0793..465facb 100644
--- a/synth/channel.cpp
+++ b/synth/channel.cpp
@@ -46,14 +46,14 @@ void Channel::cleanup()
it=notes.erase(it);
}
else
- it++;
+ ++it;
}
fixed_t Channel::get_sample()
{
fixed_t sum=0;
- for (list<NoteSkel*>::iterator it=notes.begin(); it!=notes.end(); it++)
+ for (list<NoteSkel*>::iterator it=notes.begin(), end=notes.end(); it!=end; ++it)
sum+=(*it)->get_sample();
return sum*volume >>SCALE;
@@ -90,7 +90,7 @@ void Channel::note_off(int note)
void Channel::really_do_note_off(int note)
{
- for (list<NoteSkel*>::iterator it=notes.begin(); it!=notes.end(); it++)
+ for (list<NoteSkel*>::iterator it=notes.begin(); it!=notes.end(); ++it)
if ((*it)->get_note()==note)
(*it)->release();
}
@@ -147,7 +147,7 @@ void Channel::note_on(int note, int vel)
{
bool neednewnote=true;
//if (always_reattack) always_reattack is always true when in polymode
- for (it=notes.begin(); it!=notes.end(); it++)
+ for (it=notes.begin(); it!=notes.end(); ++it)
if ( ((*it)->get_note()==note) && ((*it)->get_program()==program) )
{
neednewnote=false;
@@ -210,13 +210,13 @@ void Channel::apply_voice_limit()
list<NoteSkel*>::iterator it=notes.begin();
if (quick_release)
- for (int i=0;i<diff;i++)
+ for (int i=0;i<diff;++i)
{
(*it)->release_quickly(quick_release);
- it++;
+ ++it;
}
else
- for (int i=0;i<diff;i++)
+ for (int i=0;i<diff;++i)
{
(*it)->destroy();
it=notes.erase(it);
@@ -251,7 +251,7 @@ void Channel::set_controller(int con,int val)
void Channel::set_user_controller(int con, int val)
{
curr_prg.controller[con]=val;
- for (set<parameter_t>::iterator it=curr_prg.controller_affects[con].begin(); it!=curr_prg.controller_affects[con].end(); it++)
+ for (set<parameter_t>::iterator it=curr_prg.controller_affects[con].begin(); it!=curr_prg.controller_affects[con].end(); ++it)
recalc_param(*it,curr_prg);
}
@@ -262,7 +262,7 @@ void Channel::recalc_param(const parameter_t &par, program_t &prg)
list<term_t> *l;
l=&(prg.formula[par]);
- for (list<term_t>::iterator it=l->begin(); it!=l->end(); it++)
+ for (list<term_t>::iterator it=l->begin(); it!=l->end(); ++it)
val+=curr_prg.controller[it->c]*it->f;
if (val<0) val=0;
@@ -296,7 +296,7 @@ void Channel::recalc_param(const parameter_t &par, program_t &prg)
// waveform etc it's in int (i.e., val/ONE is very small, while
// val is what we want)
- for (list<NoteSkel*>::iterator it=notes.begin(); it!=notes.end(); it++)
+ for (list<NoteSkel*>::iterator it=notes.begin(); it!=notes.end(); ++it)
(*it)->set_param(par, val);
curr_prg.set_param(par, val);
@@ -306,7 +306,7 @@ void Channel::reset_controllers()
{
program_t *orig=&program_settings[program];
- for (int i=0;i<128;i++)
+ for (int i=0;i<128;++i)
set_user_controller(i,orig->controller[i]);
}
@@ -363,7 +363,7 @@ void Channel::set_real_portamento_frames()
portamento_frames=0;
list<NoteSkel*>::iterator it;
- for (it=notes.begin(); it!=notes.end(); it++)
+ for (it=notes.begin(); it!=notes.end(); ++it)
(*it)->set_portamento_frames(portamento_frames);
}
@@ -378,7 +378,7 @@ void Channel::set_hold_pedal(bool newstate)
//check for all held keys: is the key not pressed any more?
// is the key not in sostenuto_keys?
//if both conditions are fulfilled, release that note
- for (set<int>::iterator it=held_keys.begin(); it!=held_keys.end(); it++)
+ for (set<int>::iterator it=held_keys.begin(); it!=held_keys.end(); ++it)
if ( (pressed_keys.find(*it)==pressed_keys.end()) &&
(sostenuto_keys.find(*it)==sostenuto_keys.end()) )
note_off(*it);
@@ -400,7 +400,7 @@ void Channel::set_sostenuto_pedal(bool newstate)
else
{
if (hold_pedal_pressed==false)
- for (set<int>::iterator it=sostenuto_keys.begin(); it!=sostenuto_keys.end(); it++)
+ for (set<int>::iterator it=sostenuto_keys.begin(); it!=sostenuto_keys.end(); ++it)
if (pressed_keys.find(*it)==pressed_keys.end())
really_do_note_off(*it);
@@ -439,7 +439,7 @@ void Channel::kill_program(int prog)
it=notes.erase(it);
}
else
- it++;
+ ++it;
}
void Channel::maybe_reload_program(int prog)
@@ -451,7 +451,7 @@ void Channel::maybe_reload_program(int prog)
void Channel::release_all()
{
list<NoteSkel*>::iterator it;
- for (it=notes.begin(); it!=notes.end(); it++)
+ for (it=notes.begin(); it!=notes.end(); ++it)
(*it)->release();
}
@@ -466,6 +466,6 @@ void Channel::set_pitch_bend(float val)
pitchbend=pow(2.0,val/12.0)*ONE;
list<NoteSkel*>::iterator it;
- for (it=notes.begin(); it!=notes.end(); it++)
+ for (it=notes.begin(); it!=notes.end(); ++it)
(*it)->set_pitchbend(pitchbend);
}
diff --git a/synth/defines.h b/synth/defines.h
index 34d745e..1421c30 100644
--- a/synth/defines.h
+++ b/synth/defines.h
@@ -56,7 +56,7 @@ extern float LFO_FREQ_HZ[];
#define WAVE_RES 44100
-#define N_WAVEFORMS 5
+#define N_WAVEFORMS 8
#define NO_CONT 128
diff --git a/synth/envelope.cpp b/synth/envelope.cpp
index a6e79e0..13b1044 100644
--- a/synth/envelope.cpp
+++ b/synth/envelope.cpp
@@ -160,6 +160,6 @@ fixed_t Envelope::get_level() //must be called each frame
break;
}
- t++;
+ ++t;
return level;
}
diff --git a/synth/in_synth_cli.cpp b/synth/in_synth_cli.cpp
index 7bf1fda..fd1570d 100644
--- a/synth/in_synth_cli.cpp
+++ b/synth/in_synth_cli.cpp
@@ -59,7 +59,7 @@ void lock_and_load_program(int prg_no, string file)
else
cout << "failed" << endl;
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]->maybe_reload_program(prg_no);
do_request(prg_no, false);
@@ -139,7 +139,7 @@ void do_in_synth_cli()
else if (command=="panic")
{
if ((params=="") || (params=="all"))
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]->panic();
else if (isnum(params))
{
@@ -153,7 +153,7 @@ void do_in_synth_cli()
else if (command=="release")
{
if ((params=="") || (params=="all"))
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]->release_all();
else if (isnum(params))
{
@@ -180,7 +180,7 @@ void do_in_synth_cli()
if ((num>=0) && (num<128))
{
if (chanstr=="")
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]->kill_program(num);
else
{
@@ -228,7 +228,7 @@ void do_in_synth_cli()
else if (command=="reset")
{
if ((params=="") || (params=="all"))
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]->reset_controllers();
else if (isnum(params))
{
diff --git a/synth/jack.cpp b/synth/jack.cpp
index d0a6169..79c7b4a 100644
--- a/synth/jack.cpp
+++ b/synth/jack.cpp
@@ -30,14 +30,14 @@ void manage_program_lock(int prog, bool lock) //TODO woandershinschieben?
program_lock[prog]=lock;
if (lock)
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]->kill_program(prog);
}
void process_request()
{
if (suspend_request.prog==-1)
- for (int i=0;i<128;i++)
+ for (int i=0;i<128;++i)
manage_program_lock(i,suspend_request.suspend);
else
manage_program_lock(suspend_request.prog,suspend_request.suspend);
@@ -69,7 +69,7 @@ void init_jack()
if (midi_in == NULL)
throw string ("Registering MIDI IN failed");
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
{
#ifndef STEREO
out_port[i]=jack_port_register(jack_client, (OUT_NAME+IntToStr(i)).c_str(),
@@ -114,19 +114,19 @@ void start_jack(bool connect_audio_out, bool connect_midi_in)
int i=0;
while(ports[i]!=NULL)
{
- for (int j=0;j<N_CHANNELS;j++)
+ for (int j=0;j<N_CHANNELS;++j)
if (jack_connect (jack_client, jack_port_name (out_port[j]), ports[i]))
output_warning("WARNING: could not connect some output port. this may or may not result\n"
" in being unable to produce sound. you can still connect them\n"
" manually. proceeding...");
- i++;
+ ++i;
}
#else
if (ports[1]==NULL)
{
output_note("NOTE: could not find two output ports. connecting to one, making everything\n"
" mono. this is not fatal, proceeding...");
- for (int j=0;j<N_CHANNELS;j++)
+ for (int j=0;j<N_CHANNELS;++j)
{
if (jack_connect (jack_client, jack_port_name (out_port[j]), ports[0]))
output_warning("WARNING: could not connect some output port. this may or may not result\n"
@@ -141,7 +141,7 @@ void start_jack(bool connect_audio_out, bool connect_midi_in)
}
else
{
- for (int j=0;j<N_CHANNELS;j++)
+ for (int j=0;j<N_CHANNELS;++j)
{
if (jack_connect (jack_client, jack_port_name (out_port[j]), ports[0]))
output_warning("WARNING: could not connect some output port. this may or may not result\n"
@@ -178,7 +178,7 @@ void start_jack(bool connect_audio_out, bool connect_midi_in)
output_warning("WARNING: could not connect some MIDI OUT to my MIDI IN. this may or may not\n"
" result in being unable to receive any notes. you can still connect\n"
" the port manually. proceeding...");
- i++;
+ ++i;
}
free(ports);
}
@@ -218,7 +218,7 @@ int xrun_callback(void *notused)
if (history.size() >= xrun_n)
{
cout << "PANIC -- TOO MANY XRUNs! killing all voices" << endl<<endl;
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]->panic();
history.clear();
@@ -264,7 +264,7 @@ int process_callback(jack_nframes_t nframes, void *notused)
- for (i=0;i<N_CHANNELS;i++)
+ for (i=0;i<N_CHANNELS;++i)
{
outbuf[i]=(jack_default_audio_sample_t*) jack_port_get_buffer(out_port[i], nframes);
#ifdef STEREO
@@ -294,15 +294,15 @@ int process_callback(jack_nframes_t nframes, void *notused)
//as long as there are some events left and getting one fails, get the next
while ((n_events) && (jack_midi_event_get(&event, inport, curr_event /*, nframes */)))
{
- output_note("NOTE: lost a note :(");
- n_events--;
- curr_event++;
+ output_note("NOTE1: lost a note :(");
+ --n_events;
+ ++curr_event;
}
if (lastframe>=next_cleanup)
{
next_cleanup=lastframe+cleanup_interval;
- for (i=0;i<N_CHANNELS;i++)
+ for (i=0;i<N_CHANNELS;++i)
channel[i]->cleanup();
}
#ifdef DO_DEBUGGING_EVENTS
@@ -396,9 +396,9 @@ int process_callback(jack_nframes_t nframes, void *notused)
outtemp_nframes_left=0;
}
- for (i=0;i<real_nframes;i++)
+ for (i=0;i<real_nframes;++i)
{
- for (int j=0;j<N_CHANNELS;j++)
+ for (int j=0;j<N_CHANNELS;++j)
{
outbuf[j][i]=outtemp[j];
#ifdef STEREO
@@ -416,7 +416,7 @@ int process_callback(jack_nframes_t nframes, void *notused)
if (upperbound<0) upperbound=0;
for (i=i;i<upperbound;i+=frameskip)
#else
- for (i=0;i<nframes;i++)
+ for (i=0;i<nframes;++i)
#endif
{
while ((n_events) && (i>=event.time))
@@ -434,21 +434,21 @@ int process_callback(jack_nframes_t nframes, void *notused)
channel[chan]->event(event.buffer[0], event.buffer[1], event.buffer[2]);
}
- n_events--;
- curr_event++;
+ --n_events;
+ ++curr_event;
//as long as there are some events left and getting one fails, get the next
while ((n_events) && (jack_midi_event_get(&event, inport, curr_event /*, nframes */)))
{
- output_note("NOTE: lost a note :(");
- n_events--;
- curr_event++;
+ output_note("NOTE2: lost a note :(");
+ --n_events;
+ ++curr_event;
}
}
maybe_calc_lfos();
- for (int j=0;j<N_CHANNELS;j++)
+ for (int j=0;j<N_CHANNELS;++j)
{
#ifndef STEREO
outbuf[j][i]=jack_default_audio_sample_t(channel[j]->get_sample())/ONE*VOL_FACTOR;
@@ -473,7 +473,7 @@ int process_callback(jack_nframes_t nframes, void *notused)
#ifdef FRAMESKIP
if (i!=nframes) // nicht aufgegangen?
{
- for (int j=0;j<N_CHANNELS;j++)
+ for (int j=0;j<N_CHANNELS;++j)
{ // (1)
#ifndef STEREO
outtemp[j]=jack_default_audio_sample_t(channel[j]->get_sample())/ONE*VOL_FACTOR;
@@ -486,9 +486,9 @@ int process_callback(jack_nframes_t nframes, void *notused)
outtemp_nframes_left=frameskip-nframes+i;
- for (i=i; i<nframes; i++)
+ for (i=i; i<nframes; ++i)
{
- for (int j=0;j<N_CHANNELS;j++)
+ for (int j=0;j<N_CHANNELS;++j)
{
outbuf[j][i]=outtemp[j];
#ifdef STEREO
diff --git a/synth/lfos.cpp b/synth/lfos.cpp
index 5916937..8234a7a 100644
--- a/synth/lfos.cpp
+++ b/synth/lfos.cpp
@@ -10,7 +10,7 @@ void uninit_lfo(int i)
{
if (lfo[i])
{
- for (int j=0;j<lfo_res[i];j++)
+ for (int j=0;j<lfo_res[i];++j)
delete [] lfo[i][j];
delete [] lfo[i];
@@ -26,11 +26,11 @@ void init_lfo(int i)
lfo_res[i]=samp_rate/lfo_freq_hz[i]/lfo_update_frames;
lfo[i]=new fixed_t* [lfo_res[i]];
- for (int j=0;j<lfo_res[i];j++)
+ for (int j=0;j<lfo_res[i];++j)
{
lfo[i][j]=new fixed_t [N_LFO_LEVELS];
float temp=sin(j*2.0*3.141592654/lfo_res[i]);
- for (int k=0;k<N_LFO_LEVELS;k++)
+ for (int k=0;k<N_LFO_LEVELS;++k)
lfo[i][j][k]= (1.0 + temp*(float(LFO_MAX)*k/N_LFO_LEVELS)) * ONE;
}
@@ -50,7 +50,7 @@ void maybe_calc_lfos()
{
lfocnt=lfo_update_frames;
- for (int i=0;i<N_LFOS;i++)
+ for (int i=0;i<N_LFOS;++i)
{
lfo_phase[i]=(lfo_phase[i]+1)%lfo_res[i];
curr_lfo[i]=lfo[i][lfo_phase[i]];
@@ -64,7 +64,7 @@ void maybe_calc_lfos()
//temp ranges between -ONE and ONE
fixed_t temp = (float(rand())/(RAND_MAX/2) - 1.0) * ONE;
- for (int i=0;i<N_LFO_LEVELS;i++)
+ for (int i=0;i<N_LFO_LEVELS;++i)
sample_and_hold[i]= temp*i/(N_LFO_LEVELS-1) + ONE;
curr_lfo[SNH_LFO]=sample_and_hold;
@@ -72,6 +72,6 @@ void maybe_calc_lfos()
// does not eat up the cpu too much ;)
}
- lfocnt--;
- snhcnt--;
+ --lfocnt;
+ --snhcnt;
}
diff --git a/synth/main.cpp b/synth/main.cpp
index f4dcd54..a9d7ef0 100644
--- a/synth/main.cpp
+++ b/synth/main.cpp
@@ -27,7 +27,7 @@ int main(int argc, char** argv)
{
init_communication();
- for (int i=0;i<N_LFOS;i++)
+ for (int i=0;i<N_LFOS;++i)
lfo_freq_hz[i]=0;
try
@@ -38,7 +38,7 @@ int main(int argc, char** argv)
add_dir("/etc/flosynth", false);
if (cleanup_interval_sec<=0) cleanup_interval_sec=CLEANUP_INTERVAL_SEC;
- for (int i=0;i<N_LFOS;i++)
+ for (int i=0;i<N_LFOS;++i)
if (lfo_freq_hz[i]<=0) lfo_freq_hz[i]=LFO_FREQ_HZ[i];
if (snh_freq_hz<=0) snh_freq_hz=SNH_FREQ_HZ;
@@ -52,8 +52,8 @@ int main(int argc, char** argv)
dump_options();
- frameskip++; //because a value of 0 means using each frame,
- //a value of 1 means using each 2nd frame and so on
+ frameskip+=1; //because a value of 0 means using each frame,
+ //a value of 1 means using each 2nd frame and so on
init_jack();
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
if (lfo_update_frames<1) lfo_update_frames=1;
if (envelope_update_frames<1) envelope_update_frames=1;
- int i,j;
+ int i;
init_default_program(default_program);
@@ -81,31 +81,37 @@ int main(int argc, char** argv)
init_snh();
- for (i=0;i<N_LFOS;i++)
+ for (i=0;i<N_LFOS;++i)
init_lfo(i);
program_settings=new program_t[128];
- for (i=0;i<128;i++)
+ for (i=0;i<128;++i)
{
program_lock[i]=false;
load_program(programfile[i],program_settings[i]);
}
- for (i=0;i<N_WAVEFORMS;i++)
+ for (i=0;i<N_WAVEFORMS;++i)
wave[i]=new fixed_t[WAVE_RES];
- for (i=0;i<WAVE_RES;i++)
+ for (i=0;i<WAVE_RES;++i)
{
- wave[0][i]=sin(i*2.0*3.141592654/WAVE_RES)*ONE;
- wave[1][i]=abs(wave[0][i]);
- wave[2][i]=(wave[0][i]>=0) ? wave[0][i] : 0;
- wave[3][i]=(i<=WAVE_RES/4) ? wave[0][i] : 0;
+ float temp1, temp2;
+ temp1=sin(i*2.0*3.141592654/WAVE_RES);
+ temp2=sin(i*3.141592654/WAVE_RES);
+ wave[0][i]=temp1*ONE;
+ wave[1][i]=temp2*ONE;
+ wave[2][i]=(i<=WAVE_RES/2) ? wave[0][i] : 0;
+ wave[3][i]= (i<=WAVE_RES/2) ? wave[1][i] : 0;
wave[4][i]=(i<WAVE_RES/2) ? ONE : -ONE;
+ wave[5][i]=(i<=WAVE_RES/2) ? (ONE*2*i/WAVE_RES) : (ONE*2*i/WAVE_RES - 2*ONE);
+ wave[6][i]=(i<=WAVE_RES/2) ? (ONE*2*i/WAVE_RES) : (ONE*2*(WAVE_RES-i)/WAVE_RES);
+ wave[7][i]=float(rand() - RAND_MAX/2) / (RAND_MAX/2) *ONE;
}
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
channel[i]=new Channel;
srand (time(NULL));
@@ -133,13 +139,13 @@ void cleanup()
uninit_communication();
- for (int i=0;i<N_CHANNELS;i++)
+ for (int i=0;i<N_CHANNELS;++i)
{
delete channel[i];
channel[i]=NULL;
}
- for (int i=0;i<128;i++)
+ for (int i=0;i<128;++i)
maybe_unload_note(program_settings[i]);
delete [] program_settings;
@@ -147,7 +153,7 @@ void cleanup()
void dump_options()
{
- for (int i=0;i<128;i++)
+ for (int i=0;i<128;++i)
if (programfile[i]!="")
cout << "program #"<<i<<":\t'"<<programfile[i]<<"'"<<endl;
@@ -155,7 +161,7 @@ void dump_options()
cout << "frameskip:\t\t"<<frameskip<<endl;
cout << "cleanup-interval:\t"<<cleanup_interval_sec<<endl;
- for (int i=0;i<N_LFOS;i++)
+ for (int i=0;i<N_LFOS;++i)
cout << "lfo"<<i<<" freq:\t\t"<<lfo_freq_hz[i]<<endl;
cout << "sample and hold freq:\t"<<snh_freq_hz<<endl;
diff --git a/synth/note.cpp b/synth/note.cpp
index 35a7115..57d8302 100644
--- a/synth/note.cpp
+++ b/synth/note.cpp
@@ -25,7 +25,7 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr
pfactor.out=new fixed_t [n_oscillators];
pfactor.freq_env_amount=new fixed_t [n_oscillators];
pfactor.fm=new fixed_t* [n_oscillators];
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
pfactor.fm[i]=new fixed_t [n_oscillators];
freqfactor_factor=new double[n_oscillators];
@@ -33,13 +33,13 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr
oscval=new fixed_t[n_oscillators];
old_oscval=new fixed_t[n_oscillators];
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
envval[i]=oscval[i]=old_oscval[i]=0;
envelope=new Envelope*[n_oscillators];
factor_env=new Envelope*[n_oscillators];
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
envelope[i]=new Envelope(prg.env_settings[i], envelope_update_frames);
factor_env[i]=new Envelope(prg.osc_settings[i].freq_env, envelope_update_frames);
@@ -59,7 +59,7 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr
//phase ever becomes negative (which would cause the program to
//segfault, or at least to produce noise). this saves an additional
//(slow) sanity check for the phase.
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
if (oscillator[i].custom_wave)
oscillator[i].phase=init_custom_osc_phase(oscillator[i].custom_wave->wave_len, oscillator[i].custom_wave->samp_rate);
@@ -108,7 +108,7 @@ Note::~Note()
{
int i;
- for (i=0;i<n_oscillators;i++)
+ for (i=0;i<n_oscillators;++i)
{
delete [] oscillator[i].fm_strength;
delete envelope[i];
@@ -138,12 +138,12 @@ void Note::recalc_factors()
pfactor.filter_res=calc_pfactor(curr_prg->pfactor.filter_res, vel);
pfactor.filter_offset=calc_pfactor(curr_prg->pfactor.filter_offset, vel);
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
pfactor.out[i]=calc_pfactor(curr_prg->pfactor.out[i], vel) * volume_factor;
pfactor.freq_env_amount[i]=calc_pfactor(curr_prg->pfactor.freq_env_amount[i], vel);
- for (int j=0;j<n_oscillators;j++)
+ for (int j=0;j<n_oscillators;++j)
pfactor.fm[i][j]=calc_pfactor(curr_prg->pfactor.fm[i][j], vel);
}
}
@@ -151,12 +151,12 @@ void Note::recalc_factors()
void Note::apply_pfactor()
{
//apply pfactor to all necessary parameters
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
oscillator[i].output=orig.oscillator[i].output*pfactor.out[i] >>SCALE;
oscillator[i].freq_env_amount=orig.oscillator[i].freq_env_amount*pfactor.freq_env_amount[i] /ONE; //because it's a float
- for (int j=0;j<n_oscillators;j++)
+ for (int j=0;j<n_oscillators;++j)
oscillator[i].fm_strength[j]=orig.oscillator[i].fm_strength[j]*pfactor.fm[i][j] >>SCALE;
}
filter_params.env_amount=orig.filter_params.env_amount*pfactor.filter_env /ONE;
@@ -247,7 +247,7 @@ void Note::set_param(const parameter_t &p, fixed_t v) //ACHTUNG:
bool Note::still_active()
{
- for (int i=0; i<n_oscillators; i++)
+ for (int i=0; i<n_oscillators; ++i)
if ((oscillator[i].output>0) && (envelope[i]->still_active()))
return true;
@@ -259,7 +259,7 @@ bool Note::still_active()
//when called a second time, there shall be no effect
void Note::release_quickly(jack_nframes_t maxt)
{
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
if (envelope[i]->get_release() > maxt)
envelope[i]->set_release(maxt);
@@ -274,7 +274,7 @@ void Note::release_quickly(jack_nframes_t maxt)
void Note::release()
{
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
envelope[i]->release_key();
factor_env[i]->release_key();
@@ -286,7 +286,7 @@ void Note::release()
void Note::reattack()
{
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
envelope[i]->reattack();
factor_env[i]->reattack();
@@ -301,7 +301,7 @@ void Note::do_ksl()
{ //osc.ksl is in Bel/octave (i.e. dB/10)
//if ksl=1, this means that for each octave the loudness
//decreases by half
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
{
if (oscillator[i].ksl==0)
envelope[i]->set_max(ONE);
@@ -312,7 +312,7 @@ void Note::do_ksl()
void Note::do_ksr()
{
- for (int i=0;i<n_oscillators;i++)
+ for (int i=0;i<n_oscillators;++i)
envelope[i]->set_ratefactor(1.0 / pow(freq>>SCALE, oscillator[i].ksr));
}
@@ -329,7 +329,7 @@ fixed_t Note::get_sample()
do_ksl();
- portamento_t++;
+ ++portamento_t;
}
fixed_t actual_freq=freq*pitchbend >>SCALE;
@@ -352,7 +352,7 @@ fixed_t Note::get_sample()
{
sync_phase-=ONE;
- for (i=0;i<n_oscillators;i++)
+ for (i=0;i<n_oscillators;++i)
if (oscillator[i].sync)
{
if (oscillator[i].custom_wave)
@@ -364,11 +364,11 @@ fixed_t Note::get_sample()
}
- env_frame_counter++;
+ ++env_frame_counter;
if (env_frame_counter>=envelope_update_frames)
{
env_frame_counter=0;
- for (i=0;i<n_oscillators;i++)
+ for (i=0;i<n_oscillators;++i)
{
envval[i]=envelope[i]->get_level();
@@ -378,11 +378,11 @@ fixed_t Note::get_sample()
}
- for (i=0;i<n_oscillators;i++)
+ for (i=0;i<n_oscillators;++i)
{
fm=0;
- for (j=0;j<n_oscillators;j++)
+ for (j=0;j<n_oscillators;++j)
if (oscillator[i].fm_strength[j]!=0) //osc_j affects osc_i (FM)
fm+=old_oscval[j]*oscillator[i].fm_strength[j];
@@ -417,7 +417,7 @@ fixed_t Note::get_sample()
if (filter_params.enabled)
{
- filter_update_counter++;
+ ++filter_update_counter;
if (filter_update_counter>=filter_update_frames)
{
filter_update_counter=0;
diff --git a/synth/parser.cpp b/synth/parser.cpp
index cd4ed02..174e0ee 100644
--- a/synth/parser.cpp
+++ b/synth/parser.cpp
@@ -22,7 +22,7 @@ string extract_array_name(string s)
int extract_array_index(string s, int dim)
{
size_t p=-1,p2;
- for (int i=0;i<dim;i++)
+ for (int i=0;i<dim;++i)
{
p=s.find('[',p+1);
if (p==string::npos) return -1;
@@ -80,12 +80,12 @@ list<term_t> extract_formula(string s)
term_t tmp;
list<string> terms=extract_terms(s);
- for (list<string>::iterator term=terms.begin(); term!=terms.end(); term++)
+ for (list<string>::iterator term=terms.begin(); term!=terms.end(); ++term)
{
list<string> factors=extract_factors(term->substr(1));
double fac= ((*term)[0]=='+') ? 1.0 : -1.0;
string cont="";
- for (list<string>::iterator factor=factors.begin(); factor!=factors.end(); factor++)
+ for (list<string>::iterator factor=factors.begin(); factor!=factors.end(); ++factor)
{
if (factor->find_first_not_of("0123456789.*/+-")==string::npos)
{
@@ -135,12 +135,12 @@ param_factor_t parse_pfactor(string s) //TODO fast dasselbe wie oben. mergen?
list<string> terms=extract_terms(s);
- for (list<string>::iterator term=terms.begin(); term!=terms.end(); term++)
+ for (list<string>::iterator term=terms.begin(); term!=terms.end(); ++term)
{
list<string> factors=extract_factors(term->substr(1));
double fac= ((*term)[0]=='+') ? 1.0 : -1.0;
string cont="";
- for (list<string>::iterator factor=factors.begin(); factor!=factors.end(); factor++)
+ for (list<string>::iterator factor=factors.begin(); factor!=factors.end(); ++factor)
{
if (factor->find_first_not_of("0123456789.*/+-")==string::npos)
{
@@ -182,12 +182,12 @@ param_factor_t parse_pfactor(string s) //TODO fast dasselbe wie oben. mergen?
void init_oscs(int n_osc, oscillator_t *osc)
{
- for (int i=0;i<n_osc;i++)
+ for (int i=0;i<n_osc;++i)
{
osc[i].n_osc=n_osc;
osc[i].fm_strength=new fixed_t[n_osc];
- for (int j=0;j<n_osc;j++)
+ for (int j=0;j<n_osc;++j)
osc[i].fm_strength[j]=0;
osc[i].output=0;
@@ -210,7 +210,7 @@ void init_oscs(int n_osc, oscillator_t *osc)
void init_envs(int n_osc, env_settings_t *env)
{
- for (int i=0;i<n_osc;i++)
+ for (int i=0;i<n_osc;++i)
{
env[i].attack=0;
env[i].decay=0;
@@ -250,7 +250,7 @@ void init_pfactors(int n_osc, pfactor_formula_t &pfactor)
pfactor.filter_offset.offset=ONE;
pfactor.filter_offset.vel_amount=0;
- for (int i=0;i<n_osc;i++)
+ for (int i=0;i<n_osc;++i)
{
pfactor.out[i].offset=0;
pfactor.out[i].vel_amount=ONE;
@@ -259,7 +259,7 @@ void init_pfactors(int n_osc, pfactor_formula_t &pfactor)
pfactor.freq_env_amount[i].vel_amount=ONE;
pfactor.fm[i]=new param_factor_t [n_osc];
- for (int j=0;j<n_osc;j++)
+ for (int j=0;j<n_osc;++j)
{
pfactor.fm[i][j].offset=ONE;
pfactor.fm[i][j].vel_amount=0;
@@ -288,7 +288,7 @@ program_t parse(string fn)
map< parameter_t, list<term_t> > formula;
int controller_default[128];
- for (int i=0;i<128;i++)
+ for (int i=0;i<128;++i)
controller_default[i]=0;
filter_params_t filter;
@@ -557,7 +557,7 @@ program_t parse(string fn)
par.index=ind2;
terms=extract_formula(strval);
- for (list<term_t>::iterator it=terms.begin(); it!=terms.end(); it++)
+ for (list<term_t>::iterator it=terms.begin(); it!=terms.end(); ++it)
if (it->c!=NO_CONT)
affect[it->c].insert(par);
@@ -632,11 +632,11 @@ program_t parse(string fn)
bool neverending_tone=false;
- for (map< parameter_t, list<term_t> >::iterator it=formula.begin(); it!=formula.end(); it++)
+ for (map< parameter_t, list<term_t> >::iterator it=formula.begin(); it!=formula.end(); ++it)
if ((it->first.par==OUTPUT) && (env[it->first.osc].release<0))
neverending_tone=true;
- for (int i=0;i<n_osc;i++)
+ for (int i=0;i<n_osc;++i)
if ((osc[i].output!=0) && (env[i].release<0))
neverending_tone=true;
@@ -662,7 +662,7 @@ program_t parse(string fn)
result.env_settings=new env_settings_t[n_osc];
copy(&env[0],&env[n_osc],result.env_settings);
- for (int i=0;i<128;i++)
+ for (int i=0;i<128;++i)
result.controller[i]=controller_default[i];
result.filter_settings=filter;
@@ -675,7 +675,7 @@ program_t parse(string fn)
//clean up a bit
- for (int i=0;i<n_osc;i++)
+ for (int i=0;i<n_osc;++i)
delete [] osc[i].fm_strength;
delete [] osc;
diff --git a/synth/programs.cpp b/synth/programs.cpp
index 0f675d6..23da924 100644
--- a/synth/programs.cpp
+++ b/synth/programs.cpp
@@ -66,7 +66,7 @@ void program_t::cleanup()
{
if (osc_settings)
{
- for (unsigned int i=0;i<n_osc;i++)
+ for (unsigned int i=0;i<n_osc;++i)
delete [] osc_settings[i].fm_strength;
delete [] osc_settings;
}
@@ -79,7 +79,7 @@ void program_t::cleanup()
delete [] pfactor.freq_env_amount;
if (pfactor.fm)
{
- for (unsigned int i=0;i<n_osc;i++)
+ for (unsigned int i=0;i<n_osc;++i)
delete [] pfactor.fm[i];
delete [] pfactor.fm;
}
@@ -99,7 +99,7 @@ program_t& program_t::operator=(const program_t &that)
this->cleanup();
- for (i=0;i<(sizeof(controller_affects)/sizeof(*controller_affects));i++)
+ for (i=0;i<(sizeof(controller_affects)/sizeof(*controller_affects));++i)
this->controller_affects[i]=that.controller_affects[i];
this->formula=that.formula;
this->n_osc=that.n_osc;
@@ -126,7 +126,7 @@ program_t& program_t::operator=(const program_t &that)
memcpy(this->pfactor.freq_env_amount, that.pfactor.freq_env_amount, sizeof(param_factor_t)*n_osc);
this->pfactor.fm=new param_factor_t* [n_osc];
- for (i=0;i<n_osc;i++)
+ for (i=0;i<n_osc;++i)
{
this->pfactor.fm[i]=new param_factor_t [n_osc];
memcpy(this->pfactor.fm[i], that.pfactor.fm[i], sizeof(param_factor_t)*n_osc);
diff --git a/synth/readwave.cpp b/synth/readwave.cpp
index 08106ca..0b2c0a0 100644
--- a/synth/readwave.cpp
+++ b/synth/readwave.cpp
@@ -102,7 +102,7 @@ void read_wave(const char *fn, custom_wave_t *result)
result->wave=new fixed_t[n_samples];
double sample;
- for (int i=0;i<n_samples;i++)
+ for (int i=0;i<n_samples;++i)
{
if (feof(f))
throw string("unexpected end-of-file");
diff --git a/synth/shared_object_manager.cpp b/synth/shared_object_manager.cpp
index 045f409..b9e2be7 100644
--- a/synth/shared_object_manager.cpp
+++ b/synth/shared_object_manager.cpp
@@ -31,7 +31,7 @@ void* my_dlopen(string file)
output_verbose("the requested shared object '"+file+"' has been loaded with handle #"+IntToStr(int(handle)));
}
- dl_ref_count[handle]++;
+ ++dl_ref_count[handle];
return handle;
}
@@ -44,7 +44,7 @@ void dlref_inc(void* handle)
if (dl_ref_count[handle]==0)
throw string("dlref_inc: tried to increment the ref-count for a nonexistent handle");
- dl_ref_count[handle]++;
+ ++dl_ref_count[handle];
}
void dlref_dec(void* handle)
@@ -55,7 +55,7 @@ void dlref_dec(void* handle)
if (dl_ref_count[handle]==0)
throw string("dlref_inc: tried to decrement the ref-count for a nonexistent handle");
- dl_ref_count[handle]--;
+ --dl_ref_count[handle];
if (dl_ref_count[handle]==0)
{
diff --git a/synth/util.cpp b/synth/util.cpp
index c54f2d5..fb32d4d 100644
--- a/synth/util.cpp
+++ b/synth/util.cpp
@@ -20,7 +20,7 @@ string IntToStrHex(int i)
bool isnum(string s)
{
- for (size_t i=0;i<s.length();i++)
+ for (size_t i=0;i<s.length();++i)
if (!isdigit(s[i]))
return false;
@@ -37,7 +37,7 @@ string remove_all_spaces(string s)
{
string result;
- for (size_t i=0; i<s.length(); i++)
+ for (size_t i=0; i<s.length(); ++i)
if ((s[i]!=' ') && (s[i]!='\t'))
result+=s[i];
@@ -49,14 +49,14 @@ string trim_spaces(string s)
string result;
int i;
- for (i=0;i<s.length();i++)
+ for (i=0;i<s.length();++i)
if ((s[i]!=' ') && (s[i]!='\t'))
break;
if (i!=s.length())
{
result=s.substr(i);
- for (i=result.length()-1;i>=0;i--)
+ for (i=result.length()-1;i>=0;--i)
if ((result[i]!=' ') && (result[i]!='\t'))
break;