Commit ed03c60b authored by Jacob Vosmaer's avatar Jacob Vosmaer

Unison gates

parent 2a4907cc
......@@ -5,6 +5,34 @@
#include "voices.h"
#include "dac.h"
void
gate_on(uint8_t voice)
{
if (voice > NUM_VOICES) {
return;
}
PORTC |= _BV(voice);
}
void
gate_off(uint8_t voice)
{
if (voice > NUM_VOICES) {
return;
}
PORTC &= ~_BV(voice);
}
void
gate_off_all(void)
{
for (uint8_t i = 0; i < NUM_VOICES; i++) {
gate_off(i);
}
}
void
io_init(void)
{
......@@ -17,6 +45,7 @@ io_init(void)
// PORTD0 is UART RX. Set all other PORTD pins output, to save power.
DDRD = _BV(PORTD1) | _BV(PORTD2) | _BV(PORTD3) | _BV(PORTD4) | _BV(PORTD5) | _BV(PORTD6) | _BV(PORTD7);
}
int
main(void)
{
......@@ -36,8 +65,13 @@ main(void)
if (velocity) {
for (uint8_t i = 0; i < NUM_VOICES; i++) {
dac_set_note(i, key);
gate_on(i);
}
} else {
gate_off_all();
}
} else if (midi_status() == MIDI_NOTE_OFF) {
gate_off_all();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment