Return type from AudioProcessorUsage() & AudioProcessorUsageMax() functions

Status
Not open for further replies.

kd5rxt-mark

Well-known member
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 (https://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html) 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.

Code:
Representative code:

Serial.print("Current audio processor usage = ");
Serial.println(AudioProcessorUsage());
Serial.print("Max audio processor usage = ");
Serial.println(AudioProcessorUsageMax());

Resulting output to serial monitor:

Current audio processor usage = 49.76
Max audio processor usage = 51.48

Mark J Culross
KD5RXT
 
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
KD5RXT
 
[ 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 !!): https://drive.google.com/drive/folders/1ULPmJhpSQKHGne5fTUbfLNNLCdPRF13J
See https://forum.pjrc.com/threads/60690-TeensyMIDIPolySynth #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):
Code:
#define CHECK_CYCLE_TIME
//#define DEBUG_NOTE_MSGS
//#define DEBUG_CC_MSGS
//#define DEBUG_POTS
//#define DEBUG_PBUTTONS
//#define DISABLE_POT_MUX_SETTLING_TIME
//#define DISABLE_PB_MUX_SETTLING_TIME
//#define ENABLE_LED_MUX_SETTLING_TIME
//#define DISABLE_STATUS
#define DISABLE_POT_READ
#define DISABLE_PB_READ
#define DISABLE_EEPROM_READ
#define DISABLE_EEPROM_WRITE
//#define DEBUG_EEPROM_WRITE
//#define DEBUG_EEPROM_READ
//#define DEBUG_MAKE_NOTE_AVAILABLE
#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
KD5RXT
 
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
KD5RXT
 
Status
Not open for further replies.
Back
Top