CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Posts
    1

    #include related issues

    Evening all,

    Heres the problem, I have an assignment that requiredsme 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
    
    	
    
    }
    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"
    ...then the opposite happens, it doesnt find the Delay class.

    Anyone know where I'm going wrong?


    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;
    }
    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;
    }

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: #include related issues

    It would be better to show us the header files: delay.h and lfo.h, as the problem seems to be in one or both of them.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured