12-polyphonic "chiptune" MIDI synthesizer for LPC1768 (Standalone version)
Dependencies: ClockControl PowerControl mbed
Diff: main.cpp
- Revision:
- 2:ca10e33bde0a
- Parent:
- 1:5f0c89bffec1
- Child:
- 3:cf57d7031c12
diff -r 5f0c89bffec1 -r ca10e33bde0a main.cpp --- a/main.cpp Sun Nov 09 08:15:11 2014 +0000 +++ b/main.cpp Wed Nov 12 23:46:31 2014 +0000 @@ -14,7 +14,7 @@ Serial pc(/*Tx*/ USBTX, /*Rx*/ USBRX); Serial midiIn(/*Tx*/ p13, /*Rx*/ p14); Serial console(/*Tx*/ p28, /*Rx*/ p27); -DigitalIn swSerialSelect(); +DigitalIn swSerialSelect(p12); DigitalIn swPanic(p15); BusOut led(/*Left*/ LED1, LED2, LED3, LED4 /*Right*/); BusOut ledBar(p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p29, p30); @@ -33,7 +33,7 @@ void sampleOut() { dacCs = 0; - spi.write(0x3000 | gemCore.makeSample() >> 4); + spi.write(0x3000 | gemCore.makeSample(noteSent) >> 4); dacCs = 1; } @@ -71,7 +71,7 @@ #endif // Enable pull-up at switch inputs - // swSerialSelect.mode(PullUp); + swSerialSelect.mode(PullDown); swPanic.mode(PullUp); wait(0.2); // Wait a moment for stability @@ -118,11 +118,8 @@ t1ms.attach_us(&count1ms, 1000); // Start playback & attach interrupt -#if defined(POWER_SAVE) && defined(CLOCKUP) - tSample.attach_us(&sampleOut, 1250000 / GeminiCore::samplingRate); -#else - tSample.attach_us(&sampleOut, 1000000 / GeminiCore::samplingRate); -#endif + float clockUpRatio = SystemCoreClock / 96000000.0; + tSample.attach_us(&sampleOut, 1000000 * clockUpRatio / GeminiCore::samplingRate); } void consoleOperations(uint8_t c) {