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

Thread: reroute patch cords after compilation?

  1. #1

    reroute patch cords after compilation?

    Is it possible to change this to this:
    Code:
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc1x(A2);      //xy=200.00001525878906,320.00000381469727
    AudioAmplifier           amp1L;          //xy=389.00000762939453,341.0000057220459
    AudioOutputUSB           usb2;           //xy=566.0000114440918,496.0000066757202
    AudioFilterBiquad        biquad1L;       //xy=605.0000076293945,314.00000381469727
    AudioAnalyzePeak         peakL;          //xy=813.0000114440918,308.00000381469727
    AudioConnection          patchCord1(adc1x, amp1L);
    AudioConnection          patchCord2(amp1L, 0, usb2, 0);
    AudioConnection          patchCord3(amp1L, 0, usb2, 1);
    AudioConnection          patchCord4(amp1L, biquad1L);
    AudioConnection          patchCord5(biquad1L, peakL);
    // GUItool: end automatically generated code
    To this:
    Code:
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc1x(A2);       //xy=120,232.00000381469727
    AudioFilterBiquad        biquad1L; //xy=321,171
    AudioAmplifier           amp1L; //xy=520.0000076293945,130.00000190734863
    AudioAnalyzePeak         peakL; //xy=710,122
    AudioOutputUSB           usb2; //xy=726.0000076293945,317.00000286102295
    //AudioOutputAnalog        dac1;           //xy=821,245
    AudioConnection          patchCord1(adc1x, biquad1L);
    AudioConnection          patchCord2(biquad1L, amp1L);
    AudioConnection          patchCord3(amp1L, peakL);
    AudioConnection          patchCord4(amp1L, 0, usb2, 0);
    AudioConnection          patchCord5(amp1L, 0, usb2, 1);
    //AudioConnection          patchCord6(amp1L, dac1);
    // GUItool: end automatically generated code
    During runtime?

    in one config the Audio is pushed to Filter, then amp, then USB +PEAK
    the other config it's Amp then branch to USB...then filter then peak.

  2. #2

  3. #3
    Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    79
    Thanks for the plug, @manicksan!

    Yes, my updated audio core and library (Dynamic Audio Objects) should make this fairly trivial:
    Code:
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc1x(A2);      //xy=200.00001525878906,320.00000381469727
    AudioAmplifier           amp1L;          //xy=389.00000762939453,341.0000057220459
    AudioOutputUSB           usb2;           //xy=566.0000114440918,496.0000066757202
    AudioFilterBiquad        biquad1L;       //xy=605.0000076293945,314.00000381469727
    AudioAnalyzePeak         peakL;          //xy=813.0000114440918,308.00000381469727
    AudioConnection          patchCord1(adc1x, amp1L);
    AudioConnection          patchCord2(amp1L, 0, usb2, 0);
    AudioConnection          patchCord3(amp1L, 0, usb2, 1);
    AudioConnection          patchCord4(amp1L, biquad1L);
    AudioConnection          patchCord5(biquad1L, peakL);
    // GUItool: end automatically generated code
    
    // Call either of these functions within loop() to re-patch at run-time
    void patch1(void)
    {
          patchCord1.disconnect();
          patchCord4.disconnect();
          patchCord5.disconnect();
    
          patchCord1.connect(adc1x, amp1L);
          patchCord4.connect(amp1L, biquad1L);
          patchCord5.connect(biquad1L, peakL);
    }
    
    void patch2(void)
    {
          patchCord1.disconnect();
          patchCord4.disconnect();
          patchCord5.disconnect();
    
          patchCord1.connect(adc1x, biquad1L);
          patchCord4.connect(amp1L, peakL);
          patchCord5.connect(biquad1L, amp1L);
    }
    You may want to add a fade block to do a smooth fade out before, and fade in after the re-patch, as you're quite likely to get pops at the output otherwise. Note that the patchcord numbering doesn't matter (for either library), so I just used your first example. DAO library doesn't care about the declaration order of the audio objects, it tries to update them in the correct order based on the connections existing at the time.

    Note you need to replace both the Teensy audio core and the audio library to get the functionality: I don't know how hard this is for others to do, because no-one's yet reported back on the other thread. If you go for it and need to ask specifically about using the Dynamic Audio Objects, please post on that thread rather than this one if possible. I'd really welcome some feedback!

    Cheers

    Jonathan

  4. #4
    Can you point me to your library as i want to try it/include it

  5. #5
    Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    79
    Hi there

    The Audio Library is at features/dynamic-updates, and the modified core at cores. Note that from the latter you should only take AudioStream.cpp and AudioStream.h from the teensy4 folder, and replace your existing ones. In Windows these will be somewhere like C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4

    Cheers

    Jonathan

Posting Permissions

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