Output equivalent in processBlock()?


#1

Sorry again for a noob question 

how would you code 




(*out1++) += (*in1++) * something;
(*out2++) += (*in2++) * something;

 

in juce? 

Thank you!


#2

outn and inn is buffer.getSampleData(n), so you can for example do this:

const int numSamples = buffer.getNumSamples()

for (int channel = 0; channel < getNumInputChannels(); ++channel)
{
    float* channelData = buffer.getSampleData (channel);
    
    for (int n=0; n<numSamples; ++n)
        channelData[n] *= something;
}

#3

Thanks for a reply! 

I am trying to follow tremolo tutorial from 

http://www.euphoriaaudio.com/tutorials/tremolo/EA_Tremolo_paper.pdf (page 20)

I don't know what I'm doing wrong! 

void AddictiveAmAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)

{

    const int numSamples = buffer.getNumSamples();

    int counter = 0;

    float modifier;


    for(int channel = 0; channel < getNumInputChannels(); channel++)

    {

        

        float* channelData = buffer.getSampleData(channel);


       for (int n=0; n<numSamples; ++n)

        {

            

            if(counter < ((1/period[0] * 10) * currentSamplerate))

            {

                counter++;

            }else

            {

                counter = 0;

            }

            

            

            modifier = (1.0 - depth[0]) + depth[0] * (sin((2 * 3.14 * (period[0] * 10)) * (counter/currentSamplerate))) * (sin((2 * 3.14 * (period[0] * 10)) * (counter/currentSamplerate)));

            

                channelData[n] *= modifier;

            

        }

    }


    // In case we have more outputs than inputs, we'll clear any output

    // channels that didn't contain input data, (because these aren't

    // guaranteed to be empty - they may contain garbage).

    for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)

    {

        buffer.clear (i, 0, buffer.getNumSamples());

    }

}

#4

What output are you getting?   Did you attach a debugger and look at what modifier is calcuating itself to be?


#5

Im just getting plain audio! 

Attatching a debugger? How is it done in xcode? Thanks!