Issue with Audio on T4.1

nubie

Active member
I used to work with T3.2. Now that I want to work on T4.1 nothing works.
I had to install Teensyduino from here on Catalina (Teensyduino has full access to your Documents folder): https://www.pjrc.com/teensy/td_download.html

I was able to get rid of the error about SD.h (see bottom of code) by deleting by hand the SD folder in the /Applications/Teensyduino.app/Contents/Java/libraries/ (seems weird to me that SD is double with this standard Teensyduino .app!).

What I could not solve is the AudioStream.h errors.
I checked this thread https://forum.pjrc.com/threads/67864-Audio-applications-error which has the same error but I'm on MAC not PC. There's no "installer" for the Teensyduino. Just the Teensyduino.app. All permissions are ok. No anti-virus active. I don't know what to do.

Code:
Arduino: 1.8.19 (Mac OS X), TD: 1.57, Board: "Teensy 4.1, Serial, 600 MHz, Faster, US English"

In file included from /Users/batchas/Documents/Arduino/kesako player/RadioMusic/SDPlayPCM.h:30:0,
                 from /Users/batchas/Documents/Arduino/kesako player/RadioMusic/SDPlayPCM.cpp:27:
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h: In member function 'float AudioStream::processorUsage()':
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h:112:142: error: 'F_CPU_ACTUAL' was not declared in this scope
 #define CYCLE_COUNTER_APPROX_PERCENT(n) (((float)((uint32_t)(n) * 6400u) * (float)(AUDIO_SAMPLE_RATE_EXACT / AUDIO_BLOCK_SAMPLES)) / (float)(F_CPU_ACTUAL))
                                                                                                                                              ^
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h:146:38: note: in expansion of macro 'CYCLE_COUNTER_APPROX_PERCENT'
  float processorUsage(void) { return CYCLE_COUNTER_APPROX_PERCENT(cpu_cycles); }
                                      ^
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h: In member function 'float AudioStream::processorUsageMax()':
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h:112:142: error: 'F_CPU_ACTUAL' was not declared in this scope
 #define CYCLE_COUNTER_APPROX_PERCENT(n) (((float)((uint32_t)(n) * 6400u) * (float)(AUDIO_SAMPLE_RATE_EXACT / AUDIO_BLOCK_SAMPLES)) / (float)(F_CPU_ACTUAL))
                                                                                                                                              ^
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h:147:41: note: in expansion of macro 'CYCLE_COUNTER_APPROX_PERCENT'
  float processorUsageMax(void) { return CYCLE_COUNTER_APPROX_PERCENT(cpu_cycles_max); }
                                         ^
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h: In static member function 'static void AudioStream::update_all()':
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h:166:50: error: 'IRQ_SOFTWARE' was not declared in this scope
  static void update_all(void) { NVIC_SET_PENDING(IRQ_SOFTWARE); }
                                                  ^
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/AudioStream.h:166:62: error: 'NVIC_SET_PENDING' was not declared in this scope
  static void update_all(void) { NVIC_SET_PENDING(IRQ_SOFTWARE); }
                                                              ^
/Users/batchas/Documents/Arduino/kesako player/RadioMusic/SDPlayPCM.cpp: In member function 'virtual void SDPlayPCM::update()':
SDPlayPCM.cpp:293: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
      *out++ = (audioBuffer[l0] | (audioBuffer[++l0] << 8) | (audioBuffer[++l0] << 16)) >> 8;
                                                                                            ^
SDPlayPCM.cpp:293: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
SDPlayPCM.cpp:300: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
      *out++ = (audioBuffer[l0] | (audioBuffer[++l0] << 8) | (audioBuffer[++l0] << 16)) >> 8;
                                                                                            ^
SDPlayPCM.cpp:300: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
SDPlayPCM.cpp:310: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
      *out++ = (audioBuffer[l0] | (audioBuffer[++l0] << 8) | (audioBuffer[++l0] << 16)) >> 8;
                                                                                            ^
SDPlayPCM.cpp:310: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
SDPlayPCM.cpp:317: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
      *out++ = (audioBuffer[l0] | (audioBuffer[++l0] << 8) | (audioBuffer[++l0] << 16)) >> 8;
                                                                                            ^
SDPlayPCM.cpp:317: warning: operation on '((SDPlayPCM*)this)->SDPlayPCM::l0' may be undefined 
/Users/batchas/Documents/Arduino/kesako player/RadioMusic/SDPlayPCM.cpp: In member function 'bool SDPlayPCM::fillBuffer(int32_t)':
SDPlayPCM.cpp:374: warning: comparison between signed and unsigned integer expressions 
  if(bytesLeftInFile > avail) {
                     ^
SDPlayPCM.cpp:368: warning: unused variable 'seekRequired' 
  bool seekRequired = false;
       ^
SDPlayPCM.cpp:369: warning: unused variable 'seek' 
  int seek = 0;
      ^
SDPlayPCM.cpp:370: warning: unused variable 'fillStyle' 
  int fillStyle = 0;
      ^
Multiple libraries were found for "SD.h"
 Used: /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD
 Not used: /Applications/Teensyduino.app/Contents/Java/libraries/SD
Error compiling for board Teensy 4.1.
 
I noticed that my post is by error under "Suggestions & Bug Reports". Could it be possible to move it to the "Audio Projects" part of the forum, so someone could help me find a solution, please?
 
Back
Top