comparison projects/basic/render.cpp @ 24:ad5cd8dd99b3 bbb_network

UDP communication in place, pre-alpha
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 08 May 2015 11:12:13 +0100
parents 6adb088196a7
children 579c86316008
comparison
equal deleted inserted replaced
23:182ae9367104 24:ad5cd8dd99b3
20 // userData holds an opaque pointer to a data structure that was passed 20 // userData holds an opaque pointer to a data structure that was passed
21 // in from the call to initAudio(). 21 // in from the call to initAudio().
22 // 22 //
23 // Return true on success; returning false halts the program. 23 // Return true on success; returning false halts the program.
24 24
25 bool initialise_render(int numMatrixChannels, int numAudioChannels, 25 bool initialise_render(int numMatrixChannels, int numDigitalChannels, int numAudioChannels,
26 int numMatrixFramesPerPeriod, 26 int numMatrixFramesPerPeriod,
27 int numAudioFramesPerPeriod, 27 int numAudioFramesPerPeriod,
28 float matrixSampleRate, float audioSampleRate, 28 float matrixSampleRate, float audioSampleRate,
29 void *userData) 29 void *userData, RTAudioSettings* settings)
30 { 30 {
31 // Retrieve a parameter passed in from the initAudio() call 31 // Retrieve a parameter passed in from the initAudio() call
32 gFrequency = *(float *)userData; 32 gFrequency = *(float *)userData;
33 33
34 gInverseSampleRate = 1.0 / audioSampleRate; 34 gInverseSampleRate = 1.0 / audioSampleRate;
40 // render() is called regularly at the highest priority by the audio engine. 40 // render() is called regularly at the highest priority by the audio engine.
41 // Input and output are given from the audio hardware and the other 41 // Input and output are given from the audio hardware and the other
42 // ADCs and DACs (if available). If only audio is available, numMatrixFrames 42 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
43 // will be 0. 43 // will be 0.
44 44
45 void render(int numMatrixFrames, int numAudioFrames, float *audioIn, float *audioOut, 45 void render(int numAnalogFrames, int numAudioFrames, int numDigitalFrames, float *audioIn, float *audioOut,
46 uint16_t *matrixIn, uint16_t *matrixOut) 46 float *analogIn, float *analogOut, uint32_t *digital)
47 { 47 {
48 for(int n = 0; n < numAudioFrames; n++) { 48 for(int n = 0; n < numAudioFrames; n++) {
49 float out = 0.8f * sinf(gPhase); 49 float out = 0.8f * sinf(gPhase);
50 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate; 50 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate;
51 if(gPhase > 2.0 * M_PI) 51 if(gPhase > 2.0 * M_PI)