this line in the audio code will not compile playSdWav2.play(&mySounds[tracknum]); //??????????
apologies in advance, I cannot even do that code in the window thing......
apologies in advance, I cannot even do that code in the window thing......
Code:
String mySounds[]= {
"surf0001.WAV",
"surf0002.WAV",
"surf0003.WAV",
"surf0004.WAV",
"surf0005.WAV",
"wavetest.WAV"
};
///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav2; //xy=115,388
AudioPlaySdWav playSdWav3; //xy=116,532
AudioPlaySdWav playSdWav1; //xy=120,264
AudioMixer4 mixer1; //xy=300,274
AudioMixer4 mixer2; //xy=307,399
AudioEffectFade fade2; //xy=470,396
AudioEffectFade fade1; //xy=471,275
AudioMixer4 mixer3; //xy=666,436
AudioOutputI2S i2s1; //xy=832,352
AudioConnection patchCord1(playSdWav2, 0, mixer2, 0);
AudioConnection patchCord2(playSdWav2, 1, mixer2, 1);
AudioConnection patchCord3(playSdWav3, 0, mixer3, 2);
AudioConnection patchCord4(playSdWav3, 1, mixer3, 3);
AudioConnection patchCord5(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord6(playSdWav1, 1, mixer1, 1);
AudioConnection patchCord7(mixer1, fade1);
AudioConnection patchCord8(mixer2, fade2);
AudioConnection patchCord9(fade2, 0, mixer3, 1);
AudioConnection patchCord10(fade1, 0, mixer3, 0);
AudioConnection patchCord11(mixer3, 0, i2s1, 0);
AudioConnection patchCord12(mixer3, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=574,610
// GUItool: end automatically generated code
// Use these with the Teensy Audio Shield it is slower than the onboard SD card reader
//#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
//***************************************************************************************************
//***************************************************************************************************
void setup() {
Serial.begin(9600);
//audio setup code starts here
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);
}
#define RAMPSIZE 10000
int ramper=0,ramper2=10000,stepled,stepledlast;
int up=1;
long int ramp=100000;
//These return a number between 0 to 4294967295. For millis, that's 49.7 days. For micros, 1 hour+
elapsedMillis milliDontTouch,milli1,milli2,milli3;
bool tenmS=0,tenmSLong=0;
//elapsedMicros micro1,micro2,micro3;
//******************************************************************************************************
//******************************************************************************************************
void loop() {
tenmS=(((milliDontTouch%10)==0)&&!tenmS&&!tenmSLong); // on for a single scan ...this may not work 100.000%, because of == could concievably skip if any scan time exceeds 1mS
if (tenmS){
tenmSLong=1; //on for multiple scans over a full mS
}
if(tenmSLong&&((milliDontTouch%10)!=0)){ //next millisecond has clicked by
tenmSLong=0;
}
if(tenmS){
playbackingtrack(3,0.5);
}
}
byte channelnum=1; //channel 1 or 2 only
byte tracknum=-1;
float gayn;
bool playbackingtrack(int newtracknum, float newgain){
if(tracknum<0||tracknum>6){ //illegal track number, stop playing everything
fade1.fadeOut(2000);
fade2.fadeOut(2000);
//playSdWav1.stop(); //should fade out first
//playSdWav2.stop();
}
else if (newtracknum!=tracknum){ // track change
tracknum=newtracknum;
if(channelnum==1){
fade1.fadeOut(4000);
playSdWav2.play(&mySounds[tracknum]); //??????????
fade2.fadeIn(4000); //note both tracks are still playing even with one faded out, this may slow down processor???? or can call stop() after the fade out has happened
channelnum=2;
}
else if(channelnum==2){
fade2.fadeOut(4000);
playSdWav1.play(&mySounds[tracknum]);
fade1.fadeIn(4000); //note both tracks are still playing even with one faded out, this may slow down processor???? or can call stop() after the fade out has happened
channelnum=1;
}
Serial.print("Start playing ");Serial.print(mySounds[tracknum]);Serial.print(" on channel # ");Serial.println(channelnum);
}
if(gayn!=newgain){
gayn=newgain;
mixer3.gain(0,gayn); //not fading it in at this time
mixer3.gain(1,gayn);
}
return(playSdWav1.isPlaying() || playSdWav2.isPlaying());
}
Last edited by a moderator: