Issues playing 2 WAV files

Status
Not open for further replies.

Sonerico

New member
So, I’m having issues playing back 2 WAV files using T4.0 and the Audio Shield for it.

First, I can’t the Mixer example to work. I haven’t changed any of the code from the example, copying in the generated code from the Design Tool (which looks right to me). I’m using a Sandisk 32GB SD card, which I reformatted to MS-DOS (FAT), Master Reboot Record with the most secure erase on a Mac. I’m using the example sound files. It simply doesn’t make any sound at all.

I was able to get the Simple_Wave_Player example to work just fine. So I don’t think it’s the hardware

To test things out, I did make a sketch which had playSdWav1 going into i2s1’s left channel and playSdWav2 going into i2s1’s right channel, bypassing the mixers. It did play both files but was super poppy and crackly and I think played them both at a slower speed. It did not sound like distortion but digital glitchiness to my ears.

I did search the threads here and found nothing that helped.

Any suggestion?

Thanks in advance.



// Advanced Microcontroller-based Audio Workshop
//
// http://www.pjrc.com/store/audio_tutorial_kit.html
// https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015
//
// Part 2-2: Mixers & Playing Multiple Sounds


///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=238.66665649414062,213.66666412353516
AudioPlaySdWav playSdWav2; //xy=258.6666564941406,317.66666412353516
AudioMixer4 mixer1; //xy=534.6666564941406,214.66666412353516
AudioMixer4 mixer2; //xy=534.6665954589844,318.6666488647461
AudioOutputI2S i2s1; //xy=748.6666564941406,238.6666488647461
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord2(playSdWav1, 1, mixer2, 0);
AudioConnection patchCord3(playSdWav2, 0, mixer1, 1);
AudioConnection patchCord4(playSdWav2, 1, mixer2, 1);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer2, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=179.66665649414062,62.666664123535156
// GUItool: end automatically generated code




// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14

// Use these with the Teensy 3.5 & 3.6 SD card
//#define SDCARD_CS_PIN BUILTIN_SDCARD
//#define SDCARD_MOSI_PIN 11 // not actually used
//#define SDCARD_SCK_PIN 13 // not actually used

// Use these for the SD+Wiz820 or other adaptors
//#define SDCARD_CS_PIN 4
//#define SDCARD_MOSI_PIN 11
//#define SDCARD_SCK_PIN 13

void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
pinMode(13, OUTPUT); // LED on pin 13
mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);
mixer2.gain(0, 0.5);
mixer2.gain(1, 0.5);
delay(1000);
}

void loop() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing 1");
playSdWav1.play("SDTEST1.WAV");
delay(10); // wait for library to parse WAV info
}
if (playSdWav2.isPlaying() == false) {
Serial.println("Start playing 2");
playSdWav2.play("SDTEST4.WAV");
delay(10); // wait for library to parse WAV info
}
// uncomment this code to allow Knob A3 to pan between songs
/*
int knob = analogRead(A3); // knob = 0 to 1023
float gain1 = (float)knob / 1023.0;
float gain2 = 1.0 - gain1;
mixer1.gain(0, gain1);
mixer1.gain(1, gain2);
mixer2.gain(0, gain1);
mixer2.gain(1, gain2);
*/
}
 

Attachments

  • Part_2_02_Mixers_TEST2.ino
    2.9 KB · Views: 37
Status
Not open for further replies.
Back
Top