简介
DFRduino M0专用音频扩展板,使用Wolfson新近推出WM8978全功能音频处理器,带有一个HI-FI级数字信号处理内核,支持增强3D硬件环绕音效,以及5频段的硬件均衡器,可以有效改善音质;并有一个可编程的陷波滤波器,用以去除屏幕开、切换等噪音。
归功于DFRduino M0丰富的硬件资源,我们终于可以把这款HiFi级codec芯片移植到Arduino平台上。无需串口MP3模块,就可以实现双声道放音,SD卡存储,单声道录音,双声道3W功放等功能。节省了串口资源,使用更加的灵活和方便,自由地掌控音频功能。
DFRduino M0 音频扩展板采用标准音频IIS接口,板载MIC,并预留麦克分接口,支持外部音源输入,预留左右声道接口,可以外接耳机或者喇叭。
产品参数
- 工作电压:5V
- 最大工作电流:2A
- DFRduino M0 shield
- 输入接口:Linein & MIC
- 输出接口:Lineout & Speaker
- 尺寸 55mm*53mm
- 重量 26g
引脚说明
标号 | 名称 | 功能描述 |
---|---|---|
1 | linein | linein |
2 | lineout | lineout |
3 | sdcard | sd卡插槽 |
4 | SPEAK_L | 左声道功放输出 |
5 | SPEAK_R | 右声道功放输出 |
使用教程
教程1——wav音频播放
准备
- 硬件
- DFRduino M0 Mainboard x1
- Audio Shield for DFRduino M0 x1
- 3.5mm接口耳机或者3W喇叭
- 已经格式化为FAT格式的SD卡一张(当前不支持exFAT,请使用FAT16或者FAT32进行格式化)
- 软件
- Arduino IDE 版本1.6.6及以上版本 点击下载Arduino IDE
样例代码
#include <SPI.h>
#include <Wire.h>
#include <SD.h>
#include <WAV.h>
// set up variables using the SD utility library functions:
Sd2Card card;
///< assign sd card chipselect pin
const int chipSelect = 30;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
while(1){
Serial.print("\nInitializing SD card...");
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card inserted?");
Serial.println("* is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
delay(2000);
continue;
} else {
Serial.println("Wiring is correct and a card is present.");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
delay(2000);
continue;
}
break;
}
}
}
void loop()
{
int ret;
//assign music file and trigger transport dma
wav.play("test.wav");
do{
//We must continue to decode to provide data to the player
ret = wav.decode();
//user code
}while(ret == WAV_DECODING);
while(1);
}
使用方法
- 将您的音频转化为wav格式(名称可自定义,样例代码使用test.wav),放入SD卡根目录下(文件夹内无法识别)
- 将SD卡插入SD卡槽中,注意:SD的存储格式必须为FAT
- 插上喇叭或者耳机
- 烧入样例代码后,打开串口助手自动放音
教程2——wav音频录制
准备
- 硬件
- DFRduino M0 Mainboard x1
- Audio Shield for DFRduino M0 x1
- 3.5mm接口耳机
- 已经格式化为FAT格式的SD卡一张(当前不支持exFAT,请使用FAT16或者FAT32进行格式化)
- 软件
- Arduino IDE 版本1.6.6及以上版本 点击下载Arduino IDE
样例代码
#include <SPI.h>
#include <Wire.h>
#include <SD.h>
#include <WAV.h>
// set up variables using the SD utility library functions:
Sd2Card card;
const int chipSelect = 30; ///< assign sd card chipselect pin
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
while(1){
Serial.print("\nInitializing SD card...");
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card inserted?");
Serial.println("* is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
delay(2000);
continue;
} else {
Serial.println("Wiring is correct and a card is present.");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
delay(2000);
continue;
}
break;
}
}
}
void loop()
{
int ret;
ret = wav.record("rec.wav");
unsigned int start = millis();
while(ret == WAV_ENCODING){
ret = wav.encode();
if(millis() - start > 5000){
wav.stop();
ret = WAV_ENCODE_END;
}
};
while(1);
}
结果
烧入样例代码后开始录音,5秒后停止录音,录音文件:REC.wav。
常见问题
还没有客户对此产品有任何问题,欢迎通过qq或者论坛联系我们!
更多问题及有趣的应用,可以 访问论坛 进行查阅或发帖!