andrewm@0: /* andrewm@0: * Utilities.h andrewm@0: * andrewm@0: * Created on: Oct 27, 2014 andrewm@0: * Author: parallels andrewm@0: */ andrewm@0: andrewm@0: #ifndef UTILITIES_H_ andrewm@0: #define UTILITIES_H_ andrewm@0: andrewm@13: extern int gNumAudioChannels; // How many audio channels are present andrewm@13: extern int gNumMatrixChannels; // How many matrix channels are present andrewm@13: andrewm@5: // Macros for accessing the matrix values: usable _only_ within render() andrewm@5: andrewm@5: // Read an analog input from input pin p at frame f andrewm@13: #define analogRead(p, f) (matrixIn[(f)*gNumMatrixChannels + (p)]) andrewm@5: // Write an analog output frame at output pin p, frame f, to value v andrewm@13: #define analogWrite(p, f, v) (matrixOut[(f)*gNumMatrixChannels + (p)] = (uint16_t)(v)) andrewm@5: andrewm@0: float map(float x, float in_min, float in_max, float out_min, float out_max); andrewm@0: float constrain(float x, float min_val, float max_val); andrewm@0: andrewm@0: #endif /* UTILITIES_H_ */