Get sound data after dsp processing

hey cameron

Thank you for your reply. I have already finished using Sound::lock to access to the audio data. But it seems that the data is from the original sound. What I want is to get the PCM data from the processed sound by some DSP effect.

I try to add a custom DSP and I read the example ‘dsp_custom’, but I can not fully understand this callback function. Is the data in the ‘data->buffer’ PCM data? I save these data in a text file and when I try to play sound from this file, it just sound like noise. I do some conversion for the type of the data because I need data in Int16.

PS: Is the function ‘getParameterData’ can be used to get the PCM data in this circumstance?

FMOD_RESULT F_CALLBACK myDSPCallback(FMOD_DSP_STATE* dsp_state, float* inbuffer, float* outbuffer, unsigned int length, int inchannels, int* outchannels)
{
	mydsp_data_t* data = (mydsp_data_t*)dsp_state->plugindata;
	//FILE* saveFile;
	ofstream savefile("G:\\app_zhanan\\data.txt", ios::app);
	int16_t buffer;

	for (unsigned int samp = 0; samp < length; samp++)
	{

		for (int chan = 0; chan < *outchannels; chan++)
		{

			data->buffer[(samp * *outchannels) + chan] = outbuffer[(samp * inchannels) + chan] = inbuffer[(samp * inchannels) + chan] * data->volume_linear;
			float num = data->buffer[(samp * *outchannels) + chan];
			int32_t temp = *(int*)& num;
			int16_t conversion = temp & ~(0xFFFF << 16);
			//int16_t conversion = (int16_t) num;
			//int16_t* conversion = reinterpret_cast<int16_t*>(&num);
			savefile << conversion << endl;
			//cout << *conversion << endl;


		}
	}
	data->channels = inchannels;
	savefile.close();
	return FMOD_OK;
}