diff include/Utilities.h @ 539:b486344aa796 prerelease

merge
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 24 Jun 2016 01:43:53 +0100
parents bfcbeb437869
children
line wrap: on
line diff
--- a/include/Utilities.h	Fri Jun 24 01:40:25 2016 +0100
+++ b/include/Utilities.h	Fri Jun 24 01:43:53 2016 +0100
@@ -42,7 +42,7 @@
 /** @} */
 
 /**
- * \ingroup wiring
+ * \cond BIT_FUNCTIONS
  *
  * @{
  */
@@ -59,7 +59,9 @@
 /// Set/clear the given bit in \c word to \c value.
 #define changeBit(word,bit,value) 	((clearBit((word),(bit))) | ((value) << (bit)))
 
-/** @} */
+/** @}
+ * \endcond
+ * */
 
 /**
  * \ingroup iofunctions
@@ -294,26 +296,40 @@
  */
 static inline float constrain(float x, float min_val, float max_val);
 
+/**
+ * \brief Returns the maximum of two numbers
+ *
+ * Returns the maximum of two numbers
+ */
+static inline float min(float x, float y);
+
+/**
+ * \brief Returns the minimum of two numbers
+ *
+ * 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 +339,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 +428,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_ */