Greetings. Ok: Total Newbie here.
I’m trying to perform a sinusoidal sound wave through the Simple Harmonic Motion, but I’m getting these weird pop’s… Well, I’ve done too much, and I’m trying even more. Perhaps some blessed programming soul could help…
So, below is the code I’m trying:
void FormasDeOndaAudioProcessor::processBlock (juce::AudioBuffer< float >& buffer, juce::MidiBuffer& midiMessages) {
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
double taxaAmostragem = getSampleRate();
for ( auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
auto * channel0 = buffer.getWritePointer(0);
auto * channel1 = buffer.getWritePointer(1);
for (int amostra = 0; amostra < buffer.getNumSamples(); amostra++) {
channel0[amostra] = cos(juce::MathConstants::twoPi * *apvts.getRawParameterValue(“SENO”) * (contaSample/taxaAmostragem)) * *apvts.getRawParameterValue(“VSENO”)/100.f;
channel1[amostra] = cos((juce::MathConstants::twoPi * *apvts.getRawParameterValue(“SENO”)) * contaSample/taxaAmostragem) * *apvts.getRawParameterValue(“VSENO”)/100.f;
contaSample++;
if (contaSample >= taxaAmostragem) contaSample = 0;
}
}
