Low, High and Last playing modes.
This commit is contained in:
parent
5454bd46bc
commit
bcd3f8f33a
|
|
@ -41,8 +41,13 @@ void handleNotesChanged()
|
|||
}
|
||||
else
|
||||
{
|
||||
// Possible playing modes:
|
||||
// Mono Low: use midiNotes.getLow
|
||||
// Mono High: use midiNotes.getHigh
|
||||
// Mono Last: use midiNotes.getLast
|
||||
|
||||
byte currentNote = 0;
|
||||
if (midiNotes.getTail(currentNote))
|
||||
if (midiNotes.getLast(currentNote))
|
||||
{
|
||||
tone(sAudioOutPin, sNotePitches[currentNote]);
|
||||
pulseGate(); // Retrigger envelopes. Remove for legato effect.
|
||||
|
|
@ -67,7 +72,7 @@ void handleNoteOff(byte inChannel, byte inNote, byte inVelocity)
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setup()
|
||||
{
|
||||
{
|
||||
pinMode(sGatePin, OUTPUT);
|
||||
pinMode(sAudioOutPin, OUTPUT);
|
||||
MIDI.setHandleNoteOn(handleNoteOn);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ public:
|
|||
|
||||
public:
|
||||
inline bool get(byte inIndex, byte& outPitch) const;
|
||||
inline bool getTail(byte& outPitch) const;
|
||||
inline bool getLast(byte& outPitch) const;
|
||||
inline bool getHigh(byte& outPitch) const;
|
||||
inline bool getLow(byte& outPitch) const;
|
||||
|
||||
public:
|
||||
inline bool empty() const;
|
||||
|
|
@ -257,14 +259,65 @@ inline bool MidiNoteList<Size>::get(byte inIndex, byte& outPitch) const
|
|||
}
|
||||
|
||||
template<byte Size>
|
||||
inline bool MidiNoteList<Size>::getTail(byte& outPitch) const
|
||||
inline bool MidiNoteList<Size>::getLast(byte& outPitch) const
|
||||
{
|
||||
if (mTail)
|
||||
if (!mTail)
|
||||
{
|
||||
outPitch = mTail->note.pitch;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
outPitch = mTail->note.pitch;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<byte Size>
|
||||
inline bool MidiNoteList<Size>::getHigh(byte& outPitch) const
|
||||
{
|
||||
if (!mTail)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outPitch = 0;
|
||||
const Cell* it = mTail;
|
||||
for (byte i = 0; i < mSize; ++i)
|
||||
{
|
||||
if (it->note.pitch > outPitch)
|
||||
{
|
||||
outPitch = it->note.pitch;
|
||||
}
|
||||
|
||||
if (it->prev)
|
||||
{
|
||||
it = it->prev;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<byte Size>
|
||||
inline bool MidiNoteList<Size>::getLow(byte& outPitch) const
|
||||
{
|
||||
if (!mTail)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outPitch = 0xff;
|
||||
const Cell* it = mTail;
|
||||
for (byte i = 0; i < mSize; ++i)
|
||||
{
|
||||
if (it->note.pitch < outPitch)
|
||||
{
|
||||
outPitch = it->note.pitch;
|
||||
}
|
||||
|
||||
if (it->prev)
|
||||
{
|
||||
it = it->prev;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue