uilleann/main-play.h

72 lines
1.8 KiB
C
Raw Normal View History

2020-11-25 17:13:54 -07:00
#pragma once
void playDrones() {
for (int i = 0; i < NUM_DRONES; ++i) {
float pitch = tuning.GetPitch(NOTE_D3);
pitch /= 1 << i; // Take down the appropriate number of octaves
pitch *= (i - 1) / 1000; // Detune ever so AudioProcessorUsageMaxReset();
Drones[i].NoteOn(pitch);
}
}
2020-11-25 21:38:29 -07:00
void doPlay(bool forceDisplayUpdate) {
2020-11-25 17:13:54 -07:00
static Note last_note = NOTE_ZERO;
bool updateDisplay = forceDisplayUpdate;
2020-11-25 21:38:29 -07:00
if (updateDisplay) {
display.clearDisplay();
display.fillRect(0, 0, 2, 2, SSD1306_WHITE);
display.display();
}
2020-11-26 18:49:09 -07:00
if (pipe.Silent) {
2020-11-25 17:13:54 -07:00
Chanter.NoteOff();
} else {
// Calculate pitch, and glissando pitch
2020-11-26 18:49:09 -07:00
float pitch = tuning.GetPitch(pipe.CurrentNote);
float glissandoPitch = tuning.GetPitch(pipe.GlissandoNote);
2020-11-25 17:13:54 -07:00
// Bend pitch if fewer than 3 half steps away
2020-11-26 18:49:09 -07:00
if (abs(pipe.GlissandoNote - pipe.CurrentNote) < 3) {
2020-11-25 17:13:54 -07:00
float diff = glissandoPitch - pitch;
2020-11-26 18:49:09 -07:00
pitch = glissandoPitch - (diff * pipe.GlissandoPressure);
2020-11-25 17:13:54 -07:00
}
// Apply a low shelf filter if this is the alternate fingering
2020-11-26 18:49:09 -07:00
if (pipe.AltFingering) {
2020-11-25 17:13:54 -07:00
biquad1.setLowShelf(0, 2000, 0.2, 1);
} else {
biquad1.setHighShelf(0, 1000, 1.0, 1);
}
// We've figured out what pitch to play, now we can play it.
if (Chanter.playing) {
Chanter.SetPitch(pitch);
} else {
Chanter.NoteOn(pitch);
}
}
2020-11-26 18:49:09 -07:00
if (pipe.CurrentNote != last_note) {
2020-11-25 17:13:54 -07:00
updateDisplay = true;
}
if (updateDisplay) {
// Look up the note name
2020-11-26 18:49:09 -07:00
const char *noteName = NoteName(pipe.CurrentNote);
if (pipe.Silent) {
noteName = "--";
2020-11-25 17:13:54 -07:00
updateDisplay = true;
}
display.clearDisplay();
display.setFont(&FreeSans9pt7b);
display.setCursor(0, 16);
2020-11-26 18:49:09 -07:00
display.print(noteName);
2020-11-25 17:13:54 -07:00
display.display();
2020-11-26 18:49:09 -07:00
last_note = pipe.CurrentNote;
2020-11-25 17:13:54 -07:00
}
}