Mercurial > hg > beaglert
comparison core/Utilities.cpp @ 179:f1012082f142
Added audioReadFrame() and audioWriteFrame(). Closes #1519
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 02 Jan 2016 13:50:36 +0100 |
parents | 8bd351ca8b46 |
children |
comparison
equal
deleted
inserted
replaced
178:a156a694864d | 179:f1012082f142 |
---|---|
4 * Created on: Oct 27, 2014 | 4 * Created on: Oct 27, 2014 |
5 * Author: parallels | 5 * Author: parallels |
6 */ | 6 */ |
7 | 7 |
8 #include "../include/Utilities.h" | 8 #include "../include/Utilities.h" |
9 | |
10 // audioReadFrame() | |
11 // | |
12 // Returns the value of the given audio input at the given frame number. | |
13 float audioReadFrame(BeagleRTContext *context, int frame, int channel) { | |
14 return context->audioIn[frame * context->audioChannels + channel]; | |
15 } | |
16 | |
17 // audioWriteFrame() | |
18 // | |
19 // Sets a given audio output channel to a value for the current frame | |
20 void audioWriteFrame(BeagleRTContext *context, int frame, int channel, float value) { | |
21 context->audioOut[frame * context->audioChannels + channel] = value; | |
22 } | |
9 | 23 |
10 // analogReadFrame() | 24 // analogReadFrame() |
11 // | 25 // |
12 // Returns the value of the given analog input at the given frame number. | 26 // Returns the value of the given analog input at the given frame number. |
13 float analogReadFrame(BeagleRTContext *context, int frame, int channel) { | 27 float analogReadFrame(BeagleRTContext *context, int frame, int channel) { |
14 return context->analogIn[frame * context->analogChannels + channel]; | 28 return context->analogIn[frame * context->analogChannels + channel]; |
15 } | 29 } |
16 | 30 |
17 // analogWriteFrame() | 31 // analogWriteFrame() |
18 // | 32 // |
19 // Sets a given channel to a value for the current frame and, if persistent outputs are | 33 // Sets a given analog output channel to a value for the current frame and, if persistent outputs are |
20 // enabled, for all subsequent frames | 34 // enabled, for all subsequent frames |
21 void analogWriteFrame(BeagleRTContext *context, int frame, int channel, float value) { | 35 void analogWriteFrame(BeagleRTContext *context, int frame, int channel, float value) { |
22 if(context->flags & BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST) { | 36 if(context->flags & BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST) { |
23 for(unsigned int f = frame; f < context->analogFrames; f++) | 37 for(unsigned int f = frame; f < context->analogFrames; f++) |
24 context->analogOut[frame * context->analogChannels + channel] = value; | 38 context->analogOut[frame * context->analogChannels + channel] = value; |