// Simple WAV file player example
//
//
// This example code is in the public domain.
#include <LittleFS.h>
LittleFS_QSPIFlash myfs;
uint64_t fTot, totSize1;
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Bounce.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=323,171
AudioPlaySdWav playSdWav2; //xy=323,171
AudioPlaySdWav playSdWav3; //xy=323,171
AudioPlaySdWav playSdWav4; //xy=323,171
AudioPlaySdWav playSdWav5; //xy=323,171
AudioPlaySdWav playSdWav6; //xy=323,171
AudioPlaySdWav playSdWav7; //xy=323,171
AudioPlaySdWav playSdWav8; //xy=323,171
AudioMixer4 mixer1; //xy=647,123
AudioMixer4 mixer3; //xy=648,212
//AudioOutputPT8211 pt8211_1; //xy=828,169
//AudioOutputI2S audioOutput;
AudioOutputMQS mqs1;
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord2(playSdWav2, 1, mixer3, 0);
AudioConnection patchCord3(playSdWav3, 2, mixer1, 1);
AudioConnection patchCord4(playSdWav4, 3, mixer3, 1);
AudioConnection patchCord5(playSdWav5, 4, mixer1, 2);
AudioConnection patchCord6(playSdWav6, 5, mixer3, 2);
AudioConnection patchCord7(playSdWav7, 6, mixer1, 3);
AudioConnection patchCord8(playSdWav8, 7, mixer3, 3);
AudioConnection patchCord9(mixer1, 0, mqs1, 1);
AudioConnection patchCord10(mixer3, 0, mqs1, 1);
AudioConnection patchCord11(mixer1, 0, mqs1, 0);
AudioConnection patchCord12(mixer3, 0, mqs1, 0);
//AudioControlSGTL5000 sgtl5000_1;
// GUItool: end automatically generated code
// Bounce objects to read six pushbuttons (pins 0-5)
//
Bounce button0 = Bounce(0, 5);
Bounce button1 = Bounce(1, 5); // 5 ms debounce time
Bounce button2 = Bounce(2, 5);
Bounce button3 = Bounce(3, 5);
Bounce button4 = Bounce(4, 5);
Bounce button5 = Bounce(5, 5);
Bounce button6 = Bounce(6, 5);
void setup() {
Serial.begin(9600);
if (CrashReport) {
Serial.println(CrashReport);
CrashReport.clear();
}
AudioMemory(50);
Serial.println("LittleFS Test"); delay(5);
if (!myfs.begin()) {
//if (!myfs.begin(chipSelect)) {
Serial.println("Error starting qspidisk");
while (1) ;
}
Serial.printf("TotalSize (Bytes): %d\n", myfs.totalSize());
//myfs.deviceErase();
delay(1000);
Serial.println("started");
printDirectory();
// Configure the pushbutton pins for pullups.
// Each button should connect from the pin to GND.
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
}
void playFile(const char *filename)
{
Serial.print("Playing file: ");
Serial.println(filename);
// Start playing the file. This sketch continues to
// run while the file plays.
File ccc = myfs.open(filename); ///Change to play off QSPI flash
playSdWav1.play(ccc);
// Simply wait for the file to finish playing.
while (playSdWav1.isPlaying()) {
Serial.println("play wav");
delay(100);
}
}
void loop() {
// Update all the button objects
button0.update();
button1.update();
button2.update();
button3.update();
button4.update();
button5.update();
button6.update();
// When the buttons are pressed, just start a sound playing.
// The audio library will play each sound through the mixers
// so any combination can play simultaneously.
//
if (button0.fallingEdge()) {
playFile("MOTORLOOP.WAV");
}
while (playSdWav1.isPlaying()) {
}
}
void printDirectory() {
Serial.println("printDirectory\n--------------");
printDirectory(myfs.open("/"), 0);
Serial.println();
}
void printDirectory(File dir, int numTabs) {
//dir.whoami();
uint64_t fSize = 0;
uint32_t dCnt = 0, fCnt = 0;
if ( 0 == dir ) {
Serial.printf( "\t>>>\t>>>>> No Dir\n" );
return;
}
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
Serial.printf("\n %u dirs with %u files of Size %u Bytes\n", dCnt, fCnt, fSize);
fTot += fCnt;
totSize1 += fSize;
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
if (entry.isDirectory()) {
Serial.print("DIR\t");
dCnt++;
} else {
Serial.print("FILE\t");
fCnt++;
fSize += entry.size();
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println(" / ");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
//Serial.flush();
}
}
WavFilePlayerLittlsFS: In function 'void playFile(const char*)':
WavFilePlayerLittlsFS:100: error: no matching function for call to 'AudioPlaySdWav::play(File&)'
playSdWav1.play(ccc);
^
In file included from /home/microguy/Téléchargements/arduino-1.8.15/hardware/teensy/avr/libraries/Audio/Audio.h:128:0,
from /home/microguy/Nexcloud/New_Teensy_2021/Prog/test flash w25q128/WavFilePlayerLittlsFS/WavFilePlayerLittlsFS.ino:11:
/home/microguy/Téléchargements/arduino-1.8.15/hardware/teensy/avr/libraries/Audio/play_sd_wav.h:39:7: note: candidate: bool AudioPlaySdWav::play(const char*)
bool play(const char *filename);
^
/home/microguy/Téléchargements/arduino-1.8.15/hardware/teensy/avr/libraries/Audio/play_sd_wav.h:39:7: note: no known conversion for argument 1 from 'File' to 'const char*'
Does it work if you use
AudioPlayWav instead AudioPlaySdWav?
Have updated the example.. indeed it was outdated. Sorry for that.
Just tested it - it's working.
It runs onPT8211 by default, and NAND flash - You have to edit these things.
No.
Do you have some code?
// Simple WAV file player example
//
//
// This example code is in the public domain.
#include <LittleFS.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Bounce.h>
#include <play_wav.h>
LittleFS_QSPIFlash myfs;
uint64_t fTot, totSize1;
// GUItool: begin automatically generated code
AudioPlayWav playWav1; //xy=232,621
AudioPlayWav playWav2; //xy=230,663
AudioPlayWav playWav3; //xy=232,706
AudioPlayWav playWav4; //xy=230,749
AudioPlayWav playWav5; //xy=230,850
AudioPlayWav playWav6; //xy=229,890
AudioPlayWav playWav7; //xy=226,929
AudioPlayWav playWav8; //xy=227,968
AudioMixer4 mixerSingle; //xy=450,905
AudioMixer4 mixerloop; //xy=455,681
AudioMixer4 mixerFinal; //xy=654,814
AudioAmplifier amp1; //xy=809,815
AudioOutputMQS mqs1; //xy=972,818
AudioConnection patchCord1(playWav1, 0, mixerloop, 0);
AudioConnection patchCord2(playWav2, 0, mixerloop, 1);
AudioConnection patchCord3(playWav3, 0, mixerloop, 2);
AudioConnection patchCord4(playWav4, 0, mixerloop, 3);
AudioConnection patchCord5(playWav5, 0, mixerSingle, 0);
AudioConnection patchCord6(playWav6, 0, mixerSingle, 1);
AudioConnection patchCord7(playWav7, 0, mixerSingle, 2);
AudioConnection patchCord8(playWav8, 0, mixerSingle, 3);
AudioConnection patchCord9(mixerSingle, 0, mixerFinal, 1);
AudioConnection patchCord10(mixerloop, 0, mixerFinal, 0);
AudioConnection patchCord11(mixerFinal, amp1);
AudioConnection patchCord12(amp1, 0, mqs1, 0);
AudioConnection patchCord13(amp1, 0, mqs1, 1);
// GUItool: end automatically generated code
extern uint32_t _AudioPlaySdWavInstances;
int count = 0;
void setup() {
Serial.begin(9600);
AudioMemory(50);
mixerloop.gain(0, 0.3);
mixerSingle.gain(0,1.3);
Serial.println("LittleFS Test"); delay(5);
if (!myfs.begin()) {
Serial.println("Error starting qspidisk");
while (1) ;
}
Serial.printf("TotalSize (Bytes): %d\n", myfs.totalSize());
delay(1000);
Serial.println("started");
printDirectory();
// Initialize processor and memory measurements
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
}
void playLoopFile(const char *filename)
{
//Serial.print("Playing Loop file: ");
// Serial.println(filename);
File ccc = myfs.open(filename); //Change to play off QSPI flash
playWav1.play(ccc);
}
void playSingleFile1(const char *filename1)
{
if(!playWav5.isPlaying()){
File cc5 = myfs.open(filename1); //Change to play off QSPI flash
playWav5.play(cc5);
}
}
void playSingleFile2(const char *filename2)
{
if(!playWav6.isPlaying()){
File cc6 = myfs.open(filename2); //Change to play off QSPI flash
playWav6.play(cc6);
}
}
unsigned long last_time = millis();
void loop() {
// When the buttons are pressed, just start a sound playing.
// The audio library will play each sound through the mixers
// so any combination can play simultaneously.
//
if (!playWav1.isPlaying()){
playLoopFile("Pompe.wav");
}
if(millis() - last_time >= 200) {
Serial.print("Proc = ");
Serial.print(AudioProcessorUsage());
Serial.print(" (");
Serial.print(AudioProcessorUsageMax());
Serial.print("), Mem = ");
Serial.print(AudioMemoryUsage());
Serial.print(" (");
Serial.print(AudioMemoryUsageMax());
Serial.println(")");
last_time = millis();
if (!playWav5.isPlaying()){
playSingleFile1("DEMARRE.WAV");
count++;
Serial.println(count);
}
if (!playWav6.isPlaying()){
playSingleFile2("ding dong.wav");
}
}
}
void printDirectory() {
Serial.println("printDirectory\n--------------");
printDirectory(myfs.open("/"), 0);
Serial.println();
}
void printDirectory(File dir, int numTabs) {
//dir.whoami();
uint64_t fSize = 0;
uint32_t dCnt = 0, fCnt = 0;
if ( 0 == dir ) {
Serial.printf( "\t>>>\t>>>>> No Dir\n" );
return;
}
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
Serial.printf("\n %u dirs with %u files of Size %u Bytes\n", dCnt, fCnt, fSize);
fTot += fCnt;
totSize1 += fSize;
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
if (entry.isDirectory()) {
Serial.print("DIR\t");
dCnt++;
} else {
Serial.print("FILE\t");
fCnt++;
fSize += entry.size();
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println(" / ");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
//Serial.flush();
}
}
#include <LittleFS.h>
//LittleFS_QSPIFlash myfs;
LittleFS_QPINAND myfs;
File f1,f2,f3;
void setup() {
Serial.begin(9600);
delay(1000);
// try to add QSPI Flash
if (myfs.begin()) {
Serial.println("Added QSPI Flash");
} else {
Serial.println("No Littlefs");
abort();
}
long ms;
ms = millis();
f1 = myfs.open("1.txt");
Serial.printf("%d ms\n", millis() - ms);
ms = millis();
f2 = myfs.open("2.txt");
Serial.printf("%d ms\n", millis() - ms);
ms = millis();
f3 = myfs.open("3.txt");
Serial.printf("%d ms\n", millis() - ms);
}
void loop() {
// put your main code here, to run repeatedly:
}
Added QSPI Flash
9 ms
9 ms
8 ms
Frank B said:Just opening a file, without reading takes 10 milliseconds.
The Audiolibrary needs to read the files more often, so, no chance. It has to be (minimum) 10 times faster. And that's only for open(). Did not bother to measure concurrend reads().
Then, I saw LittlFS is a very old version. Maybe this is the problem.Code:Added QSPI Flash 9 ms 9 ms 8 ms
As my last bug reports got no answers, and one was even "fixed" by editing a comment in the sourcecode, it make no sense for me to report that. Maybe you want?
Edit: It may have more chances, then.
Added QSPI Flash
0 ms
0 ms
0 ms
Added QSPI Flash
30 micros
37 micros
37 micros
Added QSPI Flash
85 micros
92 micros
92 micros
#include <LittleFS.h>
LittleFS_QSPIFlash myfs;
//LittleFS_QPINAND myfs;
File f1,f2,f3;
void setup() {
Serial.begin(9600);
delay(1000);
// try to add QSPI Flash
if (myfs.begin()) {
Serial.println("Added QSPI Flash");
} else {
Serial.println("No Littlefs");
abort();
}
uint64_t ms;
ms = micros();
f1 = myfs.open("1.txt");
Serial.printf("%u micros\n", micros() - ms);
ms = micros();
f2 = myfs.open("2.txt");
Serial.printf("%u micros\n", micros() - ms);
ms = micros();
f3 = myfs.open("3.txt");
Serial.printf("%u micros\n", micros() - ms);
}
void loop() {
// put your main code here, to run repeatedly:
}
// Simple WAV file player example
//
//
// This example code is in the public domain.
#include <LittleFS.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Bounce.h>
#include <play_wav.h>
LittleFS_QSPIFlash myfs;
uint64_t fTot, totSize1;
// GUItool: begin automatically generated code
AudioPlayWav playWav1; //xy=232,621
AudioPlayWav playWav2; //xy=230,663
AudioPlayWav playWav3; //xy=232,706
AudioPlayWav playWav4; //xy=230,749
AudioPlayWav playWav5; //xy=230,850
AudioPlayWav playWav6; //xy=229,890
AudioPlayWav playWav7; //xy=226,929
AudioPlayWav playWav8; //xy=227,968
AudioMixer4 mixerSingle; //xy=450,905
AudioMixer4 mixerloop; //xy=455,681
AudioMixer4 mixerFinal; //xy=654,814
AudioAmplifier amp1; //xy=809,815
AudioOutputI2S mqs1; //xy=972,818
AudioConnection patchCord1(playWav1, 0, mixerloop, 0);
AudioConnection patchCord2(playWav2, 0, mixerloop, 1);
AudioConnection patchCord3(playWav3, 0, mixerloop, 2);
AudioConnection patchCord4(playWav4, 0, mixerloop, 3);
AudioConnection patchCord5(playWav5, 0, mixerSingle, 0);
AudioConnection patchCord6(playWav6, 0, mixerSingle, 1);
AudioConnection patchCord7(playWav7, 0, mixerSingle, 2);
AudioConnection patchCord8(playWav8, 0, mixerSingle, 3);
AudioConnection patchCord9(mixerSingle, 0, mixerFinal, 1);
AudioConnection patchCord10(mixerloop, 0, mixerFinal, 0);
AudioConnection patchCord11(mixerFinal, amp1);
AudioConnection patchCord12(amp1, 0, mqs1, 0);
AudioConnection patchCord13(amp1, 0, mqs1, 1);
// GUItool: end automatically generated code
AudioControlSGTL5000 sgtl5000_1;
extern uint32_t _AudioPlaySdWavInstances;
int count = 0;
void setup() {
Serial.begin(9600);
AudioMemory(50);
mixerloop.gain(0, 0.3);
mixerSingle.gain(0,1.3);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
Serial.println("LittleFS Test"); delay(5);
if (!myfs.begin()) {
Serial.println("Error starting qspidisk");
while (1) ;
}
Serial.printf("TotalSize (Bytes): %d\n", myfs.totalSize());
delay(1000);
Serial.println("started");
printDirectory();
// Initialize processor and memory measurements
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
}
void playLoopFile(const char *filename)
{
//Serial.print("Playing Loop file: ");
// Serial.println(filename);
File ccc = myfs.open(filename); //Change to play off QSPI flash
playWav1.play(ccc);
}
void playSingleFile1(const char *filename1)
{
if(!playWav5.isPlaying()){
File cc5 = myfs.open(filename1); //Change to play off QSPI flash
playWav5.play(cc5);
}
}
void playSingleFile2(const char *filename2)
{
if(!playWav6.isPlaying()){
File cc6 = myfs.open(filename2); //Change to play off QSPI flash
playWav6.play(cc6);
}
}
unsigned long last_time = millis();
void loop() {
// When the buttons are pressed, just start a sound playing.
// The audio library will play each sound through the mixers
// so any combination can play simultaneously.
//
if (!playWav1.isPlaying()){
playLoopFile("operational.wav");
}
if(millis() - last_time >= 200) {
Serial.print("Proc = ");
Serial.print(AudioProcessorUsage());
Serial.print(" (");
Serial.print(AudioProcessorUsageMax());
Serial.print("), Mem = ");
Serial.print(AudioMemoryUsage());
Serial.print(" (");
Serial.print(AudioMemoryUsageMax());
Serial.println(")");
last_time = millis();
if (!playWav5.isPlaying()){
playSingleFile1("one_moment.wav");
count++;
Serial.println(count);
}
if (!playWav6.isPlaying()){
playSingleFile2("calculations.wav");
}
}
}
void printDirectory() {
Serial.println("printDirectory\n--------------");
printDirectory(myfs.open("/"), 0);
Serial.println();
}
void printDirectory(File dir, int numTabs) {
//dir.whoami();
uint64_t fSize = 0;
uint32_t dCnt = 0, fCnt = 0;
if ( 0 == dir ) {
Serial.printf( "\t>>>\t>>>>> No Dir\n" );
return;
}
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
Serial.printf("\n %u dirs with %u files of Size %u Bytes\n", dCnt, fCnt, fSize);
fTot += fCnt;
totSize1 += fSize;
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
if (entry.isDirectory()) {
Serial.print("DIR\t");
dCnt++;
} else {
Serial.print("FILE\t");
fCnt++;
fSize += entry.size();
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println(" / ");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
//Serial.flush();
}
}
LittleFS Test
TotalSize (Bytes): 16777216
started
printDirectory
--------------
FILE calculations.wav 426812
FILE completed.wav 276972
FILE dangerous_to_remain.wav 373404
FILE enough_info.wav 513900
FILE functional.wav 237868
FILE odd1.wav 553516
FILE one_moment.wav 202748
FILE operational.wav 772652
FILE sorry_dave.wav 791676
FILE stop.wav 201356
0 dirs with 10 files of Size 4350904 Bytes
Proc = 0.05 (0.05), Mem = 0 (0)
1
Proc = 6.85 (7.18), Mem = 1 (4)
Proc = 5.87 (7.18), Mem = 1 (4)
Proc = 0.32 (7.18), Mem = 1 (4)
Proc = 0.32 (7.18), Mem = 1 (4)
Proc = 5.13 (7.18), Mem = 1 (4)
Proc = 0.22 (7.18), Mem = 1 (4)
2
Proc = 0.32 (7.18), Mem = 1 (4)
Proc = 0.32 (7.18), Mem = 1 (4)
Proc = 6.11 (7.18), Mem = 1 (4)
Proc = 5.13 (7.18), Mem = 1 (4)
Proc = 0.32 (7.18), Mem = 1 (4)
Proc = 0.22 (7.18), Mem = 1 (4)
3
Proc = 0.26 (7.18), Mem = 1 (4)
#ifdef LFS_THREADSAFE
// Lock the underlying block device. Negative error codes
// are propogated to the user.
int (*lock)(const struct lfs_config *c);
// Unlock the underlying block device. Negative error codes
// are propogated to the user.
int (*unlock)(const struct lfs_config *c);
#endif
Added QSPI Flash
8962 us
8457 us
8459 us
Added QSPI Flash
3708 us
3808 us
3808 us
Added QSPI Flash
14138 us
12430 us
10622 us
Ok, resoldered my faulty board with NOR flash.
These times look way better:
Code:546 us 418 us 593 us
Can someone confirm, that tha 10x slower times are with NAND only?
[B]Added QSPI NOR Flash (16MB)[/B]
781 micros
813 micros
780 micros
[B]Added QSPI NAND Flash (256MB)
[/B]8765 micros
2937 micros
7075 micros
2838 micros
2937 micros
2938 micros