Aenimus

Frames and Beats

Apr 27th, 2020
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. #CHANGE THE TWO OPTIONS BELOW
  2. frame_rate = 24 #This is the frame rate at which you're animating
  3. beats_per_minute = 174 #This is the beats per minute of the music
  4.  
  5. k = 60
  6. beats_per_second = beats_per_minute / k
  7. alternative_rates = [24, 25, 30, 60]
  8.  
  9. fpb = beats_per_second * frame_rate
  10.  
  11. print("The Frames Per Beat (FPB) is {} at {} FPS and {} BPM.".format(fpb, frame_rate, beats_per_minute))
  12. if not fpb.is_integer():
  13.     print("Your chosen frame rate of {} does not provide an integer.".format(frame_rate))
  14.     print("You could try one of these other common frame rates:")
  15.     chosen = 0
  16.     for rate in alternative_rates:
  17.         fpb = beats_per_second * rate
  18.         print("{} FPS: {} Frames Per Beat".format(rate, fpb))
  19.         if fpb.is_integer() and not chosen:
  20.             chosen = rate
  21.             break
  22.     print("Luckily, {} FPS provides an integer, so consider using that.".format(chosen))
Advertisement
Add Comment
Please, Sign In to add comment