极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9765|回复: 2

TMRh20/TMRpcm 更好的音乐播放库

[复制链接]
发表于 2013-8-10 11:00:54 | 显示全部楼层 |阅读模式
https://github.com/TMRh20/TMRpcm/wiki

Home

Arduino library for asynchronous playback of PCM/WAV files direct from SD card

Requires Arduino, SD card and output device (Speaker, Headphones, Amplifier, etc)

Features

PCM/WAV audio playback direct from SD card
Asynchronous Playback: Allows code in main loop to run while audio playback occurs.
Playback uses a single timer: Timer 1 (Uno,Mega) or Timer 3,4 or 5 (Mega)
Supported formats: WAV files, 8-bit, 8-20khz Sample Rate, mono
Complimentary or Dual Outputs - see examples
Supported devices: Arduino Uno, Nano, Mega, etc.
Files easily converted using iTunes or other software:
Click > Edit > Preferences > Import Settings
Change the dropdown to WAV Encoder and Setting: Custom > 16.000kHz, 8-bit, Mono
Right click any file in iTunes, and select "Create WAV Version"
Copy file to SD card using computer
Functions

tmrpcm.play("filename"); plays a file
tmrpcm.speakerPin = 11; set to 5,6,11 or 46 for Mega, 9 for Uno, Nano, etc
tmrpcm.disable(); disables the timer on output pin and stops the music
tmrpcm.stopPlayback(); stops the music, but leaves the timer running
tmrpcm.isPlaying();  returns 1 if music playing, 0 if not
tmrpcm.pause();  pauses/unpauses playback
tmrpcm.pwmMode = 1; **REMOVED**
tmrpcm.volume(0); 1(up) or 0(down) to control volume
Known Limitations

This library is very processor intensive, so 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() function can be used to prevent parallel code execution.
Update to volume control allows greater range in low volume control, but will distort if volume too high
Installation

Download current package: https://github.com/TMRh20/TMRpcm/archive/master.zip
See the Manual Installation section at: http://arduino.cc/en/Guide/Libraries
Contributed How-To with Video: http://maxoffsky.com/maxoffsky-blog/how-to-play-wav-audio-files-with-arduino-uno-and-microsd-card/

Details at TMRh20.blogspot.com
回复

使用道具 举报

发表于 2013-8-10 22:14:10 | 显示全部楼层
能翻译过来吗?顺便加点使用示例最好了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-8-13 23:03:12 | 显示全部楼层
方向指给你了 各撸各的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-8 08:55 , Processed in 0.057610 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表