Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Compiling custom Audio Library compatible classes for Teensy 4

  1. #1
    Senior Member
    Join Date
    May 2016
    Posts
    218

    Compiling custom Audio Library compatible classes for Teensy 4

    In the thread F_CPU_ACTUAL error in Teensy 4 but not Teensy 3 the issue of being unable to compile code that included custom (home-grown) Audio Library classes for the T4 was introduced. I have spent many frustrating hours over the past few days trying to make it work, and tonight seem to have resolved the issue, although I don't fully understand the situation.

    KurtE made the suggestion of including the file "core_pins.h" in the header file for each custom Audio class. So I tried it - and it worked sometimes. But the breakthrough for me was to realize that the
    #include "core_pins.h" MUST appear before the
    #include "AudioStream.h" in the MyAudioObject.h file that you have written.
    and that now makes sense.

    For example, in the simple test case (audio pass through) I wrote for the above thread

    Code:
      //
      #define audio_passthru_h_
      #include "core_pins.h"
      #include "AudioStream.h"
      #include "Arduino.h"
      //
    works fine, BUT
    Code:
      //
      #define audio_passthru_h_
      #include "AudioStream.h"
      #include "core_pins.h"
      #include "Arduino.h"
      //
    fails completely. The problem is due to the fact that "core_pins.h" contains some new #defines that are needed for AudioStream in the T4. In my initial struggles I was not paying attention to the order, causing me to rip out the two remaining hairs on my head in frustration.

    Solution: Edit AudioStream.h itself to include #include "core_pins.h" in the ...\Arduino\hardware\teensy\avr\cores\teensy4 directory (you will have to do this as an administrator).
    @Paul - can this be made permanent - if it's the right thing to do?
    Last edited by DerekR; 08-19-2019 at 02:18 AM.

  2. #2
    Junior Member
    Join Date
    Jul 2016
    Posts
    7
    That might make it compile but Iím not sure everything will work for reasons Paul explained in your other thread.

    One would have to look at each library and actually look at the use of F_CPU to understand if this would make sense or not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •