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

Function PitchFromNoteName

Source/SynthGlobals.cpp:352–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352int PitchFromNoteName(std::string noteName)
353{
354 int octave = -2;
355 if (isdigit(noteName[noteName.length() - 1]))
356 {
357 octave = noteName[noteName.length() - 1] - '0';
358 if (noteName[noteName.length() - 2] == '-')
359 octave *= -1;
360 if (octave < 0)
361 noteName = noteName.substr(0, noteName.length() - 2);
362 else
363 noteName = noteName.substr(0, noteName.length() - 1);
364 }
365
366 int pitch;
367 for (pitch = 0; pitch < 12; ++pitch)
368 {
369 if (noteName == NoteName(pitch, false) || noteName == NoteName(pitch, true))
370 break;
371 }
372 if (pitch == 12)
373 TheSynth->LogEvent("error finding pitch for note " + noteName, kLogEventType_Error);
374 return pitch + (octave + 2) * 12;
375}
376
377float Interp(float a, float start, float end)
378{

Callers 2

ChordMethod · 0.85
LoadSongMethod · 0.85

Calls 3

NoteNameFunction · 0.85
lengthMethod · 0.80
LogEventMethod · 0.80

Tested by

no test coverage detected