Audio File player

Status
Not open for further replies.
Are you using the Audio Shield?

http://www.pjrc.com/store/teensy3_audio.html

Here is the info about the pins it uses:

teensy3_audio_pins.png


Notice pin 14 is SCLK. If you're reading the SD card, that pin can't be used for a pushbutton, because it's needed by the SD card.
 
Np's - I totally understand.
Libraries are well above my capability - so I'll definitely be using yours.

Could you atleast let me know what functions the library has in pls?
From your example I can see the following - but are there any more (like fast fwd or rewind):

playMp31.play(argument); STARTS PLAY of the mp3 file name defined by the argument

playMp31.isPlaying() determines if a file is being played.
Outputs 0 if false – 1 if true

playMp31.stop(); STOPS PLAY of any MP3 file that is currently being played

playMp31.pause(argument); PAUSES/RESUMES current MP3 file selected
if argument = 0 - PAUSES
if argument = 1 - RESUMES


Hi,

no, that are almost all.

For MP3, there is int bitRate() which returns the bitrate of the currently played file,
and int channels(void) which returns 1 or 2 (1=mono, 2=stereo)
I don't remember wether i implemented that for AAC or flac or not..
Frank.

@paul: my "pause" is not more than
If (paused) return;
as first line in update();

Maybe that would be a useful function for the Wav and Flashplayers ?
By the way: The codecs can play from flash (Teensy + SPI)too -. just call play( with the address..)
 
Last edited:
Managed to get the buttons working.

I had been shorting the I/O Pins to 5v - but then tried shorting to ground and Bingo!

Not sure I understand why - maybe it the fact that the "Frank's Sketch" uses Internal Pull-Up's.
My only other Teensy project used external resistors - maybe I set them up as pull ups.

I guess I'm really showing my lact of electronics knowledge now.
How I got my midi foot controller working becomes a bigger mystery by the day :)
 
I bet you can do it.
How about in the meantime with a bit Tetris ? :)
https://github.com/FrankBoesing/T3TRIS

It plays the sampled originalsound. It is compressed to AAC, at a samplerate of only 30,000 BIT/s to fit into the internal Flash of the teensy (But is STILL good quality)
So no external Memory is used, SD-Card not required.

I wrote the game on a weekend. Teensyduino is unbelievable..
 
Last edited:
Are you using the Audio Shield?

http://www.pjrc.com/store/teensy3_audio.html

Here is the info about the pins it uses:

teensy3_audio_pins.png


Notice pin 14 is SCLK. If you're reading the SD card, that pin can't be used for a pushbutton, because it's needed by the SD card.

Just trying to understand exactly what pins I've actually used on the Audio Shield/Teensy - by using Franks Sketch - "Complete_MP3_AAC_MP4_M4A_example" .

From the code looks like the following are being used:
pin 15 from - #define BUTTON1 15 //NEXT
pin 14 from - #define BUTTON2 14 //Play Pause (need to change due to already being used for SCK)
pin 16 from - #define BUTTON3 16 //PREV
pin 10 from - const int chipSelect = 10; // if using another pin for SD card CS.
pin 7 from - SPI.setMOSI(7);
pin 14 from - SPI.setSCK(14);

This isn't a pin define/setup right? AudioMemory(16);


But what I'm not sure of is if any of the other Audio Shield pins get used automatically without defining/configuring within the code.
(ie MEMCS, BCLK, MCLK, MISO, LRCLK, TX, SCL, SDA, VOL, RX).

All I have hardware wise (excluding buttons) is the Teensy & the Audio Shield.
I'm using the on board SD card reader & the onboard Audio Jack to output the sound.

Thanks
 
Just trying to understand exactly what pins I've actually used on the Audio Shield/Teensy - by using Franks Sketch - "Complete_MP3_AAC_MP4_M4A_example" .

From the code looks like the following are being used:
pin 15 from - #define BUTTON1 15 //NEXT
pin 14 from - #define BUTTON2 14 //Play Pause (need to change due to already being used for SCK)
pin 16 from - #define BUTTON3 16 //PREV
pin 10 from - const int chipSelect = 10; // if using another pin for SD card CS.
pin 7 from - SPI.setMOSI(7);
pin 14 from - SPI.setSCK(14);

This isn't a pin define/setup right? AudioMemory(16);


But what I'm not sure of is if any of the other Audio Shield pins get used automatically without defining/configuring within the code.
(ie MEMCS, BCLK, MCLK, MISO, LRCLK, TX, SCL, SDA, VOL, RX).

All I have hardware wise (excluding buttons) is the Teensy & the Audio Shield.
I'm using the on board SD card reader & the onboard Audio Jack to output the sound.

Thanks


Just use an other pin than 14.
This code was written by a user who had no audioshield.
Thanks for the info, i did not see that and didn't try with buttons.
I'll update the example this evening (MEZ), and check pause().
 
Last edited:
ok.. fix for pause() was easy. done.
i changed the example-pinassignments to pin 2, 3 and 4.
still:"// Buttons at pins 2,3,4, feel free to remap them."

Please download the updated library.

Edit: Please note, that the WAV-object does not support pause().
So you can pause mp3, aac, and flac only.
 
Last edited:
ok.. fix for pause() was easy. done.
i changed the example-pinassignments to pin 2, 3 and 4.
still:"// Buttons at pins 2,3,4, feel free to remap them."

Please download the updated library.

Edit: Please note, that the WAV-object does not support pause().
So you can pause mp3, aac, and flac only.

Excellant news -thanks Frank.

Where is teh updated library downloadable from pls.
I can't recall now where I downloaded from in the first place.
 
did you read the comments:
"// Buttons at port 14 15 16, feel free to remap them."

Hi yes I did - I understand I can remap the 3 buttons to other pins AND also add further buttons to do other things.
But what I'm trying to understand is are ALL these pins (MEMCS, BCLK, MCLK, MISO, LRCLK, TX, SCL, SDA, VOL, RX) not useable with the basic setup i have OR is it just the pins defined in your Example sketch.

Appreciate it may be a really stupid question but I'm just not sure.
 
Hi yes I did - I understand I can remap the 3 buttons to other pins AND also add further buttons to do other things.
But what I'm trying to understand is are ALL these pins (MEMCS, BCLK, MCLK, MISO, LRCLK, TX, SCL, SDA, VOL, RX) not useable with the basic setup i have OR is it just the pins defined in your Example sketch.

Appreciate it may be a really stupid question but I'm just not sure.

The pins in the example-sketch ?
Ignore that.
The only important pins are those for the Audioboard - and they are fixed. The Audiolibrary knows which pins it needs for output, and they are assigned automatically. And they are not assigned in the sketch.
SD is a little different, the pins for the SPI-BUS which is used by the sd-card-slot are defined, and can not be changed.
The CODECS don't have any pin-requirements. It is pure software.

If i remember correctly - i don't have the Example-skecth open right now - there are #defines at the beginning of the skecth were you can switch the output between Audioboard and PWM (..and DAC??)
Just set the one for the Audioboard, and disable the other(s?)
All those pins which are not in use by the Audiolibrary-output, or other libraries like SD, are free to use.
The Audioboard uses the pins in picture some posts above.


Sorry, if i - still - don't understand you correctly, my English is not very good.

You can download the new version where you donwloaded the previous version, it's the same address, i updated the files!
https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib
(Klick on the "Download ZIP" button)

p.s. When you're a bit more experienced, you can use the I2C Pins to add portexpanders and more buttons ,or other chips.. or, perhaps better, you could use a key-matrix to access more buttons with the same pincount.
p.s.s: Please let me know if i u want a little more help - currently, i don't have hardware to run the example-sketch but i could set it up if needed. But...really..i think the only changes are the #defines at the beginning. Let me know when problems occur.
p.s.s.s The sketch does not need any buttons - you can send the command via the terminal, too. the buttons are optional.
 
Last edited:
The pins in the example-sketch ?
Ignore that.
The only important pins are those for the Audioboard - and they are fixed. The Audiolibrary knows which pins it needs for output, and they are assigned automatically. And they are not assigned in the sketch.
SD is a little different, the pins for the SPI-BUS which is used by the sd-card-slot are defined, and can not be changed.
The CODECS don't have any pin-requirements. It is pure software.

If i remember correctly - i don't have the Example-skecth open right now - there are #defines at the beginning of the skecth were you can switch the output between Audioboard and PWM (..and DAC??)
Just set the one for the Audioboard, and disable the other(s?)
All those pins which are not in use by the Audiolibrary-output, or other libraries like SD, are free to use.
The Audioboard uses the pins in picture some posts above.


Sorry, if i - still - don't understand you correctly, my English is not very good.

You can download the new version where you donwloaded the previous version, it's the same address, i updated the files!
https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib
(Klick on the "Download ZIP" button)

p.s. When you're a bit more experienced, you can use the I2C Pins to add portexpanders and more buttons ,or other chips.. or, perhaps better, you could use a key-matrix to access more buttons with the same pincount.
p.s.s: Please let me know if i u want a little more help - currently, i don't have hardware to run the example-sketch but i could set it up if needed. But...really..i think the only changes are the #defines at the beginning. Let me know when problems occur.

Thanks again Frank - appreciate all your help.
BTW your English is 1.000,000% better than my German :)
The Github download page confused me as I couldnt see any files with a modified date of today.
But I'll take a look - cheers.
 
Oh big SORRY. Somehow my Github-software did not upload it.
NOW they are updated. Thank you for the hint !
 
Thanks for all the help so far.

If anyone's interested, I've got all my initial required features/functions working now.
Just need to buy the required mounting hardware/enclosure & momentary switches etc & then look for a suitable display.

Moving fwd I've got a few further questions if that's OK?

1] is it possible fast forward/reverse by a defined amount - ie skip 10sec ahead or go back 10 secs?
2] is it possible to use 'folders' on the SD card to say store songs by artist/genre etc? and navigate through the folders.
3] report playing position of a file being played - ie 30secs of 3mins 50 secs etc (without the use of a timer).
4] can anyone explain when you take an inventory/list of what files are on the SD card - what defines the order they are reported back (ie is it alphabetically, date stamp of file, date when files were copied to the SD card, etc)?

Thanks
 
1] is it possible fast forward/reverse by a defined amount - ie skip 10sec ahead or go back 10 secs?

in theory yes, but needs editing of play_sd_wav or whatever you're using; take a look at "seek" in SD. it's not difficult to add. or take a look at the thing i had linked above, it can do this.

2] is it possible to use 'folders' on the SD card to say store songs by artist/genre etc? and navigate through the folders.

yes

3] report playing position of a file being played - ie 30secs of 3mins 50 secs etc (without the use of a timer).

take a look at the libraries, they all come with a function such as: uint32_t positionMillis(void);

4] can anyone explain when you take an inventory/list of what files are on the SD card - what defines the order they are reported back (ie is it alphabetically, date stamp of file, date when files were copied to the SD card, etc)?

don't know, i think it's in the order they were copied.
 
take a look at the libraries, they all come with a function such as: uint32_t positionMillis(void);

I've literally searched all afternoon but have no idea how to use that - could you expand a little futther pls.
 
Hi folks,

Really struggling here - can anyone help with how I implement mxxx's suggestion of "uint32_t positionMillis(void);" into my code to return the playing position of a file being played please.
 
Hi folks,

Really struggling here - can anyone help with how I implement mxxx's suggestion of "uint32_t positionMillis(void);" into my code to return the playing position of a file being played please.

Perhaps something like Serial.print (playWav1.positionMillis() );
or Serial.print (playWav1.positionMillis() / 1000, 2);
 
Perhaps something like Serial.print (playWav1.positionMillis() );
or Serial.print (playWav1.positionMillis() / 1000, 2);

Thanks Frank - but I guess I need to replace "playWav1" with something relavent to my sketch right?
Thats teh file currently played - right?

I just cant work out what that should be.
 
Status
Not open for further replies.
Back
Top