首頁 > 評測 > 8位機也玩音頻-Arduino+SD+DAC+運放打造的播放器
8位機也玩音頻-Arduino+SD+DAC+運放打造的播放器
- [導(dǎo)讀]
- 比如本文要介紹的Adafruit Wave Shield,就能是專門為Arduino設(shè)計的音頻模塊.確切的說是為AVR這一類的8位機而設(shè)計的音頻模塊.下文將從硬件到軟件詳細介紹一下子此模塊的設(shè)計細節(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
}
}
}
}
如果一切正常的話,下載此程序后即可開始播放.如果你一時沒有合適的資源,請下載本文后面的附件中本人的資源進行播放.
總結(jié)與參考
這個Arduino的Shield模塊具備了音頻播放器的種種功能,因為配備了SD卡, 使得資源不成問題.受限于主控性能, 不能解碼一些流行格式如MP3,AAC,但是轉(zhuǎn)換也是個一次性的工作,也不顯得非常麻煩.筆者自己轉(zhuǎn)換了幾十集的評書, 準備每天回來聽一集. 總體來說,這個模塊很有味道, 值得喜歡音頻的同學(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)友評論
- 聯(lián)系人:巧克力娃娃
- 郵箱:board@21ic.com
- 我要投稿
-
歡迎入駐,開放投稿
-
人均百萬?英偉達中國員工收入曝光! 2024-08-29
-
《黑神話:悟空》玩家硬盤升級攻略:提升游戲體驗,暢享3A大作 2024-08-29
-
數(shù)睿數(shù)據(jù)參加《系統(tǒng)與軟件工程 低代碼開發(fā)平臺通用技術(shù)要求》國家標準編制 2024-08-29
- NRF52810藍牙數(shù)字耳機找人定制
預(yù)算:¥30005天前
- 125KW模塊式PCS軟硬件外包開發(fā)
預(yù)算:¥1100000015小時前
- 12V汽車啟動電源項目BMS設(shè)計
預(yù)算:¥50000023小時前
- 數(shù)據(jù)可視化軟件 開發(fā)
預(yù)算:¥5000023小時前
- PLC項目調(diào)試修改
預(yù)算:¥100001天前
- 起動電機控制器開發(fā)
預(yù)算:¥1100001天前