Compare commits
No commits in common. "32d25d982619c03938730275de68bf81ab7c5331" and "192a2e21493e64c11528dc51c4559126e073c2a6" have entirely different histories.
32d25d9826
...
192a2e2149
33
main.py
33
main.py
|
@ -1,33 +0,0 @@
|
||||||
from tkinter import filedialog as fd
|
|
||||||
import slider as sl
|
|
||||||
from datetime import timedelta
|
|
||||||
import place
|
|
||||||
import sound_process
|
|
||||||
|
|
||||||
def alexandre_process(bpm, offset, filename):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def main():
|
|
||||||
filename = fd.askopenfilename()
|
|
||||||
beatmap = sl.Beatmap.from_path(filename)
|
|
||||||
timing = beatmap.timing_points[0]
|
|
||||||
bpm = timing.bpm
|
|
||||||
offset = timing.offset.total_seconds() * 10e3
|
|
||||||
print(beatmap.audio_filename)
|
|
||||||
|
|
||||||
timings, amplitudes, freqs = sound_process.process_song(beatmap.audio_filename, offset, bpm)
|
|
||||||
|
|
||||||
beatmap._hit_objects = place.greedy(bpm, offset, timings, amplitudes)
|
|
||||||
#beatmap._hit_objects = [sl.Slider(sl.Position(0, 0), timedelta(milliseconds=3), timedelta(milliseconds=130), 0, sl.curve.Linear([sl.Position(0, 0), sl.Position(100, 100)], 100), 100, 2, 1, 1, 1, timing.ms_per_beat, [], [],)]
|
|
||||||
beatmap.write_path("rewrite.osu")
|
|
||||||
|
|
||||||
#timings, intensities = alexandre_process(bpm, offset, beatmap.audio_filename)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(bpm)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
37
place.py
37
place.py
|
@ -1,43 +1,32 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import slider as sl
|
|
||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
QUARTER = 1
|
"""
|
||||||
HALF = 2
|
whle
|
||||||
NOTE = 4
|
"""
|
||||||
|
|
||||||
def beatify(bpm:float, offset:int, time_ms:timedelta) -> float:
|
|
||||||
return bpm/60000 * (time_ms - offset)
|
|
||||||
|
|
||||||
def debeatify(bpm:float, offset:int, beat:int) -> timedelta:
|
|
||||||
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(bpm:int, offset:int, timings:list, amplitudes:list):
|
def greedy():
|
||||||
"""
|
"""
|
||||||
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
|
||||||
notes = [sl.HitObject(0, timedelta(milliseconds=0), 0) * len(timings)]
|
song_beat = 0
|
||||||
beats = np.array(beatify(timings))
|
notes = [0 * len(rhythms)]
|
||||||
for (delta, note_beat, intensity, i) in zip(timings, beats, amplitudes, range(len(timings))):
|
for (rhythm, i) in zip(rhythms, range(len(rhythms))):
|
||||||
|
song_beat += rhythm.time
|
||||||
try:
|
try:
|
||||||
duration = note_beat - beats[i + 1]
|
duration = rhythm.time - rhythms[i + 1].time
|
||||||
if duration in (QUARTER, HALF):
|
if duration in (1, 2):
|
||||||
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
note_type = "cercle"
|
||||||
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:
|
||||||
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
note_type = "cercle"
|
||||||
# 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
|
||||||
|
@ -47,8 +36,6 @@ def greedy(bpm:int, offset:int, timings:list, amplitudes:list):
|
||||||
y3 = y2 + (intensity * np.sin(angle + old_angle))
|
y3 = y2 + (intensity * np.sin(angle + old_angle))
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
"""
|
|
||||||
return notes
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ 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
|
||||||
|
|
||||||
|
@ -381,15 +380,16 @@ 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) -> tuple[timedelta, int, float]:
|
def convert_tuple(datares, freq):
|
||||||
"""
|
"""
|
||||||
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 [(timedelta(milliseconds=i), datares[i], freq[i]) for i in range(len(datares)) if datares[i] > 0]
|
return [(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)
|
||||||
|
|
Loading…
Reference in New Issue