Hello All,
I've been following this forum for a few months while building a project using the Teensy 3.1. and the Audio Shield. I must say, I'm VERY impressed with Paul's work (as well as Robins and other contributors work) and the level of expertise on this forum. But it's the very friendly and inviting atmosphere towards people new to electronics and embedded systems that amazes me most. This is a unique place and I hope that I never do anything anger the forum Gods!
I'm trying to test the resource overhead used by playing multiple WAV files on the Teensy through the Audio Shield, which is fantastic to work with I must say, but I'm not sure I understand the results. The Audio library describes the AudioProcessorUsageMax() as :
I seem to get two different results for the same code. I am new to Arduino/Teensy so I may be missing boot time information and should read the Freescale docs (am currently doing), but I was hoping for some guidance. The difference happens after I boot the Teensy from a cold start.
When I plug the prototype into my USB port with the Serial monitor open, I get the following:
1 pos1: 994 pos2: 994 maxblocks: 8 maxproc: 151.32
2 pos1: 1995 pos2: 1998 maxblocks: 8 maxproc: 151.32
3 pos1: 2999 pos2: 2999 maxblocks: 8 maxproc: 151.32
4 pos1: 4000 pos2: 4000 maxblocks: 8 maxproc: 151.32
5 pos1: 5001 pos2: 5001 maxblocks: 8 maxproc: 151.32
6 pos1: 6002 pos2: 6002 maxblocks: 8 maxproc: 151.32
7 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
8 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
9 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
10 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
Only the last column of numbers is relevant. the 151.32% is the output from the AudioProcessorUsageMax() function while playing back two WAV files simultaneously. It appears that the estimated Max CPU usage is 151.32% if I'm reading the documentation correctly. If I recompile and upload the exact same sketch I get the following:
1 pos1: 994 pos2: 994 maxblocks: 6 maxproc: 71.57
2 pos1: 1995 pos2: 1995 maxblocks: 6 maxproc: 71.57
3 pos1: 2996 pos2: 2996 maxblocks: 6 maxproc: 71.57
4 pos1: 3997 pos2: 3997 maxblocks: 6 maxproc: 71.57
5 pos1: 4998 pos2: 4998 maxblocks: 6 maxproc: 71.57
6 pos1: 5999 pos2: 5999 maxblocks: 6 maxproc: 71.57
7 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
8 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
9 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
10 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
I'm not sure why there is this difference. Are there other processor related startup setting that I need to set? Is the 96Mhz overclock setting not retained through reboot? The hardware is a Teensy 3.1 soldered to the Audio Board via headers as described on the Audio Board page. No deviations or customization's (yet). My apologies if this is something simple and I should reread the documentation again. Thanks for any help!
Here's the sketch:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=160.1999969482422,307.39998626708984
AudioPlaySdWav playSdWav2; //xy=160.1999969482422,349.39998626708984
AudioMixer4 mixer1; //xy=428.2000274658203,322.39998626708984
AudioMixer4 mixer2; //xy=429.2000274658203,392.39998626708984
AudioOutputI2S i2s1; //xy=579.2000274658203,357.39998626708984
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord2(playSdWav1, 1, mixer2, 0);
AudioConnection patchCord3(playSdWav2, 0, mixer1, 1);
AudioConnection patchCord4(playSdWav2, 1, mixer2, 1);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer2, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=202.2000274658203,539.400016784668
// GUItool: end automatically generated code
/*-----------------------------------------------------------------------*/
int count = 10;
signed int last_millis = millis();
#define LED 13 // LED pin on Arduino Uno
void setup() {
// put your setup code here, to run once:
//---------------
// General Setup
pinMode(LED, OUTPUT);
digitalWrite( LED, HIGH );
Serial.begin(115200);
//Setup Audio
SPI.setMOSI(7);
SPI.setSCK(14);
delay(500);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(10);
sgtl5000_1.enable();
sgtl5000_1.volume(0.9);
mixer1.gain(0, .5);
mixer1.gain(1, .5);
mixer2.gain(0, .5);
mixer2.gain(1, .5);
if (!(SD.begin(10))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
Serial.println("Ready");
}
/*--------------------------------------------------------*/
void loop() {
// put your main code here, to run repeatedly:
//-----------------------
// Audio Debug
if ( count >= 10 ) {
delay(5);
playSdWav1.play("C.WAV");
playSdWav2.play("E.WAV");
count = 0;
}
//delay(1000);
if ( millis() > last_millis + 1000 ) {
last_millis = millis();
count++;
Serial.print(count);
Serial.print(" pos1: ");
Serial.print( playSdWav1.positionMillis() );
Serial.print(" pos2: ");
Serial.print( playSdWav2.positionMillis() );
Serial.print(" maxblocks: ");
Serial.print( AudioMemoryUsageMax() );
Serial.print(" maxproc: ");
Serial.println( AudioProcessorUsageMax() );
}
}
I've been following this forum for a few months while building a project using the Teensy 3.1. and the Audio Shield. I must say, I'm VERY impressed with Paul's work (as well as Robins and other contributors work) and the level of expertise on this forum. But it's the very friendly and inviting atmosphere towards people new to electronics and embedded systems that amazes me most. This is a unique place and I hope that I never do anything anger the forum Gods!
I'm trying to test the resource overhead used by playing multiple WAV files on the Teensy through the Audio Shield, which is fantastic to work with I must say, but I'm not sure I understand the results. The Audio library describes the AudioProcessorUsageMax() as :
AudioProcessorUsageMax();
Return an estimate of the maximum percentage of CPU time any audio update has ever used. This function is the most useful for assuring the audio processing is operating within acceptable limits. The number is an integer from 0 to 100, representing an estimate of the percentage of the total CPU time consumed.
Return an estimate of the maximum percentage of CPU time any audio update has ever used. This function is the most useful for assuring the audio processing is operating within acceptable limits. The number is an integer from 0 to 100, representing an estimate of the percentage of the total CPU time consumed.
I seem to get two different results for the same code. I am new to Arduino/Teensy so I may be missing boot time information and should read the Freescale docs (am currently doing), but I was hoping for some guidance. The difference happens after I boot the Teensy from a cold start.
When I plug the prototype into my USB port with the Serial monitor open, I get the following:
1 pos1: 994 pos2: 994 maxblocks: 8 maxproc: 151.32
2 pos1: 1995 pos2: 1998 maxblocks: 8 maxproc: 151.32
3 pos1: 2999 pos2: 2999 maxblocks: 8 maxproc: 151.32
4 pos1: 4000 pos2: 4000 maxblocks: 8 maxproc: 151.32
5 pos1: 5001 pos2: 5001 maxblocks: 8 maxproc: 151.32
6 pos1: 6002 pos2: 6002 maxblocks: 8 maxproc: 151.32
7 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
8 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
9 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
10 pos1: 0 pos2: 0 maxblocks: 8 maxproc: 151.32
Only the last column of numbers is relevant. the 151.32% is the output from the AudioProcessorUsageMax() function while playing back two WAV files simultaneously. It appears that the estimated Max CPU usage is 151.32% if I'm reading the documentation correctly. If I recompile and upload the exact same sketch I get the following:
1 pos1: 994 pos2: 994 maxblocks: 6 maxproc: 71.57
2 pos1: 1995 pos2: 1995 maxblocks: 6 maxproc: 71.57
3 pos1: 2996 pos2: 2996 maxblocks: 6 maxproc: 71.57
4 pos1: 3997 pos2: 3997 maxblocks: 6 maxproc: 71.57
5 pos1: 4998 pos2: 4998 maxblocks: 6 maxproc: 71.57
6 pos1: 5999 pos2: 5999 maxblocks: 6 maxproc: 71.57
7 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
8 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
9 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
10 pos1: 0 pos2: 0 maxblocks: 6 maxproc: 71.57
I'm not sure why there is this difference. Are there other processor related startup setting that I need to set? Is the 96Mhz overclock setting not retained through reboot? The hardware is a Teensy 3.1 soldered to the Audio Board via headers as described on the Audio Board page. No deviations or customization's (yet). My apologies if this is something simple and I should reread the documentation again. Thanks for any help!
Here's the sketch:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=160.1999969482422,307.39998626708984
AudioPlaySdWav playSdWav2; //xy=160.1999969482422,349.39998626708984
AudioMixer4 mixer1; //xy=428.2000274658203,322.39998626708984
AudioMixer4 mixer2; //xy=429.2000274658203,392.39998626708984
AudioOutputI2S i2s1; //xy=579.2000274658203,357.39998626708984
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord2(playSdWav1, 1, mixer2, 0);
AudioConnection patchCord3(playSdWav2, 0, mixer1, 1);
AudioConnection patchCord4(playSdWav2, 1, mixer2, 1);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer2, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=202.2000274658203,539.400016784668
// GUItool: end automatically generated code
/*-----------------------------------------------------------------------*/
int count = 10;
signed int last_millis = millis();
#define LED 13 // LED pin on Arduino Uno
void setup() {
// put your setup code here, to run once:
//---------------
// General Setup
pinMode(LED, OUTPUT);
digitalWrite( LED, HIGH );
Serial.begin(115200);
//Setup Audio
SPI.setMOSI(7);
SPI.setSCK(14);
delay(500);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(10);
sgtl5000_1.enable();
sgtl5000_1.volume(0.9);
mixer1.gain(0, .5);
mixer1.gain(1, .5);
mixer2.gain(0, .5);
mixer2.gain(1, .5);
if (!(SD.begin(10))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
Serial.println("Ready");
}
/*--------------------------------------------------------*/
void loop() {
// put your main code here, to run repeatedly:
//-----------------------
// Audio Debug
if ( count >= 10 ) {
delay(5);
playSdWav1.play("C.WAV");
playSdWav2.play("E.WAV");
count = 0;
}
//delay(1000);
if ( millis() > last_millis + 1000 ) {
last_millis = millis();
count++;
Serial.print(count);
Serial.print(" pos1: ");
Serial.print( playSdWav1.positionMillis() );
Serial.print(" pos2: ");
Serial.print( playSdWav2.positionMillis() );
Serial.print(" maxblocks: ");
Serial.print( AudioMemoryUsageMax() );
Serial.print(" maxproc: ");
Serial.println( AudioProcessorUsageMax() );
}
}