sensorium / Mozzi

sound synthesis library for Arduino
https://sensorium.github.io/Mozzi/
GNU Lesser General Public License v2.1
1.07k stars 186 forks source link

Fix compilation for Teensy3 #137

Closed tomcombriat closed 2 years ago

tomcombriat commented 2 years ago

Mozzi would not compile with the new TeensyDuino (probably since the arrival of Teensy4). This is caused by a small change in the Teensy API regarding ADC.

This PR fix the problem and allow to use Mozzi on Teensy 3X with the newer Teensyduino. Note that this will probably won't compile for people still using the old Teensyduino. In that case a simple update of Teensyduino solves the problem.

tomcombriat commented 2 years ago

This also fix a frequency shift because of a rounding error in timer calculation.

tfry-git commented 2 years ago

Is it possible to check whether people have the old or new version of TeensyDuino?

tomcombriat commented 2 years ago

@tfry-git Not of my knowledge yet. Will let you know if I stumble into it. If that in the case, I would suggest putting a clear error message at compilation asking to update Teensyduino to avoid spilling further MozziGuts into different sub-teensy cases. Also, I suspect audio_input to be impacted, so let's just wait some time before considering merging.

The rounding error was present for both versions of Teensyduino. An easy fix as the intervaltimer supports floating numbers.

I am now trying to port Teensy4X (hence the update of Teensyduino). So far everything is very close to Teensy3, so I am using the same audio config file to avoid too much code duplication. If that works, might be worth switching this file to AudioConfigTeensy. I am standard PWM as default output mode, except some dropouts as regular intervals, which I suspect being a wrongly configured PWM frequency it seems to work.

tomcombriat commented 2 years ago

Will be superseded by #138