giuliomoro@18: /* giuliomoro@18: * giuliomoro@18: * First assignment for ECS732 RTDSP, to implement a 2-way audio crossover giuliomoro@18: * using the BeagleBone Black. giuliomoro@18: * giuliomoro@18: * Andrew McPherson and Victor Zappi giuliomoro@18: * Queen Mary, University of London giuliomoro@18: */ giuliomoro@18: giuliomoro@18: #include "../include/render.h" giuliomoro@18: #include giuliomoro@18: #include giuliomoro@18: giuliomoro@18: /* TASK: declare any global variables you need here */ giuliomoro@18: giuliomoro@18: // initialise_render() is called once before the audio rendering starts. giuliomoro@18: // Use it to perform any initialisation and allocation which is dependent giuliomoro@18: // on the period size or sample rate. giuliomoro@18: // giuliomoro@18: // userData holds an opaque pointer to a data structure that was passed giuliomoro@18: // in from the call to initAudio(). giuliomoro@18: // giuliomoro@18: // Return true on success; returning false halts the program. giuliomoro@18: int gNumMatrixGpioFrames=0; giuliomoro@18: bool initialise_render(int numMatrixChannels, int numMatrixGpioChannels, int numAudioChannels, giuliomoro@18: int numMatrixFramesPerPeriod, giuliomoro@18: int numAudioFramesPerPeriod, giuliomoro@18: float matrixSampleRate, float audioSampleRate, giuliomoro@18: void *userData) giuliomoro@18: { giuliomoro@18: gNumMatrixChannels=numMatrixChannels; giuliomoro@18: return true; giuliomoro@18: } giuliomoro@18: giuliomoro@18: // render() is called regularly at the highest priority by the audio engine. giuliomoro@18: // Input and output are given from the audio hardware and the other giuliomoro@18: // ADCs and DACs (if available). If only audio is available, numMatrixFrames giuliomoro@18: // will be 0. giuliomoro@18: giuliomoro@18: long int gCountFrames=0; giuliomoro@18: void render(int numMatrixFrames, int numMatrixGpioFrames, int numAudioFrames, float *audioIn, float *audioOut, giuliomoro@18: float *matrixIn, float *matrixOut, uint32_t *matrixGpio) giuliomoro@18: /* giuliomoro@18: * Hey, expect buffer underruns to happen here, as we are doing lots of printfs giuliomoro@18: * */ giuliomoro@18: { giuliomoro@18: gNumMatrixGpioFrames=numMatrixGpioFrames; giuliomoro@18: if(gCountFrames==0){ //this will be executed only on the first call to render(), but the bits will go through this cycle for every subsequent buffer giuliomoro@18: // that is, P8_29 will pulse at the beginning of each buffer giuliomoro@18: } giuliomoro@18: for(int i=1; i