New WAV player (V2)
Kye
Posts: 2,200
Hey all,
I made a new WAV player using the noise shaping technique described here:
http://forums.parallax.com/showthread.php/148280-Prop-sound-quality-question
It sounds great and doesn't need a dither cog anymore. Additionally, I have a bunch of nice things built around the WAV Player to make it fast and responsive.
The WAV player can switch between wav files with zero delay because I queue up the next file to play in the code before the first file has finished playing.
---
I've include 2 demos in the file. One of which just plays a WAV file in a loop (top.spin), and one of which that plays some sounds over and over again very fast (gun.spin).
I made a new WAV player using the noise shaping technique described here:
http://forums.parallax.com/showthread.php/148280-Prop-sound-quality-question
It sounds great and doesn't need a dither cog anymore. Additionally, I have a bunch of nice things built around the WAV Player to make it fast and responsive.
The WAV player can switch between wav files with zero delay because I queue up the next file to play in the code before the first file has finished playing.
---
I've include 2 demos in the file. One of which just plays a WAV file in a loop (top.spin), and one of which that plays some sounds over and over again very fast (gun.spin).
zip
113K
Comments
The code for this wav player is much easier to tinker with than the previous one because I didn't try to optimize everything.
...
This code was developed on commission. I'm just releasing it for others to use. My aim is not really to write extensive documentation here. All the functions work pretty much like you would expect.
breakout and check it out.
I had to do a bunch of work to get it to run up to 48 KHz * 4 = 192 KHz, so, the code hits basically every hub window. I also made the code able to switch seamlessly between files.
Thanks for the work Mark_T!
Jonathan
The more oversample, the better will be the sound. In my code here: http://forums.parallax.com/showthread.php/148280-Prop-sound-quality-question you have 7x oversampling @44100 Hz.When overclocked, it can do 10x oversampling and the difference between 7x and 10x is hearable.
Your code seems to be universal, playing 1- or 2-channel WAVs at different sample rates and it can do online volume changes. All of this stuff eats the precious loop time. Maybe there will be a better solution to limit the code to 2-channel, 16-bit, 32000, 44100 and 48000 kHz WAV's. 99.9% of all wav files will then still be played. The volume change can be made outside of the main DAC loop. The transfer size can be made at 512 bytes (=SD sector size). The goal is of course make one worst case loop in less than 256 clocks because this is the one full PWM time.
We have 1814 clocks for one 44100 Hz sample and 1666 clocks for one 48000 Hz sample when the Propeller is clocked at 80 MHz. An integer number of loops has to be done for one sample. If we can do one loop at 256 clocks, we may have 7 loops@259 clocks=1813 clocks for 44100 and 6 loops @ 277 clocks for 48000. This is theoretical maximum for non-overclocked Propeller.
Because the Propeller can be easily overclocked, I recommend to do it when using for wave playing application. The more Mhz, the more overclocking and the better sound quality. Of course, even 4x oversampling gives enough SNR gain to give better sound than any dithered duty dac.
However, I'm going to leave it with universal support. I'd rather it just "work" versus it only working for a few wave files. The person who commissioned me to do this wanted to play back short clips of low quality audio as fast as possible. Possibly for a toy.
Okay, I'll get to uploading this as it is, I'll leave the old wav player up and put a forwarding link to this new one.
---
@lonesock - Thanks for the kind words.
Using a propeller platform sd on 0,1,2,3 output L26 R27 xtal 5Mhz
When using on same hardware and wav file , with Wav player (one) it sound better but with noise ?
Same sound with embedded gun examples?
Somebody a path ?
Thanks
I don't know what your problem is. The audio is find on an activity board. Maybe your RC filter is not good.
I don't use the op-ams ..... Only resistor and capa.
Strange it works with wavplayer(one) litle noisy
The V2 version uses a new technique: http://forums.parallax.com/showthrea...ality-question
But I do not understand.
-Wav player1 play nice on board. SD on pin 0-4. Output on pin 26&27.
-On the same board, same sd memory, same RC output, the only difference is Wav player2 spin. The wav play very bad, metallic, saturating,
Only change of original files are the SD pining on 0-4 in stead of 22-25 (used gun.spin an included wav)
Is in an issue on pin 0 ?
I can't guess what the problem is. Have you tried playing music? The gun.wav is just the sound of a gun firing very quickly. I would just keep using the original wav player if the new one is causing issues.
Try reducing aplitude of the sample to 0.9 (for example with Audacity) and check if it helped.
I am trying to do the same thing. Any resolution thus far?
http://forums.parallax.com/showthread.php/156354-Kye-s-WAV-driver-question.?p=1277866&viewfull=1#post1277866
Note that you can make the queue larger if you want. This takes more memory however.