Hi!
I'm adapting SimpleSynth and adding LFOs that are global and outside the voices.
Part of this is so I can learn more about object-oriented programming, which I am new to.
Here is the LFO class, which works. I have been able to grab its output from the main program and spit it out the headphones just fine. (this way of grabbing output is also how the main program gets the output of each voice).
However, I am not able to take pull the LFO output into the Voices themselves. This has something to do with objects in one class not being able to call objects from another class, but I don't know a good solution.
Here is the relevant portion of the voice code that does not work:
I'm open to any possible solution. My thoughts on possibilities are:
- Making the LFO output somehow more global, so that it can be seen by other objects belonging to other classes (such as Voice)
- Making an overarching class somehow that both voice and LFO are a part of so they can share the LFO audio stream
- Creating a voice INPUTS inside the voice class, and then hooking up the LFO to each voice object inside main
I don't know how to do any of the above and don't know if they are feasible. Any insight would be appreciated.
I'm having a hell of a time understanding pointers, inheritance, etc.
Thank you!
I'm adapting SimpleSynth and adding LFOs that are global and outside the voices.
Part of this is so I can learn more about object-oriented programming, which I am new to.
Here is the LFO class, which works. I have been able to grab its output from the main program and spit it out the headphones just fine. (this way of grabbing output is also how the main program gets the output of each voice).
Code:
class LFO_OSC{
private:
AudioSynthWaveform *LFO;
public:
LFO_OSC(); // constructor
float FREQ;
void SET_FREQ(float Amnt);
AudioSynthWaveform * getOutput ();
// AudioConnection *patches[1];
};
inline LFO_OSC::LFO_OSC (){ // constructor
Serial.println ("Started constructing an LFO");
this->LFO = new AudioSynthWaveform ();
this->LFO->begin(WAVEFORM_TRIANGLE);
this->LFO->frequency(0);
this->LFO->amplitude(1);
this->FREQ=0;
}
void LFO_OSC::SET_FREQ(float Amnt){
this->LFO->frequency ((Amnt *10) * (Amnt *10)*10); //100*10=1000 max
};
inline AudioSynthWaveform * LFO_OSC::getOutput(){
return this->LFO;
};
However, I am not able to take pull the LFO output into the Voices themselves. This has something to do with objects in one class not being able to call objects from another class, but I don't know a good solution.
Here is the relevant portion of the voice code that does not work:
Code:
class Voice{
}
// constructor
Voice::Voice(){
this->patchCords[0] = new AudioConnection (*lfos[0].getOutput(), 0, *this->output, 0);
}
I'm open to any possible solution. My thoughts on possibilities are:
- Making the LFO output somehow more global, so that it can be seen by other objects belonging to other classes (such as Voice)
- Making an overarching class somehow that both voice and LFO are a part of so they can share the LFO audio stream
- Creating a voice INPUTS inside the voice class, and then hooking up the LFO to each voice object inside main
I don't know how to do any of the above and don't know if they are feasible. Any insight would be appreciated.
I'm having a hell of a time understanding pointers, inheritance, etc.
Thank you!