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

Method RowToPitch

Source/NoteStepSequencer.cpp:459–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459int NoteStepSequencer::RowToPitch(int row)
460{
461 row += mRowOffset;
462
463 int numPitchesInScale = TheScale->NumTonesInScale();
464 switch (mNoteMode)
465 {
466 case kNoteMode_Scale:
467 return TheScale->GetPitchFromTone(row + mOctave * numPitchesInScale + TheScale->GetScaleDegree());
468 case kNoteMode_Chromatic:
469 return row + mOctave * TheScale->GetPitchesPerOctave();
470 case kNoteMode_Pentatonic:
471 {
472 bool isMinor = TheScale->IsInScale(TheScale->ScaleRoot() + 3);
473 const int minorPentatonic[5] = { 0, 3, 5, 7, 10 };
474 const int majorPentatonic[5] = { 0, 2, 4, 7, 9 };
475
476 if (isMinor)
477 return TheScale->ScaleRoot() + (row / 5 + mOctave) * TheScale->GetPitchesPerOctave() + minorPentatonic[row % 5];
478 else
479 return TheScale->ScaleRoot() + (row / 5 + mOctave) * TheScale->GetPitchesPerOctave() + majorPentatonic[row % 5];
480 }
481 case kNoteMode_Fifths:
482 {
483 int oct = (row / 2) * numPitchesInScale;
484 bool isFifth = row % 2 == 1;
485 int fifths = oct;
486 if (isFifth)
487 fifths += 4;
488 return TheScale->GetPitchFromTone(fifths + mOctave * numPitchesInScale + TheScale->GetScaleDegree());
489 }
490 }
491 return row;
492}
493
494int NoteStepSequencer::PitchToRow(int pitch)
495{

Callers

nothing calls this directly

Calls 6

GetPitchFromToneMethod · 0.80
GetScaleDegreeMethod · 0.80
GetPitchesPerOctaveMethod · 0.80
IsInScaleMethod · 0.80
NumTonesInScaleMethod · 0.45
ScaleRootMethod · 0.45

Tested by

no test coverage detected