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 giuliomoro@19: extern int gNumAnalogChannels; // How many analog channels are present andrewm@13: giuliomoro@19: // Macros for accessing the analog values: usable _only_ within render() andrewm@5: giuliomoro@19: // Read an Analog input from input pin p at frame f giuliomoro@19: #define AnalogRead(p, f) (analogIn[(f)*gNumAnalogChannels + (p)]) giuliomoro@19: // Write an Analog output frame at output pin p, frame f, to value v giuliomoro@19: #define AnalogWriteFrame(p, f, v) (analogOut[(f)*gNumAnalogChannels + (p)] = (v)) giuliomoro@19: #define AnalogWrite(pin, frame, value) \ giuliomoro@18: (({do {\ giuliomoro@19: for (int _privateI=(frame); _privateI>(bit))&1) giuliomoro@16: #define changeBit(word,bit,value) ((clearBit((word),(bit))) | ((value)<<(bit))) giuliomoro@19: //digital API: giuliomoro@19: #define setDigitalDirectionFrame(pin,frame,direction) digital[(frame)]=changeBit(digital[(frame)],(pin),(direction)) giuliomoro@19: #define setDigitalDirection(pin,frame,direction) (for(int _privateI=(frame);_privateI