prepare for pre-calculated pitch table

This commit is contained in:
tildearrow 2023-10-10 20:15:58 -05:00
parent f1145a14ad
commit 43468653a0
5 changed files with 41 additions and 1 deletions

View file

@ -267,6 +267,29 @@ struct DivCommand {
value2(0) {}
};
struct DivPitchTable {
int pitch[(12*128)+1];
unsigned char linearity, blockBits;
bool period;
// get pitch
int get(int base, int pitch, int pitch2);
// linear: note
// non-linear: get(note,0,0)
int getBase(int note);
// calculate pitch table
void init(float tuning, double clock, double divider, int octave, unsigned char linear, bool isPeriod, unsigned char block=0);
DivPitchTable():
linearity(2),
blockBits(0),
period(false) {
memset(pitch,0,sizeof(pitch));
}
};
struct DivDelayedCommand {
int ticks;
DivCommand cmd;
@ -692,6 +715,11 @@ class DivDispatch {
*/
virtual void renderSamples(int sysID);
/**
* tell this DivDispatch that the tuning and/or pitch linearity has changed, and therefore the pitch table must be regenerated.
*/
virtual void notifyPitchTable();
/**
* initialize this DivDispatch.
* @param parent the parent DivEngine.
@ -718,6 +746,7 @@ class DivDispatch {
if (chipClock<getClockRangeMin()) chipClock=getClockRangeMin(); \
}
// NOTE: these definitions may be deprecated in the future. see DivPitchTable.
// pitch calculation:
// - a DivDispatch usually contains four variables per channel:
// - baseFreq: this changes on new notes, legato, arpeggio and slides.