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

Thread: Tonesweep object appears to be broken

  1. #1
    Junior Member
    Join Date
    Nov 2021
    Posts
    3

    Tonesweep object appears to be broken

    Howdy all,

    I am working on integrating a tonesweep object into a larger project of mine.
    From the testing I have done so far the tonesweep object appears to start but it does not output any audio.
    I have been able to use the isPlaying() and read() commands to see that the tone sweep is successfully running but I have been unable to get audio out of it.

    My main project works as intended besides the tone sweep part of it so I do not think that the issue is related to my audio path.

    I have created a very simple test script to help debug my issue, even this test script is not working.

    I am running all of this code on a teensy 4.0, I have tried both with and without USB audio mode enabled and I am unable to get output from the tone sweep object in either case.

    Here is my simple test script...

    Any help is greatly appreciated!

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthToneSweep      tonesweep1;     //xy=457.00000381469727,233.00000381469727
    AudioOutputSPDIF3        spdif3_1;       //xy=648.0000076293945,237.00000381469727
    AudioConnection          patchCord1(tonesweep1, 0, spdif3_1, 0);
    AudioConnection          patchCord2(tonesweep1, 0, spdif3_1, 1);
    // GUItool: end automatically generated code
    
    void setup() {
      // put your setup code here, to run once:
        tonesweep1.play(1, 100, 1000, 30);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      while(1){}
    }

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,768
    You are missing at least two things. You need to define an output object for I2S, otherwise processing audio packets doesn't occur. Add this at the end of the audio connections:
    Code:
    AudioOutputI2S      audioOutput;
    If you are using the audio board and want to control its volume etc., you'll also need:
    Code:
    AudioControlSGTL5000 audioShield;
    You must also allocate some buffers for the audio system. In setup():
    Code:
      AudioMemory(2);
    Pete

  3. #3
    Senior Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    146
    Agree about audio buffers (an easy one to miss....), but I believe that the AudioOutputSPDIF3 object can assume update responsibility, so you don't need the AudioOutputI2S. That's based on my reading of the code and the documentation, not experience, though!

    Cheers

    Jonathan

  4. #4
    Junior Member
    Join Date
    Nov 2021
    Posts
    3
    You are absolutely correct, my test code is missing the audio memory allocation, that's important...
    I've had good luck using all of the other audio processing blocks in my larger project without a specific I2S output block (instead I've been using that spdif output block)

    Let me add in the audio memory to this test script and try again...

  5. #5
    Junior Member
    Join Date
    Nov 2021
    Posts
    3
    I've added the audio memory allocation and that has fixed my test script, it now works as expected.
    I am still having issues with my much more complex main project but as this test script works I can rule out the tonesweep object as the source of my issues.

    Thanks for your help!

    For those who find this thread later via a web search, here is the final test code that works for me.

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthToneSweep      tonesweep1;     //xy=457.00000381469727,233.00000381469727
    AudioOutputSPDIF3        spdif3_1;       //xy=648.0000076293945,237.00000381469727
    AudioConnection          patchCord1(tonesweep1, 0, spdif3_1, 0);
    AudioConnection          patchCord2(tonesweep1, 0, spdif3_1, 1);
    // GUItool: end automatically generated code
    
    void setup() {
      // put your setup code here, to run once:
        AudioMemory(16); //allocate 16 frames of memory to audio system
        tonesweep1.play(1, 100, 1000, 30);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      while(1){}
    }

Posting Permissions

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