mp3 playback module

Grogster

Senior Member
OK, formatted card to FAT32 using Puppy Linux, put in XP machine, copy 6 MP3's named 001.mp3 - 006.mp3 to the card one-by one to keep things in the right order.

Still having problems.

If I ask for 002.mp3, the module is playing 001.mp3.
If I ask for 006.mp3, it does play 006.mp3, but any of the other numbers are not the correct songs.

I can't wait to see posts from you other members who have ordered some to play with, and see if you have the same problems.

My (very basic) test code is:

Code:
high 0 ' Serial output pin idle-high
wait 5 'Allow module to fire up

start:
  serout 0,T4800,($EF) 'STOP module
  wait 2
  serout 0,T4800,($02) 'PLAY song 002.mp3
  wait 5
  serout 0,T4800,($EA) 'PAUSE playback
  wait 2
  serout 0,T4800,($EA) 'UNPAUSE playback
  wait 5
  serout 0,T4800,($06) 'PLAY song 006.mp3
  end
The commands($EF, $EA) are working fine - it's just the filenames I am still having issues with.

EDIT: Changed code so high 0 is FIRST, then it waits 5 seconds to allow the module to fire up, and this seems to be working - I will try more files in the sequence and let you know how it goes. :)

ANOTHER EDIT: Yes, this code seems to be working well. THERE IS ALSO A 4k7 PULLUP TO 5v ON THE RXD PIN - This is not on the circuit, but seems to help keep things stable from fire-up.

I will now add more files so I have more then 10, and rum more tests and post back with results.

Progress though. :)
 
Last edited:

Grogster

Senior Member
Interesting, this FAT thing - screenshot of files as copied by Windoze in group mode attached.

I wonder why Windoze does not auto-sort BEFORE copying, or why it copies files like this anyway? Oh well, with DriveSort, I can put things in the right order easily. :)
 

Attachments

Haku

Senior Member
Grogster, does that mean the DriveSort program sorts the files into correct order in the FAT so the mp3 module now plays the correct file?

It also begs the question; can you call the files things like:
"001 - sound effect 1.mp3"
"002 - sound effect 2.mp3"
"003 - music track.mp3"
"004 - background sounds.mp3"
etc.
because it's actually reading where file X starts and not the name of the file?
 

Grogster

Senior Member
@ Haku - YES - you can sort the files in the SD card, then rewrite the FAT with it, so they are all in the right order - this is MUCH faster then one-by-one.

1) Copy 100 or so MP3's using Explorer
2) Use DriveSort to arrange them in accending order, rewrite the FAT and away you go. :)

On the filenames - I have wondered the exact same thing myself. :)
I will do a test and find out, and post back...
 

hippy

Technical Support
Staff member
I wonder why Windoze does not auto-sort BEFORE copying, or why it copies files like this anyway?
1) It doesn't need to. As programs looking for files in the FAT should be searching through it to look for a name match ( or the telling the OS to do that ) then it doesn't gain anything.

2) It takes time and resources. Which is wasted time and resources as it doesn't need to be doing it anyway.

3) It impacts system performance. As it's the destination FAT which needs to be kept in sorted order it means sorting every time a file is added to a FAT. This will have a massive impact on the system performance.
 

1968neil

Senior Member
MP3 Module

Just ordered an Mp3 Module,

Just a note to say look at the other stuff on the site, they have some very interesting modules and the costs are very low, especially RFID tags Xtals and the like.
www.mdfly.com
Makes our UK suppiers look very expensive !
Lcd modules are also VERY cheap.

Enjoy

Regards

Neil
 

Haku

Senior Member
Grogster, extremely pleased you've managed to figure out the initial hiccups with using the module, and especially testing the filename theory, it's going to be so much easier to keep track of files when you can give them proper names :)

Seriously can't wait to get mine now! Maybe Mdfly should be notified about the FAT mis-ordering problem causing out-of-sequence track playback and the easy solution.
The stock level has dropped quite quickly, now down to 24, I think the word is definitely out ;)


edit: They arrived!!! :D
*furiously sets up one on some breadboard*
 
Last edited:

Haku

Senior Member
I'm listening to a 320kbit mp3 from an 8GB SDHC card played back on one of these modules through my main 5.1 speaker setup, the sound quality is quite amazing.

Two minor gripes with the sound quality; the output volume is much lower than standard 1V P-P so I've had to turn the volume right up, and secondly the it's not 'hi-fi' quality in that there's a very slight background inteference from the embedded microcontroller which can be picked up during quiet moments in the audio, which can be especially noticable when I play it through the 3+3 watt amplifier from DealExtreme (bit of a downer that).

But for $10+P&P it's bloody amazing! :D

I notice there's 10k resistors on the audio output lines, if I bypass these would I get a louder output?


Looking at the back of the unit it has this printed on it:
"MP3 Playback Module"
" TDB380 V1.0 "
and there's a lot of hits on Google for TDB380, including a proper datasheet, which states it can run as low as 5v, and I'm running mine from 4x rechargable AAs giving out 5.24v without a problem.


edit: looking at the datasheet the output vol is 200mV P-P which explains the low volume, but interestingly it has different control modes set by a couple of resistor positions, and it's not limited to 199 mp3 files, but almost 3000 :eek: by making 14 folders which can each have 199 mp3's in and selecting which folder through use of another serial command.
 
Last edited:

hippy

Technical Support
Staff member
Good sleuthing. There's a V2.1 datasheet around but I forgot to note where the link was.

Around 250mV used to be standard for HiFi before CD's came along. Try and reverse engineer the circuit before replacing resistors; it could be PWM'd output using R+C so could have other consequences.

Mine haven't turned up yet :-(
 

Grogster

Senior Member
@ 1968neil - Yes, they have lots of other interesting stuff. I bought a half-watt stereo FM transmitter - it's even PLL and has an LCD, all for US$50! :eek:
http://www.mdfly.com/index.php?main_page=product_info&cPath=8_50&products_id=454

@ Haku - Top job on locating a proper datasheet - I have downloaded and printed that one, cheers! :) Yes, you are right about the low level, but as hippy points out, before CD's came along... A small low-noise pre-amp would get around this problem, and this is what I am planning to try next. Also great news on not being limited to 199 files - EXCELLENT bit of info. :) :)

I am so impressed with these little things, I have bought another 8 units.

You are also right about the low-volume noise - I did not notice that, but now you point me to it, with a quiet song, might be noticable. Me thinks you MIGHT be able to help that, by setting the module's volume control down a bit, and putting a pre-amp on the output to make up the difference. Sometimes those noises are only there at maximum volume...

@ hippy - Yours can't be far away, if Haku has his ones.
 

MartinM57

Moderator
How long is the delay between commanding an MP3 to play and it starting?

Can you queue up MP3s to play or does it jump to the new one as soon as the command is received?

Just thinking if you had speech fragments as separate MP3s could you use this as some sort of "announciator" - like a speaking LED display voltmeter..."two point four volts precisely" ;)
 

Grogster

Senior Member
I notice there's 10k resistors on the audio output lines, if I bypass these would I get a louder output?
I don't see them - C17 and C18 SMD audio coupling caps, but I don't see any 10k resistors on the audio output... :confused:
 

Grogster

Senior Member
How long is the delay between commanding an MP3 to play and it starting?

Can you queue up MP3s to play or does it jump to the new one as soon as the command is received?

Just thinking if you had speech fragments as separate MP3s could you use this as some sort of "announciator" - like a speaking LED display voltmeter..."two point four volts precisely" ;)
In button mode and serial mode, the playback is within about 200ms or so, but without a more accurate way to test... Instant, for all intents and purposes. You can select another song while another is playing, and it switches to the new song just as quick.

You can't cue any songs. You select them either with buttons, or if you are in serial mode(as most people here would be), you start a song playing, and via the BUSY pin, wait till it's finished then select the next one etc.

YES, it does jump to the next song immediately on receipt of a command to do so.

Your idea is a good one, and I see no reason why you could not use it as an annunciate exactly like that - the PDF Haku links to says you can use the module eactly like that. :)
 

Haku

Senior Member
Grogster, I have pretty good hearing which is why I picked up on the noise quite quickly, despite having tinnitus :)(), but in testing it's mostly only noticable with this 3+3 watt amplifier which is tetchy about having an ultra-clean power source (when powered from USB it picks up on the PC inteference too easily), when plugged into a 'proper' audio amplifier it's not so noticable.
Still, I don't have any high-end audio projects for this module, just toys :D

Oh caps not resistors, nevermind, guess I wasn't looking closely enough.

MartinM57, the delay is a fraction of a second and you can interrupt the current playing mp3 and start playing another without having to send a stop signal, on some tracks it appears to cut off the very beginning, maybe a first clash of the drums of a beat, but mostly it's not a problem and if you were designing it to be an automated announcer you'd account for this when editing the original wav files.

To queue up a string of mp3s you feed the busy signal from the module into your picaxe and watch for it to drop, then tell the odule to play the next mp3 and wait for the busy signal and so on.

Speaking voltmeter... now that's a great idea! :)
 

Grogster

Senior Member
How you doin' yours, Haku? ;)

I had to wait for busy line to go high before sending next song command - BUSY is active low(is low while playing, goes high when idle).
 

Grogster

Senior Member
Here is my working code. This code just plays the first 15 songs one after the other - nothing fancy, but uses the BUSY line. Chip is an 18X, and input2(leg1) has a 10k pull-down, output 0(leg 6) has a 4k7 pull-up. 5v supply.

Code:
high 0 ' set output 0 idle high
wait 5 'allow module to wake up and initialize(might not need that long)

serout 0,T4800,($EF) 'STOP module before doing anything

start:
  for b1=$01 to $0F 'Setup playlist
  high 3 'Turn on command-sent LED
  serout 0,T4800,(b1) 'Play song
  pause 500 'Allow module to respond
  low 3 'Turn off command-sent LED
  gosub busy 'Check if song is finished
  next b1 'Play next song.

busy:
  if pin2=1 then 'If BUSY is high then
        return 'go back and play the next song
    else 'Otherwise
  goto busy 'Stay in this loop until pin2 IS high
  endif
 

Haku

Senior Member
I've only really just scratched the surface of using the module from a Picaxe, first bit of code is this, it continually plays random tracks one after another and you can manually skip to another random track through a push button:
Code:
#picaxe 18m2
#no_data
pullup %00001000
pause 400
do
 if pinb.3=0 or pinb.2=1 then 'b.3=push button, b.2=busy signal
  serout c.2,T4800_4,(w0) 'play random track
  do while pinb.3=0:loop 'wait untul push button is let go
  pause 100 'for debouncing & waiting for the mp3 module to run
 endif
loop
Finding out that it can handle an 8GB SDHC card and almost 3000 tracks gave me the idea that you could use one to build a jukebox, throw in an LCD screen and a numerical keypad along with a flip-book printout of all the track names & numbers - not that I'm going to attempt it as I've got other plans for my first installation, a remote controlled talking Pontiac Firebird... :D
 

Haku

Senior Member
Yeah, it's like magic or something :D

That should been 0 not w0, a minor throwback from tinkering with the code too much.
 

MartinM57

Moderator
I need to be careful with the irony - I see that you might live just down the road from me and might come and hit me with a Bat ;)
 

hippy

Technical Support
Staff member
Haku gets a Gold Star

To say I'm impressed is an understatement. Thanks to Haku for bringing it to my, and our, attention. Knocks the spots off a consumer 'MP3 stick' and trying to control the buttons!

Haven't tried a lot but working fine using high-speed serial on a 20X2 at 5V. Module draws about 62mA when turned on and after $EF (Stop) command, about 72mA when playing. Gets flaky approaching 4V5.

$01-$C7 (Play Track) commands select Nth file on disk which isn't exactly the same as FAT entry in the strictest sense. Using a 1GB FAT32 SD card with long filenames, haven't tried any directory stuff yet.

I've not noticed any audio artefacts but only have it plumbed into the TV ( has easy access front sockets ). Will try with the Hi-Fi and the super-dooper Sennheiser HD560 headphones when I get some tracks I'm familiar with on there.

And a quick note to anyone who sells old SD Cards to Cash Converters, Computer Exchange etc ... be sure to not leave contact details like your name, home address, bank account and password details on it. Probably best not to put them on a phone in the first place ;-)
 

Grogster

Senior Member
$01-$C7 (Play Track) commands select Nth file on disk which isn't exactly the same as FAT entry in the strictest sense. Using a 1GB FAT32 SD card with long filenames, haven't tried any directory stuff yet.
Use DriveSort to get you around that problem - nice and easy to use, small, free, can display both short and long filenames, works a treat for resorting the FAT.

Haku linked us to that one too, so I 2nd the motion for a gold star. :)

You can download DriveSort here:
http://www.anerty.net/software/file/DriveSort.php
 

Haku

Senior Member
*Haku does the smarty pants dance* (but probably doesn't look so cute being a 6'2" guy) ;)

It doesn't seem to be fussy about what SD cards you throw at it so long as they're 8GB or less, I've got two 1GB BluBox SD cards from eBay (new, sealed) and a 8GB SDHC Veho branded card and haven't had problems with any of them. All formatted to FAT32 and used DriveSort on them to properly organize the files.

If you've got one of these modules, post what brand SD cards you've tried with it and the results.


A while back I bought a cheap 512mb USB stick mp3 player in the hope I might be able to hack it to work with a Picaxe but it turned out to only have 3 buttons, the disappointment I had drove me to spend a couple of days scouring the web for something better that didn't cost an arm and a leg, that's when I discovered this neat module.
 
Last edited:

hippy

Technical Support
Staff member
So who's up to be the first to post some code (and MP3s) to count out loud from 0 to 10 to 1 decimal place using speech fragments without sounding like TIM
Not quite as spec'd, and not entirely different to TIM ( it's Mrs TIM ! ), but here's a sheep counter to send you comatose if having trouble sleeping.

Written for the 20X2 but should also work on any X2; uses scratchpad. I'll try to create a generic program which works on any PICAXE but it's getting late now, and it's 'one thousand, two hundred and sixty four' and I'm feeling sleepy :)

It's a zipped file so lose the .DSN extension after download, then unzip the .MP3 in numerical order to SD or use DriveSort etc. Download the .BAS into a PICAXE.

MP3 files come from the Open Source Asterisk project via Nathan E Pralle. Not sure if the delays between words are padding in the MP3's or sluggishness of the MP3 module ...

http://www.nathanpralle.com/software/ast_masterlist.html
 

Attachments

MartinM57

Moderator
Excellent and usual Hippy style code - I suspected there must be some "open source" sound bites somewhere. There's certainly some classic bites on that site.

Have to take it down the farm and see if it works with real sheep ;)

I thought TIM was a Mrs - all about clarity down carrpy phone lines etc...
 

Grogster

Senior Member
It doesn't seem to be fussy about what SD cards you throw at it so long as they're 8GB or less,
I remember that the SOMO module from 4D Systems was VERY particular about what uSD card you fed it - this is a nice change. :) I myself have tried Adata 2GB and Trancend 2GB uSD cards(in a SD card adaptor) and they work fine. Very nice to know that the module can read SDHC, but I doubt I would ever find a need for that kind of capacity in MY applications... ;)
 

hippy

Technical Support
Staff member
@ MartinM57 : You could be right that TIM was and is female. I recall a male voice at one time (1970's?). Google probably knows.

@ Grogster : 2GB cards are usually the awkward ones to work with, on the boundary of the change from SD to SDHC, 2GB could be either and there are various versions of SD standards. It really comes down to how good the code is used to determine the different versions and type. I generally stick to 1GB and below or 4GB and above to avoid the problems.

One thing I'm doing is collating the MP3's needed to perform PICAXE number, date, time, temperature, direction and meter functions so there's a 'defacto numbering scheme' and a single file to download. All the files can be unzipped to SD and will just work as long as in the correct order. That will save others the effort of downloading plus file renaming and numbering. Should be well below 32MB so no great loss having files you'll never use on SD.

The speech isn't perfect but better than nothing. It also gives a crib sheet of what's needed if anyone wants to voice their own set. One option is to use Microsoft Agent text-to-speech to generate WAV / MP3. Personally I like Merlin the Wizard's voice but YMMV.

The only annoyance I really have with the modules is it seems quite difficult to get the SD card out. Mini/Micro-SD card in a Mini/Micro-to-Full adapter makes it much easier. There's solder pads for what looks like a Micro-SD card socket for the adventurous. A Poundland SD reader could possibly be stripped for such a socket. Could even unsolder the existing socket and reconnect via flying lead for easier access, or parallel up another.

Two possible 'bugs' or 'features' found ( haven't fully investigated ); pause track, short pause, resume track, short pause in a loop didn't seem to have the desired effect ( commands are probably queued when playing ), and resume track after end of track played the next. Could be put down to my own 'poor design' more than bug.

One thing I noticed is that, on turn-on and after issuing a play track command, two bytes are returned via serial. I suspect these are 'folder' then 'file'. With volume turned off it should be possible to determine how many folders and how many files are in each if required. Can be done once after download using Eeprom flagging. Not seen any serial come back other than at turn-on or after play track.

Still haven't investigated directories but assuming it works that will be great for me as I'm hoping to replace the bathroom ambient music system with this. As there's only a few albums each can be in its own directory and can be worked around if not. That means rid of a whole PC, larger 'disk' thus higher bit-rates, and running costs drop massively; for the PICAXE and MP3 module I calculate less than a pound a year. Plus shrinkage from a tower system to 'fag packet' size and importantly, absolutely zero fan noise.

There's got be some easyish way ( 4066 analogue switches probably ) to make the SD shareable between MP3 Module, SD Card Writer and PICAXE so should be possible to build a jukebox which is USB downloadable from PC, have the PICAXE read the FAT and determine album and track names, store those in I2C Eeprom, then control the module. That's a longer term project.
 

Haku

Senior Member
@ hippy, there's a very simple solution to easily remove the SD card from the mp3 module, a bit of stickytape on the underneath of the SD card, with the end folded over on itself:

It also makes putting the SD card into the module easier, just watch for the pins of the crystal that they don't scratch the tape.

I had a look to see if there was any such SD card externder adaptor, found a couple but nothing you can easily buy in single quantities, the idea of soldering wires to the SD card socket from a cheapie pound store looks viable, and the analogue switch with a SD-USB adaptor seems better so you don't have to remove the card at all.

I've just tried the folders thing, works like a charm, can select any folder at any time and play a track in it, but the '0' command to play random tracks only selects tracks in the root folder.
 

hippy

Technical Support
Staff member
Have managed to determine which folders exist using the two status bytes returned; the fist is the number of the folder actually selected ( so 1 if folder doesn't exist ), but the second is the number of the track (file) requested regardless of if it exists or not.

It seems to play the first track in the current folder if it cannot find the one requested so that's a solution. Create a very short 000.mp3 and then number files 001.mp3 to 198.mp3, and adjust the code to suit ( send $02 to play 001.mp3 etc ). The track count detector can play a track, if it's not playing after a second or so then it chose 000.mp3 to play. Can work the number of files out from there.

@ Haku : Thanks for the tip about the crystal pins. A bit of surgery and trimming them closer to the PCB has greatly improved things.
 

Attachments

hippy

Technical Support
Staff member
Whoot! Now determining how many tracks in each folder. Only scans the card immediately after program download so probably want to force scanning with a push button.
 

Attachments

Haku

Senior Member
I think it's hippy's turn to do the smarty pants dance for his sleuthing on the TX output and figuring out a way to determine the number of tracks in a directory. :)

I bought another USB-SDHC reader from my local 99p store today for the SD connector, I might have a go at removing it from the reader and soldering wires onto the existing connector on the mp3 module.

I notice their stock count is now 2 :eek: I think it suddenly became popular
 
Top