Fix incorrect macro guard in the UC3 EndpointStream header file.
[pub/USBasp.git] / Projects / MIDIToneGenerator / MIDIToneGenerator.c
index d558384..e1008a7 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2010.\r
+     Copyright (C) Dean Camera, 2011.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
@@ -57,7 +57,7 @@ USB_ClassInfo_MIDI_Device_t Keyboard_MIDI_Interface =
        };\r
 \r
 /** 8-bit 256 entry Sine Wave lookup table */\r
        };\r
 \r
 /** 8-bit 256 entry Sine Wave lookup table */\r
-const uint8_t SineTable[256] =\r
+static const uint8_t SineTable[256] =\r
 {\r
        128, 131, 134, 137, 140, 143, 146, 149, 152, 156, 159, 162, 165, 168, 171, 174,\r
        176, 179, 182, 185, 188, 191, 193, 196, 199, 201, 204, 206, 209, 211, 213, 216,\r
 {\r
        128, 131, 134, 137, 140, 143, 146, 149, 152, 156, 159, 162, 165, 168, 171, 174,\r
        176, 179, 182, 185, 188, 191, 193, 196, 199, 201, 204, 206, 209, 211, 213, 216,\r
@@ -78,7 +78,8 @@ const uint8_t SineTable[256] =
 };\r
 \r
 /** Array of structures describing each note being generated */\r
 };\r
 \r
 /** Array of structures describing each note being generated */\r
-DDSNoteData NoteData[MAX_SIMULTANEOUS_NOTES];\r
+static DDSNoteData NoteData[MAX_SIMULTANEOUS_NOTES];\r
+\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
  *  setup of all components and the main program loop.\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
  *  setup of all components and the main program loop.\r
@@ -165,7 +166,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
                if (NoteData[i].Pitch)\r
                {\r
                        /* Use the top 8 bits of the table position as the sample table index */\r
                if (NoteData[i].Pitch)\r
                {\r
                        /* Use the top 8 bits of the table position as the sample table index */\r
-                       uint8_t TableIndex = ((uint8_t*)&NoteData[i].TablePosition)[3];\r
+                       uint8_t TableIndex = (NoteData[i].TablePosition >> 24);\r
                        \r
                        /* Add the new tone sample to the accumulator and increment the table position */\r
                        MixedSample += SineTable[TableIndex];\r
                        \r
                        /* Add the new tone sample to the accumulator and increment the table position */\r
                        MixedSample += SineTable[TableIndex];\r