Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

MP3, WAV player

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1019
Location: France

france.gif
PostPosted: Fri Jan 08, 2021 1:29 pm    Post subject: MP3, WAV player Reply with quote

hi
a small project based on the DF0534 MP3 WAV module from DFrobot
This module allows the reading of audio files in MP3/wav format sampled from 8 kHz to 48 kHz on a storage space of 8 Mb. This is not much but very sufficient to make sound effects, to send alert messages or .... to sound a clock.
They are many possibilities and you will discover them on the wiki of the manufacturer.
What I retained:
- We transfer MP3 or WAV files to the internal flash memory as if it were a USB key.
- attention : the order of the files does not work as indicated on the notice, I did not understand why ?
so it is necessary to test everything for example I renamed my files as indicated 01.mp3, 02.mp3.... but to launch the 01 I must send the code &h0A the code &h01 makes it possible to read a pre-recorded file which I left for the tests and renamed as 20.mp3.
- You have to start by adjusting the volume
- If you are using the include and enriching it, please let us know.

The demo programme allows you to play the attached pieces.
I have added waiting times between each call of the sub play( track) but in one of your programme you can for example launch sound 01 when the pressure, the tension was low... is sends your alarm without interrupting your programme.
the video :


[url] https://youtu.be/EOLCZLjy13g[/url]

JP Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5319
Location: Holland

blank.gif
PostPosted: Fri Jan 08, 2021 1:58 pm    Post subject: Reply with quote

thanks for sharing JP.
I moved the topic to AVR since it was in 8051 and the processor used was an AVR.
Should run on 8051 too with minor changes.

_________________
Mark
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1019
Location: France

france.gif
PostPosted: Fri Jan 08, 2021 2:19 pm    Post subject: Reply with quote

Quote:
I moved the topic to AVR since it was in 8051 and the processor used was an AVR.


sometime I'm too speedy and I am very often dizzy

Embarassed Embarassed Embarassed

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1019
Location: France

france.gif
PostPosted: Wed Jan 27, 2021 4:55 pm    Post subject: Reply with quote

Hi,
I add 2 new sub: Volup (increase volume of 1 step) and voldown (decrease volume 1 step) to the include file and I use only one line to printbin , like that it is more compatible withe the C sample from Dfrobot




Code:

' module voice from DFrobot DFR0534**JP Duval january 2021****************************
'---------routines serie
'******************************************************************************
$nocompile
Sub Play(byval Track As Byte)
   Local Cs As Byte                                         'checksum
   Cs = &HAA + &H07 : Cs = Cs + &H02 : Cs = Cs + &H00 : Cs = Cs + Track
  Printbin #voicew , &HAA ; &H07 ; &H02 ; &H00 ; Track ; Cs
End Sub
'---------------------------------
Sub Volume(byval Vol As Byte)
   Local Cs As Byte                                         'checksum
   Cs = &HAA + &H13 : Cs = Cs + &H01 : Cs = Cs + Vol
    Printbin #voicew , &HAA ; &H13 ; &H01 ; Vol ; Cs
End Sub
'------------------------------
Sub Volup()
   Local Cs As Byte                                         'checksum
   Cs = &HAA + &H14 : Cs = Cs + &H00 :                      'Cs = Cs + Vol
     Printbin #voicew , &HAA ; &H14 ; &H00 ; Cs
End Sub
'------------------------------
Sub Voldown()
   Local Cs As Byte                                         'checksum
   Cs = &HAA + &H15 : Cs = Cs + &H00
    Printbin #voicew , &HAA ; &H15 ; &H00 ; Cs
End Sub
 


JP Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5319
Location: Holland

blank.gif
PostPosted: Sat Jan 30, 2021 1:29 pm    Post subject: Reply with quote

thanks for the addition. i only do not get why you add a 0 to a byte?
_________________
Mark
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1019
Location: France

france.gif
PostPosted: Sat Jan 30, 2021 5:25 pm    Post subject: Reply with quote

Hello Mark,
You know, I follow the wiki. but they give very poor help , maybe the process need a null char

Quote:
Increase the volume(14)

Command: AA 14 00 BE

Return: None

Reduce the volume(15)

Command: AA 15 00 BF

Return: None

It is working well
JP

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1548
Location: Basel, Switzerland

switzerland.gif
PostPosted: Sat Jan 30, 2021 5:48 pm    Post subject: Reply with quote

Hi,

What mark means is, why are you wasting cpu time:-

Cs = &HAA + &H14 : Cs = Cs + &H00 :

X+0=X

Regards
Ian Dobson

_________________
Home of AVRTimer, the Bascom timer value calculator.
http://www.planet-ian.com

Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1019
Location: France

france.gif
PostPosted: Sun Jan 31, 2021 10:50 am    Post subject: Reply with quote

You are right Ian
for the checksum That is a coy/paste drama . I use the same line for all routine Rolling Eyes
but you have to send the &H0 when the routine need it
see
https://wiki.dfrobot.com/Voice_Module_SKU__DFR0534
Wink JP

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum