|
|
@@ -1,4 +1,4 @@ |
|
|
|
// Simple sine wave test for WM8731 Audio Codec Board |
|
|
|
// Simple sine wave & input level test for WM8731 Audio Codec Board |
|
|
|
// |
|
|
|
// Requires the MikroElektronika Audio Codec board or similar hardware |
|
|
|
// http://www.mikroe.com/add-on-boards/audio-voice/audio-codec-proto/ |
|
|
@@ -10,7 +10,7 @@ |
|
|
|
// SCK 9 |
|
|
|
// MISO 13 |
|
|
|
// MOSI 22 |
|
|
|
// ADCL |
|
|
|
// ADCL 23 (yes, ADCL & DACL connect together) |
|
|
|
// DACL 23 |
|
|
|
// SDA 18 |
|
|
|
// SCL 19 |
|
|
@@ -26,11 +26,16 @@ |
|
|
|
#include <SerialFlash.h> |
|
|
|
|
|
|
|
// GUItool: begin automatically generated code |
|
|
|
AudioSynthWaveform waveform1; //xy=110,75 |
|
|
|
AudioOutputI2Sslave i2ss1; //xy=303,78 |
|
|
|
AudioConnection patchCord1(waveform1, 0, i2ss1, 0); |
|
|
|
AudioConnection patchCord2(waveform1, 0, i2ss1, 1); |
|
|
|
AudioControlWM8731master wm8731m1; //xy=230,154 |
|
|
|
AudioSynthWaveform waveform1; //xy=245,160 |
|
|
|
AudioInputI2Sslave i2sslave1; //xy=265,252 |
|
|
|
AudioOutputI2Sslave i2sslave2; //xy=429,158 |
|
|
|
AudioAnalyzeRMS rms2; //xy=436,323 |
|
|
|
AudioAnalyzeRMS rms1; //xy=444,265 |
|
|
|
AudioConnection patchCord1(waveform1, 0, i2sslave2, 0); |
|
|
|
AudioConnection patchCord2(waveform1, 0, i2sslave2, 1); |
|
|
|
AudioConnection patchCord3(i2sslave1, 0, rms1, 0); |
|
|
|
AudioConnection patchCord4(i2sslave1, 1, rms2, 0); |
|
|
|
AudioControlWM8731master wm8731m1; //xy=292,379 |
|
|
|
// GUItool: end automatically generated code |
|
|
|
|
|
|
|
|
|
|
@@ -44,8 +49,31 @@ void setup() { |
|
|
|
waveform1.amplitude(0.9); |
|
|
|
|
|
|
|
wm8731m1.volume(0.50); |
|
|
|
wm8731m1.inputSelect(AUDIO_INPUT_MIC); |
|
|
|
// wm8731m1.inputSelect(AUDIO_INPUT_LINEIN); // not connected on MikroE-516 |
|
|
|
} |
|
|
|
|
|
|
|
elapsedMillis msec; |
|
|
|
|
|
|
|
// Print a simple level meter |
|
|
|
void loop() { |
|
|
|
if (msec > 40) { |
|
|
|
if (rms1.available() && rms2.available()) { |
|
|
|
msec = 0; |
|
|
|
int level_left = rms1.read() * 30.0; |
|
|
|
int level_right = rms2.read() * 30.0; |
|
|
|
printchar(' ', 30 - level_left); |
|
|
|
printchar('<', level_left); |
|
|
|
Serial.print("||"); |
|
|
|
printchar('>', level_right); |
|
|
|
Serial.println(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void printchar(char c, int num) { |
|
|
|
for (int i=0; i < num; i++) { |
|
|
|
Serial.write(c); |
|
|
|
} |
|
|
|
} |
|
|
|
|