Evening all,
Heres the problem, I have an assignment that requires me to make a number of audio effects. I have a Delay class, and a Low Frequency Oscillator class, both of which I have tested and are working.
However, when it comes to Chorus, I need to use both the LFO and Delay classes, which should be simple and I know how i would code it... but Visual studio seems to think otherwise. When I build the solution it only appears to be using one of the .h files (whichever is declared first it appears). Heres the code for the chorus (this isnt finished, so it wouldnt work anyway, but it shouldnt be having ths problem):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include "Delay.h"
#include "LFO.h"
#include "Chorus.h"
Chorus::Chorus()
{
SR=44100;
delay=20;
width=10;
rate=10;
}
float Chorus::process(float sample,float channel)
{
Delay del;
LFO sweep;
sweep.SR=SR
del.SR=SR
}
|
In the above example, building the solution gives errors suggesting that it hasnt found the LFO class (Despite the fact that using the dot operator in the editor brings up its functions). If i sap the order i declare the .h files, e.g:
1 2 3
|
#include "LFO.h"
#include "Delay.h"
#include "Chorus.h"
|
...then the opposite happens, it doesnt find the Delay class.
Anyone know where I'm going wrong? I'd never programmed in my life untill a year ago so forgive me if I've missed something blindingly obvious.
Heres the code for the Delay and LFO, incase theres something in there causing a problem:
Delay:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include "Delay.h"
Delay::Delay()
{
SR=44100;
numSamps=1;
inSample=0;
delayTime=10;
wetdry=0.5f;
decay=0;
}
void Delay::DelayIn(float inSample)
{
if(inPosn==0) //initialise buffer
{
Iindex=(delayTime*SR)/1000;
pBuff = new float[Iindex];
buffPosn=pBuff;
buffEnd=pBuff+Iindex;
}
if(inPosn<Iindex)
{
*buffPosn = 0.0f; //silences empty samples before delay starts
}
outSamp = *buffPosn;
buffOut= (float)(1-wetdry)*inSample+wetdry*outSamp; //Sends delayed output from pBuff
*buffPosn=inSample+decay*outSamp; //Writes next sample into pBuff
++buffPosn; //step through buffer
if (buffPosn>=buffEnd)
{
buffPosn=pBuff; //loop back to start of buffer
}
}
void Delay::remove()
{
delete [] pBuff;
}
|
LFO:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include "LFO.h"
#include <cmath>
LFO::LFO()
{
SR=44100;
LFOFrequency=5.0;
range=1;
}
float LFO::sine(int process)
{
lfo = range*(sin(PIX2*process*(LFOFrequency/SR)))+1;
return lfo;
}
float LFO::cosine(int process)
{
lfo = range*(cos(PIX2*process*(LFOFrequency/SR)))+1;
return lfo;
}
|