12-polyphonic "chiptune" MIDI synthesizer for LPC1768 (Standalone version)

Dependencies:   ClockControl PowerControl mbed

Revision:
4:b2423ad4b248
Parent:
0:727737138ac5
--- a/Instrument.cpp	Tue Nov 18 17:05:49 2014 +0000
+++ b/Instrument.cpp	Tue Dec 09 15:04:13 2014 +0000
@@ -53,7 +53,6 @@
 /** Set wave frequency */
 void Instrument::setFrequency(uint16_t f) {
     this->frequency = f;
-    this->duration = 0;     // Reset duration
     calculatePhaseDelta();  // Recalculate phase delta
 }
 
@@ -75,6 +74,11 @@
     calculateMasterVolume();
 }
 
+/** Reset sounding duration to zero */
+void Instrument::resetDuration() {
+    this->duration = 0;
+}
+
 /** Get sampling rate */
 uint16_t Instrument::getSamplingRate() {
     return this->samplingRate;
@@ -145,7 +149,7 @@
 
 /** (Re)calculate phase delta per sample */
 void Instrument::calculatePhaseDelta() {
-    phase = 0x0000;
+    // phase = 0x0000;
     phaseDelta = (uint16_t) ((uint32_t) frequency * WAVETABLE_LENGTH * 256
                              / samplingRate);
 }