首頁 > 評(píng)測(cè) > 8位機(jī)也玩音頻-Arduino+SD+DAC+運(yùn)放打造的播放器
8位機(jī)也玩音頻-Arduino+SD+DAC+運(yùn)放打造的播放器
- [導(dǎo)讀]
- 比如本文要介紹的Adafruit Wave Shield,就能是專門為Arduino設(shè)計(jì)的音頻模塊.確切的說是為AVR這一類的8位機(jī)而設(shè)計(jì)的音頻模塊.下文將從硬件到軟件詳細(xì)介紹一下子此模塊的設(shè)計(jì)細(xì)節(jié)與使用方法.
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
}
}
}
}
如果一切正常的話,下載此程序后即可開始播放.如果你一時(shí)沒有合適的資源,請(qǐng)下載本文后面的附件中本人的資源進(jìn)行播放.
總結(jié)與參考
這個(gè)Arduino的Shield模塊具備了音頻播放器的種種功能,因?yàn)榕鋫淞薙D卡, 使得資源不成問題.受限于主控性能, 不能解碼一些流行格式如MP3,AAC,但是轉(zhuǎn)換也是個(gè)一次性的工作,也不顯得非常麻煩.筆者自己轉(zhuǎn)換了幾十集的評(píng)書, 準(zhǔn)備每天回來聽一集. 總體來說,這個(gè)模塊很有味道, 值得喜歡音頻的同學(xué)買一塊或者DIY一塊.
此模塊的官方連接: https://www.adafruit.com/product/94
本人的資源供參考使用: 鏈接: https://pan.baidu.com/s/1caYUvG 密碼: enfw
(注意要放在SD卡的根目錄)
- 本文系21ic原創(chuàng),未經(jīng)許可禁止轉(zhuǎn)載!
網(wǎng)友評(píng)論
- 聯(lián)系人:巧克力娃娃
- 郵箱:board@21ic.com
- 我要投稿
-
歡迎入駐,開放投稿
- NRF52810藍(lán)牙數(shù)字耳機(jī)找人定制
預(yù)算:¥30005天前
- 125KW模塊式PCS軟硬件外包開發(fā)
預(yù)算:¥1100000015小時(shí)前
- 12V汽車啟動(dòng)電源項(xiàng)目BMS設(shè)計(jì)
預(yù)算:¥50000023小時(shí)前
- 數(shù)據(jù)可視化軟件 開發(fā)
預(yù)算:¥5000023小時(shí)前
- PLC項(xiàng)目調(diào)試修改
預(yù)算:¥100001天前
- 起動(dòng)電機(jī)控制器開發(fā)
預(yù)算:¥1100001天前