I almost gave up on this. I was getting nowhere but just today i figured out what i was doing wrong and now have a preliminary test version that works. Shagmatic follows music now. Motion can be made to follow the beat of music from any source. Currently i am using an audio recorder but the audio board and also the Teensy 3.5 both have SD card sockets that can be used to supply the music source. I can also use a microphone input so it can follow music or audio instructions such as voice or clapping.
The beat following algorithm is subject to improvement. I also plan to use the three knob controller to allow for modifications to the motion while following the beat. Sensitivity, and stroke magnification are possibilities as well as offset control. The demo shows the Shagmatic running the full program with the three knob controller disabled due to a pin conflict. This can be resolved easily by using a few of the many extra pins available on the Teensy 3.5. The Teensy 3.5 is so fast it has no problem analyzing the audio (using the audio board that has the digital signal processor on it) and taking care of all the regular Shagmatic functions. The Teensy 3.6 would be even faster. I plan to try some FFT analysis to improve the beat following. Currently it just responds to peaks but with FFT i can narrow the focus. This could be another variable controllable by the three knob or other controller. I can’t wait to test this new function personally.
The possibilities are endless. It is also possible to make up steady tone files in an audio editing program such as Audacity and to edit them to produce files that ill run the machine. These could also be put on the SD card and could be chosen by name if a touch screen is added. For now it is convenient to test with the audio recorder. Click on the link below to view in your browser. If you have a slow connection, it may be best to right click (sorry Mac users) and save the target and play offline.