Note that there are some explanatory texts on larger screens.

plurals
  1. POPWM Audio with reading data from SD card
    primarykey
    data
    text
    <p>Currently I'm working on this Arduino/Nanode project where we want to play a collection of WAV-files stored on a SD-card, with PWM on clock OCR0. - I'm able to play the PWM perfectly, starting from the sketch from Michael Smith on the Arduino website: <a href="http://www.arduino.cc/playground/Code/PCMAudio" rel="nofollow noreferrer">http://www.arduino.cc/playground/Code/PCMAudio</a> - I'm able to read the SD-card correctly and convert the data to 8bit integers that look correct when I print them to the serial window.</p> <p>The problem I have is when I feed in these integers to the PWM value of the clock.<br> As I said, when I'm using the original PWM Audio file with my own WAV-file converted to a .h-file (through wav2c) it works and it sounds good. When I'm reading the SD-card it shows me the correct values. It shows correct when I'm reading the WAV-files direct and also (what I'm trying in my latest version posted here) as I convert them to text-files and read these. When I'm feeding in the integers from the text file, I hear a horn-like sound, like if the PWM uses the wrong values to output.</p> <p>I'm guessing the problem is somewhere in the casting of the data into the byte data the Atmega uses. But I don't have any clue where to look or how to solve it. I noticed that the original file uses unsigned char's where I'm using uint_t8. I tried to cast them but it's not working.</p> <p>Does anyone has some experience in this? Or any clue how I could possible solve this?</p> <p>Many thanks for you help and time!</p> <p>Jeroen</p> <p>PS: Below is the piece of my code where I read through the text files and convert them to integers. They always consist of 3 characters; value 21 for example is printed as 021 in the file, and seperated with a comma which the script skips with the 4th myFile.read()</p> <pre><code>myFile = SD.open(FileName); char sampleTMP[4]; sampleTMP[0] = (myFile.read()); sampleTMP[1] = (myFile.read()); sampleTMP[2] = (myFile.read()); sampleTMP[3] = 0; myFile.read(); unsigned char ss; ss = atoi(sampleTMP); Serial.println(ss, DEC); OCR0A = ss; OCR0B = ss; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload