Mercurial > hg > beaglert
comparison examples/scope_basic/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 | db2fe4e1b88e |
comparison
equal
deleted
inserted
replaced
300:dbeed520b014 | 301:e4392164b458 |
---|---|
1 #include <BeagleRT.h> | 1 #include <Bela.h> |
2 #include <Scope.h> | 2 #include <Scope.h> |
3 #include <cmath> | 3 #include <cmath> |
4 | 4 |
5 // set the frequency of the oscillators | 5 // set the frequency of the oscillators |
6 float gFrequency = 110.0; | 6 float gFrequency = 110.0; |
8 float gInverseSampleRate; | 8 float gInverseSampleRate; |
9 | 9 |
10 // instantiate the scope | 10 // instantiate the scope |
11 Scope scope; | 11 Scope scope; |
12 | 12 |
13 bool setup(BeagleRTContext *context, void *userData) | 13 bool setup(BelaContext *context, void *userData) |
14 { | 14 { |
15 // tell the scope how many channels and the sample rate | 15 // tell the scope how many channels and the sample rate |
16 scope.setup(3, context->audioSampleRate); | 16 scope.setup(3, context->audioSampleRate); |
17 | 17 |
18 gPhase = 0; | 18 gPhase = 0; |
21 return true; | 21 return true; |
22 } | 22 } |
23 | 23 |
24 float lastOut = 0.0; | 24 float lastOut = 0.0; |
25 float lastOut2 = 0.0; | 25 float lastOut2 = 0.0; |
26 void render(BeagleRTContext *context, void *userData) | 26 void render(BelaContext *context, void *userData) |
27 { | 27 { |
28 // iterate over the audio frames and create three oscillators, seperated in phase by PI/2 | 28 // iterate over the audio frames and create three oscillators, seperated in phase by PI/2 |
29 for (unsigned int n=0; n<context->audioFrames; n++){ | 29 for (unsigned int n=0; n<context->audioFrames; n++){ |
30 float out = 0.8f * sinf(gPhase); | 30 float out = 0.8f * sinf(gPhase); |
31 float out2 = 0.8f * sinf(gPhase - M_PI/2); | 31 float out2 = 0.8f * sinf(gPhase - M_PI/2); |
46 lastOut = out; | 46 lastOut = out; |
47 lastOut2 = out2; | 47 lastOut2 = out2; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 void cleanup(BeagleRTContext *context, void *userData) | 51 void cleanup(BelaContext *context, void *userData) |
52 { | 52 { |
53 | 53 |
54 } | 54 } |