Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Beginner Teensy Volume issue

  1. #1
    Member
    Join Date
    Aug 2016
    Location
    Santiago, Chile
    Posts
    22

    Beginner Teensy Volume issue

    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);
    
    }
    Click image for larger version. 

Name:	IMAG0681.jpg 
Views:	105 
Size:	53.5 KB 
ID:	7940

  2. #2
    Member
    Join Date
    Apr 2014
    Location
    Flevoland, 5 meters under water
    Posts
    32
    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.

  3. #3
    Member
    Join Date
    Aug 2016
    Location
    Santiago, Chile
    Posts
    22
    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?.

  4. #4
    Member
    Join Date
    Apr 2014
    Location
    Flevoland, 5 meters under water
    Posts
    32
    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

  5. #5
    Member
    Join Date
    Aug 2016
    Location
    Santiago, Chile
    Posts
    22
    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •