Author Topic: upload audio to PIC32mx and using I2S  (Read 2142 times)

0 Members and 1 Guest are viewing this topic.

Offline nithiA

  • Newbie
  • Posts: 4
  • Country: th
upload audio to PIC32mx and using I2S
« on: July 12, 2016, 08:09:41 pm »
Hi
I am new to microcontroller.
I am using PIC32MX1/2/5 Starter Kit with I/O expansion board.
Also the software I am using is MPLAB X IDE 3.35, XC32 1.42, Harmony 1.08.
What I want to do is
1. I want to upload a few short audio files (2-4 seconds) to the MCU. How can I do this?
2. I want to send these audio to external device via I2S. For example, If I press SW 1 on evaluation board, MCU will send a specific audio to external device by I2S. How can I do this?

Can anyone advice any solution or examples.
Thank you.
 

Online Buriedcode

  • Frequent Contributor
  • **
  • Posts: 840
  • Country: gb
Re: upload audio to PIC32mx and using I2S
« Reply #1 on: July 13, 2016, 07:09:47 am »
How large are these files? I assume they are raw, or *.wav files, in which case you won't get very long audio clips if their are 16-bit at 48kHz sample rate. Better to store the file in external memory.

In answer to your second questionL break the problem down into parts, and work on each part one at a time.  So first of all, as you're new to microcontrollers, google for 'blink code'. Then look for example code for the I2S port, and output say, a sine wave, from a table and check that with a scope to make sure the I2S part is working, then finally, you could store the wav file on external memory, like a serial EEPROM.  Then all your microcontroller will have to do is read form the EEPROM, into a buffer, and output to the I2S port.
 

Offline hans

  • Frequent Contributor
  • **
  • Posts: 931
  • Country: nl
Re: upload audio to PIC32mx and using I2S
« Reply #2 on: July 13, 2016, 05:25:06 pm »
Yep indeed, I would recommend first working on the basics, and then move on to transfer an audio stream via I2S reliably. That audio stream will need to be buffered in RAM; so it's source can be anything.. a software tone generator, USB audio device, or a WAV file.

WAV files tend to be rather big thuogh, 48kHz x 16-bit x 2 = 192kB/s of data, so if you got 256kB of internal FLASH you can only store let's say 1 second of audio data.

Connecting a button press to play of a WAV file is a matter of reading a GPIO and then commanding your playback code to start playing (e.g. filling audio buffers) that file.
 

Offline nithiA

  • Newbie
  • Posts: 4
  • Country: th
Re: upload audio to PIC32mx and using I2S
« Reply #3 on: July 15, 2016, 12:59:21 pm »
Thank you Buriedcode & hans
I can work on basic LED already.

How large are these files? I assume they are raw, or *.wav files, ...

What type of audio file does MPLAB Harmony (written using C programming) is accept?

I have 4 audio files which are 68kByte (*.wav file [1 channel-mono]) 16 bits Sampling at 22.05kHz each.
Now I am using PIC32MX570F512L which has 512Kbyte, so I think it should be enough to keep these 4 audio files.

I search online and could not file any examples for I2S in MPLAB Harmony.

Hope anyone can help.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 4220
  • Country: gb
Re: upload audio to PIC32mx and using I2S
« Reply #4 on: July 16, 2016, 07:41:45 am »
I have done I2S on PIC32 and PIC24, but as an RX only, I can't remember though whether it was frame/bit clock master/slave.

My first question, what is your codec, is there a requirement for who is master or slave for frame or clock? Sometimes it is easier to choose other protocols like LJ of you can.

My application was at 48, 96 and 192kSa/s, 2ch, at 16 and 32 bits/sample (16 bits only at 192kSa/s).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf