Beta place.py that adds circles at (0, 0)
This commit is contained in:
parent
a4fb003165
commit
f57841a11f
|
@ -11,6 +11,7 @@ import heapq
|
||||||
import scipy
|
import scipy
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
from datetime import timedelta
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
@ -380,16 +381,15 @@ def test_sample(timelist):
|
||||||
#BPM = 140
|
#BPM = 140
|
||||||
#Length = 32*60/BPM-0.01
|
#Length = 32*60/BPM-0.01
|
||||||
|
|
||||||
def convert_tuple(datares, freq):
|
def convert_tuple(datares, freq) -> tuple[timedelta, int, float]:
|
||||||
"""
|
"""
|
||||||
Takes datares and converts it to a list of tuples (amplitude, time in ms)
|
Takes datares and converts it to a list of tuples (amplitude, time in ms)
|
||||||
"""
|
"""
|
||||||
return [(i, datares[i], freq[i]) for i in range(len(datares)) if datares[i] > 0]
|
return [(timedelta(milliseconds=i), datares[i], freq[i]) for i in range(len(datares)) if datares[i] > 0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process_song(filename, offset, bpm, div_len_factor=60, n_iter=48, threshold=0.5, divisor=4):
|
def process_song(filename, offset, bpm, div_len_factor=60, n_iter=48, threshold=0.5, divisor=4):
|
||||||
#zaejzlk
|
|
||||||
div_len = div_len_factor/bpm-0.01
|
div_len = div_len_factor/bpm-0.01
|
||||||
filtered_name = f"{filename}_trimmed.wav"
|
filtered_name = f"{filename}_trimmed.wav"
|
||||||
void_freq(filename, offset, offset+div_len*(n_iter+1)+0.01, 4*60/bpm, minfreq=0, maxfreq=330, upperthr=5000, ampthr=60, ampfreq = 1200, ampval = 7.27, leniency = 0.005, write=True, output_file=filtered_name)
|
void_freq(filename, offset, offset+div_len*(n_iter+1)+0.01, 4*60/bpm, minfreq=0, maxfreq=330, upperthr=5000, ampthr=60, ampfreq = 1200, ampval = 7.27, leniency = 0.005, write=True, output_file=filtered_name)
|
||||||
|
|
34
place.py
34
place.py
|
@ -2,36 +2,42 @@ import numpy as np
|
||||||
import slider as sl
|
import slider as sl
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
def beatify(bpm:float, offset:int, time_ms:int):
|
QUARTER = 1
|
||||||
|
HALF = 2
|
||||||
|
NOTE = 4
|
||||||
|
|
||||||
|
def beatify(bpm:float, offset:int, time_ms:timedelta) -> float:
|
||||||
return bpm/60000 * (time_ms - offset)
|
return bpm/60000 * (time_ms - offset)
|
||||||
|
|
||||||
def demusicify(bpm:float, offset:int, beat:int):
|
def debeatify(bpm:float, offset:int, beat:int) -> timedelta:
|
||||||
return (beat*60000/bpm) + offset
|
return timedelta(milliseconds=(beat*60000/bpm) + offset)
|
||||||
|
|
||||||
|
|
||||||
def f(intensity): return np.pi/2 - np.arctan(2*intensity - 5)
|
def f(intensity): return np.pi/2 - np.arctan(2*intensity - 5)
|
||||||
|
|
||||||
def greedy():
|
def greedy(bpm:int, offset:int, timings:list, amplitudes:list):
|
||||||
"""
|
"""
|
||||||
input: takes Alexandre's note selection / intensity data
|
input: takes Alexandre's note selection / intensity data
|
||||||
output: list of object type / position
|
output: list of object type / position
|
||||||
"""
|
"""
|
||||||
flow = 1
|
flow = 1
|
||||||
song_beat = 0
|
notes = [sl.HitObject(0, timedelta(milliseconds=0), 0) * len(timings)]
|
||||||
notes = [0 * len(rhythms)]
|
beats = np.array(beatify(timings))
|
||||||
for (rhythm, i) in zip(rhythms, range(len(rhythms))):
|
for (delta, note_beat, intensity, i) in zip(timings, beats, amplitudes, range(len(timings))):
|
||||||
song_beat += rhythm.time
|
|
||||||
try:
|
try:
|
||||||
duration = rhythm.time - rhythms[i + 1].time
|
duration = note_beat - beats[i + 1]
|
||||||
if duration in (1, 2):
|
if duration in (QUARTER, HALF):
|
||||||
note_type = "cercle"
|
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||||
|
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||||
|
"""
|
||||||
elif duration % 2 == 0:
|
elif duration % 2 == 0:
|
||||||
rhythms.insert(0, f"slider {duration}")
|
rhythms.insert(0, f"slider {duration}")
|
||||||
else:
|
else:
|
||||||
rhythms.insert(0, f"reverse_slider {duration}")
|
rhythms.insert(0, f"reverse_slider {duration}")
|
||||||
|
"""
|
||||||
except IndexError:
|
except IndexError:
|
||||||
note_type = "cercle"
|
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||||
# TODO mettre à jour flow
|
# TODO mettre à jour flow
|
||||||
|
"""
|
||||||
if len(notes) > 2:
|
if len(notes) > 2:
|
||||||
angle = flow * f(rhythm.intensite)
|
angle = flow * f(rhythm.intensite)
|
||||||
x1, y1 = notes[i-2].position
|
x1, y1 = notes[i-2].position
|
||||||
|
@ -41,6 +47,8 @@ def greedy():
|
||||||
y3 = y2 + (intensity * np.sin(angle + old_angle))
|
y3 = y2 + (intensity * np.sin(angle + old_angle))
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
"""
|
||||||
|
return notes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue