Cplusplus sound analysis

Hello everyone,

I am trying to write my own CppChop. The aim is absolutely the same of the analyze CHOP (basically I am trying to adapt Adam Stark Gist lib to a Chop node → GitHub - adamstark/Gist: A C++ Library for Audio Analysis):have an audio in, analyze the audio sample, and output a unique value (RMS, pitch etc…), and not a sample of values.
So, I was waiting to have something like the analyze chop on top, but I get the graph looking view on bottom, and I wonder if I can use the outputted value as export CHOP:
image
So, this is the issue. I thought I would get only one value outputted, but apparently not, I am missing something but I don’t know what…

Here is my code with some comments:

void GistAudioCHOP::getGeneralInfo(CHOP_GeneralInfo* ginfo, const OP_Inputs* inputs, void* reserved1)
{
	ginfo->cookEveryFrameIfAsked = true;

    // I tried both,same result
    // I let it to true because
    // it's like in the cpp example
	//ginfo->timeslice = false;
    ginfo->timeslice = true;

	ginfo->inputMatchIndex = 0;
}

bool GistAudioCHOP::getOutputInfo(CHOP_OutputInfo* info, const OP_Inputs* inputs, void* reserved1)
{
    // Here I thought, by setting num of samples by 1
    // I would have only one value outputted
    // and the normal view in TD
    info->numChannels = 1;
    info->numSamples = 1;
    return true;
}

And inside my execute method:

        // This method compute audio in
        // and write outputValue_m
		processOutput(inputs);

		for (int i = 0; i < output->numChannels; i++)
		{
			for (int j = 0; j < output->numSamples; j++)
			{
				output->channels[i][j] = outputValue_m;
			}
		}

Thank you for reading until here, if anyone have an idea :slight_smile:

1 Like

I’m not a certified coder but it seems like you need to set the sample rate of the output of your CHOP to be the timeline sample rate (1/60 sec or whatever) and output 1 sample for every input_sample_rate. 44100/60 = 735.

More correctly, the CHOP has to be made timesliced (read timeslicing in wiki), so that if your timeline stepped forward 2 frames since the last cook, you need to output 2 samples.

Aaaaah super !
Yes apparently I had an issue with the sample rate of the ouput… I changed it in the getOutputInfo and now it works as expected.
I need to optimize now, frame rates goes down to 20 fps…

I don’t get the thing about timeslicing, apparently it does not change if it’s timesliced or not, I will read more about the subject.

Thank very much for your help greg :smiley: !