Beginner Teensy Volume issue

Status
Not open for further replies.

ulonix

Member
Hey,
I'm just getting started with Teensy and i've tried some very simple things, I created an oscillator(waveform->saw) but i can't control the volume of it, or at least i can't tell any difference when i change the values from the mixer or from the osc. Please find attached a picture of teensy. I have an audio output connected to the dac output and ground.

Any help or tips to get started to produce proper output will be great!
Note: i know about the audio shield, but i can't buy one in my country, it will take a while before arrives if i order it online.

Here is the code:

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=251,461
AudioMixer4              mixer1;         //xy=468,472
AudioOutputAnalog        dac1;           //xy=642,496
AudioConnection          patchCord1(waveform1, 0, mixer1, 0);
AudioConnection          patchCord2(mixer1, dac1);
// GUItool: end automatically generated code




void setup() {
  // put your setup code here, to run once:
  AudioMemory(12);

}

void loop() {
  // put your main code here, to run repeatedly:
  waveform1.begin(WAVEFORM_SAWTOOTH);
  waveform1.amplitude(0.1);
  waveform1.frequency(440);
  mixer1.gain(0,0.5);
  
  //waveform1.amplitude(1);

}

IMAG0681.jpg
 
Most of the code looks alright.
I'm not sure if it's the problem,
but I would personally move the waveform1.begin function from the loop() to the setup() function.
Probably that function also sets the amplitude.
 
Thanks for you reply Roel, i will try this.
I did some more testing and it looks like it's working now. Just one question when i do analogReference (INTERNAL/EXTERNAL) i have to set it up to internal to have a proper volume, on external sounds very low. Whats is this doing internally? and how does it affect my basic setup?.
 
If you use the internal reference, the output is scaled to an internal, stable value.
If you change the reference to external, it uses the AREF pin as reference.
Likely that reference pin is unconnected.

https://www.pjrc.com/teensy/adc.html
This link gives more info about the internal/external reference, even though it was written for another teensy than you might be using
 
Great, as i'm just getting started it seems that there's lot's of details involved with the audio output and now i can understand why the audio shield is recommended, it's a shame that is not that easy to get one where I live(South America).
 
Status
Not open for further replies.
Back
Top