#ifndef _MIDIFUNC_H_
#define _MIDIFUNC_H_
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include "m2c_tn10.h"
#include "sw_uart_rx.h"
#include "mididec.h"
extern void midi_note_on( uint8_t MD_2nd, uint8_t MD_3rd);
extern void midi_note_off( uint8_t MD_2nd);
extern void pitch_bend();
extern void calc_pitch( uint8_t gate_flag);
extern uint16_t lb8_to_lin(uint8_t lb);
static inline void GATEQ_ON( void )
{
unit_prop[0].gate_que |= 0x8000;
}
static inline void GATEQ_OFF( void )
{
unit_prop[0].gate_que &= 0x7fff;
}
static inline void all_note_off()
{
GATEQ_OFF();
unit_prop[0].on_cnt = 0;
unit_prop[0].gate_que = 0;
}
static inline void GM_reset(void)
{
ch_prop[0].MD_bend_range = 2;
ch_prop[0].MD_RPN_MLB = 0x7f;
all_note_off();
}
#endif
#include "sw_uart_rx.h"
#include "mididec.h"
#include "midifunc.h"
#if (0)
void midi_note_on( uint8_t MD_2nd, uint8_t MD_3rd)
{
OCR0A = ((uint16_t)MD_2nd << 2);
unit_prop[0].on_cnt++;
GATEQ_ON();
}
#endif
void midi_note_off( uint8_t MD_2nd)
{
if (unit_prop[0].on_cnt) {
unit_prop[0].on_cnt--;
}
if (0 == unit_prop[0].on_cnt) {
GATEQ_OFF();
}
}