uilleann/main-play.h

75 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-25 17:13:54 -07:00
if (pipe.silent) {
Chanter.NoteOff();
} else {
// Calculate pitch, and glissando pitch
2020-11-25 21:38:29 -07:00
float pitch = tuning.GetPitch(pipe.note);
float glissandoPitch = tuning.GetPitch(pipe.glissandoNote);
2020-11-25 17:13:54 -07:00
// Bend pitch if fewer than 3 half steps away
if (abs(pipe.glissandoNote - pipe.note) < 3) {
float diff = glissandoPitch - pitch;
pitch += diff * pipe.glissandoOpenness;
}
// Apply a low shelf filter if this is the alternate fingering
if (pipe.altFingering) {
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);
}
}
if (pipe.note != last_note) {
updateDisplay = true;
}
2020-11-25 21:53:45 -07:00
diag("%d %f", pipe.keys, pipe.glissandoOpenness);
2020-11-25 21:38:29 -07:00
#if 0
2020-11-25 17:13:54 -07:00
if (updateDisplay) {
// Look up the note name
const char *note_name = NoteName(pipe.note);
if (pipe.silent) {
note_name = "--";
updateDisplay = true;
}
display.clearDisplay();
display.setFont(&FreeSans9pt7b);
display.setCursor(0, 16);
display.print(note_name);
display.display();
2020-11-25 21:38:29 -07:00
last_note = pipe.note;
2020-11-25 17:13:54 -07:00
}
2020-11-25 21:38:29 -07:00
#endif
2020-11-25 17:13:54 -07:00
}