mirror of
https://github.com/yokemura/Magical8bitPlug2.git
synced 2025-05-24 23:00:21 -04:00
Comments and constants
This commit is contained in:
parent
88dea8e989
commit
05e27d0da6
@ -36,9 +36,9 @@ void TonalVoice::startNote (int midiNoteNumber, float velocity, SynthesiserSound
|
|||||||
arpeggioFrameTimer = 0;
|
arpeggioFrameTimer = 0;
|
||||||
arpeggioFrameLength = 0;
|
arpeggioFrameLength = 0;
|
||||||
currentNumNoteBuffer = 0;
|
currentNumNoteBuffer = 0;
|
||||||
for (int i=0; i<10; i++) { noteBuffer[i] = 0; }
|
for (int i=0; i<NUMNOTEBUFFER; i++) { noteBuffer[i] = 0; }
|
||||||
currentNumRetireBuffer = 0;
|
currentNumRetireBuffer = 0;
|
||||||
for (int i=0; i<10; i++) { retireBuffer[i] = 0; }
|
for (int i=0; i<NUMNOTEBUFFER; i++) { retireBuffer[i] = 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void TonalVoice::advanceControlFrame()
|
void TonalVoice::advanceControlFrame()
|
||||||
@ -108,7 +108,7 @@ void TonalVoice::setLegatoMode(double time, int midiCh) {
|
|||||||
// The interface says "add" but the implementation is just using the latest value.
|
// The interface says "add" but the implementation is just using the latest value.
|
||||||
// It is because the original intension was to keep all the pressing keys and choose the apropriate one with certain algorithm
|
// It is because the original intension was to keep all the pressing keys and choose the apropriate one with certain algorithm
|
||||||
void TonalVoice::addLegatoNote (int midiNoteNumber, float velocity) {
|
void TonalVoice::addLegatoNote (int midiNoteNumber, float velocity) {
|
||||||
if (currentNumNoteBuffer >= 10) {
|
if (currentNumNoteBuffer >= NUMNOTEBUFFER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ void TonalVoice::setArpeggioMode(double interval, int midiCh)
|
|||||||
|
|
||||||
void TonalVoice::addArpeggioNoteAscending(int midiNoteNumber)
|
void TonalVoice::addArpeggioNoteAscending(int midiNoteNumber)
|
||||||
{
|
{
|
||||||
if (currentNumNoteBuffer >= 10) {
|
if (currentNumNoteBuffer >= NUMNOTEBUFFER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
@ -158,7 +158,7 @@ void TonalVoice::addArpeggioNoteAscending(int midiNoteNumber)
|
|||||||
|
|
||||||
void TonalVoice::addArpeggioNoteDescending(int midiNoteNumber)
|
void TonalVoice::addArpeggioNoteDescending(int midiNoteNumber)
|
||||||
{
|
{
|
||||||
if (currentNumNoteBuffer >= 10) {
|
if (currentNumNoteBuffer >= NUMNOTEBUFFER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
@ -179,22 +179,24 @@ int TonalVoice::removeArpeggioNote(int midiNoteNumber)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Just push the note number to Retire Buffer
|
// Just push the note number to Retire Buffer
|
||||||
|
// Actual retirement happens in advanceFrameBuffer
|
||||||
retireBuffer[currentNumRetireBuffer] = midiNoteNumber;
|
retireBuffer[currentNumRetireBuffer] = midiNoteNumber;
|
||||||
currentNumRetireBuffer++;
|
currentNumRetireBuffer++;
|
||||||
|
|
||||||
// Observed like current number of notes already decreased
|
// Observed like current number of notes already decreased
|
||||||
|
// so the Synthsizer can determine if it should enter Release phase
|
||||||
return currentNumNoteBuffer - currentNumRetireBuffer;
|
return currentNumNoteBuffer - currentNumRetireBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TonalVoice::pushNoteBuffer(int index, int value) {
|
void TonalVoice::pushNoteBuffer(int index, int value) {
|
||||||
for (int i=9; i>index; i--) {
|
for (int i=NUMNOTEBUFFER-1; i>index; i--) {
|
||||||
noteBuffer[i] = noteBuffer[i-1];
|
noteBuffer[i] = noteBuffer[i-1];
|
||||||
}
|
}
|
||||||
noteBuffer[index] = value;
|
noteBuffer[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TonalVoice::shiftNoteBuffer(int index) {
|
void TonalVoice::shiftNoteBuffer(int index) {
|
||||||
for (int i=index; i<9; i++) {
|
for (int i=index; i<NUMNOTEBUFFER-1; i++) {
|
||||||
noteBuffer[i] = noteBuffer[i+1];
|
noteBuffer[i] = noteBuffer[i+1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +269,7 @@ void TonalVoice::onFrameAdvanced()
|
|||||||
|
|
||||||
// Clear Retire Buffer
|
// Clear Retire Buffer
|
||||||
currentNumRetireBuffer = 0;
|
currentNumRetireBuffer = 0;
|
||||||
for (int i=0; i<10; i++) { retireBuffer[i] = 0; }
|
for (int i=0; i<NUMNOTEBUFFER; i++) { retireBuffer[i] = 0; }
|
||||||
} /* else {
|
} /* else {
|
||||||
Retirements should not happen in Release Phase
|
Retirements should not happen in Release Phase
|
||||||
to keep the arpeggio playing during the release.
|
to keep the arpeggio playing during the release.
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "BaseVoice.h"
|
#include "BaseVoice.h"
|
||||||
|
|
||||||
|
#define NUMNOTEBUFFER 10
|
||||||
|
|
||||||
struct TonalVoice : public BaseVoice // The base for Pulse and Triangle
|
struct TonalVoice : public BaseVoice // The base for Pulse and Triangle
|
||||||
{
|
{
|
||||||
TonalVoice (SettingRefs* sRefs);
|
TonalVoice (SettingRefs* sRefs);
|
||||||
@ -36,7 +38,7 @@ struct TonalVoice : public BaseVoice // The base for Pulse and Triangle
|
|||||||
int currentPitchSequenceFrame = 0;
|
int currentPitchSequenceFrame = 0;
|
||||||
|
|
||||||
// Legato/Arpeggio
|
// Legato/Arpeggio
|
||||||
int noteBuffer[10];
|
int noteBuffer[NUMNOTEBUFFER];
|
||||||
int currentNumNoteBuffer = 0;
|
int currentNumNoteBuffer = 0;
|
||||||
int primaryMidiChannel = 1;
|
int primaryMidiChannel = 1;
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ struct TonalVoice : public BaseVoice // The base for Pulse and Triangle
|
|||||||
int currentArpeggioFrame = 0;
|
int currentArpeggioFrame = 0;
|
||||||
double arpeggioFrameTimer = 0;
|
double arpeggioFrameTimer = 0;
|
||||||
double arpeggioFrameLength = 0; // Unit: seconds. Set non-zero value to enable arpeggio
|
double arpeggioFrameLength = 0; // Unit: seconds. Set non-zero value to enable arpeggio
|
||||||
int retireBuffer[10];
|
int retireBuffer[NUMNOTEBUFFER];
|
||||||
int currentNumRetireBuffer = 0;
|
int currentNumRetireBuffer = 0;
|
||||||
|
|
||||||
void startNote (int midiNoteNumber, float velocity,
|
void startNote (int midiNoteNumber, float velocity,
|
||||||
|
Loading…
Reference in New Issue
Block a user