Unable to compile Mozzi example for Teensy 3.2

Status
Not open for further replies.

SadSteve

New member
I'm trying to get started with Mozzi on a Teensy 3.2, but I'm getting some errors right off the bat trying to compile the example code. The issue seems to be related the ADC library. I got the library with the latest install of Teensyduino (1.51) yesterday, and I'm trying to compile within the Arduino 1.8.12 editor. I'm also on the latest build of Mozzi, from 22 July 2019. Here's the code:

Code:
#include <ADC.h>

/*  Example playing a sinewave at a set frequency,
    using Mozzi sonification library.

    Demonstrates the use of Oscil to play a wavetable.

    Circuit: Audio output on digital pin 9 on a Uno or similar, or
    DAC/A14 on Teensy 3.1, or
    check the README or http://sensorium.github.com/Mozzi/

    Mozzi documentation/API
		https://sensorium.github.io/Mozzi/doc/html/index.html

		Mozzi help/discussion/announcements:
    https://groups.google.com/forum/#!forum/mozzi-users

    Tim Barrass 2012, CC by-nc-sa.
*/

#include <MozziGuts.h>
#include <Oscil.h> // oscillator template
#include <tables/sin2048_int8.h> // sine table for oscillator

// use: Oscil <table_size, update_rate> oscilName (wavetable), look in .h file of table #included above
Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin(SIN2048_DATA);

// use #define for CONTROL_RATE, not a constant
#define CONTROL_RATE 64 // Hz, powers of 2 are most reliable


void setup(){
  startMozzi(CONTROL_RATE); // :)
  aSin.setFreq(440); // set the frequency
}


void updateControl(){
  // put changing controls in here
}


int updateAudio(){
  return aSin.next(); // return an int signal centred around 0
}


void loop(){
  audioHook(); // required here
}

This should be identical to the sinewave example provided with Mozzi, with the addition of the ADC include up top. I did try compiling without it and got the same results. Here's my error output:

Code:
Arduino: 1.8.12 (Windows 10), TD: 1.51, Board: "Teensy 3.2 / 3.1, Serial, 48 MHz, Fast, US English"

C:\Program Files (x86)\Arduino\libraries\Mozzi-master\MozziGuts.cpp: In function 'void startAudioStandard()':

C:\Program Files (x86)\Arduino\libraries\Mozzi-master\MozziGuts.cpp:503:8: error: 'class ADC' has no member named 'setAveraging'

   adc->setAveraging(0);

        ^

C:\Program Files (x86)\Arduino\libraries\Mozzi-master\MozziGuts.cpp:504:8: error: 'class ADC' has no member named 'setConversionSpeed'

   adc->setConversionSpeed(

        ^

C:\Program Files (x86)\Arduino\libraries\Mozzi-master\mozzi_analog.cpp: In function 'void setupMozziADC(int8_t)':

C:\Program Files (x86)\Arduino\libraries\Mozzi-master\mozzi_analog.cpp:74:7: error: 'class ADC' has no member named 'enableInterrupts'

  adc->enableInterrupts(ADC_0);

       ^

C:\Program Files (x86)\Arduino\libraries\Mozzi-master\mozzi_analog.cpp: At global scope:

C:\Program Files (x86)\Arduino\libraries\Mozzi-master\mozzi_analog.cpp:140:13: warning: 'void adcSetChannel(uint8_t)' defined but not used [-Wunused-function]

 static void adcSetChannel(uint8_t channel) {

             ^

Error compiling for board Teensy 3.2 / 3.1.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
If it helps, verbose output here for the sake of brevity. Seems like it gets caught up compiling Mozzi itself because some things are missing from ADC, but this is the latest that came from the Teensyduino install and trying to manually download it and rip the Teensyduino version out didn't help. I've scoured the forums here and elsewhere looking for an answer and the only other person I saw who had issues compiling for a 3.2 just downloaded the latest Mozzi and it worked no problem. Maybe I'm just using the wrong search terms but that's all I found. I'm at a complete loss on how to move forward, any guidance? Is this sufficient info? Figured wire diagrams et cetera wouldn't have much bearing on this but I can write all that up if it helps. Thanks!
 
Last edited:
Yep the owner of the library changed the top level interface and removed most if not all of the methods that have a parameter of which ADC to update.

So lines like:
Code:
adc->enableInterrupts(ADC_0);

should now be:
Code:
adc->adc0.enableInterrupts();
 
Status
Not open for further replies.
Back
Top