Exemple #1
0
int CsoundObj_process(CsoundObj *self,
		int inNumberFrames,
		double *inputBuffer,
		double *outputBuffer)
{
	int result = csoundPerformKsmps(self->csound);

	if (result == 0) {

		int outputChannelCount = csoundGetNchnls(self->csound);
		int inputChannelCount = csoundGetNchnlsInput(self->csound);

		self->csoundOut = csoundGetSpout(self->csound);
		self->csoundIn = csoundGetSpin(self->csound);

		if (self->useAudioInput == 1) {

			memcpy(self->csoundIn, inputBuffer, sizeof(double) * inNumberFrames);
		}

		memcpy(outputBuffer, self->csoundOut, sizeof(double) * inNumberFrames * outputChannelCount);
//		printf("csoundOut =%f outputBuffer = %f\n", self->csoundOut[0], outputBuffer[0]);
	}

	return result;
}
Exemple #2
0
void CsoundObj_compileCSD(CsoundObj *self,
		char *filePath,
		uint32_t samplerate,
		double controlrate,
		uint32_t bufferSize)
{ 
	char samplerateArgument[10] = {0};
	char controlrateArgument[10] = {0};
	char bufferSizeArgument[10] = {0};
	sprintf((char *)&samplerateArgument, "-r %d", samplerate);
	sprintf((char *)&controlrateArgument, "-k %f", controlrate);
	sprintf((char *)&bufferSizeArgument, "-b %d", bufferSize);

	char *argv[5] = {
		"csound",
		samplerateArgument,
		controlrateArgument,
		bufferSizeArgument,
		filePath
	};

	printf("File name is %s\n", filePath);

	int result = csoundCompile(self->csound, 5, argv);

	if (result == 0) {

		printf("success\n");
		self->csoundIn = csoundGetSpin(self->csound);
		self->csoundOut = csoundGetSpout(self->csound);
		self->zerodBFS = csoundGet0dBFS(self->csound);
	}
	else {

		printf("compilation failed\n");
	}
}
Exemple #3
0
float *CsoundObj_getInputBuffer(CsoundObj *self)
{
    return csoundGetSpin(self->csound);
}