From 8a7351c760b30077f562795500d88908e4da1932 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 3 Dec 2010 03:51:46 +0000 Subject: [PATCH] Added new completed MIDIToneGenerator project. --- LUFA.pnproj | 2 +- LUFA/ManPages/ChangeLog.txt | 4 +- LUFA/ManPages/LibraryApps.txt | 1 + .../MIDIToneGenerator/Descriptors.c | 0 .../MIDIToneGenerator/Descriptors.h | 0 .../MIDIToneGenerator/MIDIToneGenerator.c | 9 ++- .../MIDIToneGenerator/MIDIToneGenerator.h | 2 +- .../MIDIToneGenerator/MIDIToneGenerator.txt | 73 +++++++++++++++++++ .../MIDIToneGenerator/makefile | 6 +- Projects/makefile | 3 + 10 files changed, 89 insertions(+), 11 deletions(-) rename Projects/{Incomplete => }/MIDIToneGenerator/Descriptors.c (100%) rename Projects/{Incomplete => }/MIDIToneGenerator/Descriptors.h (100%) rename Projects/{Incomplete => }/MIDIToneGenerator/MIDIToneGenerator.c (92%) rename Projects/{Incomplete => }/MIDIToneGenerator/MIDIToneGenerator.h (96%) create mode 100644 Projects/MIDIToneGenerator/MIDIToneGenerator.txt rename Projects/{Incomplete => }/MIDIToneGenerator/makefile (96%) diff --git a/LUFA.pnproj b/LUFA.pnproj index f76876091d..07b805233b 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 025e5bfd9f..d213b1b3ae 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -9,7 +9,7 @@ * \section Sec_ChangeLogXXXXXX Version XXXXXX * New: * - Core: - * - None + * - Added new MIDIToneGenerator project * - Library Applications: * - Added new incomplete MIDIToneGenerator project * - Added ability to write protect Mass Storage disk write operations from the host OS @@ -25,7 +25,7 @@ * Fixed: * - Core: * - Fixed broken USBFOO board drivers due to missing BOARD_USBFOO define - * - Fixed HID hpst class driver incorrectly binding to HID devices that do not have an OUT endpoint + * - Fixed HID host class driver incorrectly binding to HID devices that do not have an OUT endpoint * - Library Applications: * - Fixed Benito project discarding incoming data from the USB virtual serial port when the USART is busy * - Fixed broken DFU bootloader, added XPLAIN support for bootloader start when XCK jumpered to ground diff --git a/LUFA/ManPages/LibraryApps.txt b/LUFA/ManPages/LibraryApps.txt index 0f64345f99..98ccfc270d 100644 --- a/LUFA/ManPages/LibraryApps.txt +++ b/LUFA/ManPages/LibraryApps.txt @@ -102,6 +102,7 @@ * - Benito - Benito Board Arduino Programmer project * - LEDNotifier - USB LED Notification project * - Magstripe - Magnetic Stripe Card Reader project + * - MIDIToneGenerator - MIDI Note Tone Generator project * - MissileLaucher - Toy Missile Launcher Host project * - RelayBoard - Relay board controller, controllable via the "sismpctl" Linux application * - TempDataLogger - Temperature Datalogging project, using the FatFS library diff --git a/Projects/Incomplete/MIDIToneGenerator/Descriptors.c b/Projects/MIDIToneGenerator/Descriptors.c similarity index 100% rename from Projects/Incomplete/MIDIToneGenerator/Descriptors.c rename to Projects/MIDIToneGenerator/Descriptors.c diff --git a/Projects/Incomplete/MIDIToneGenerator/Descriptors.h b/Projects/MIDIToneGenerator/Descriptors.h similarity index 100% rename from Projects/Incomplete/MIDIToneGenerator/Descriptors.h rename to Projects/MIDIToneGenerator/Descriptors.h diff --git a/Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.c b/Projects/MIDIToneGenerator/MIDIToneGenerator.c similarity index 92% rename from Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.c rename to Projects/MIDIToneGenerator/MIDIToneGenerator.c index c8e06bed48..d55838494e 100644 --- a/Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.c +++ b/Projects/MIDIToneGenerator/MIDIToneGenerator.c @@ -109,7 +109,7 @@ int main(void) LRUNoteStruct = &NoteData[i]; break; } - else if (NoteData[i].LRUAge > LRUNoteStruct->LRUAge) + else if (NoteData[i].LRUAge >= LRUNoteStruct->LRUAge) { /* If an older entry that the current entry has been found, prefer overwriting that one */ LRUNoteStruct = &NoteData[i]; @@ -161,9 +161,14 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) /* Sum together all the active notes to form a single sample */ for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++) { + /* A non-zero pitch indicates the note is active */ if (NoteData[i].Pitch) { - MixedSample += SineTable[NoteData[i].TablePosition >> 24]; + /* Use the top 8 bits of the table position as the sample table index */ + uint8_t TableIndex = ((uint8_t*)&NoteData[i].TablePosition)[3]; + + /* Add the new tone sample to the accumulator and increment the table position */ + MixedSample += SineTable[TableIndex]; NoteData[i].TablePosition += NoteData[i].TableIncrement; } } diff --git a/Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.h b/Projects/MIDIToneGenerator/MIDIToneGenerator.h similarity index 96% rename from Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.h rename to Projects/MIDIToneGenerator/MIDIToneGenerator.h index 2936ca2c7f..97f9077555 100644 --- a/Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.h +++ b/Projects/MIDIToneGenerator/MIDIToneGenerator.h @@ -95,7 +95,7 @@ uint8_t Pitch; uint32_t TableIncrement; uint32_t TablePosition; - } DDSNoteData; + } DDSNoteData; /* Function Prototypes: */ void SetupHardware(void); diff --git a/Projects/MIDIToneGenerator/MIDIToneGenerator.txt b/Projects/MIDIToneGenerator/MIDIToneGenerator.txt new file mode 100644 index 0000000000..447ed70019 --- /dev/null +++ b/Projects/MIDIToneGenerator/MIDIToneGenerator.txt @@ -0,0 +1,73 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \mainpage MIDI Tone Generator Project + * + * \section SSec_Compat Project Compatibility: + * + * The following list indicates what microcontrollers are compatible with this project. + * + * - Series 7 USB AVRs (AT90USBxxx7) + * - Series 6 USB AVRs (AT90USBxxx6) + * - Series 4 USB AVRs (ATMEGAxxU4) + * + * \section SSec_Info USB Information: + * + * The following table gives a rundown of the USB utilization of this project. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
USB Mode:Device
USB Class:Audio Class
USB Subclass:Standard Audio Device
Relevant Standards:USBIF Audio Class Specification \n + * USB-MIDI Audio Class Extension Specification \n + * General MIDI Specification
Usable Speeds:Full Speed Mode
+ * + * \section SSec_Description Project Description: + * + * MIDI note synthesiser project. This project implements a basic DDS frequency synthesiser, capable of producing 8-bit PWM sine + * waves of variable frequency. When attached to a USB host, this project will allow for multiple MIDI notes to be synthesised into + * audiable sound via PWM, using the notes sent to MIDI channel 1. + * + * Outgoing audio will output in 8-bit PWM onto the timer 3 output compare channel A. Decouple the audio output with a capacitor + * and attach to a speaker to hear the audio. + * + * \section SSec_Options Project Options + * + * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value. + * + * + * + * + * + * + * + * + * + * + * + * + *
Define Name:Location:Description:
MAX_SIMULTANEOUS_NOTESMIDIToneGenerator.hSets the maximum number of MIDI notes that can be generated simultaneously. More notes require more processing time, + * and thus a value that is too high will cause audiable sound distortion due to insufficient CPU time.
+ */ + diff --git a/Projects/Incomplete/MIDIToneGenerator/makefile b/Projects/MIDIToneGenerator/makefile similarity index 96% rename from Projects/Incomplete/MIDIToneGenerator/makefile rename to Projects/MIDIToneGenerator/makefile index 71507f5bb4..a89cbb1007 100644 --- a/Projects/Incomplete/MIDIToneGenerator/makefile +++ b/Projects/MIDIToneGenerator/makefile @@ -112,7 +112,7 @@ OBJDIR = . # Path to the LUFA library -LUFA_PATH = ../../../ +LUFA_PATH = ../../ # LUFA library compile-time options and predefined tokens @@ -122,10 +122,6 @@ LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 LUFA_OPTS += -D USE_FLASH_DESCRIPTORS LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -LUFA_OPTS += -D AUDIO_OUT_STEREO -#LUFA_OPTS += -D AUDIO_OUT_MONO -#LUFA_OPTS += -D AUDIO_OUT_PORTC - # Create the LUFA source path variables by including the LUFA root makefile include $(LUFA_PATH)/LUFA/makefile diff --git a/Projects/makefile b/Projects/makefile index 5498877737..223896115c 100644 --- a/Projects/makefile +++ b/Projects/makefile @@ -26,6 +26,9 @@ all: $(MAKE) -C Magstripe clean $(MAKE) -C Magstripe all + $(MAKE) -C MIDIToneGenerator clean + $(MAKE) -C MIDIToneGenerator all + $(MAKE) -C MissileLauncher clean $(MAKE) -C MissileLauncher all