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_wavefuncs.cpp	Sat Mar 23 19:22:35 2019 +0000
+++ b/POKITTO_LIBS/Synth/Synth_wavefuncs.cpp	Sat Mar 23 20:03:34 2019 +0000
@@ -42,7 +42,7 @@
 void noADSR(OSC* o); void attackFunc(OSC* o); void decayFunc(OSC* o); void releaseFunc(OSC* o);
 void mix1(); void mix2(); void mix3(); void updateEnvelopes();
 
-waveFunction Farr []  = {waveoff, sqwave, sawwave, triwave, noise, tonenoise};
+waveFunction Farr []  = {waveoff, sqwave, sawwave, triwave, noise, tonenoise, sample};
 envFunction Earr [] = {noADSR, attackFunc, decayFunc, releaseFunc};
 mixFunction Marr [] = {updateEnvelopes,mix3,mix2,mix1}; // counts down
 mixFunction HWMarr [] = {updateEnvelopes,mix3,mix2,mix1}; // counts down
@@ -97,14 +97,15 @@
 }
 
 void sample(OSC* o) {
-
-    /*if (o->samplepos > o->samplelength ) o->samplepos = 0;
-
-    if (o->count > o->wcycle) {
-        o->count=0;
-        if (o->output) o->output = 0;
-        //else o->output = o->output=pgm_read_byte((uint32_t)(sfxBike) + o->inccount);
-    }*/
+    if (sample==NULL) o->output = 0;
+    else {
+          o->samplepos+=o->samplestep;
+          if ((o->samplepos>>8) > o->samplelength ) {
+                o->samplepos = 0;
+                if (o->loop == 0) o->duration=0;
+          }
+          o->output = *(o->sample + (o->samplepos>>8))<<8;
+    }
 }