Änderungen

Aus Hackerspace Ffm
Wechseln zu: Navigation, Suche

SimpleSDAudio

2.807 Byte hinzugefügt, 17:35, 7. Apr. 2015
/* It does not compile */
<div style="clear: both; border-width:0px; border-color:#333300; border-style:solid; padding:5px; background-color:#FFEFEF; margin:1em; margin-left:5em; margin-right:5em;">
Please note: If you got here by clicking a link from internet parasites like "gotlinks" that force you to install software that takes over you computer or force you to do other things that you don't want to just to get the correct link to this free site, please be aware that we are NOT responsible for that! Feel free to correct such links if you have access to those sites. </div>
 
[[Datei:SSDA Minimal.jpg|320px|right|thumb|Minimal setup for SimpleSDAudio (here without level-shifters - only for Arduino running at 3.3V)]]
[[Datei:SSDA Arduino Ethernet.jpg|320px|right|thumb|Minimal setup for SimpleSDAudio with Arduino Ethernet - loudspeaker connected via 100uF capacitor to audio output]]
* Integrated SD library (minimal FAT only, optimized for low RAM usage and high performance)
* Works with most SD card shields that are hooked to SPI port
* Easy to use API: 1. init library, 2. select audio file, 3. call play, 4. call worker while audio is playing
* Supports SD and SDHC cards formated with FAT16 or FAT32
* Combination of fullrate and quadro-output actually leads to buffer underruns
* Minimum controller required: ATmega368. ATmega168 is too low on RAM.
 
=== Alternatives ===
Now there is an alternative library called '''TMRpcm''' that does something similar: https://github.com/TMRh20/TMRpcm/wiki . This is a little bit easier to use (no conversion of WAV file needed). Here a table with the differences:
{| class="wikitable"
!Feature!!SimpleSDAudio!!TMRpcm
|-
|Highest sampling rate||X||-
|-
|Native WAV playback (no file conversion needed)||-||X
|-
|Highly speed-optimized code (using Assembler for audio core)||X||-
|-
|Using size-optimized minimal SD-FAT library||X||-
|-
|Universal SD library in the background supporting fragmented files and many other uses||-||X
|-
|Stereo operation possible||X||X
|-
|Quad speaker operation possible||X||X
|-
|Volume setting support||-||X
|}
So depending on your needs, try the library that best fit your needs. TMRpcm might be easier for beginners. Both libraries should work with the same connections. You can take the information about the connections from here and use the TMRpcm library with that.
 
You want even more, multi-channel audio playback, digital filters, mixers, DSP functions? Then take a look at the [http://www.pjrc.com/teensy/td_libs_Audio.html Teensy 3.1 Audio Library] using a serious (but still affordable) micro controller but still using the Arduino IDE.
= Download =
Datei:SSDA Better16bit.png|Still unexpensive solution to get nice 16-bit audio output
</gallery>
 
The 16-bit output is done by operating two 8-bit outputs together: One will provide an 8-bit signal containing the higher 8-bits and the other one contains the lower 8-bits. If you listen to each of those channels separately, you will hear the usual audio on the upper 8-bit outputs but with noticable 8-bit noise especially on quiet audio parts. On the lower 8-bit you will hear just noise. But when you add this noise (reduced in volume by a factor of 256th done by the resistors) to the higher 8-bits then something magic will happen: The 8-bit noise will vanish (but unfortunately often a lot of noise originating from power supply might still be left).
=== Audio amplifier for loudspeakers ===
providing the filename in 8.3 format.
The function return true if successfullsuccessful, false if an error
occured. You can use getLastError() to retrieve the error code.
Typical reasons for errors are that the file was not found.
== It does not compile ==
* Are you using the latest version of Arduino IDE?
** SimpleSDAudio_V1.00 need at least V1.0.1 of Arduino IDE. It has been tested and works ok also under V1.6.1.
** SimpleSDAudio_V1.01 need at least V1.0 of Arduino IDE (remove complete block with !Serial from examples when using with Arduino IDE V1.0).
* Have you selected the correct CS pin for your SD-card? Uncomment the line <pre>// SdPlay.setSDCSPin(10);</pre> in the examples and enter correct pin number here.
* Your SD shield may be crap and SD communication is only possible with limited speed. Try commenting the line <pre>SPSR |= (1 << SPI2X);</pre> in function ''SD_L0_SpiSetHighSpeed()''. If this doesn't help, comment out also the first line and try again. If then init works you have a bad SD card shield.
 
== How to use 16-Bit audio? ==
If you want to use 16-Bit audio, you need 2 PWM outputs joined together with a resistor (see above). Select SSDA_MODE_STEREO if you want one 16-Bit output channel, select SSDA_MODE_QUAD if you want two 16-Bit output channels (works only on Mega-Arduinos or with Timer2 patch).
1.954
Bearbeitungen