examples/demo/instrument_demo.cpp
// Returns the pitch for the given `key`.
Returns the pitch for the given `key`.
Returns the pitch for the given ` key ` .
std::optional<double> PitchFromKey(const InputManager::Key& key) {
  const auto* it = std::find(std::cbegin(kOctaveKeys), std::cend(kOctaveKeys),
                             std::toupper(key));
  if (it == std::cend(kOctaveKeys)) {
    return std::nullopt;
  }
  const double distance =
      static_cast<double>(std::distance(std::cbegin(kOctaveKeys), it));
  return kRootPitch + distance / barelyapi::kNumSemitones;
}
std :: optional < double > PitchFromKey ( const InputManager :: Key & key ) { const auto * it = std :: find ( std :: cbegin ( kOctaveKeys ) , std :: cend ( kOctaveKeys ) , std :: toupper ( key ) ) ; if ( it == std :: cend ( kOctaveKeys ) ) { return std :: nullopt ; } const double distance = static_cast < double > ( std :: distance ( std :: cbegin ( kOctaveKeys ) , it ) ) ; return kRootPitch + distance / barelyapi :: kNumSemitones ; }
Returns the pitch for the given `key`.
Returns the pitch for the given ` key ` .