Pages: 1 ... 6 7 [8] 9 10 ... 14   Go Down
Author Topic: New library for PWM playback from SD cards: SimpleSDAudio  (Read 41218 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello Tuttut,

one more thing.  you can pre-distort a wav file so that it plays back identical to the source material.  the pwm transform is a known function, and although not invertible, it can be compensated for perfectly.  i have yet to implement this, but i have read research papers on it, which prove it mathematically.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
@tack: have you looked inside the new version? I think I've put your stuff in, but it would be nice if you can try if also autoworker works on your platform as it needs additional stuff in those hardware-settings.

OK, I've now had time to test it and I can report that it works perfectly 'out of the box'. Many thanks for adding those mods to the definitions as it will save re-applying them in future.

I've also tested the Autoworker mode and that also works fine on the 1284P. It has been tested with a 3 minute music file of 27Mb size and it played perfectly in 8 bit stereo full rate, sounding good through a set of hacked active PC speakers.

At the moment this is just running with a 100R in series with each channel. I want to use this now with a little 3W stereo amplifier as an onboard solution. - http://www.technobase.jp/eclib/OTHER/DATASHEET/pam8403.pdf

Any thoughts on input filtering/control prior to the amp? At the moment I'm thinking of a .1uF capacitor in series and a 10k trimmer to control the input level, as per attached schematic. I don't need to be able to adjust volume by the user, just set it and leave it.


* audio_stage.png (15.46 KB, 862x681 - viewed 37 times.)
Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 75
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The amplifier's datasheet uses an 0.47uF input capacitor, if this is already there you don't need the additional 100nF one in series. The trimmer is ok, you want it otherwise it will be to loud. If audio output is to noisy try adding a capacitor after the trimmer to GND to do a little low-pass filtering. I don't know a value but experiment in range of 100nF to several uF for best results.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've added the additional cap pads to my design but I can always jumper them out for testing on the prototype boards.

One thing I am doing is setting a 28 pin DIL socket inside my 40 pin one, with some approrpiate 328P pins joined through to 1284pins. This lets me use a 328P on the same board if I don't need all the peripherals or FLASH/SRAM of the 1284P/644P.

On the 1284P the 2 pins used for Channel 1 & 2 (8 Bit Stereo Full Rate) don't clash with anything else. On the 328P Channel 2 is Pin 10, clashing with SPI hardware SS.

I saw the wiring.c patch for the timers, saying that pin 6 & 5 can be used to get 16 bit stereo at half rate. What I would like to do, is use 6 & 5 instead of 9 & 10 for the default 8 bit stereo. Is this possible? I tried making a few changes to the defs file but realised it needs some of the hardware timer definitions altering too if it is possible to make it work.

If possible then It would be ideal if there was a setup parameter to use the alternate pins IF the patch is applied. I'm sure this would be useful for 328 users who want 8 bit stereo but use Ethernet shields or other SPI devices.
Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 75
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First, hardware SS is often only an issue when SPI is used as slave, which is often not the case. Second, to use the pins 6 & 5 on mega328 Arduinos, you have to apply the wiring.c patch as you already figured out and then you have to patch the file SimpleSDAudioDefs.h. Scroll to the end and you find the last big #else part that sets up all the stuff for mega328 Arduino. Below that, there is the same part again but this time for use pin 6 & 5, but it is commented out. Rework the comments that the old #else-part for pins 9 & 10 will become commented out and activate the part below instead. Then audio will use pin 6 & 5, but it requires the wiring.c patch. Beware, I have not tested that thoroughly so please leave a note if it works for you.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Does this also work with Arduino with ATMEGA168 only?
Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 75
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I am sorry, I think the minimum requirement is ATmega368 ATmega328P. The ATmega168 is to low on RAM.7
« Last Edit: February 09, 2013, 05:59:34 pm by Tuttut » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How about ATMEGA 328.
Sorry. I don't know which is which.

Additional: I tried converting a .wav file but no file appears on the "converted" folder I created.
Is there any requirement for the format of the wav file?
How do I choose the appropriate batch file?
A real newbie in here, hope you understand.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Tuttut - sorry, I didn't realise that section was there. I'll give that alternativ section a try and report back on whether it works ok. Many thanks again, it's very much appreciated.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How about ATMEGA 328.
Sorry. I don't know which is which.

Additional: I tried converting a .wav file but no file appears on the "converted" folder I created.
Is there any requirement for the format of the wav file?
How do I choose the appropriate batch file?
A real newbie in here, hope you understand.

It works fine in both the 328 and the 328P.

You need to choose the batch file for the playback rate and type you want. I have used 8 bit Mono Fullrate and 8 bit Stereo Fullrate and find the quality very good with a set of PC 2.1 active speakers.

If you are struggling for cycles (a processor intensive sketch) then you may want to try the Halfrate variants.

I've not found any problems with any Wav files at all. I've used downloaded movie/TV sound effects and also used freeware converters to convert a music track MP3 to Wav and then drop on a batch file to convert to 8 bit Stereo Fullrate .asm file, that then played very nicely in SimpleSDAudio
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

What free converter did you use?
What are the settings like encoding etc?
This is killing me for quite a while now  smiley-razz

I have a .wav file.
attributes: 64000 Hz, 8-bits, mono.
format: PCM uncompressed

On the command prompt, it says:
A subdirectory or file converted already exists.
Press any key to continue . . .
« Last Edit: February 09, 2013, 03:42:33 pm by meowth08 » Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 75
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
maybe you have a Wav-File that contains something that sox is not aware of, try converting it using commandline and verbose mode of sox. Or try a program like Audacity to import and export the file to a proper PCM Wav-file.
Maybe you even look at the wrong path of the converted folder...
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not at home to check what file converter I used.

The command line message you got, about a subdiretory or file already converted, is normal. Once you already have a 'converted' folder then that message always appears, but you should find your newly converted file inside that folder.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm ok now.
I redownloaded the zip file.
Maybe an error on the first zip file downloaded was the cause.

Question:
What pins are to be connected to the SD card.
This is my arduino: http://www.e-gizmo.com/KIT/Gizduino.html
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Question:
What pins are to be connected to the SD card.

D4 - SS or CS
D11 - MOSI
D12 - MISO
D13 - SCK

First, hardware SS is often only an issue when SPI is used as slave, which is often not the case.

Yes, on the 328P it was working OK on 9 & 10 with SD Card used on SPI and with D4 as SS. On my new PCB's I could also be using radio and ethernet modules on SPI (I know they work together), as well as SimpleSDAudio, although any sounds would only be played when those devices aren't being used. I thought it would be cleaner if I could use 6 & 5 instead.

Second, to use the pins 6 & 5 on mega328 Arduinos, you have to apply the wiring.c patch as you already figured out and then you have to patch the file SimpleSDAudioDefs.h. Scroll to the end and you find the last big #else part that sets up all the stuff for mega328 Arduino. Below that, there is the same part again but this time for use pin 6 & 5, but it is commented out. Rework the comments that the old #else-part for pins 9 & 10 will become commented out and activate the part below instead. Then audio will use pin 6 & 5, but it requires the wiring.c patch. Beware, I have not tested that thoroughly so please leave a note if it works for you.

Patches all made and audio works perfectly now switched to Pins 6 & 5. Tested in 8 bit Stereo Fullrate. Many thanks again. :-)
« Last Edit: February 10, 2013, 04:55:16 pm by tack » Logged

Pages: 1 ... 6 7 [8] 9 10 ... 14   Go Up
Jump to: