Mercurial > hg > beaglert
diff include/Utilities.h @ 528:5c8f46fcd4d0 API-update
Updated BelaContext to use separate values for in/ou channels
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 23 Jun 2016 18:17:35 +0100 |
parents | 02c4ca0e3718 |
children | bfcbeb437869 |
line wrap: on
line diff
--- a/include/Utilities.h Thu Jun 23 18:15:26 2016 +0100 +++ b/include/Utilities.h Thu Jun 23 18:17:35 2016 +0100 @@ -294,26 +294,36 @@ */ static inline float constrain(float x, float min_val, float max_val); +/** + * Returns the maximum of two numbers + */ +static inline float min(float x, float y); + +/** + * Returns the minimum of two numbers + */ +static inline float max(float x, float y); + /** @} */ // audioRead() // // Returns the value of the given audio input at the given frame number. static inline float audioRead(BelaContext *context, int frame, int channel) { - return context->audioIn[frame * context->audioChannels + channel]; + return context->audioIn[frame * context->audioInChannels + channel]; } // audioWrite() // // Sets a given audio output channel to a value for the current frame static inline void audioWrite(BelaContext *context, int frame, int channel, float value) { - context->audioOut[frame * context->audioChannels + channel] = value; + context->audioOut[frame * context->audioOutChannels + channel] = value; } // analogRead() // // Returns the value of the given analog input at the given frame number. static inline float analogRead(BelaContext *context, int frame, int channel) { - return context->analogIn[frame * context->analogChannels + channel]; + return context->analogIn[frame * context->analogInChannels + channel]; } // analogWrite() @@ -323,17 +333,17 @@ static inline void analogWrite(BelaContext *context, int frame, int channel, float value) { if(context->flags & BELA_FLAG_ANALOG_OUTPUTS_PERSIST) { for(unsigned int f = frame; f < context->analogFrames; f++) - context->analogOut[frame * context->analogChannels + channel] = value; + context->analogOut[frame * context->analogOutChannels + channel] = value; } else - context->analogOut[frame * context->analogChannels + channel] = value; + context->analogOut[frame * context->analogOutChannels + channel] = value; } // analogWriteOnce() // // Sets a given channel to a value for only the current frame static inline void analogWriteOnce(BelaContext *context, int frame, int channel, float value) { - context->analogOut[frame * context->analogChannels + channel] = value; + context->analogOut[frame * context->analogOutChannels + channel] = value; } // digitalRead() @@ -412,4 +422,12 @@ return x; } +static inline float max(float x, float y){ + return x > y ? x : y; +} + +static inline float min(float x, float y){ + return x < y ? x : y; +} + #endif /* UTILITIES_H_ */