chjmartin2 Posted November 16, 2015 Share Posted November 16, 2015 Good News, Bad News. First the bad news:- the CH376 doesn't double buffer internally, so when reading a file it pauses for up to 2ms before reading each sector. This isn't too much of a problem for video, but wreaks havoc on audio playback. I tried playing a wave file with a fixed delay after reading each sample, but the 0.2~2ms gaps caused the sound to be scratchy and off-pitch. To fill in the gaps I had to read the samples into a buffer at a higher rate, then continue to output samples while waiting for the CH376 to read the next sector. Implementing a circular buffer took up so many CPU cycles that stereo playback at 15kHz was impossible. Since the Aquarius doesn't have a hardware timer I had to count CPU cycles and add different delays for each path in the program - not an easy job . Now the good news:- I managed to get it working in mono at 15kHz, and it sounds pretty good! The DAC hardware is a little more complex than I had hoped to get away with. An octal buffer is required (I used a 74HC245) because the AY's I/O ports have weak pullups that affected the accuracy of the R/2R resistor ladder. The circuit is still cheap and relatively simple, though having to wire in the 17 1% resistors was a pain. I have an AD558 which would be more accurate and make life easier, but it is an expensive chip. Another possibility is the TLC7524 (which only costs about $2 in one off quantity). The attached source code plays a raw 8 bit wave file from the CH376 at (approximately) 15Khz. Because the file is read one byte at a time its size is not limited to 64k - the file I used for testing is 6.5MB and plays for over 7 minutes. To convert it from mp3 to raw 8 bit binary I used SoX Sound eXchange. First I converted the mp3 into 15.734 KHz 8 bit mono WAV format (to hear what it sounded like) then I converted from WAV to AFS (raw 8 bit unsigned data). Interestingly the final result was about the same size as the original mp3! SoX 'drag and drop' batch files for doing the conversions are included in the attachment. The attached mp3 is the output from my Aquarius recorded by my PC's sound card. So the original song has gone full circle:- from mp3 to WAV to raw binary, copied to a USB stick and played through a crude DAC on the Aquarius, then re-sampled in WAV format and finally converted back to mp3! It really has to be great to have a huge mass storage device for the computer. So many possibilities! Sounds awesome. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.