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

Thread: Return type from AudioProcessorUsage() & AudioProcessorUsageMax() functions

  1. #1

    Return type from AudioProcessorUsage() & AudioProcessorUsageMax() functions

    I'm guessing that this may simply be a case where the website is out-of-date, so I did not really want to post it in the "bugs" section of the forum.

    The "Audio Library Processor Usage & Interrupts" webpage ( indicates that the AudioProcessorUsage() & AudioProcessorUsageMax() functions each return integers from 0 to 100. However simply printing the return value (on a T4) to the serial port appears to indicate that the return type is a float.

    Representative code:
    Serial.print("Current audio processor usage = ");
    Serial.print("Max audio processor usage = ");
    Resulting output to serial monitor:
    Current audio processor usage = 49.76
    Max audio processor usage = 51.48
    Mark J Culross

  2. #2
    Now for the question: are the return values from these two functions actually float, or are they int as indicated on the website ?? I am seeing an anomaly when I read/treat them as float . . . the return results seem to "rollover" (start back over at 0.0) for values greater than about 60.71. I'd like to confirm that I should really be expecting/reading a float before filing a potential bug report.

    Thanks for any knowledgeable replies !!

    Mark J Culross

  3. #3
    [ Sorry in advance if this more correctly belongs in the bug report section ]

    Anomalous observation: return values from AudioProcessorUsage() & AudioProcessorUsageMax() seem to rollover (start back over at 0.0) above about 60.71
    Hardware required: Teensy 4.0 + Rev D Audio Shield
    Arduino version: 1.8.12
    Teensyduino version: 1.51
    Arduino IDE Configuration:

    Tools/Board: "Teensy 4.0"
    Tools/USB Type: "Serial + MIDI"
    Tools/CPU Speed: "600MHz"
    Tools/Optimize: "Fastest"
    Tools/Keyboard Layout: "US English"
    Tools/Port: "COMx Serial (Teensy 4.0)"

    Sourcefiles (TeensyMIDIPolySynth.ino, name.c, & pitches.h) to demonstrate (won't post actual code - it's an excessive 18200 lines !!):
    See #1 for the background on this project.

    Steps to reproduce:
    1) Change the #define block at the top of the source file to the following (to enable cycle time checks & to eliminate any need for external hardware):
    #define CHECK_CYCLE_TIME
    //#define DEBUG_NOTE_MSGS
    //#define DEBUG_CC_MSGS
    //#define DEBUG_POTS
    //#define DEBUG_PBUTTONS
    //#define DISABLE_STATUS
    #define DISABLE_POT_READ
    #define DISABLE_PB_READ
    //#define DEBUG_EEPROM_WRITE
    //#define DEBUG_EEPROM_READ
    #define SKIP_LED_TEST
    2) connect the Teensy 4.0 + Rev D Sound Shield to your PC via USB
    3) run your favorite MIDI player (I'm using "Aria Maestosa" specifically, but most any MIDI player should work)
    4) choose the Teensy16PolySynth as the MIDI output device
    5) open the Arduino Serial Monitor on the Teensy 4.0
    6) note that the idle return values in the Serial Monitor are somewhere just slightly less than 50% (& roughly 50 msecs per cycle, but that number is not related to the bug question)
    7) from the same Google Drive link given above, open the "MIDI" folder, then open the "carousel.mid" file (sorry about the "carousel.mid.MID" name . . . give Google credit for thinking that the extra extension was needed) in your MIDI player
    8) start the "carousel.mid" file playing in your MIDI player
    9) note that the return values in the Serial Monitor are now somewhere around 5.5% (& roughly 75-100 msecs per cycle, increasing under the load of lots of noteOn/noteOff messages)
    10) note that, when playing the MIDI file completes, the return values in the Serial Monitor remain somewhere around 5.5 % (& roughly 75 msecs)

    It does not seem reasonable for the return value from AudioProcessorUsage() to be lower while processing MIDI notes (which results in activating multiple simultaneous waveform generators, activating multiple filters, etc.) than when idle. It also seems suspicious for the AudioProcessorUsageMax() specifically to report a lower number after playing a MIDI file than before playing that file.

    Mark J Culross

  4. #4
    Has anyone been able to reproduce the steps in post #3 & verify the same unexpected results ??

  5. #5
    In case anyone stumbles across this old thread, Paul pushed a fix for this rollover problem today, which should be included in the next TeensyDuino release.

    Mark J Culross

Posting Permissions

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