
Originally Posted by
SteveS
Hi there-
I'll jump in on this thread. I'm also very old school. I do like arduino OK, but more comfortable with makefiles.
Thanks Steve, very helpful tips. I have a teensy 3.1 project building outside of Arduino with the 3.0 makefile edited for the 3.1's arm. Things seem to be compiling and working fine.
Where i'm running into a snag is in trying to integrate the Audio Library and using the Audio Shield. I can compile and upload the PassThrough project in Arduino and audio passes just fine. However when I compile it using the c++ compiler / makefile outside of arduino … no audio. I'm calling all of the same functions as the arduino project. Maybe I'm missing something in the initialization?
Any help is greatly appreciated! Here's my C code.
Code:
#include "WProgram.h"
#include "Audio.h"
#include "Wire.h"
//Global objects
AudioInputI2S audioInput; // audio shield: mic or line-in
AudioOutputI2S audioOutput; // audio shield: headphones & line-out
// Create Audio connections between the components
AudioConnection c1(audioInput, 0, audioOutput, 0);
AudioConnection c2(audioInput, 1, audioOutput, 1);
AudioControlSGTL5000 audioShield;
void init(void);
extern "C" int main(void)
{
init();
//MAIN LOOP
pinMode(13, OUTPUT);
elapsedMillis volmsec=0;
int blinkrate = 0;
while (1)
{
//blink
digitalWriteFast(13, HIGH);
delay(blinkrate);
digitalWriteFast(13, LOW);
delay(blinkrate);
// every 50 ms, adjust the volume & blink rate
if (volmsec > 50)
{
float vol = analogRead(15);
vol = vol / 10.24;
audioShield.volume(vol);
volmsec = 0;
blinkrate = analogRead(17);
}
}
}
void init(void)
{
//Init code
AudioMemory(12); //allocate memory for audio buffer
// Enable the audio shield and set the output volume.
audioShield.enable();
audioShield.inputSelect(AUDIO_INPUT_LINEIN);
audioShield.volume(60);
}