PWM music

edmunds

Senior Member
If anyone is interested I can uplaod the vb.net and picaxe programs for programming the sound files into the eeprom. It may take me awhile to clean up the code so it's usable. It has a lot of debugging
stuff in it that makes it hard to use. I don't make any guarantees it will work on your computer but it works on mine.
I would be grateful if this is not too much trouble. Looking at 256MBit EEPROM solution now, so manual copy/paste is not an option.


Thank you for your time,

Edmunds
 

Rick100

Senior Member
I'll work on the code and upload it in a zip file. It will probably be this weekend before I have the time though. It will only program eeproms with a 16 word address. It won't help with the higher capacity parts. It takes approximately 2.5 minutes to program a 24lc256 and 3.5 minutes to verify it. You'll need some other method to program the parts your talking about.
 

edmunds

Senior Member
Sure thing, I'm on it. Just while I'm at it, I might as well try yours to test something. I still don't have a higher resolution file running, since I cannot get it into the chip.


Thank you for your time,

Edmunds
 

Rick100

Senior Member
Here is a zip file containing the picaxe and vb.net programs for programming a 24lc256 or 24lc512 eeprom. I have only tested it with a 24lc256. I think the exe files will run without installing anything if you have your dotnet framework up to date but I'm not sure about that. The Seeprom1.exe files are in the bin\debug and bin\release directories. Just doubleclick on one and see if it runs. The picaxe program is written for a 20X2. It uses the hardware serial port. Depending on your hardware (real serial port with level convertor or usb serial), you may have to change the hsersetup polarity. The included readme file will explain how to wire it. It has 2 modes depending on the state of pin B.3 at power up. If B.3 is low then it will operate with the vb.net program. If B.3 is high it will enter a terminal mode so the eeprom can be erased or the contents dumped to a terminal program. The vb.net program was written with the 2013 version of Visual Studio. If the exe files won't run by doubleclicking on them then try loading it in visual studio and running it from there.

Let me know if it works or not. I have run it in several stages of development on 3 different windows 7 machines and not had any problems.

View attachment SeepromProg.zip

Good luck,
Rick
 

edmunds

Senior Member
Here is a zip file containing the picaxe and vb.net programs for programming a 24lc256 or 24lc512 eeprom. I have only tested it with a 24lc256. I think the exe files will run without installing anything if you have your dotnet framework up to date but I'm not sure about that. The Seeprom1.exe files are in the bin\debug and bin\release directories. Just doubleclick on one and see if it runs. The picaxe program is written for a 20X2. It uses the hardware serial port. Depending on your hardware (real serial port with level convertor or usb serial), you may have to change the hsersetup polarity. The included readme file will explain how to wire it. It has 2 modes depending on the state of pin B.3 at power up. If B.3 is low then it will operate with the vb.net program. If B.3 is high it will enter a terminal mode so the eeprom can be erased or the contents dumped to a terminal program. The vb.net program was written with the 2013 version of Visual Studio. If the exe files won't run by doubleclicking on them then try loading it in visual studio and running it from there.

Let me know if it works or not. I have run it in several stages of development on 3 different windows 7 machines and not had any problems.

View attachment 18179

Good luck,
Rick
Dear Rick,

At this point, I cannot get your software to work with an error message 'Unhandled exception bla bla bla. Invalid Argument=Value of '0'is not valid for 'SelectedIndex'. Parameter name: SelectedIndex.' But I'm a mac person since Windows 98Me came out and thus my Windows-any-clue is rusty to say the least. It would probably take me a day to assemble a machine with everything required to run Visual Studio even though I remember coding bits and pieces in it. I think I recall a version 4.0 or something :). Having to do anything on Windows 7 juts sends rodents down my spine. Nevertheless, this is not to say I'm giving up. I just need to re-group and start over. And I believe I2C is not the way to go. Since I have now figured out I need between 8 and 32Mbit flash and these do not come I2C, I'm looking into SPI now. This causes an awful lot of redesign, since this eats picaxe pins. At some point, I will have to come back to "loading the flash", but I think I should find my own way here or rely on something commercial if I can find and pay for one.

Thank you so much for your input, which I might want more of,

Edmunds
 

edmunds

Senior Member
Pauses and polyphonic sounds

Dear all,

I was thinking if I should start another thread on this or not.

The story is, I have now tried everything there is to try with WTV020SD module (same thing as SOMO-14D) and also the IC alone and it has lead to an understanding this solution is not suitable for what I need due to the following reasons:

1. There is always a noticeable pause between the sound files. So if you want to loop an "engine idling" file, say, forever, you will get noticeable pauses of tens of milliseconds between each "restart". Similarly, if you play "engine start" and want to continue with "engine idling", there will be a pause or silence between the two. The pauses are because of how WTV020SD is designed. Response times much faster than those in the data sheet are achievable, but are still way to slow for the observer not to notice.

2. There is no way to play multiple sounds or mix sounds. Say, my model car is cruising around at certain speed that corresponds to "revs22" file. Now, if I want to play a "horn" file, the only option would be to play "revs22_horn" file shortly in between "revs22" file playbacks. While that would be fine, given the massive storage available on the SD card (I would need 33 horn files, for every speed step of 32+idle), the problem #1 excludes that option alltogether.

If either of those problems could be overcome, I could probably use this solution by working around the limitation. Both at the same time - not possible.

Now I have a reasonable standard approach forward. Namely, there are ICs that are fully capable of solving all my current problems (probably introducing new problems :)). However, as mentioned earlier, the size of the ICs themselves, the number of external components required and cost (like this VS1003 here) all make this approach prohibitive.

Thus, there is a strong incentive and some "budget" to try and do the impossible of picaxe based sound system. The results on this thread seem to prove this might not be so impossible. Here is a little roadmap I have put up:

0. Learn more about sound files and how machines record, generate and play back sounds;
1. Source suitable, 8Mbit+, SPI flash ICs;
2. Figure out how to write raw audio files onto the flash, how to organise it into "files", etc;
2a. Make picaxe40x2 to talk to the flash memory (SPI, random and continuous modes);
2b. Make a mac to talk to the picaxe40x2;
2c. Teach picaxe40x2 to get data from mac and store it in the flash memory;
3. Teach picaxe to playback the audio files;
4. Teach picaxe40x2 to listen to hserin or I2C commands from another picaxe for which file to play;
5. Attempt to play more than one file at the same time [switch between pieces of files, do it very fast];
5a. Find out if the two independent pwm channels can be supplied with sound file data each and then mixed;
5b. Find out if there are external ICs with reasonable footprint (like none) for mixing that provide any advantage;
6. Look at output filter and speaker designs to see what gives the best sound output quality;
7. Investigate if adding an amplifier would make things any better.


If you have any thoughts on the above [apart from those I'm a crazy person :) ], you are most welcome to share.


Thank you all for your input,

Edmunds
 

techElder

Well-known member
Aww, I was going to say you're "a crazy person", but you won't let me! :)

You sure have a heavy agenda to keep you busy and having fun.
 

Rick100

Senior Member
At this point, I cannot get your software to work with an error message 'Unhandled exception bla bla bla. Invalid Argument=Value of '0'is not valid for 'SelectedIndex'. Parameter name: SelectedIndex.' But I'm a mac person since Windows 98Me came out and thus my Windows-any-clue is rusty to say the least.
Hello Edmunds. I'm sorry the program didn't work for you. Were you running it on a Mac or PC?

Since I have now figured out I need between 8 and 32Mbit flash and these do not come I2C, I'm looking into SPI now.
I used an 8 Mbit Winbond SPI chip in this project.
http://www.picaxeforum.co.uk/showthread.php?27506-Talking-Guess-the-Number-game&p=283776#post283776

Here's a 64 Mbit Winbond SPI chip.
http://www.digikey.com/product-detail/en/W25Q64FVSSIG/W25Q64FVSSIG-ND/2815931

5. Attempt to play more than one file at the same time [switch between pieces of files, do it very fast];
If the files are on the same memory chip, you can't use the continuous read. You will have to send 1 command byte and 3 address bytes to read each audio sample. The playback loop would be very slow.

5a. Find out if the two independent pwm channels can be supplied with sound file data each and then mixed;[/qoute]
That should work but it will make the playback loop even slower.

http://dsp.stackexchange.com/questions/3581/algorithms-to-mix-audio-signals-without-clipping


I think what you're trying to do is possible but not with the Picaxe's interpreted basic. My first choice would be a "raw" pic and assembly language or C but they have a steep learning curve. The Arduino is easier to get started and cheap but you may need to do a lot of tweaking to get a fast playback loop. The Parallax Propellor is another option with a steep learning curve.


Goodluck,
Rick
 
Last edited:

edmunds

Senior Member
Dear Rick,

Hello Edmunds. I'm sorry the program didn't work for you. Were you running it on a Mac or PC?
A PC. Started out with an old IBM ThinkPad with XP on it, but that complained about the wrong .NET version. Then borrowed a Toshiba Windows 7 machine and got it to run, but with the aforementioned error message and not good at all.

I used an 8 Mbit Winbond SPI chip in this project.
http://www.picaxeforum.co.uk/showthr...776#post283776
Thank you for sharing, great project. Since your project is speech, it is a bit difficult to judge if pause-less looping of the same file would be achievable with the given memory/picaxe combo.

If the files are on the same memory chip, you can't use the continuous read. You will have to send 1 command byte and 3 address bytes to read each audio sample. The playback loop would be very slow.
The interesting thing is, I have been considering putting files on separate memory chips because of package sizes - possibly, it would be easier to place and route two 8M chips than one 16M chip. I'm not sure, how this could make things faster though - there is only one SPI channel anyway unless I force background hserin to become SPI or something :). But that is just bla bla bla for now, have not done the homework yet.

I think what you're trying to do is possible
No doubt it is. DCC sound decoder producers charge between 100 and 300 USD per piece for having achieved more or less what I'm trying to do. The ones I have looked at use Atmel ICs. I just want to push this as far as it would go. While I'm doing it I will learn a great deal of things that will come in handy, even if I have to outsource this to somebody, who can do raw PIC.


Thank you for all the input,

Edmunds
 
Top