diff options
Diffstat (limited to 'Projects')
-rw-r--r-- | Projects/MIDIToneGenerator/Descriptors.c (renamed from Projects/Incomplete/MIDIToneGenerator/Descriptors.c) | 0 | ||||
-rw-r--r-- | Projects/MIDIToneGenerator/Descriptors.h (renamed from Projects/Incomplete/MIDIToneGenerator/Descriptors.h) | 0 | ||||
-rw-r--r-- | Projects/MIDIToneGenerator/MIDIToneGenerator.c (renamed from Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.c) | 9 | ||||
-rw-r--r-- | Projects/MIDIToneGenerator/MIDIToneGenerator.h (renamed from Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.h) | 2 | ||||
-rw-r--r-- | Projects/MIDIToneGenerator/MIDIToneGenerator.txt | 73 | ||||
-rw-r--r-- | Projects/MIDIToneGenerator/makefile (renamed from Projects/Incomplete/MIDIToneGenerator/makefile) | 6 | ||||
-rw-r--r-- | Projects/makefile | 3 |
7 files changed, 85 insertions, 8 deletions
diff --git a/Projects/Incomplete/MIDIToneGenerator/Descriptors.c b/Projects/MIDIToneGenerator/Descriptors.c index 505ea4aef..505ea4aef 100644 --- a/Projects/Incomplete/MIDIToneGenerator/Descriptors.c +++ b/Projects/MIDIToneGenerator/Descriptors.c diff --git a/Projects/Incomplete/MIDIToneGenerator/Descriptors.h b/Projects/MIDIToneGenerator/Descriptors.h index b56fb6ff6..b56fb6ff6 100644 --- a/Projects/Incomplete/MIDIToneGenerator/Descriptors.h +++ b/Projects/MIDIToneGenerator/Descriptors.h diff --git a/Projects/Incomplete/MIDIToneGenerator/MIDIToneGenerator.c b/Projects/MIDIToneGenerator/MIDIToneGenerator.c index c8e06bed4..d55838494 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 index 2936ca2c7..97f907755 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 000000000..447ed7001 --- /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.
+ *
+ * <table>
+ * <tr>
+ * <td><b>USB Mode:</b></td>
+ * <td>Device</td>
+ * </tr>
+ * <tr>
+ * <td><b>USB Class:</b></td>
+ * <td>Audio Class</td>
+ * </tr>
+ * <tr>
+ * <td><b>USB Subclass:</b></td>
+ * <td>Standard Audio Device</td>
+ * </tr>
+ * <tr>
+ * <td><b>Relevant Standards:</b></td>
+ * <td>USBIF Audio Class Specification \n
+ * USB-MIDI Audio Class Extension Specification \n
+ * General MIDI Specification</td>
+ * </tr>
+ * <tr>
+ * <td><b>Usable Speeds:</b></td>
+ * <td>Full Speed Mode</td>
+ * </tr>
+ * </table>
+ *
+ * \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.
+ *
+ * <table>
+ * <tr>
+ * <td><b>Define Name:</b></td>
+ * <td><b>Location:</b></td>
+ * <td><b>Description:</b></td>
+ * </tr>
+ * <tr>
+ * <td>MAX_SIMULTANEOUS_NOTES</td>
+ * <td>MIDIToneGenerator.h</td>
+ * <td>Sets 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.</td>
+ * </tr>
+ * </table>
+ */
+
diff --git a/Projects/Incomplete/MIDIToneGenerator/makefile b/Projects/MIDIToneGenerator/makefile index 71507f5bb..a89cbb100 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 549887773..223896115 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 |