Download

Can't open project using MySynthComponent.cpp in 4.24

Hello,
I was following this tutorial on creating a simple frequency generator: https://www.youtube.com/watch?v=ErejaBCicds&feature=youtu.be&t=47m52s

In 4.23 it works fine. I get a build.
When I nativize the Blueprints to build I get the following error:
error C2248: ‘UMySynthComponent::SetFrequency’: cannot access private member declared in class ‘UMySynthComponent’

When I upgrade to 4.24 I’m not able to open my project. I’m getting around 6 errors with the MySynthComponent.cpp
They are LNK2001 and LNK2019 errors in VS2017 15.9.6.

Any ideas how to remedy this? I don’t really understand all the synth code.

Here is the code I copied:


#include "MySynthComponent.h"

bool UMySynthComponent::Init(int32& SampleRate)
{
    NumChannels = 1;

    // Initialize the DSP objects
    Osc.Init(SampleRate);
    Osc.SetFrequency(440.0f);
    Osc.Start();

    return true;
}

int32 UMySynthComponent::OnGenerateAudio(float* OutAudio, int32 NumSamples)
{
    // Perform DSP operations here
    for (int32 Sample = 0; Sample < NumSamples; ++Sample)
    {
        OutAudio[Sample] = Osc.Generate();
    }

    return NumSamples;
}

void UMySynthComponent::SetFrequency(const float InFrequencyHz)
{
    // Use this protected base class method to push a lambda function which will safely execute in the audio render thread.
    SynthCommand([this, InFrequencyHz]()
    {
        Osc.SetFrequency(InFrequencyHz);
        Osc.Update();
    });
}