首页 > 评测 > 8位机也玩音频-Arduino+SD+DAC+运放打造的播放器
8位机也玩音频-Arduino+SD+DAC+运放打造的播放器
- [导读]
- 比如本文要介绍的Adafruit Wave Shield,就能是专门为Arduino设计的音频模块.确切的说是为AVR这一类的8位机而设计的音频模块.下文将从硬件到软件详细介绍一下子此模块的设计细节与使用方法.
PgmPrint(", ");
Serial.println(card.errorData(), HEX);
while(1);
}
/*
* play recursively - possible stack overflow if subdirectories too nested
*/
void play(FatReader &dir) {
FatReader file;
while (dir.readDir(dirBuf) > 0) { // Read every file in the directory one at a time
// Skip it if not a subdirectory and not a .WAV file
if (!DIR_IS_SUBDIR(dirBuf)
&& strncmp_P((char *)&dirBuf.name[8], PSTR("WAV"), 3)) {
continue;
}
Serial.println(); // clear out a new line
for (uint8_t i = 0; i < dirLevel; i++) {
Serial.write(' '); // this is for prettyprinting, put spaces in front
}
if (!file.open(vol, dirBuf)) { // open the file in the directory
error("file.open failed"); // something went wrong
}
if (file.isDir()) { // check if we opened a new directory
putstring("Subdir: ");
printEntryName(dirBuf);
Serial.println();
dirLevel += 2; // add more spaces
// play files in subdirectory
play(file); // recursive!
dirLevel -= 2;
}
else {
// Aha! we found a file that isnt a directory
putstring("Playing ");
printEntryName(dirBuf); // print it out
if (!wave.create(file)) { // Figure out, is it a WAV proper?
putstring(" Not a valid WAV"); // ok skip it
} else {
Serial.println(); // Hooray it IS a WAV proper!
wave.play(); // make some noise!
uint8_t n = 0;
while (wave.isplaying) {// playing occurs in interrupts, so we print dots in realtime
putstring(".");
if (!(++n % 32))Serial.println();
delay(100);
}
sdErrorCheck(); // everything OK?
// if (wave.errors)Serial.println(wave.errors); // wave decoding errors
}
}
}
}
如果一切正常的话,下载此程序后即可开始播放.如果你一时没有合适的资源,请下载本文后面的附件中本人的资源进行播放.
总结与参考
这个Arduino的Shield模块具备了音频播放器的种种功能,因为配备了SD卡, 使得资源不成问题.受限于主控性能, 不能解码一些流行格式如MP3,AAC,但是转换也是个一次性的工作,也不显得非常麻烦.笔者自己转换了几十集的评书, 准备每天回来听一集. 总体来说,这个模块很有味道, 值得喜欢音频的同学买一块或者DIY一块.
此模块的官方连接: https://www.adafruit.com/product/94
本人的资源供参考使用: 链接: https://pan.baidu.com/s/1caYUvG 密码: enfw
(注意要放在SD卡的根目录)
- 本文系21ic原创,未经许可禁止转载!
网友评论
- 联系人:巧克力娃娃
- 邮箱:board@21ic.com
- 我要投稿
-
欢迎入驻,开放投稿
-
RAK831 Lite:基于树莓派3的LoRa网关... 2022-06-17
-
Imagination推出PowerVR AX2185和AX2145神经... 2022-06-17
-
ODROID-GO是一款兼容Arduino的基于ESP32的便... 2022-06-17
- PID温度控制器
预算:¥700003天前
- 摄像头的可视画面需要一直超上(linux系统,ARM)
预算:¥1000018小时前
- DICOM协议搭建(ARM架构,linux系统)
预算:¥1000017小时前
- 需MIPI摄像头隔离电路,实现3-4米能长距离
预算:¥1000017小时前
- 膨宫仪的控制板,控制流量和检测压力
预算:¥1000016分钟前
- 无创自动测量血压计 NIBP模块
预算:¥100007小时前