summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2010-12-30 17:32:08 +0100
committerFlorian Jung <flo@thinkpad.(none)>2010-12-30 17:32:08 +0100
commit725302c54573d1095d49d466ebda94abe9c13dd5 (patch)
tree958d3ca2e1eb9407cd9b41d1645fdb874db918ab
parentc1a2c43aa8d4c5bcfa345fd3b92215c18c938683 (diff)
Use NoteSkel wherever possible
Notes are still created from the built-in Note class, but theoretically, other classes could be used, too.
-rw-r--r--synth/channel.cpp23
-rw-r--r--synth/channel.h4
2 files changed, 15 insertions, 12 deletions
diff --git a/synth/channel.cpp b/synth/channel.cpp
index 35ee375..ddad9fe 100644
--- a/synth/channel.cpp
+++ b/synth/channel.cpp
@@ -3,6 +3,9 @@
#include "math.h"
#include "globals.h"
+#include "note.h"
+
+
Channel::Channel()
{
volume=ONE;
@@ -27,7 +30,7 @@ Channel::~Channel()
void Channel::cleanup()
{
- list<Note*>::iterator it;
+ list<NoteSkel*>::iterator it;
for (it=notes.begin(); it!=notes.end(); it++)
if ((*it)->still_active()==false)
{
@@ -40,7 +43,7 @@ fixed_t Channel::get_sample()
{
fixed_t sum=0;
- for (list<Note*>::iterator it=notes.begin(); it!=notes.end(); it++)
+ for (list<NoteSkel*>::iterator it=notes.begin(); it!=notes.end(); it++)
sum+=(*it)->get_sample();
return sum*volume >>SCALE;
@@ -70,13 +73,13 @@ void Channel::note_off(int note)
void Channel::note_on(int note, int vel)
{
- list<Note*>::iterator it;
+ list<NoteSkel*>::iterator it;
if (vel>0) //note on
{
if ( (n_voices==1) && (!notes.empty()) )
{
//no need to create a new note; reuse the existing
- Note *n; //i'm lazy
+ NoteSkel *n; //i'm lazy
n= *(notes.begin());
if (n->get_program() != program)
@@ -153,7 +156,7 @@ void Channel::apply_voice_limit()
int diff=notes.size()-n_voices;
if (diff>0)
{
- list<Note*>::iterator it=notes.begin();
+ list<NoteSkel*>::iterator it=notes.begin();
if (quick_release)
for (int i=0;i<diff;i++)
@@ -239,7 +242,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<Note*>::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);
@@ -300,14 +303,14 @@ void Channel::set_real_portamento_frames()
else
portamento_frames=0;
- list<Note*>::iterator it;
+ list<NoteSkel*>::iterator it;
for (it=notes.begin(); it!=notes.end(); it++)
(*it)->set_portamento_frames(portamento_frames);
}
void Channel::panic()
{
- list<Note*>::iterator it;
+ list<NoteSkel*>::iterator it;
for (it=notes.begin(); it!=notes.end();)
{
delete *it;
@@ -317,7 +320,7 @@ void Channel::panic()
void Channel::release_all()
{
- list<Note*>::iterator it;
+ list<NoteSkel*>::iterator it;
for (it=notes.begin(); it!=notes.end(); it++)
(*it)->release();
}
@@ -332,7 +335,7 @@ void Channel::set_pitch_bend(float val)
{
pitchbend=pow(2.0,val/12.0)*ONE;
- list<Note*>::iterator it;
+ list<NoteSkel*>::iterator it;
for (it=notes.begin(); it!=notes.end(); it++)
(*it)->set_pitchbend(pitchbend);
}
diff --git a/synth/channel.h b/synth/channel.h
index ead3a67..2668bc4 100644
--- a/synth/channel.h
+++ b/synth/channel.h
@@ -7,7 +7,7 @@
#include "fixed.h"
#include "programs.h"
-#include "note.h"
+#include "note_skel.h"
#include "defines.h"
#include "util.h"
@@ -50,7 +50,7 @@ class Channel
fixed_t pitchbend;
float max_pitchbend;
- std::list<Note*> notes;
+ std::list<NoteSkel*> notes;
bool always_reattack;
bool do_portamento;