How to move auto generated Audio GUI code to a separate source file?

Status
Not open for further replies.
Hello everyone,

In order to organize my code, I'd like to move the entire code block generated from the audio gui into a separate source file. This would help me make my main.cpp neater and also it would help me iterate the audio gui more quickly by facilitating easy copy/paste and getting rid of scrolling.

Here is the method I tried:
-added a audioGui.h file to my src folder
-added the preprocessor directive #include<"audioGui.h"> to my main.cpp
-move auto generated code block to audioGui.h and comment out the same code in main.cpp

When I compile I get the following error:
Code:
Compiling .pio/build/teensy41/src/main.cpp.o
src/main.cpp: In function 'void updateParams()':
src/main.cpp:393:3: error: 'plateRvbStero1' was not declared in this scope
   plateRvbStero1.size(reverbSize);     // max reverb length
   ^
src/main.cpp: In function 'void setup()':
src/main.cpp:504:3: error: 'plateRvbStero1' was not declared in this scope
   plateRvbStero1.size(reverbSize);     // max reverb length
   ^
*** [.pio/build/teensy41/src/main.cpp.o] Error 1

The funny thing is, that audio object in the error is the PLATE REVERB made by Pio. I added that to my code by copying Pio's .h and .cpp file into my audio library folder, then I edited Audio.h to add a #include for the plate reverb. Finally, I edited the index.html file to get the plate reverb to appear in my audio GUI.

It appears that all the standard audio objects are working OK.

Does anyone have any ideas about how to get out of this tangled web?

If there is a good reference on how to add custom audio objects to my code I can reset to the standard audio library and retry from scratch. I tried to follow the CREATING NEW AUDIO OBJECTS post but that is a bit too advanced for me and it doesn't address how to get the new audio objects to show in the GUI.

Thank you for your help!
 
You need to have
#include "effect_platervbstereo.h"
Before the
#include "audioGui.h"
As an alternative you will need to have the
#include "effect_platervbstereo.h"
In the top of audioGui.h

To add items to the tool you need to edit the local version of the tool index.html
Search for NodeDefinitions and you will find a lot of lines describing all the audio objects,
then you copy paste one line,
Then in the new line,
Change:
Type
Short name
Inputs
Outputs
Category

In my modified version of the tool,
there is functionality now to add items directly
in the tool GUI
But the documentation/manual is not yet finished
(I just need to read thought it first)
 
Hi Manicksan,

Thank you for the quick reply, unfortunately that does not fix it.

What surprises me is the error occurs when I first call a method for plateRvbStereo, and not when I instanciate plateRvbStereo. So maybe this is a scope issue? Maybe the audioGui.h has access to the plate reverb header file and successfully instanciates a plate reverb object, but then the plate reverb object has a scope that is not seen in my void setup() function? Here is my audioGui.h file:

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

// GUItool: begin automatically generated code
AudioSynthNoiseWhite     noise4;         //xy=73,779
AudioSynthNoiseWhite     noise3;         //xy=74,567
AudioSynthWaveformModulated oscB4;          //xy=75,727
AudioSynthWaveformModulated oscB3;          //xy=76,515
AudioSynthWaveformModulated oscA4;          //xy=77,674
AudioSynthWaveformModulated oscA3;          //xy=78,462
AudioSynthNoiseWhite     noise2;         //xy=82,364
AudioSynthNoiseWhite     noise1;         //xy=84,169
AudioSynthWaveformModulated oscB2;          //xy=84,312
AudioSynthWaveformModulated oscB1;          //xy=86,117
AudioSynthWaveformModulated oscA2;          //xy=86,259
AudioSynthWaveformModulated oscA1;          //xy=88,64
AudioMixer4              mixA4;          //xy=257,733
AudioMixer4              mixA3;          //xy=258,521
AudioMixer4              mixA2;          //xy=266,318
AudioMixer4              mixA1;          //xy=268,123
AudioEffectEnvelope      env4;           //xy=398,733
AudioEffectEnvelope      env3;           //xy=399,521
AudioEffectEnvelope      env2;           //xy=407,318
AudioEffectEnvelope      env1;           //xy=409,123
AudioAmplifier           amp4;           //xy=541,733
AudioAmplifier           amp3;           //xy=542,521
AudioAmplifier           amp2;           //xy=550,318
AudioAmplifier           amp1;           //xy=552,123
AudioFilterStateVariable filter4;        //xy=697,738
AudioFilterStateVariable filter3;        //xy=698,526
AudioFilterStateVariable filter2;        //xy=706,323
AudioFilterStateVariable filter1;        //xy=708,128
AudioMixer4              voiceMix1;      //xy=913,215
AudioFilterStateVariable delayFilterLP;  //xy=1007,582
AudioAnalyzePeak         peak1;          //xy=1063,112
AudioFilterStateVariable delayFilterHP;  //xy=1187,591
AudioMixer4              delayMix1;      //xy=1207,360
AudioEffectDelay         delay1;         //xy=1219,753
AudioAnalyzePeak         peak2;          //xy=1438,111
AudioMixer4              reverbMix1;     //xy=1729,279
AudioMixer4              reverbMix2;     //xy=1735,426
AudioAnalyzePeak         peak3;          //xy=1954,146
AudioAmplifier           mainOut1;       //xy=2008,344
AudioAmplifier           mainOut2;       //xy=2017,387
AudioOutputI2S           i2s1;           //xy=2196,355
AudioConnection          patchCord1(noise4, 0, mixA4, 2);
AudioConnection          patchCord2(noise3, 0, mixA3, 2);
AudioConnection          patchCord3(oscB4, 0, mixA4, 1);
AudioConnection          patchCord4(oscB3, 0, mixA3, 1);
AudioConnection          patchCord5(oscA4, 0, mixA4, 0);
AudioConnection          patchCord6(oscA3, 0, mixA3, 0);
AudioConnection          patchCord7(noise2, 0, mixA2, 2);
AudioConnection          patchCord8(noise1, 0, mixA1, 2);
AudioConnection          patchCord9(oscB2, 0, mixA2, 1);
AudioConnection          patchCord10(oscB1, 0, mixA1, 1);
AudioConnection          patchCord11(oscA2, 0, mixA2, 0);
AudioConnection          patchCord12(oscA1, 0, mixA1, 0);
AudioConnection          patchCord13(mixA4, env4);
AudioConnection          patchCord14(mixA3, env3);
AudioConnection          patchCord15(mixA2, env2);
AudioConnection          patchCord16(mixA1, env1);
AudioConnection          patchCord17(env4, amp4);
AudioConnection          patchCord18(env3, amp3);
AudioConnection          patchCord19(env2, amp2);
AudioConnection          patchCord20(env1, amp1);
AudioConnection          patchCord21(amp4, 0, filter4, 0);
AudioConnection          patchCord22(amp3, 0, filter3, 0);
AudioConnection          patchCord23(amp2, 0, filter2, 0);
AudioConnection          patchCord24(amp1, 0, filter1, 0);
AudioConnection          patchCord25(filter4, 0, voiceMix1, 3);
AudioConnection          patchCord26(filter3, 0, voiceMix1, 2);
AudioConnection          patchCord27(filter2, 0, voiceMix1, 1);
AudioConnection          patchCord28(filter1, 0, voiceMix1, 0);
AudioConnection          patchCord29(voiceMix1, peak1);
AudioConnection          patchCord30(voiceMix1, 0, delayMix1, 0);
AudioConnection          patchCord31(delayFilterLP, 0, delayFilterHP, 0);
AudioConnection          patchCord32(delayFilterHP, 2, delayMix1, 1);
AudioConnection          patchCord33(delayMix1, delay1);
AudioConnection          patchCord34(delayMix1, peak2);
AudioConnection          patchCord35(delayMix1, 0, reverbMix1, 0);
AudioConnection          patchCord36(delayMix1, 0, reverbMix2, 0);
AudioConnection          patchCord37(delay1, 0, delayFilterLP, 0);
AudioConnection          patchCord38(reverbMix1, mainOut1);
AudioConnection          patchCord39(reverbMix1, peak3);
AudioConnection          patchCord40(reverbMix2, mainOut2);
AudioConnection          patchCord41(mainOut1, 0, i2s1, 0);
AudioConnection          patchCord42(mainOut2, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=2104,477
// GUItool: end automatically generated code
 
How do you use the AudioEffectPlateReverb?
It's not visible in your posted code
If you use it in the main.cpp then you need to do the include there.
 
OK I fixed it! Sorry for the hassle everyone.

Here is the root cause: while working on this, I imported my audio graph into the GUI tool. However, I did not use the correct index.html file when I did the import, this broke the plateReverb object. without noticing, I clicked export, took that auto generated code, and placed it into my audioGui file. I did not notice that the plateReverb object was gone (in post #3 you can see that the plate reverb object is not listed). As a result, the plate reverb object was never instanciated and caused an error in the voidSetup function the first time I try to call a method.

I learned that once I start working with a modified audio library it becomes super important to be careful with the index.html file. Thank you Manicksan and El_supremo! (hey supremo you caught a typo in my code I didn't notice before, I fixed the Stero to Stereo).
 
Hi Manicksan,

What surprises me is the error occurs when I first call a method for plateRvbStereo, and not when I instanciate plateRvbStereo.

The order errors are reported is dependent on the way the compiler crawls the parse tree in its various analysis and
code-generation phases - don't read anything into this.
 
Status
Not open for further replies.
Back
Top