RSS YouTube LinkedIn Twitter Facebook


WAV audio player

by Berni1438

  • Status: Public release
  • Downloads: 673
  • Licence: Please contact author for terms
  • Last updated: 12/Dec/2009 at 09:20 PM

Version 0.1

Size: 1458.11kb

View older versions

Project Overview

So here is a small project that plays *.WAV files from a FAT16 formated SD card.Audio output is done using PWM and a RC filter to smooth it out.Its built very modular so you can take the hardware drivers out very easily as they are grouped in folders.

Supported wav formats:
PCM 8bit mono
PCM 8bit stereo
PCM 16bit mono
PCM 16bit stereo
Supported sample rates:
1-192Khz (nonstandard rates are ok)
Note: The normal SD cards are too slow to play very high bitrate wav files!


Project awards

Verified to run on


Images and diagrams

Rate this project

Average: 4.8 (10 votes)
Your rating: None
Login or register to vote

Comments / Updates


I actually imitated the PWM code from the C64 project.

Well i am suspecting both. Altho i wont work on improving this method as it was never meant to be a way to get great quality audio from it. I need to etch me breakout board for a proper audio DAC chip that will get me audio up to 192Khz 24bit if i need it, as a bonus it also includes a audio ADC in it so i can input audio to my XC-2 then too. So i can try doing some real time audio effects (hmm an XC-2 autotune would be awsome!)

I tried the C64 - software synth example, and thought about if the largest error came from jitter in the time-base or ripple in the rail. Check the rail with a Scope and you see!

I guess that you could improve the SNR+D alot in the Audio, just by buffering the PWM signal - feeding the buffer with it´s own low noise LDO. (16 bit ~ 96 dB ~ (1 / 100 000) V => 30uV maximum ripple on a 3.3 V rail )

I must say, I love the video, it is descriptive and fun to watch. Great effort!

Glad we got that sorted.

So for the rest of you, don't extract these archived projects use the method described in my last comment!

I unzipped it and then imported it. I'll try importing the zip file as you did.

That worked OK - I cleaned the project and rebuilt it without any problems. I can't see why I was getting those errors previously, though.

Thanks for the help. I'll try it with my SD card tomorrow.


I made it with the 9.9.0 tools

I tried importing the zip file my self in to a new workspace and it compiled no problem. Did you meaby extract it and then add the files in a project or something? You should use Import>Exisitng project in to workspace>Select archive file
then just put in the zip file you download from here

I removed it, and the code using led_1, which fixed that problem. I also tried using the port name, as you suggested, and that worked. However, I'm getting these errors now:

xcc -O0 -g -Wall -c -o "XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.o" "../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc"
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:84: warning: End of input with no newline, supplemented newline
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:5: error: `XS1_PORT_1A' undeclared here (not in a function)
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:5: error: invalid initializer
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:6: error: `XS1_PORT_1B' undeclared here (not in a function)
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:6: error: invalid initializer
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:7: error: `XS1_PORT_1C' undeclared here (not in a function)
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:7: error: invalid initializer
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:8: error: `XS1_PORT_1D' undeclared here (not in a function)
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:8: error: invalid initializer
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:9: error: `XS1_PORT_8A' undeclared here (not in a function)
../XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.xc:9: error: invalid initializer
xmake: *** [XMOS/WAV_Player/Driver_CharLCD/LCD_Driver.o] Error 1

What version of the tools did you use? I'm using 9.9.1.


Hmm thats strange, try putting in the port that the LED is connected to, or just delete the stuff since its not inportant. The LED shows a buffer underflow, this usually means the SD card is reading too slow for a very high bitrate wav file.(and it flashes on the start when the buffer hasent been filled yet)

I just built the project and got this error:

../XMOS/WAV_Player/main.xc:26: error: `PORT_LED_1_0' undeclared here (not in a function)
../XMOS/WAV_Player/main.xc:26: error: invalid initializer

for this statement:

on stdcore[1] : out port led_1 = PORT_LED_1_0;

But I can't see anything wrong with it. PORT_LED_1_0 is defined for Core 1 in the XC-2.xn file.


You miust have tried it just after I posted the msg. I noticed that the URL was wrong and changed it very quickly.

The artwork and layout are in the same directory:

oogely boogely