MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / RandomizePitches

Method RandomizePitches

Source/NoteStepSequencer.cpp:1213–1256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1211}
1212
1213void NoteStepSequencer::RandomizePitches(bool fifths)
1214{
1215 if (fifths)
1216 {
1217 for (int i = 0; i < mLength; ++i)
1218 {
1219 if (ofRandom(1) <= mRandomizePitchChance)
1220 {
1221 switch (gRandom() % 5)
1222 {
1223 default:
1224 case 0:
1225 mTones[i] = 0;
1226 break;
1227 case 1:
1228 mTones[i] = 4;
1229 break;
1230 case 2:
1231 mTones[i] = 7;
1232 break;
1233 case 3:
1234 mTones[i] = 11;
1235 break;
1236 case 4:
1237 mTones[i] = 14;
1238 break;
1239 }
1240 }
1241 }
1242 }
1243 else
1244 {
1245 //reduce overall randomness: choose from a limited pool of pitches
1246 std::vector<int> newTones;
1247 for (int i = 0; i < mRandomizePitchVariety; ++i)
1248 newTones.push_back(ofClamp(int(ofRandom(0, mNoteRange) + .5f), 0, mNoteRange - 1));
1249
1250 for (int i = 0; i < mLength; ++i)
1251 {
1252 if (ofRandom(1) <= mRandomizePitchChance)
1253 mTones[i] = newTones[gRandom() % newTones.size()];
1254 }
1255 }
1256}
1257
1258void NoteStepSequencer::RandomizeVelocities()
1259{

Callers

nothing calls this directly

Calls 3

ofRandomFunction · 0.85
ofClampFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected