This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to save a song on my Tiva Launchpad TM4C124GH and then play it with a buzzer

I want to save a song from my laptop into the Tiva microcontroller and then play it with a buzzer. I´m not sure were to start, I haven´t seen many projects related to it, just some with Arduino...

  • Hello Sergio,

    First of all note that the buzzer plays a PWM output that is used to imitate a audio signal. It is not the output of a true Audio DAC.

    1. What is the format of the song on your laptop that you want to transfer to TM4C?
    2. What is the storage or transfer medium that you will use, since the uC's have limited on chip flash and it can't be expected to store the entire 5 minutes of a song.

    I would suggest a good read of the example code in TivaWare

    D:\ti\TivaWare_C_Series-2.1.1.71\examples\boards\dk-tm4c123g\usb_host_audio

    Regards
    Amit
  • Amit Ashara said:
    note that the buzzer plays a PWM output that is used to imitate a audio signal. It is not the output of a true Audio DAC.

    One wonders if poster really meant, "buzzer?"

    If so - and next project is high-power, Class D, Audio Amp - cb1 & co. (already) are "holding their ears..."   

  • Hello cb1,

    I wanted to make sure that the output is not 16 bit high quality audio.

    Regards
    Amit
  • Hello Amit and thank you very much for your prompt answer.

    My idea is to record piano sounds, 30 of no more than 1.5 seconds. That means 45 seconds of sounds. The format I was thinking is mp3. So let's say that we have 30 sounds of 40kb each. ( The way I will play the sounds is with an ultrasonic sensor, depending on the distance a piano sound should be emmitted.)

    About the buzzer, you mean I would need a normal speaker instead of it. It's that right?

    Thanks a lot and best regards!
  • Hello Sergio,

    Again: TM4C does not have a mp3 decoder on it. So you would have to first decode the mp3 to wav file format. Then use the value for every sample as the DC of a PWM signal to a buzzer to play back.

    Regards
    Amit
  • Hello Amit,

    Actually, I wanted to use every sample to play a particular sound, but as I said, the sounds are recordings of piano notes. So, in my laptop I have 30 recordings of 1.5s each (in wav format, thanks for that!). I want to save them on my microcontroller and play them according to the samples obtained from sensor logic. So how do I proceed?
  • Hello Sergio

    The internal flash and ram of the device is limited. So storing them in internal memory would not be a good idea. There are other alternatives like serial flash, sd card or usb stick out of which IMHO the simplest would be the sd card with fatfs from TivaWare. Now each of the tone file can be saved as independent file on the sd card with defined names. Based on what the sensor logic obtains the appropriate wav file can be read and then sent over the PWM output of the timer.

    Regards
    Amit