void Update() { if (songAudioPlayer.PositionInSongInMillis <= 0) { return; } PitchEvent pitchEvent = playerPitchTracker.GetPitchEventOfSamples(micSampleRecorder.MicSamples.Length - 1 - samplesPerBeat, micSampleRecorder.MicSamples.Length - 1); if (pitchEvent != null) { // Shift midi note to octave of last recorded midi note (can be different because PlayerPitchTracker is rounding towards the target note) int midiNote = lastRecordedRoundedMidiNote > 0 ? MidiUtils.GetRelativePitch(pitchEvent.MidiNote) + (12 * (MidiUtils.GetOctave(lastRecordedRoundedMidiNote) + 1)) : pitchEvent.MidiNote; UpdatePosition(midiNote); } }