Jonne Valola / PokittoLib Featured

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Revision:
66:6281a40d73e6
Parent:
31:f4b9b85c7b62
--- a/POKITTO_LIBS/Synth/Synth_mixfuncs.cpp	Sat Mar 23 19:22:35 2019 +0000
+++ b/POKITTO_LIBS/Synth/Synth_mixfuncs.cpp	Sat Mar 23 20:03:34 2019 +0000
@@ -48,12 +48,12 @@
     // Track 1
     if (osc1.on) {
     Farr[osc1.wave](&osc1);
-    #if PROJ_ARDUBOY > 0
+    //#if PROJ_ARDUBOY > 0
     if (osc1.duration) {
         /**this is special for osc1 and is only used to emulate arduino Tone(); */
         osc1.duration--;
     } else osc1.on = 0;
-    #endif
+    //#endif
 
     #ifdef POK_SIM
     soundbyte = (((osc1.output>>8) * (osc1.adsrvol >>8 )) >> 8) >> osc1.echodiv; // To output, shift back to 8-bit
@@ -76,6 +76,10 @@
     // Track 2
     if (osc2.on) {
     Farr[osc2.wave](&osc2);
+    if (osc2.duration) {
+        osc2.duration--;
+    } else osc2.on = 0;
+
     #ifdef POK_SIM
     soundbyte = (((osc2.output>>8) * (osc2.adsrvol >>8 )) >> 8) >> osc2.echodiv;
     if (osc2.overdrive) soundbyte *= OVERDRIVE;
@@ -97,6 +101,9 @@
     // Track 3
     if (osc3.on) {
     Farr[osc3.wave](&osc3);
+    if (osc3.duration) {
+        osc3.duration--;
+    } else osc3.on = 0;
     #ifdef POK_SIM
     soundbyte = (((osc3.output>>8) * (osc3.adsrvol >>8 )) >> 8) >> osc3.echodiv;
     if (osc3.overdrive) soundbyte *= OVERDRIVE;
@@ -116,7 +123,11 @@
 
 void updateEnvelopes(){
     //calculate volume envelopes, I do this to save cpu power
+    #if POK_ALT_MIXING > 0
     if (arptick) --arptick;
+    #else
+    if (arptick) --arptick;
+    #endif
     else {
             if (osc1.arpmode && osc1.on) {
                 osc1.cinc = cincs[osc1.tonic+arptable[osc1.arpmode][osc1.arpstep]];
@@ -139,11 +150,25 @@
 
     }
 
+    #if POK_ALT_MIXING > 0
     if (voltick) --voltick;
+    #else
+    if (voltick) --voltick;
+    #endif
     else {
             bendtick = !bendtick;
             if (osc1.on) Earr[osc1.adsrphase](&osc1);
-            if (bendtick) osc1.pitchbend += osc1.bendrate; //slow bend to every second beat
+            if (bendtick) {
+                    osc1.pitchbend += osc1.bendrate; //slow bend to every second beat
+                    /*if (osc1.wave == 6 && osc1.bendrate) {
+                        if (osc1.samplebendtick > osc1.samplebendcount) {
+                            if (osc1.bendrate>0) osc1.samplestep++;
+                            else if (osc1.bendrate<0) osc1.samplestep--;
+                            osc1.samplebendtick=0;
+                        } else osc1.samplebendtick++;
+
+                    }*/
+            }
             if (osc1.bendrate > 0 && osc1.pitchbend > osc1.maxbend) {
                     osc1.pitchbend = osc1.maxbend;
                     osc1.bendrate = 0; // STOP BENDING !