giuliomoro@19: /* giuliomoro@19: * giuliomoro@19: * First assignment for ECS732 RTDSP, to implement a 2-way audio crossover giuliomoro@19: * using the BeagleBone Black. giuliomoro@19: * giuliomoro@19: * Andrew McPherson and Victor Zappi giuliomoro@19: * Queen Mary, University of London giuliomoro@19: */ giuliomoro@19: giuliomoro@19: #include "../include/render.h" giuliomoro@19: #include giuliomoro@19: #include giuliomoro@19: giuliomoro@19: /* TASK: declare any global variables you need here */ giuliomoro@19: giuliomoro@19: // initialise_render() is called once before the audio rendering starts. giuliomoro@19: // Use it to perform any initialisation and allocation which is dependent giuliomoro@19: // on the period size or sample rate. giuliomoro@19: // giuliomoro@19: // userData holds an opaque pointer to a data structure that was passed giuliomoro@19: // in from the call to initAudio(). giuliomoro@19: // giuliomoro@19: // Return true on success; returning false halts the program. giuliomoro@20: int gNumDigitalFrames=0; giuliomoro@20: bool initialise_render(int numAnalogChannels, int numDigitalChannels, int numAudioChannels, giuliomoro@20: int numAnalogFramesPerPeriod, giuliomoro@19: int numAudioFramesPerPeriod, giuliomoro@20: float analogSampleRate, float audioSampleRate, giuliomoro@19: void *userData) giuliomoro@19: { giuliomoro@20: gNumAnalogChannels=numAnalogChannels; giuliomoro@19: return true; giuliomoro@19: } giuliomoro@19: giuliomoro@19: // render() is called regularly at the highest priority by the audio engine. giuliomoro@19: // Input and output are given from the audio hardware and the other giuliomoro@20: // ADCs and DACs (if available). If only audio is available, numAnalogFrames giuliomoro@19: // will be 0. giuliomoro@19: giuliomoro@19: long int gCountFrames=0; giuliomoro@20: void render(int numAnalogFrames, int numDigitalFrames, int numAudioFrames, float *audioIn, float *audioOut, giuliomoro@20: float *analogIn, float *analogOut, uint32_t *digital) giuliomoro@19: /* giuliomoro@19: * Hey, expect buffer underruns to happen here, as we are doing lots of printfs giuliomoro@19: * */ giuliomoro@19: { giuliomoro@20: gNumDigitalFrames=numDigitalFrames; giuliomoro@19: 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@19: // that is, P8_29 will pulse at the beginning of each buffer giuliomoro@19: } giuliomoro@20: for(int i=1; i