Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. if (midiNote > 0)
  2. {
  3. int octave = midiNote / 8;
  4. int noteNum = midiNote % 12;
  5.  
  6. int normalizedNote;
  7. if (octave % 2 == 0)
  8. {
  9. normalizedNote = noteNum;
  10. }
  11. else
  12. {
  13. normalizedNote = (12 - 1) - noteNum;
  14. }
  15.  
  16. // normalizedNote range == [0, 11]
  17. // int normalizedNote = midiNote - 50;
  18. // normalizedNote = (int)Mathf.Clamp(normalizedNote, -4, 4);
  19. normalizedNote -= 6;
  20. // normalizedNote range == [-6, 5]
  21.  
  22. if (turningPolicy == TurningPolicy.DIRECT ||
  23. turningPolicy == TurningPolicy.DIRECT_SILENCE_TO_NEUTRAL)
  24. {
  25. cachedTargetRotation.eulerAngles = new Vector3(0, 0, -normalizedNote * 15.0f);
  26. }
  27.  
  28. lastNormalizedNote = normalizedNote;
  29.  
  30. // transform.rotation = rot;
  31. // Debug.Log("Detected note: " + midiNote);
  32. Debug.Log("Detected freq: " + freq + " - Note: " + midiNote);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement