diff --git a/Karplus_Strong/Karplus_Strong.ino b/Karplus_Strong/Karplus_Strong.ino index a5d7136..071f75e 100644 --- a/Karplus_Strong/Karplus_Strong.ino +++ b/Karplus_Strong/Karplus_Strong.ino @@ -14,7 +14,6 @@ Adafruit_MCP4728 mcp; unsigned int phase; unsigned int repeats; - void setup() { Serial.begin(115200); @@ -25,18 +24,17 @@ void setup() { } } -// mcp.setSpeed(400000L); -// mcp.setSpeed(800000L); + randomSeed(analogRead(A0)); mcp.setSpeed(800000L); phase=0; - pluck(); } byte waveform[nsamp]; + + void pluck(){ - Serial.println("pluck"); - for (int i=0; i nsamp ) { + if( phase >= nsamp ) { phase = 0; repeats += 1; } @@ -54,9 +52,8 @@ void loop() { waveform[p0] = ( s1 & s2 ) + ((s1 ^ s2) >> 1); mcp.fastWrite(s1 << 4, 0, 0, 0); if( repeats > 100 ) { - pluck(); - repeats = 0; - + pluck(); + repeats = 0; } }