afb
Member
BACKGROUND
For some time I've been looking at making a sound effect system for model boats utilising recorded sounds - horns, guns, bells, asdic whoops etc plus repeated loops for engine sounds, clocked out at a variable rate proportional to the throttle setting. And yes, I know the latter doesn't necessarily work very well with all engine sound samples but a few minutes experimentation with Audacity will sort out the candidates that do work tolerably well. A huge library of sounds are available on the web in WAV format.
You can see my efforts at synthesizing an engine sound with the PICAXE here http://uk.youtube.com/watch?v=pX3biLUAtkI&feature=channel Those who are interested can follow a link from there to our boat club website where you'll find the code.
I decided at the outset I'd like to represent the sound waveform as a serial bitstream so that the D/A conversion was really cheap and simple - an RC filter. To that end I wrote a VB6 program to implement a software delta modulator to encode a WAV file into a serial bit stream and it allows me to play with the sampling rate to (experimentally) get the best compromise between conversion accuracy and file size (see attached)
I had planned to use up to eight different 1-bit sound files in a conventional 27 series 256Kx8 EPROM (file1=D0, file2=D1 etc) and use a binary counter to gallop through the addresses and an 8 way multiplexer to select which data stream was switched to the RC filter.
PICAXE IMPLEMENTATION
I was following the above hardware approach as I considered (but correct me if you think otherwise) that an 08M at 8Mhz and and a serial EPROM would be nowhere near fast enough to generate audio output. Web research shows it has been done with assembler, but I reckoned with intepreted BASIC it was a non-starter.
But having bought some 20X2s for their 11 ADC capabilities, I've been studying the command sets and now wonder whether it might now be possible to implement this project in PICAXE after all. But this is based on two observations made by someone who has never used the SPI !
(1) the 20X2 can be run at 64MHz.
(2) there is a (h=hardware?) "hspiout" which is "faster and more efficient" than the bit-banged "spiout"
It seems the data is shifted out in bytes, but a hardware parallel to serial conversion would be no great heartache (I note the "spiout" has the option to shift out a defined number of bits which could be set to unity)
With the example WAV file shown of duration 1.4 secs at 16x oversampling, 172K samples have to be output in that time which equates to 123Kbits/sec or 15.3Kbytes/sec. At 4x oversampling the RMS conversion error is still only a couple of percent which may not sound too terrible in this lo-fi application so the above rates could be further divided by four.
YOUR ADVICE/COMMENTS PLEASE
So gentleman, I seek your advice - the best way to get EPROM contents to the 20X2 pin or (8) pins and a maximum sample rate I could expect. BTW, the time taken to load the data into the EEPROM is of no consequence in this application.
Thank you in advance for the undoubtedly erudite comments that will follow!
(yes, I know I could spend £100 plus and buy a real one, but where's the fun in that!)
For some time I've been looking at making a sound effect system for model boats utilising recorded sounds - horns, guns, bells, asdic whoops etc plus repeated loops for engine sounds, clocked out at a variable rate proportional to the throttle setting. And yes, I know the latter doesn't necessarily work very well with all engine sound samples but a few minutes experimentation with Audacity will sort out the candidates that do work tolerably well. A huge library of sounds are available on the web in WAV format.
You can see my efforts at synthesizing an engine sound with the PICAXE here http://uk.youtube.com/watch?v=pX3biLUAtkI&feature=channel Those who are interested can follow a link from there to our boat club website where you'll find the code.
I decided at the outset I'd like to represent the sound waveform as a serial bitstream so that the D/A conversion was really cheap and simple - an RC filter. To that end I wrote a VB6 program to implement a software delta modulator to encode a WAV file into a serial bit stream and it allows me to play with the sampling rate to (experimentally) get the best compromise between conversion accuracy and file size (see attached)
I had planned to use up to eight different 1-bit sound files in a conventional 27 series 256Kx8 EPROM (file1=D0, file2=D1 etc) and use a binary counter to gallop through the addresses and an 8 way multiplexer to select which data stream was switched to the RC filter.
PICAXE IMPLEMENTATION
I was following the above hardware approach as I considered (but correct me if you think otherwise) that an 08M at 8Mhz and and a serial EPROM would be nowhere near fast enough to generate audio output. Web research shows it has been done with assembler, but I reckoned with intepreted BASIC it was a non-starter.
But having bought some 20X2s for their 11 ADC capabilities, I've been studying the command sets and now wonder whether it might now be possible to implement this project in PICAXE after all. But this is based on two observations made by someone who has never used the SPI !
(1) the 20X2 can be run at 64MHz.
(2) there is a (h=hardware?) "hspiout" which is "faster and more efficient" than the bit-banged "spiout"
It seems the data is shifted out in bytes, but a hardware parallel to serial conversion would be no great heartache (I note the "spiout" has the option to shift out a defined number of bits which could be set to unity)
With the example WAV file shown of duration 1.4 secs at 16x oversampling, 172K samples have to be output in that time which equates to 123Kbits/sec or 15.3Kbytes/sec. At 4x oversampling the RMS conversion error is still only a couple of percent which may not sound too terrible in this lo-fi application so the above rates could be further divided by four.
YOUR ADVICE/COMMENTS PLEASE
So gentleman, I seek your advice - the best way to get EPROM contents to the 20X2 pin or (8) pins and a maximum sample rate I could expect. BTW, the time taken to load the data into the EEPROM is of no consequence in this application.
Thank you in advance for the undoubtedly erudite comments that will follow!
(yes, I know I could spend £100 plus and buy a real one, but where's the fun in that!)
Attachments
-
145.4 KB Views: 32