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):
[code]#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
}[/code]
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:
[code]
#include "LFO.h"
#include "Delay.h"
#include "Chorus.h"
[/code]
...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:
[code]
#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;
}[/code]
LFO:
[code]
#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;
}[/code]
Wait, so in *.h your including itself?
nah ive only posted the .cpp files above, the .h files just have the clss definitions in them
Is one H file including one, which then includes the same one back? A loop?
Check this out:
[url]http://en.wikipedia.org/wiki/Pragma_once[/url]
Fixed it guys... i'm an idiot:
LFO header:
[code]
#ifndef __MNLFO__
#define __MNLFO__
class LFO
{ ...[/code]
Delay header:
[code]
#ifndef __MNDELAY__
#define __MNDELAY__
class Delay
{ ...[/code]
Thanks though, still learnt something.
Those include guards should be unique.
[QUOTE=blankthemuffin;18797276]Those include guards should be unique.[/QUOTE]
Oh yeah, cheers.
Sorry, you need to Log In to post a reply to this thread.