Merge branch 'exporting'
This commit is contained in:
commit
32d25d9826
|
@ -0,0 +1,33 @@
|
|||
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,32 +1,43 @@
|
|||
import numpy as np
|
||||
import slider as sl
|
||||
from datetime import timedelta
|
||||
|
||||
"""
|
||||
whle
|
||||
"""
|
||||
QUARTER = 1
|
||||
HALF = 2
|
||||
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 greedy():
|
||||
def greedy(bpm:int, offset:int, timings:list, amplitudes:list):
|
||||
"""
|
||||
input: takes Alexandre's note selection / intensity data
|
||||
output: list of object type / position
|
||||
"""
|
||||
flow = 1
|
||||
song_beat = 0
|
||||
notes = [0 * len(rhythms)]
|
||||
for (rhythm, i) in zip(rhythms, range(len(rhythms))):
|
||||
song_beat += rhythm.time
|
||||
notes = [sl.HitObject(0, timedelta(milliseconds=0), 0) * len(timings)]
|
||||
beats = np.array(beatify(timings))
|
||||
for (delta, note_beat, intensity, i) in zip(timings, beats, amplitudes, range(len(timings))):
|
||||
try:
|
||||
duration = rhythm.time - rhythms[i + 1].time
|
||||
if duration in (1, 2):
|
||||
note_type = "cercle"
|
||||
duration = note_beat - beats[i + 1]
|
||||
if duration in (QUARTER, HALF):
|
||||
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||
"""
|
||||
elif duration % 2 == 0:
|
||||
rhythms.insert(0, f"slider {duration}")
|
||||
else:
|
||||
rhythms.insert(0, f"reverse_slider {duration}")
|
||||
"""
|
||||
except IndexError:
|
||||
note_type = "cercle"
|
||||
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||
# TODO mettre à jour flow
|
||||
"""
|
||||
if len(notes) > 2:
|
||||
angle = flow * f(rhythm.intensite)
|
||||
x1, y1 = notes[i-2].position
|
||||
|
@ -36,6 +47,8 @@ def greedy():
|
|||
y3 = y2 + (intensity * np.sin(angle + old_angle))
|
||||
else:
|
||||
pass
|
||||
"""
|
||||
return notes
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import heapq
|
|||
import scipy
|
||||
import os
|
||||
import random
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
|
||||
|
@ -380,16 +381,15 @@ def test_sample(timelist):
|
|||
#BPM = 140
|
||||
#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)
|
||||
"""
|
||||
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):
|
||||
#zaejzlk
|
||||
div_len = div_len_factor/bpm-0.01
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue