SPE035 Serial MP3 - Folder ADVERT ?

zorgloub

Member
Good evening to the Team,
I'm currently trying this small module described in Picaxe's SPE035.pdf file.
The MP3 module is a "DFPLAYER Mini" model.
Has anyone succeeded in activating a track placed in the folder ADVERT?
The command 0x13 ... does not work for my tests?
Do you have an example of a functional code?
Thanks to all
 

westaust55

Moderator
Can be helpful to provide a link to the datasheet so others do not need to spend time searching.
Here is the ne ready link:
http://www.picaxe.com/docs/spe035.pdf

As a first question, do you have the "Advert" folder as a sub-folder as mentioned in the datasheet (page 17)?
Not 100% clear (to me at least and reading on an iPhone) but I presume that is a sub-folder of the folder "MP3".

EDIT:
Appendix2 (page22) makes no mention of "Advet" being a sub-folder.
Both "MP3" and "Advert" are both referenced in the same sentence as "folders"

Hmmm at page 5, "MP3" is referred to firstly as a sub-folder (of the root directory/device) then later as just a folder in the bullet points.
 
Last edited:

zorgloub

Member
Hi Westaust55 ;)

Nothing really seems clear in this pdf! :confused:

For me, MP3 and ADVERT folders are independent directories placed directly on the root of the SD Card.

I am already wondering if this "DFPlayer" module actually handles the ADVERT folder or if you need to use the "BY8001-16P" module?

So many questions that need to be clearer in Picaxe's Pdf! :(

Has anyone ever tried this module SPE035 and successfully launched an Advert?

Regards
 
Last edited:

tmfkam

Senior Member
Hmm... I thought I had tried the Advert function in some experimentation with these modules, but found it didn't have the results I was hoping for. I can't remember what, or how, or why. Which isn't much help, but I'm sure I did get the function to work, just not as I wanted. I don't have any code that does demonstrate the Advert function, but as I changed the code 'on the fly' I'm not totally surprised.

The manual I have for the DfPlayer makes no mention of the Advert function however as it is very confusing, and misses out a whole bunch of other information, I'm not too surprised to find that.

It may be that the Advert function requires that the tracks are named/numbered/selected using a different command and folder/track protocol than you are using? Some of the commands appear to require a two digit folder with three digit track numbering system, some require the opposite.

A few of the playback commands from the command set given in the (SPE035?) manual, although I think this is my interpretation of the commands, so there may be some inaccuracies:

Code:
'All commands to be sent in Hexadecimal format
'$01	$00 $00	Next 
'$02	$00 $00	Previous 
'$03	$nn $nn	Specify track 0000-0BB7
......
'$0F	$ff $tt	Play from folder ff=01-63, track tt=01-FF 
'This is the command I use, requires folders numbered 01, 02, 03...etc, tracks numbered 001, 002, 003...255
......
'$12	$tt $tt	Play from MP3 folder, track tt=0001-270F 
'$13	$tt $tt	Play from ADVERT folder, track tt=0001-270F 
'$14	$ft $tt	Play from folder f=1-F, track ttt=001-3E7
Now you'd *assume* from that, that the Advert function requires the same track numbering system as the MP3 folder, and that both the MP3 folder, and Advert folder were placed in the root directory of the disk given that the commands are listed as requiring the same 'track number' only values. In practice, I'd do some experimentation.

Here is the manual for the DfPlayer module, make of it what you will.
 

Attachments

zorgloub

Member
Hi tmfkam

Thanks for the link of the Pdf I had already consulted.
In this document are also abberations!

On the first page, it is mentioned "The audio data is sorted by folder; supports up to 100 folders, each folder can be assigned to 1000 songs".
According to my tests, there can be only 99 folders each containing a maximum of 255 tracks!

Note that you can also add an MP3 directory in which you can place 9999 tracks.

And there is no mention of the folder Advert, unlike picaxe file spe035.pdf!

I tried to put the Advert directory in the MP3 folder but with no result.

It seems that only the pdf file of Picaxe mentions the possibility of these priority Advert warning messages.

At this point in my research, I still can not activate them!

This post remains open ...;)
 

Steve2381

Senior Member
Why are the instructions for these potentially complicated items so rubbish? Do the people that write them not read it back to themselves and think 'Hmm, that is as clear as mud'
 

hippy

Technical Support
Staff member
Why are the instructions for these potentially complicated items so rubbish? Do the people that write them not read it back to themselves and think 'Hmm, that is as clear as mud'
Much of the problem is the core datasheets are written in Chinese and translations are not as accurate or as complete as they could be.

As to advert playing; there is example code included with PE6 along the lines of -

Code:
SerTxd("Play MP3 folder song 0010", CR, LF )
cmd = $12 : arg = 0010 : Gosub Send
Pause 5000
   
SerTxd("Insert ADVERT folder advert 0001", CR, LF )
cmd = $13 : arg = 0001 : Gosub Send
From that I would say that there needs to be an "X:\ADVERT\0001.mp3" alongside the "X:\MP3\0010.mp3" file.

It has been a while since I used the AXE171/SPE035 but I recall the commands were tested while it was being developed.
 
Last edited by a moderator:

zorgloub

Member
Hi Hippy,

Yes, this is the code I use [cmd = $ 13: arg = 0001: Gosub Send]
I have a \MP3 directory and another \ADVERT.
However, Advert files do not work ...
 

hippy

Technical Support
Staff member
It's hard to tell what the problem may be from afar. Does the advert MP3 play when it's used as a normal file ?

Perhaps describe your hardware in full, which PICAXE and board you are using, post your full code and a full directory listing of your SD card.
 

hippy

Technical Support
Staff member
I would say trim the code down, don't use tracks as high as 9999, remove the 01-99 directories. Adverts are meant to be inserts for what is currently playing so it may be that trying to play them when there is no other song playing may not work.
 

zorgloub

Member
OK Hippy,

The folders 01 to 99 was just to test the limits of the circuit. I can settle for the only MP3 folder. Idem for test files nr 9999.

I read that you would have to run a track advert WHILE a normal MP3 would be running...

Well, How to do this because during the MP3 track playback, I assume that the picaxe is busy? Should an interrupt be used?

Do you have just a sample code to launch a "Track Advert" while a "normal" MP3 track is being executed?

Thank you for your help.
 

zorgloub

Member
So, I tried this code:

Code:
Sertxd (" *** Reading Folder MP3 ---------------------->", cr, lf)
VarA = 3 
Sertxd (" ---> Playing Track nr 3", cr, lf)
 Cmd = $12 : Arg = VarA : Gosub Send   ' : Gosub Busy
 
pause 5000  'To leave a little time to the MP3 message that will soon be interrupted
VarA = 1
 Sertxd (" ---> Playing ADVERT Track nr 1", cr, lf)
 Cmd = $13 : Arg = VarA : Gosub Send]
And it works :)
However, I must remove my routine "Busy" because it loops until the end of the MP3 message.
Or, to "break" this loop use an interruption to launch an Advert.

Correct?

Other:
- I see that the serial protocol provides a CheckSum but if you do not use it, it does not matter! Is not it odd then a checkSum is "blocking" if it is wrong ??

- Finally, one last question, do you know the function of the parameter "FeedBack" in this serial protocol?

Thanks
 
Last edited:

hippy

Technical Support
Staff member
However, I must remove my routine "Busy" because it loops until the end of the MP3 message. Or, to "break" this loop use an interruption to launch an Advert.

Correct?
You would probably need to use something like ...

Code:
Do

  Cmd = $12 : Arg = 3 : Gosub Send ; Play background music track

  Do
    If time > 20 Then
      time = 0
      Cmd = $13 : Arg = 1 : Gosub Send ; Insert advert 
    End If
  Loop While BUSY = 0

Loop
You will have to play around to get busy handling right for advert and main track. You might have to use the serial responses to do it properly.

I see that the serial protocol provides a CheckSum but if you do not use it, it does not matter! Is not it odd then a checkSum is "blocking" if it is wrong ??
That's just the way it is; one would need to ask the designers of the firmware why. It could be to have it compatible with some other system and also easier to use.

Finally, one last question, do you know the function of the parameter "FeedBack" in this serial protocol?
I recall it controls serial responses and what data is echoed back using those.
 

tmfkam

Senior Member
The time taken for the player to load tracks depends on how far 'into' the disk they are. Track 001.mp3 in folder 01 may take less than a second to load. Track 001.mp3 in folder 25 may take 30 seconds (or more) to load. I had to build a variable delay for detecting the busy signal to take account of this. It is also possible for the 'busy' line to indicate a track is playing momentarily (I believe as it is located in the FAT table, but have no proof of this) and then to indicate it is stopped while the actual track is located and loaded. This can, if not considered, cause any software checking the busy status to imagine that the track started to play then, shortly afterwards came to an end. I have now had to check that the busy status indicates play continuously for a number of seconds before assuming the track requested is playing, along with that variable delay.

After saying that, I have got a microSD filled with over 6000 tracks, initially spread across 25 folders, with 254 tracks in all folders apart from the last one. I'm now trying to move all the tracks into one 'MP3' folder to make managing them easier.

As I read the datasheet (which is open to much interpretation) tracks in a folder named MP3 must have a four digit numeric index, not a three digit. When I tried a three digit numbering system in the MP3 folder, it failed to work for me using the command $12 to call the playback.

Files do not seem to need to be purely numerically named. A file named 0001.mp3 is treated the same as a file named 0001_File one in the folder.mp3 which makes things a little easier.

Requesting data responses back from the module gives yet more confusion. Trying to request the track count where there are multiple folders (01, 02, 03 etc.) appears to return only Number of folders - 1, if there are differing numbers of tracks within the folders it is difficult to deduce the actual track count. In very brief testing, where there is only one folder (MP3) the number of tracks - 1 seems to be returned. Although as of yet, I've only got 510 tracks in that folder, I'm still waiting for the copy procedure to complete before I can test with the full 6000+ tracks.

All that being said, I think the SPE035 module is fabulous. Once the limitations are understood they are a great little unit. Using either good quality headphones or connecting the auxiliary/headphone outputs to a quality amplifier shows that the sound quality they produce is very good.
 

zorgloub

Member
Hi,"Technical,
Thank for your intervention.

OK, no problem with this point: 4 digits useful for files in the folder MP3 and Advert, and 3 digits useful for files in folders 01 to 99.
That was very clear to me.
Only explanations of your pdf file should be clearer about enabling files in the Advert directory.
Notably the absolute necessity that another file is already being read / broadcast!
The key to the mystery lies in this "detail".
But it is now very clear at the end of this post.
If anyone is interested, I will post a review (in french) of this module on my page http://www.alpmn.byethost32.com/serial_mp3.htm

Thank you for your contribution to all.
 

hippy

Technical Support
Staff member
Hi Hippy,
I look at your little code and wonder where and when the time variable is incremented. (If time> 20) ?
'Time' auto-increments by itself on the M2's but you will need something else on an X2; either SETTIMER or simply count PAUSE periods ...

Code:
Do

  Cmd = $12 : Arg = 3 : Gosub Send ; Play background music track

  Do
    If time > 20000 Then
      time = 0
      Cmd = $13 : Arg = 1 : Gosub Send ; Insert advert 
    End If
    Pause 10
    time = time + 10
  Loop While BUSY = 0

Loop
 

zorgloub

Member
Oh yeah, that's talking to me about an X2.
But I do not know this "function" time that would be auto-increment on an M2 !?
I do not see anything about it in the picaxes booklet.
 

westaust55

Moderator
Oh yeah, that's talking to me about an X2.
But I do not know this "function" time that would be auto-increment on an M2 !?
I do not see anything about it in the picaxes booklet.
"Time" is a special pre-defined variable that is incremented once per second at some clock speeds (4 and 16 MHz) and other intervals if other clock speeds are selected .

See PICAXE Manual 2 on page 16.

Also on pages 17 and 18: Variables - Special function
time - the current time (seconds counter at 4MHz or 16MHz)
 

westaust55

Moderator
If anyone is interested, I will post a review (in french) of this module on my page http://www.alpmn.byethost32.com/serial_mp3.htm

Thank you for your contribution to all.
Please consider to post your information on the PICAXE forum - say in the Finished Projects area for audio-visual topics
That way it is available for all in the future who come here with the same/similar questions.
If you post separately, experience is that after some time a number of external websites no longer existing and the information may no longer be available to others.

You can always post in both English and French as you do with your questions.
 

zorgloub

Member
Hi everyone,

To launch an advert message in all conditions, with my 28X2, I finally opted for this solution:
(The blank file is a short mute file of 2 or 3 seconds, which allows the launch of the Advert message in case of no other file is being broadcast)

Code:
   Advert_Msg = 0003     ' Advert to launch: ---> 0003 - MCU Heat Alarm.mp3
      if Busy_pin = 0 then   'A other "normal" track is being playing
       Cmd = $13 : Arg = Advert_Msg : Gosub Send  ' Launch ADVERT  ---> 0003 - MCU Heat Alarm.mp3
                                                                           ' And the normal track resumes here where he was arrested
      Else
       Cmd = $12 : Arg = 0001 : Gosub Send            ' Launch blank file  ---> 0001 - Advert Calling.mp3
       Cmd = $13 : Arg = Advert_Msg : Gosub Send  ' Launch ADVERT  ---> 0003 - MCU Heat Alarm.mp3
      Endif
Good night ... or good day ... according to ;)
 

zorgloub

Member
Attention, there is still a finesse (Tested)!
It is essential to place a short pause just after launching the very short blank "calling" file.
This allows you to run the Advert file before the short, blank file has reached its end!
Indeed, to launch the Advert, it is necessary that another file (here the blank) is active in the background.

And the functional code becomes:

Rich (BB code):
Advert_Msg = 0003     ' Advert to launch: ---> 0003 - MCU Heat Alarm.mp3
      if Busy_pin <> 0 then ' Nothing playing
        Cmd = $12 : Arg = 0001 : Gosub Send : Pause 10
      Endif   
  Cmd = $13 : Arg = Advert_Msg : Gosub Send
 

Technical

Technical Support
Staff member
Is there any reason why you could not simply duplicate the advert file in both the MP3 and ADVERT folders?
Then you could simply play it as a normal MP3 file if there was no file already playing - this would prevent the need for the 'blank file' system completely.
 

zorgloub

Member
Hi Technical,

I had already imagined, at the beginning of my study, and tested, your proposal which also works.
It also requires a conditional test to know if we play the file from the Advert directory or if we play the "duplicated" file in the MP3 directory.
However, I did not find it very practical or "structured" to have to duplicate the Advert file to place it in two different directories!
So I prefer to place the Alert files in the Advert directory and the usual files in the MP3 directory, and use a small conditional test to launch a "blank and mute calling file", if necessary.
Thank you for your interest in my initial question.
 
Top