Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to transmit a .wav file into a flash device used with PIC

Status
Not open for further replies.

matrixofdynamism

Advanced Member level 2
Joined
Apr 17, 2011
Messages
593
Helped
24
Reputation
48
Reaction score
23
Trophy points
1,298
Activity points
7,681
A .wave file is an uncompressed form of audio storage and I assume that a PIC can easily process it and send samples to an ADC. Since a PIC does not have sufficient memory, rather than store a several KB or few MB of .wave files it makes sense to store them on an external Flash or external EEPROM. However, this raises the question, how to send this .wav file from the PC to the nonvolatile memory. Is there a standard procedure to do this for PICs e.g use a special program on the PIC and send the data through serial port from the PC and then the PIC can write it to the Flash or EEPROM?
 

Whatever the solution you chose for the architecture of the system, you should consider to implement some FIFO buffering at the PIC side, as well as to send the data from PC to PIC at a rate somewhat above the sampling rate, because of the fact that if you are running a program over a preemptive OS ( e.g Windows ) you cannot assure that it will occur at a precise tick, which is a requisite to properly reconstruct the audio, and than should send the data from the PIC to the D/A based on timer interrupts at the firmware.
 

Actually transmitting the audio samples is a one off thing. i.e it is done once and never again since in the actual application the PIC shall merely read the flash. It is just for short sound effects like khlish, dub, thuff e.t.c they are all only some 100s of ms long. The PIC or for that matter a CPLD or FPGA just has to read these samples and send them to an DAC and then these shall pass through a filter and then through an audio amplifer and goto a speaker.
 

Considering that most I2C memory devices are able to deal with clocks up to 400 Kbps, perhaps this will be an issue to the PIC to "read-from-there-and-send-to-converter", particularly if you chose a high quality audio, i.e at 20 KHz. I'm not sure if the complete reading cycle of the I2C protocol spend more than 40 clocks ( 400K/20K ), but unless you reduce the bandwidth of the audio - e.g undersampling and interleaving the read - seems like almost at the limit of its capacity. Instead of using a serial memory, I would think about using some parallel Flash memory, but it would require more pins of the PIC.
 

Save as wav file in mono PCM 8 or 16 bit format. Open in hex editor and delete first 168 bytes of header data. All the rest is your raw sound data.
 
A wav file may store signed or unsigned numbers for sample values. As far as I know DAC does not have concept of signed number since it only has power supply and GND and not negative supply so its output cannot go negative. How does one deal with negative signed numbers when it comes to digital to analogue coversion? How is this issue dealt with from the perspective of analogue to digital coversion?
 

As far as I know, the conversion of an signed to unsiged number is quite simple, done either by adding an offset value or just by type casting.
 

Actually for some messing around I loaded the wav file into MATLAB. The MATLAB seems to store it as floating point number which is signed. The .wav file header however explains whether it is 8 bit integer or whatever it might be. I guess the correct approach is to use MATLAB or C program to read all those samples and convert them into unsigned integers and store them back.

Also, I am trying to remember how does the computer store signed integers. What does -1 and so on.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top