Tympan / Tympan_Library

Arduino/Teensy Library for Tympan Open Source Hearing Aid
MIT License
116 stars 31 forks source link

Teensy 4.0 Compatibility #68

Open NBAmin opened 1 year ago

NBAmin commented 1 year ago

Dear Developers,

I successfully compiled the library in VSCode/Platformio and specifically "SoundLevelMeter" example for teensy36 by copying it into project src directory. However when I tweaked the platformio.ini file to compile it for teensy 4.0, it complains about a class implemented in usb_audio.h in teensy4 core libraries.

Processing teensy40 (platform: teensy; framework: arduino; board: teensy40)
-----------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.18.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-arduinoteensy @ 1.158.0 (1.58) 
 - tool-teensy @ 1.158.0 (1.58) 
 - toolchain-gccarmnoneeabi-teensy @ 1.110301.0 (11.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 95 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Tympan_Library @ 1.0.0
|-- Audio @ 1.3.0+sha.7346c54
|-- SD @ 2.0.0+sha.a877769
|-- SdFat @ 2.1.2
|-- Wire @ 1.0
Building in release mode
Compiling .pio/build/teensy40/src/AudioEffectFade_F32.cpp.o
Compiling .pio/build/teensy40/src/AudioEffectFormantShift_FD_F32.cpp.o
Compiling .pio/build/teensy40/src/AudioEffectFreqShift_FD_F32.cpp.o
Compiling .pio/build/teensy40/src/AudioEffectMultiBandWDRC_F32.cpp.o
In file included from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/WProgram.h:61,
                 from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/Arduino.h:6,
                 from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/AudioStream.h:39,
                 from src/AudioStream_F32.h:19,
                 from src/AudioEffectFormantShift_FD_F32.h:5,
                 from src/AudioEffectFormantShift_FD_F32.cpp:2:
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:66:1: error: expected class-name before '{' token
   66 | {
      | ^
In file included from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/WProgram.h:61,
                 from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/Arduino.h:6,
                 from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/AudioStream.h:39,
                 from src/AudioStream_F32.h:19,
                 from src/AudioEffectFreqShift_FD_F32.h:16,
                 from src/AudioEffectFreqShift_FD_F32.cpp:2:
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:66:1: error: expected class-name before '{' token
   66 | {
      | ^
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:81:16: error: 'audio_block_t' does not name a type
   81 |         static audio_block_t *incoming_left;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:81:16: error: 'audio_block_t' does not name a type
   81 |         static audio_block_t *incoming_left;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:82:16: error: 'audio_block_t' does not name a type
   82 |         static audio_block_t *incoming_right;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:83:16: error: 'audio_block_t' does not name a type
   83 |         static audio_block_t *ready_left;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:82:16: error: 'audio_block_t' does not name a type
   82 |         static audio_block_t *incoming_right;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:84:16: error: 'audio_block_t' does not name a type
   84 |         static audio_block_t *ready_right;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: In constructor 'AudioInputUSB::AudioInputUSB()':
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:68:31: error: class 'AudioInputUSB' does not have any field named 'AudioStream'
   68 |         AudioInputUSB(void) : AudioStream(0, NULL) { begin(); }
      |                               ^~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: At global scope:
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:90:1: error: expected class-name before '{' token
   90 | {
      | ^
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:83:16: error: 'audio_block_t' does not name a type
   83 |         static audio_block_t *ready_left;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:98:16: error: 'audio_block_t' does not name a type
   98 |         static audio_block_t *left_1st;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:84:16: error: 'audio_block_t' does not name a type
   84 |         static audio_block_t *ready_right;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: In constructor 'AudioInputUSB::AudioInputUSB()':
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:68:31: error: class 'AudioInputUSB' does not have any field named 'AudioStream'
   68 |         AudioInputUSB(void) : AudioStream(0, NULL) { begin(); }
      |                               ^~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:99:16: error: 'audio_block_t' does not name a type
   99 |         static audio_block_t *left_2nd;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: At global scope:
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:90:1: error: expected class-name before '{' token
   90 | {
      | ^
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:98:16: error: 'audio_block_t' does not name a type
   98 |         static audio_block_t *left_1st;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:99:16: error: 'audio_block_t' does not name a type
   99 |         static audio_block_t *left_2nd;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:100:16: error: 'audio_block_t' does not name a type
  100 |         static audio_block_t *right_1st;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:100:16: error: 'audio_block_t' does not name a type
  100 |         static audio_block_t *right_1st;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:101:16: error: 'audio_block_t' does not name a type
  101 |         static audio_block_t *right_2nd;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:101:16: error: 'audio_block_t' does not name a type
  101 |         static audio_block_t *right_2nd;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:103:9: error: 'audio_block_t' does not name a type
  103 |         audio_block_t *inputQueueArray[2];
      |         ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: In constructor 'AudioOutputUSB::AudioOutputUSB()':
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:92:32: error: class 'AudioOutputUSB' does not have any field named 'AudioStream'
   92 |         AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
      |                                ^~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:103:9: error: 'audio_block_t' does not name a type
  103 |         audio_block_t *inputQueueArray[2];
      |         ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: In constructor 'AudioOutputUSB::AudioOutputUSB()':
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:92:32: error: class 'AudioOutputUSB' does not have any field named 'AudioStream'
   92 |         AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
      |                                ^~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:92:47: error: 'inputQueueArray' was not declared in this scope
   92 |         AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
      |                                               ^~~~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:92:47: error: 'inputQueueArray' was not declared in this scope
   92 |         AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
      |                                               ^~~~~~~~~~~~~~~
*** [.pio/build/teensy40/src/AudioEffectFreqShift_FD_F32.cpp.o] Error 1
*** [.pio/build/teensy40/src/AudioEffectFormantShift_FD_F32.cpp.o] Error 1
In file included from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/WProgram.h:61,
                 from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/Arduino.h:6,
                 from /home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/AudioStream.h:39,
                 from src/AudioStream_F32.h:19,
                 from src/AudioEffectFade_F32.h:15,
                 from src/AudioEffectFade_F32.cpp:2:
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:66:1: error: expected class-name before '{' token
   66 | {
      | ^
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:81:16: error: 'audio_block_t' does not name a type
   81 |         static audio_block_t *incoming_left;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:82:16: error: 'audio_block_t' does not name a type
   82 |         static audio_block_t *incoming_right;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:83:16: error: 'audio_block_t' does not name a type
   83 |         static audio_block_t *ready_left;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:84:16: error: 'audio_block_t' does not name a type
   84 |         static audio_block_t *ready_right;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: In constructor 'AudioInputUSB::AudioInputUSB()':
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:68:31: error: class 'AudioInputUSB' does not have any field named 'AudioStream'
   68 |         AudioInputUSB(void) : AudioStream(0, NULL) { begin(); }
      |                               ^~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: At global scope:
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:90:1: error: expected class-name before '{' token
   90 | {
      | ^
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:98:16: error: 'audio_block_t' does not name a type
   98 |         static audio_block_t *left_1st;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:99:16: error: 'audio_block_t' does not name a type
   99 |         static audio_block_t *left_2nd;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:100:16: error: 'audio_block_t' does not name a type
  100 |         static audio_block_t *right_1st;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:101:16: error: 'audio_block_t' does not name a type
  101 |         static audio_block_t *right_2nd;
      |                ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:103:9: error: 'audio_block_t' does not name a type
  103 |         audio_block_t *inputQueueArray[2];
      |         ^~~~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h: In constructor 'AudioOutputUSB::AudioOutputUSB()':
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:92:32: error: class 'AudioOutputUSB' does not have any field named 'AudioStream'
   92 |         AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
      |                                ^~~~~~~~~~~
/home/<$USER>/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_audio.h:92:47: error: 'inputQueueArray' was not declared in this scope
   92 |         AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
      |                                               ^~~~~~~~~~~~~~~
*** [.pio/build/teensy40/src/AudioEffectFade_F32.cpp.o] Error 1

Here's my platformio.ini file:

; [platformio]
; default_envs = teensy36_pegged

; Global data for all [env:***]
[env]
framework = arduino
board = teensy40
build_flags = -D USB_EVERYTHING
lib_deps =
    /home/<$User>/IoT/Tympan_Library
    https://github.com/PaulStoffregen/Audio.git
    https://github.com/PaulStoffregen/SD.git

; Environment for the latest everything:
;[env:teensy36_dev]
;platform = teensy

; Environment for teensy3.6 with a pegged teensyduino version:
[env:teensy40]
platform = teensy

I'd like to ask first if the library is compatible with teensy 4.0 board and appreciate it if you could point me to the right direction to compile it for my teensy 4.0 board. Thank you in advance.

biomurph commented 1 year ago

The Tympan library has options for selecting our versions, Rev D and Rev E are the main options. Rev D was built on the Teensy 3.6 and the Rev E was built on the Teensy 4.1. The Teensy 4.0 and Teensy 4.1 are quite similar, based on the same processor, but the 4.0 is 10mm and the 4.1 is 12mm chip size.

Try compiling the sketch for the Rev E, but instead of targeting the 4.1, target the 4.0?

Also, we primarily use the Arduino IDE. PJRC offers a version called Teensyduino. https://www.pjrc.com/teensy/td_download.html I would also suggest that you attempt to target the 4.0 with our library using Arduino to see if the issues are stemming from the platformio toolchain that you are currently using?