Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (midiNote > 0)
- {
- int octave = midiNote / 8;
- int noteNum = midiNote % 12;
- int normalizedNote;
- if (octave % 2 == 0)
- {
- normalizedNote = noteNum;
- }
- else
- {
- normalizedNote = (12 - 1) - noteNum;
- }
- // normalizedNote range == [0, 11]
- // int normalizedNote = midiNote - 50;
- // normalizedNote = (int)Mathf.Clamp(normalizedNote, -4, 4);
- normalizedNote -= 6;
- // normalizedNote range == [-6, 5]
- if (turningPolicy == TurningPolicy.DIRECT ||
- turningPolicy == TurningPolicy.DIRECT_SILENCE_TO_NEUTRAL)
- {
- cachedTargetRotation.eulerAngles = new Vector3(0, 0, -normalizedNote * 15.0f);
- }
- lastNormalizedNote = normalizedNote;
- // transform.rotation = rot;
- // Debug.Log("Detected note: " + midiNote);
- Debug.Log("Detected freq: " + freq + " - Note: " + midiNote);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement