As a simple test after I powered up my Teensy 3.1, I used the audio design tool to define two sine wave sources, mix them together and output them to the on-board DAC. Below is an image of my session with the tool (it is web based or you can download and run locally).
After the design is completed in the tool you just press the RED "Export" button and it will output the code for your sketch. I ended up tailoring mine to generate a Dial Tone and I was blown away how good it sounded! I just took the output of the DAC and feed it directly into a standard PC powered speaker.
You do need to do a little coding since the tool just sets up the streams. The tool generated the code that is between the "// GUItool ..." comments below in the example. I needed to call the audio objects in the "loop()" section which you can figure out from the docs and the examples provided. The comment section at the bottom is when I was playing with other Tel-co sounds (e.g. Busy Signal).
I am very impressed with the Teensy 3.1 platform and intend on replacing my Teensy 2.0 in my Proto Type Radio with it soon and try out some of the audio SDR functions.
Example Code:
// Simple Mixer to generate a Dialtone
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=183,181
AudioSynthWaveformSine sine2; //xy=192,251
AudioMixer4 mixer1; //xy=392,207
AudioOutputAnalog dac; //xy=591,178
AudioConnection patchCord1(sine1, 0, mixer1, 0);
AudioConnection patchCord2(sine2, 0, mixer1, 1);
AudioConnection patchCord3(mixer1, dac);
// GUItool: end automatically generated code
void setup() {
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(3);
}
void loop() {
sine1.frequency(350); //350
sine1.amplitude(0.1);
sine2.frequency(440);//440
sine2.amplitude(0.1);
//delay(100);
//sine1.amplitude(0);
//sine2.amplitude(0);
//delay(100);
}
No comments:
Post a Comment