int Grid::getColor(int i, int count) { ofColor color; int startHue = round(255*_startHue); int startSat = round(255*_startSat); int startBri = round(255*_startBri); if (count == 1) { color.setHsb(startHue, startSat, startBri); } else { int endHue = round(255*_endHue); int endSat = round(255*_endSat); int endBri = round(255*_endBri); int hue = getIntervalValue(i, count, startHue, endHue); int sat = getIntervalValue(i, count, startSat, endSat); int bri = getIntervalValue(i, count, startBri, endBri); // hue offset int hueOffset = round(255*_hueOffset); hue = hueOffset + hue; if (hue > 255) hue -= 255; // translate to black/white opposites sat = round(((float) (sat <= 127 ? sat : (255-sat))/127)*255); //ofLog() << "i: " << i << " color: " << index << "/" << count << " hue:" << hue << " sat: " << sat << " bri: " << bri; color.setHsb(hue, sat, bri); } return color.getHex(); // return startColor+interval*ABS(whichColor); // return startColor+(range*sin(ofDegToRad((color/count)*90))); }
String getIntervalStringFromNoteNames(int root, String noteString, int bottomOctave) { bool multichannel = noteString.contains("."); StringArray sa; sa.addTokens(noteString," ,",String::empty); bool absolute; int bass = getNoteValue(sa[0].upToFirstOccurrenceOf(".",false,false),bottomOctave,absolute); int last = 0; String string; if (bass!=NOT_A_NOTE) { int channel = multichannel ? sa[0].fromFirstOccurrenceOf(".",false,false).getIntValue() : 0; if (!absolute) { root %= 12; if (bass>root) bass-=12; last = bass-root; if (channel>0) string += String(last) + "." + String(channel); else string += String(last); for(int i=1;i<sa.size();i++) { const int note = getNoteValue(sa[i].upToFirstOccurrenceOf(".",false,false)); if (note!=NOT_A_NOTE) { int step = note-root; while (step-last<0) step+=12; channel = sa[i].fromFirstOccurrenceOf(".",false,false).getIntValue(); if (channel>0) string += " " + String(step) + "." + String(channel); else string += " "+String(step); last = step; } } } else { last = bass-root; if (channel>0) string += String(last) + "." + String(channel); else string += String(last); for(int i=1;i<sa.size();i++) { const int note = getNoteValue(sa[i].upToFirstOccurrenceOf(".",false,false),bottomOctave,absolute); if (note!=NOT_A_NOTE) { int step = note-root; while (step-last<0) step+=12; channel = sa[i].fromFirstOccurrenceOf(".",false,false).getIntValue(); if (channel>0) string += " " + String(step) + "." + String(channel); else string += " "+String(step); last = step; } } } } else { root %= 12; bass = getIntervalValue(sa[0].upToFirstOccurrenceOf(".",false,false)); if (bass>root) bass-=12; last = bass-root; int channel = multichannel ? sa[0].fromFirstOccurrenceOf(".",false,false).getIntValue() : 0; if (channel>0) string += String(last) + "." + String(channel); else string += String(last); for(int i=1;i<sa.size();i++) { const int note = getIntervalValue(sa[i].upToFirstOccurrenceOf(".",false,false)); if (note!=NOT_A_NOTE) { int step = note-root; while (step-last<0) step+=12; if (channel>0) string += " " + String(step) + "." + String(channel); else string += " "+String(step); last = step; } } } return string; }