Commit eba4db4e authored by Jacob Vosmaer's avatar Jacob Vosmaer

Split out poly note on/off handling

parent fbacf042
PRG = crowbx
OBJ = crowbx.o midi.o dac.o voice.o uart.o gate.o
OBJ = crowbx.o midi.o dac.o voice.o uart.o gate.o poly.o
MCU_TARGET = atmega328p
#MCU_TARGET = at90s2313
#MCU_TARGET = at90s2333
......
#include <avr/io.h>
#include <util/delay.h>
#include "dac.h"
#include "midi.h"
#include "voice.h"
#include "dac.h"
#include "gate.h"
#include "poly.h"
void
io_init(void)
......@@ -19,31 +19,6 @@ io_init(void)
DDRD = _BV(PORTD1) | _BV(PORTD2) | _BV(PORTD3) | _BV(PORTD4) | _BV(PORTD5) | _BV(PORTD6) | _BV(PORTD7);
}
void
note_on(uint8_t note)
{
uint8_t v = voice_acquire(note);
if (v == NUM_VOICES) {
// This should never happen if the voice assigner is working correctly.
return;
}
dac_set_note(v, note);
gate_on(v);
}
void
note_off(uint8_t note)
{
uint8_t v = voice_release(note);
if (v == NUM_VOICES) {
// This can happen if we get a spurious note off message from MIDI
return;
}
gate_off(v);
}
int
main(void)
{
......@@ -62,13 +37,13 @@ main(void)
uint8_t velocity = midi_data() & 0xff;
if (velocity > 0) {
note_on(note);
poly_note_on(note);
} else {
note_off(note);
poly_note_off(note);
}
} else if (midi_status() == MIDI_NOTE_OFF) {
uint8_t note = midi_data() >> 8;
note_off(note);
poly_note_off(note);
}
}
......
#ifndef dac_h
#define dac_h
#include <inttypes.h>
void dac_set_note(uint8_t voice, uint8_t note);
void dac_init(void);
......
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