- Permission to use, copy, modify, distribute, and sell this
+ Permission to use, copy, modify, distribute, and sell this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software without specific, written prior permission.
The author disclaim all warranties with regard to this
if ((ReceivedMIDIEvent.Command == (MIDI_COMMAND_NOTE_ON >> 4)) && ((ReceivedMIDIEvent.Data1 & 0x0F) == 0))
{
DDSNoteData* LRUNoteStruct = &NoteData[0];
if ((ReceivedMIDIEvent.Command == (MIDI_COMMAND_NOTE_ON >> 4)) && ((ReceivedMIDIEvent.Data1 & 0x0F) == 0))
{
DDSNoteData* LRUNoteStruct = &NoteData[0];
/* Find a free entry in the note table to use for the note being turned on */
for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++)
{
/* Find a free entry in the note table to use for the note being turned on */
for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++)
{
/* Update the oldest note entry with the new note data and reset its age */
LRUNoteStruct->Pitch = ReceivedMIDIEvent.Data2;
LRUNoteStruct->TableIncrement = (uint32_t)(BASE_INCREMENT * SCALE_FACTOR) +
/* Update the oldest note entry with the new note data and reset its age */
LRUNoteStruct->Pitch = ReceivedMIDIEvent.Data2;
LRUNoteStruct->TableIncrement = (uint32_t)(BASE_INCREMENT * SCALE_FACTOR) +
else if ((ReceivedMIDIEvent.Command == (MIDI_COMMAND_NOTE_OFF >> 4)) && ((ReceivedMIDIEvent.Data1 & 0x0F) == 0))
{
bool FoundActiveNote = false;
else if ((ReceivedMIDIEvent.Command == (MIDI_COMMAND_NOTE_OFF >> 4)) && ((ReceivedMIDIEvent.Data1 & 0x0F) == 0))
{
bool FoundActiveNote = false;
/* Find the note in the note table to turn off */
for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++)
{
/* Find the note in the note table to turn off */
for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++)
{
/* If all notes off, turn off the indicator LED */
if (!(FoundActiveNote))
LEDs_SetAllLEDs(LEDS_NO_LEDS);
}
}
/* If all notes off, turn off the indicator LED */
if (!(FoundActiveNote))
LEDs_SetAllLEDs(LEDS_NO_LEDS);
}
}
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
uint16_t MixedSample = 0;
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
uint16_t MixedSample = 0;
/* Sum together all the active notes to form a single sample */
for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++)
{
/* Sum together all the active notes to form a single sample */
for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++)
{
{
/* Use the top 8 bits of the table position as the sample table index */
uint8_t TableIndex = (NoteData[i].TablePosition >> 24);
{
/* Use the top 8 bits of the table position as the sample table index */
uint8_t TableIndex = (NoteData[i].TablePosition >> 24);
/* Add the new tone sample to the accumulator and increment the table position */
MixedSample += SineTable[TableIndex];
NoteData[i].TablePosition += NoteData[i].TableIncrement;
}
}
/* Add the new tone sample to the accumulator and increment the table position */
MixedSample += SineTable[TableIndex];
NoteData[i].TablePosition += NoteData[i].TableIncrement;
}
}
/* Output clamped mixed sample value to the PWM */
OCR3A = (MixedSample <= 0xFF) ? MixedSample : 0xFF;
}
/* Output clamped mixed sample value to the PWM */
OCR3A = (MixedSample <= 0xFF) ? MixedSample : 0xFF;
}
bool ConfigSuccess = true;
ConfigSuccess &= MIDI_Device_ConfigureEndpoints(&Keyboard_MIDI_Interface);
bool ConfigSuccess = true;
ConfigSuccess &= MIDI_Device_ConfigureEndpoints(&Keyboard_MIDI_Interface);