Declaring coordinates for pads to be referenced


#1

I am currently trying to figure out how to declare what my custom pads are and reference those values in my code to keep things concise and efficient. I would like it that depending on the touch and move events, the cc being transmitted is different depending on whatever it determines the active pad is.

Currently, I have been looking at the Note Grid App to figure out how to do this, but I am a little confused about what I am looking at regarding setting data to the heap.

Gladly accepting all help.

Example of what I am reviewing:

Been looking at the code for the Note Grid App.

/*


*/

#heapsize: 436

//==============================================================================
/*
Heap layout:

=== 25 x Pad ===

0 4 byte x 25 colours
100 1 byte x 25 note numbers

=== 24 x Touch ===

125 1 byte x 24 corresponding pad index (0xff if none)
149 4 byte x 24 initial x positions (for relative pitchbend)
245 4 byte x 24 initial y positions (for relative y axis)
341 1 byte x 24 MIDI channel assigned

=== 16 x Channel ===

365 1 byte x 16 touch to track for this channel (depends on tracking mode)

=== 24 x Touch ===

381 1 byte x 24 Touch note number
405 1 byte x 24 Touch velocity
429 1 byte x 24 list of active touch indicies in order of first played to last played

*/
//==============================================================================

const int gradientColour1 = 0x7199ff;
const int gradientColour2 = 0x6fe6ff;

//==============================================================================

int gridSize, padWidth, padSpacing;
int dimFactor, dimDelay, dimDelta;
int scaleBitmask;
int numNotesInScale;
int channelLastAssigned;
int activePads;
int pitchbendRange;
int octave;
int xShift, yShift;
int transpose;
int scale; // Major;Minor;Harmonic Minor;Pentatonic Neutral;Pentatonic Major;Pentatonic Minor;Blues;Dorian;Phrygian;Lydian;Mixolydian;Locrian;Whole Tone;Arabic (A);Arabic (B);Japanese;Ryukyu;8-Tone Spanish;Chromatic;
bool hideMode;
int position; // Split into X and Y offsets
int clusterWidth;
int clusterHeight;
int xPos;
int yPos;

bool glideLockEnabled;
int glideLockInitialNote;
float glideLockTarget;
int glideLockChannel;

bool gammaCorrected;
bool isSongMakerKit;
int smkMode; //0 = Macro, 1 = Sensitivity, 2 = XY Pad
int sbbAddress;

//==============================================================================
void Pad_setColour (int padIndex, int colour) { setHeapInt (padIndex * 4, colour); }
int Pad_getColour (int padIndex) { return getHeapInt (padIndex * 4); }
void Pad_setNote (int padIndex, int note) { setHeapByte (padIndex + 100, note); }
int Pad_getNote (int padIndex) { return getHeapByte (padIndex + 100); }
void Pad_setActive (int padIndex, bool setActive) { activePads = setActive ? (activePads | (1 << padIndex)) : (activePads & ~(1 << padIndex)); }
bool Pad_isActive (int padIndex) { return activePads & (1 << padIndex); }
bool isAnyPadActive() { return activePads; }

//==============================================================================
void Touch_setPad (int touchIndex, int padIndex) { setHeapByte (touchIndex + 125, padIndex); }
int Touch_getPad (int touchIndex) { return getHeapByte (touchIndex + 125); }
void Touch_setInitialX (int touchIndex, float initialX) { setHeapInt ((touchIndex * 4) + 149, int (initialX * 1e6)); }
float Touch_getInitialX (int touchIndex) { return float (getHeapInt ((touchIndex * 4) + 149)) / 1e6; }
void Touch_setInitialY (int touchIndex, float initialY) { setHeapInt ((touchIndex * 4) + 245, int (initialY * 1e6)); }
float Touch_getInitialY (int touchIndex) { return float (getHeapInt ((touchIndex * 4) + 245)) / 1e6; }
void Touch_setChannel (int touchIndex, int channel) { setHeapByte (touchIndex + 341, channel); }
int Touch_getChannel (int touchIndex) { return getHeapByte (touchIndex + 341); }
void Touch_setNote (int touchIndex, int noteNumber) { setHeapByte (touchIndex + 381, noteNumber); }
int Touch_getNote (int touchIndex) { return getHeapByte (touchIndex + 381); }
void Touch_setVelocity (int touchIndex, int velocity) { setHeapByte (touchIndex + 405, velocity); }
int Touch_getVelocity (int touchIndex) { return getHeapByte (touchIndex + 405); }
void Touch_setTouchByHistory (int touchIndex, int order){ setHeapByte (order + 429, touchIndex); }
int Touch_getTouchByHistory (int order) { return getHeapByte (order + 429); }