mirror of
https://github.com/ibratabian17/OpenParty.git
synced 2026-01-15 14:22:54 -03:00
15 lines
479 B
Python
15 lines
479 B
Python
|
|
import json
|
||
|
|
def generate_beats(bpm, duration):
|
||
|
|
# Calculate time per beat
|
||
|
|
time_per_beat = 60000 / bpm
|
||
|
|
|
||
|
|
# Generate an array of beats for 30 seconds
|
||
|
|
beats_array = [time_per_beat * i for i in range(int(duration / time_per_beat))]
|
||
|
|
|
||
|
|
# Multiply each beat by 48
|
||
|
|
final_array = [round(beat * 48) for beat in beats_array]
|
||
|
|
|
||
|
|
return json.dumps(beats_array, separators=(',', ':'))
|
||
|
|
|
||
|
|
print(generate_beats(int(input('bpm : ')), int(input('duration in ms : '))))
|
||
|
|
input()
|