Refactoring to build on the new AVR core.

This commit is contained in:
Francois Best 2012-06-16 17:36:34 +02:00
parent 22218892c0
commit 3edb9c15ea
2 changed files with 21 additions and 22 deletions

View File

@ -9,7 +9,8 @@
*/
#include "MIDI.h"
#include "Serial.h"
#include "core.h"
#include "hardware_Serial.h"
#include <stdlib.h>
@ -21,7 +22,7 @@ MIDI_Class MIDI;
MIDI_Class::MIDI_Class()
{
#if USE_CALLBACKS
#if COMPILE_MIDI_IN && USE_CALLBACKS
// Initialise callbacks to NULL pointer
mNoteOffCallback = NULL;
@ -310,8 +311,7 @@ void MIDI_Class::sendPitchBend(double PitchValue,
byte Channel)
{
unsigned int pitchval = (PitchValue+1.f)*8192;
if (pitchval > 16383) pitchval = 16383; // overflow protection
int pitchval = PitchValue * MIDI_PITCHBEND_MAX;
sendPitchBend(pitchval,Channel);
}
@ -528,16 +528,16 @@ bool MIDI_Class::read(const byte inChannel)
// Private method: MIDI parser
bool MIDI_Class::parse(byte inChannel)
{
const byte bytes_available = MIDI_SERIAL_PORT.available();
const int bytes_available = MIDI_SERIAL_PORT.available();
if (bytes_available <= 0) {
if (bytes_available == 0)
// No data available.
return false;
}
// If the buffer is full -> Don't Panic! Call the Vogons to destroy it.
if (bytes_available == UART_BUFFER_SIZE) { Serial << "Overflow, call the Vogons!!" << endl;
if (bytes_available == UART::bufferSize)
{
PRINT_DEBUG("MIDI Overflow");
MIDI_SERIAL_PORT.flush();
}
else {
@ -1184,5 +1184,3 @@ void MIDI_Class::thru_filter(byte inChannel)
#endif // Thru

View File

@ -8,11 +8,10 @@
* license GPL Forty Seven Effects - 2011
*/
#ifndef LIB_MIDI_H_
#define LIB_MIDI_H_
#include "Types.h" // Include all the types we need.
#ifndef _FSE_LIB_MIDI_H_
#define _FSE_LIB_MIDI_H_
#include "core_Types.h" // Include all the types we need.
/*
###############################################################
@ -58,7 +57,7 @@
#define MIDI_CHANNEL_OMNI 0
#define MIDI_CHANNEL_OFF 17 // and over
#define MIDI_SYSEX_ARRAY_SIZE 255 // Maximum size is 65535 bytes.
#define MIDI_SYSEX_ARRAY_SIZE 128 // Maximum size is 65535 bytes.
#define MIDI_PITCHBEND_MIN -8192
#define MIDI_PITCHBEND_MAX 8191
@ -66,7 +65,8 @@
/*! Enumeration of MIDI types */
enum kMIDIType {
enum kMIDIType
{
NoteOff = 0x80, ///< Note Off
NoteOn = 0x90, ///< Note On
AfterTouchPoly = 0xA0, ///< Polyphonic AfterTouch
@ -252,9 +252,9 @@ private:
byte mRunningStatus_RX;
byte mInputChannel;
byte mPendingMessage[MIDI_SYSEX_ARRAY_SIZE];
byte mPendingMessage[3]; // SysEx are dumped into mMessage directly.
unsigned int mPendingMessageExpectedLenght;
unsigned int mPendingMessageIndex; // Extended to unsigned int for larger sysex payloads.
unsigned int mPendingMessageIndex; // Extended to unsigned int for larger SysEx payloads.
midimsg mMessage;
@ -347,4 +347,5 @@ private:
extern MIDI_Class MIDI;
#endif // LIB_MIDI_H_
#endif // _FSE_LIB_MIDI_H_