Mercurial > hg > beaglert
comparison examples/basic_network/render.cpp @ 301:e4392164b458 prerelease
RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
| author | Giulio Moro <giuliomoro@yahoo.it> | 
|---|---|
| date | Fri, 27 May 2016 14:34:41 +0100 | 
| parents | dbeed520b014 | 
| children | 1feb9c23ac57 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 300:dbeed520b014 | 301:e4392164b458 | 
|---|---|
| 3 * | 3 * | 
| 4 * Created on: Oct 24, 2014 | 4 * Created on: Oct 24, 2014 | 
| 5 * Author: parallels | 5 * Author: parallels | 
| 6 */ | 6 */ | 
| 7 | 7 | 
| 8 #include <BeagleRT.h> | 8 #include <Bela.h> | 
| 9 //#include <rtdk.h> | 9 //#include <rtdk.h> | 
| 10 #include <cmath> | 10 #include <cmath> | 
| 11 #include <NetworkSend.h> | 11 #include <NetworkSend.h> | 
| 12 #include <ReceiveAudioThread.h> | 12 #include <ReceiveAudioThread.h> | 
| 13 #include <Utilities.h> | 13 #include <Utilities.h> | 
| 24 NetworkSend networkSend; | 24 NetworkSend networkSend; | 
| 25 ReceiveAudioThread receive; | 25 ReceiveAudioThread receive; | 
| 26 float gFrequency; | 26 float gFrequency; | 
| 27 float gInverseSampleRate; | 27 float gInverseSampleRate; | 
| 28 float gPhase; | 28 float gPhase; | 
| 29 bool setup(BeagleRTContext *context, void *userData) | 29 bool setup(BelaContext *context, void *userData) | 
| 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 networkSend.setup(context->audioSampleRate, context->audioFrames, 0, 9999, "192.168.7.1"); | 34 networkSend.setup(context->audioSampleRate, context->audioFrames, 0, 9999, "192.168.7.1"); | 
| 42 // render() is called regularly at the highest priority by the audio engine. | 42 // render() is called regularly at the highest priority by the audio engine. | 
| 43 // Input and output are given from the audio hardware and the other | 43 // Input and output are given from the audio hardware and the other | 
| 44 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 44 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 
| 45 // will be 0. | 45 // will be 0. | 
| 46 | 46 | 
| 47 void render(BeagleRTContext *context, void *userData) | 47 void render(BelaContext *context, void *userData) | 
| 48 { | 48 { | 
| 49 for(unsigned int n = 0; n < context->audioFrames; n++) { | 49 for(unsigned int n = 0; n < context->audioFrames; n++) { | 
| 50 float out = 0.7f * sinf(gPhase); | 50 float out = 0.7f * sinf(gPhase); | 
| 51 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate; | 51 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate; | 
| 52 if(gPhase > 2.0 * M_PI) | 52 if(gPhase > 2.0 * M_PI) | 
| 62 } | 62 } | 
| 63 | 63 | 
| 64 // cleanup() is called once at the end, after the audio has stopped. | 64 // cleanup() is called once at the end, after the audio has stopped. | 
| 65 // Release any resources that were allocated in setup(). | 65 // Release any resources that were allocated in setup(). | 
| 66 | 66 | 
| 67 void cleanup(BeagleRTContext *context, void *userData) | 67 void cleanup(BelaContext *context, void *userData) | 
| 68 { | 68 { | 
| 69 } | 69 } | 
