### C++ beginner - need help with encapsulation

Hey Everybody I am currently attending a course in c++ programming on a basic level.

I received a code from my teacher, the other day and I have to encapsulate the content. here is the teacher description of the assignment.

"Encapsulate the audio de-zippering solution we did during lecture into a reusable class. Demonstrate its use in de-zippering two amplitude controls (that are updated in onAnimate) of two different sine oscillators."

Im a bit clueless, could anyone help me a bit, the code is attached here[code]

mvh Bjørn Dam Larsen

#include "allocore/io/al_App.hpp"
#include "Gamma/Oscillator.h"
using namespace al;

class MyApp : public App{
public:

float mPhase;
float mAmpCtrl;
float mAmpCurr, mAmpPrev;
gam::Sine<> mSineOsc;

MyApp()
: mPhase(0), mAmpCtrl(0), mAmpCurr(0), mAmpPrev(0)
{
initWindow();

// Initialize audio: sample rate, block size, # output chans, # input chans
initAudio(44100, 128, 2,1);
}

virtual void onSound(AudioIOData& io){
gam::Sync::master().spu(io.framesPerSecond());
mSineOsc.freq(110);

mAmpPrev = mAmpCurr;
mAmpCurr = mAmpCtrl;

float ampDiff = mAmpCurr - mAmpPrev;
float ampInc = ampDiff / io.framesPerBuffer();
float ampRamp = mAmpPrev;

while(io()){
float out1 = mSineOsc() * mAmpCtrl * 0.2;

//float out1 = mSineOsc() * ampRamp * 0.2;
float out2 = out1;

io.out(0) = out1;
io.out(1) = out2;

ampRamp += ampInc;
}
}

virtual void onAnimate(double dt){
mPhase += dt/2.;
if(mPhase > 1) mPhase -= 1;

mAmpCtrl = sin(mPhase * M_2PI);
}

virtual void onDraw(Graphics& g, const Viewpoint& v){
}
};

int main(){
MyApp().start();
}
Topic archived. No new replies allowed.