Troubles compiling with Teensy 4.1

499 views
Skip to first unread message

Gary White

unread,
Oct 26, 2021, 2:39:48 PM10/26/21
to Mozzi-users
Hey Mozzi-Users!

I've just picked up a Teensy 4.1 & was hoping to use it with the Mozzi library...  does anyone know if it's compatible?

I've been trying to run some of the example sketches but I've been failing to get it to compile.  I've re-installed everything to the latest versions: Arduino (1.8.16), teensyDuino, Mozzi & 47 effects midi library and still no luck.

I've added the #include <ADC.h> to the top of the file and it actually creates more errors than without it.  So far using the LowPassFilter example sketch I'm getting the following error;

In file included from C:\Users\User\Documents\Arduino\libraries\STM32ADC\src/STM32ADC.h:1:0,
Multiple libraries were found for "ADC.h"
                 from C:\Users\User\Documents\Arduino\libraries\Mozzi-master/hardware_defines.h:50,
 Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ADC
                 from C:\Users\User\Documents\Arduino\libraries\Mozzi-master/MozziGuts.h:23,
 Not used: C:\Users\User\Documents\Arduino\libraries\ADC-master
                 from C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_332184\LowPassFilter.ino:23:
C:\Users\User\Documents\Arduino\libraries\STM32ADC\src/utility/util_adc.h:8:26: fatal error: libmaple/adc.h: No such file or directory
compilation terminated.
Error compiling for board Teensy 4.1.

Originally before I updated to the latest versions it asked for 'hardwaretimer.h', and then after updating it asked for stm32adc.h.  I found this and installed it & now it appears to be asking for 'libmaple/adc.h' .  These last two appear to be used with the STM32 series of processors...  it's taken me a little while to get to this point, so I thought I'd ask if anyone else has had success before I keep heading down the rabbit hole...

Thanks in advance!

Gary

tomco...@live.fr

unread,
Oct 27, 2021, 2:30:24 PM10/27/21
to Mozzi-users
Hei,

There is a hive mind in there! A pull request has been recently posted ( https://github.com/sensorium/Mozzi/pull/138 ) to allow support of Teensy4X series and could use some testings!
This as been tested with Teensy3.2 and Teensy4.0 (the latter should be fully compatible with 4.1 as the base chip is the same) so far. LC seems to have some troubles thought…
The default output is PWM on pin A8, but an external output chip can also be used. You can try before it is merged in plain mozzi by cloning the tomcombriat:Teensy4X branch.

Hope it helps,
Tom

Gary White

unread,
Oct 28, 2021, 10:39:23 AM10/28/21
to Mozzi-users
Hey Tom,

Thanks for the help, I'll see if I can get it running this weekend & let you know how it goes.

Thanks again,

Gary

Gary White

unread,
Oct 31, 2021, 9:33:10 AM10/31/21
to Mozzi-users
Hi again,

It compiles!  Unfortunately I'm getting a few errors though  (just be aware, it might be me causing them!)

I've only had chance to test a few of the example Mozzi sketches but here's what I found;

The mozzi home page says to add #include <ADC.h> for teensy 2.0 through to 3.6,  but I found it didn't make a difference if it was included or not with 4.1.  Should I be adding this?

Tested with latest teensyduino, Arduino 1.8.16 and Mozzi Teensy4x port #138

FMSynth -  Works OK
LowPassFilter - compiles but seems to be distorted (I can't remember the Arduino Uno sounding like this but I could be wrong)
Control_Oscil_Wash - Works OK
Control_Tremelo -failed to compile -> error -> 
Arduino: 1.8.16 (Windows 10), TD: 1.55, Board: "Teensy 4.1, Serial, 600 MHz, Faster, US English"
In file included from C:\Users\User\Documents\Arduino\libraries\Mozzi/MozziGuts.h:195:0,
from C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_88275\Control_Tremelo.ino:25:
C:\Users\User\Documents\Arduino\libraries\Mozzi/AudioConfigTeensy4_10bitPwm.h:4:2: warning: #warning If you get a compilation error you should probably update Teensyduino to its latest version [-Wcpp]
#warning If you get a compilation error you should probably update Teensyduino to its latest version  ^
Control_Tremelo: In function 'int updateAudio()':
Control_Tremelo:60: error: call of overloaded 'fromNBit(int, long unsigned int)' is ambiguous
   return MonoOutput::fromNBit(24, (int32_t) aSig.next() * aGain.next()); // shifted back to audio range after multiply
In file included from C:\Users\User\Documents\Arduino\libraries\Mozzi/MozziGuts.h:223:0,
                 from C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_88275\Control_Tremelo.ino:25:
C:\Users\User\Documents\Arduino\libraries\Mozzi/AudioOutput.h:157:28: note: candidate: static MonoOutput MonoOutput::fromNBit(uint8_t, int16_t)
   static inline MonoOutput fromNBit(uint8_t bits, int16_t l) { return MonoOutput(SCALE_AUDIO(l, bits)); }
C:\Users\User\Documents\Arduino\libraries\Mozzi/AudioOutput.h:159:28: note: candidate: static MonoOutput MonoOutput::fromNBit(uint8_t, int32_t)
   static inline MonoOutput fromNBit(uint8_t bits, int32_t l) { return MonoOutput(SCALE_AUDIO(l, bits)); }
call of overloaded 'fromNBit(int, long unsigned int)' is ambiguous

LowPassFilteX2 = Did not compile;
Arduino: 1.8.16 (Windows 10), TD: 1.55, Board: "Teensy 4.1, Serial, 600 MHz, Faster, US English"
In file included from C:\Users\User\Documents\Arduino\libraries\Mozzi/MozziGuts.h:195:0,
                 from C:\Users\User\Documents\Arduino\libraries\Mozzi\examples\10.Audio_Filters\LowPassFilterX2\LowPassFilterX2.ino:19:
C:\Users\User\Documents\Arduino\libraries\Mozzi/AudioConfigTeensy4_10bitPwm.h:4:2: warning: #warning If you get a compilation error you should probably update Teensyduino to its latest version [-Wcpp]
 #warning If you get a compilation error you should probably update Teensyduino to its latest version
LowPassFilterX2: In function 'int updateAudio()':
LowPassFilterX2:57: error: expected ')' before ';' token
   return MonoOutput::fromAlmostNBit(9, (((char)lpf1.next(aCrunchySound1.next()))>>1) + (char)lpf2.next(aCrunchySound2.next());
expected ')' before ';' token

StateVariableFilter = Did not compile;
Arduino: 1.8.16 (Windows 10), TD: 1.55, Board: "Teensy 4.1, Serial, 600 MHz, Faster, US English"
In file included from C:\Users\User\Documents\Arduino\libraries\Mozzi/MozziGuts.h:195:0,
                 from C:\Users\User\Documents\Arduino\libraries\Mozzi\examples\10.Audio_Filters\StateVariableFilter\StateVariableFilter.ino:19:
C:\Users\User\Documents\Arduino\libraries\Mozzi/AudioConfigTeensy4_10bitPwm.h:4:2: warning: #warning If you get a compilation error you should probably update Teensyduino to its latest version [-Wcpp]
 #warning If you get a compilation error you should probably update Teensyduino to its latest version
StateVariableFilter: In function 'int updateAudio()':
StateVariableFilter:55: error: call of overloaded 'fromAlmostNBit(int, int)' is ambiguous
   return MonoOutput::fromAlmostNBit(12, svf.next(aNoise.next()));
In file included from C:\Users\User\Documents\Arduino\libraries\Mozzi/MozziGuts.h:223:0,
                 from C:\Users\User\Documents\Arduino\libraries\Mozzi\examples\10.Audio_Filters\StateVariableFilter\StateVariableFilter.ino:19:
C:\Users\User\Documents\Arduino\libraries\Mozzi/AudioOutput.h:173:28: note: candidate: static MonoOutput MonoOutput::fromAlmostNBit(uint8_t, int16_t)
   static inline MonoOutput fromAlmostNBit(uint8_t bits, int16_t l) { return MonoOutput(SCALE_AUDIO_NEAR(l, bits)); }
C:\Users\User\Documents\Arduino\libraries\Mozzi/AudioOutput.h:175:28: note: candidate: static MonoOutput MonoOutput::fromAlmostNBit(uint8_t, int32_t)
static inline MonoOutput fromAlmostNBit(uint8_t bits, int32_t l) { return MonoOutput(SCALE_AUDIO_NEAR(l, bits)); }
 call of overloaded 'fromAlmostNBit(int, int)' is ambiguous

These were all unmodified sketches, so I don't think it's me causing the compile errors, but if I'm doing something wrong please let me know.  I tried loading a few of my own sketches and they all compiled ok (although I didn't have any pots connected or MIDI keyboards added). 

Thanks for taking the time to update the library!

Gary

tomco...@live.fr

unread,
Oct 31, 2021, 1:53:43 PM10/31/21
to Mozzi-users
Hi,

Thanks for testing! I have to say that I am happy that it seems to work with 4.1!
About the errors: except LowPassFilterX2 which has a missing parenthesis (I spot that a little while ago but did not take the time to correct it, sorry), all the others seem to be related with a problem between 32bits platform and the fromAlmostNBit function.
I'll raise an issue in Git to find out the best way to resolve that but meanwhile if you need that function on Teensy just add a manual cast on 32 (or 16 if you are not using more than that, there is no difference in perf for Teensy), for instance:
  return MonoOutput::fromAlmostNBit(12, svf.next(aNoise.next()));
should become
  return MonoOutput::fromAlmostNBit(12, (int32_t) svf.next(aNoise.next()));

Last thing, I think the include<ADC.h> is a remain of from long time ago. The current PR for Teensy4.X will probably also affect the information on this page.

Thanks for the feedback!

Gary White

unread,
Nov 1, 2021, 8:19:52 AM11/1/21
to Mozzi-users
Great stuff, thanks for the tip.  If you'd like me to test anything else just let me know.

Thanks again,

Gary

Reply all
Reply to author
Forward
0 new messages