Arduino Library – TMRpcm

Installatie van Arduino IDE libraries: Arduino info
arduino logo rond
Informatie (ENG):

Arduino library for asynchronous playback of PCM/WAV files direct from SD card, it utilizes standard Arduino SD library, SD card and output device (Speaker, Headphones, Amplifier, etc)

Supported Boards

All 328 based boards: Arduino Uno, Nano, Duemilanove, etc
Mega Types: 1280, 2560, etc
No Due support currently.

Features

  • PCM/WAV playback direct from SD card
  • Main formats: WAV files, 8-bit, 8-32khz Sample Rate, mono.
  • Asynchronous Playback: Allows code in main loop to run while audio playback occurs.
  • Single timer operation: TIMER1 (Uno,Mega) or TIMER3,4 or 5 (Mega)
  • Complimentary output or dual speakers
  • 2x Oversampling
  • Supported devices: Arduino Uno, Nano, Mega, etc.

Download @ Github (TMRh20)

Functions

Known Limitations

This library can be very processor intensive, and code execution during playback will be slower than normal Processing load can be reduced by using lower quality sounds encoded at a lower sample rate (8khz minimum) May interfere with other libraries that rely on interrupts. The isPlaying() disable() or noInterrupts() functions can be used to prevent parallel code execution.
Volume control allows good range in volume control, but will distort if volume too high

Common Issues

  1. Pop or click when playback is started or stopped:
    Ramps are built into the library to prevent popping when PWM is engaged, disabled, and between music tracks of the same sample rate. See the [Advanced Features wiki page](https://github.com/TMRh20/TMRpcm/wiki/Advanced-Features) for causes and fixes.
  2. Popping or clicking when music is playing
    If pops or clicks are heard during playback, it is most likely that buffer underruns are occurring or the volume is just too high.
    Ensure that #define SD_FULLSPEED is uncommented in pcmConfig.h. The value in #define buffSize 128 can be increased to provide additional memory for playback, which will reduce these issues. Audio can be encoded at a lower sample rate otherwise.
  3. The library works fine on its own, but doesn’t play when library <name> is also included.
    The first thing to check is memory usage, since nothing will work if out of memory.
    The library uses two timer pins by default. This may interfere with other libraries that use it. (pin 10 on Arduino Uno)
    Disable the second pin by uncommenting the line #define DISABLE_SPEAKER2 in pcmConfig.h
    Boards like Uno only have one 16-bit timer. #define USE_TIMER2 can be uncommented in pcmConfig.h if TIMER1 is required for something else. See the [Advanced Features wiki page](https://github.com/TMRh20/TMRpcm/wiki/Advanced-Features)
  4. Error message when compiling: “Has no member named…” or “no matching function…”
    These errors usually indicate that commands are being run which are not available in the current configuration. Check the #defines in pcmConfig.h to ensure you are using the correct mode(s), and ensure your commands are correct.
Top