Compare commits

..

2 Commits

Author SHA1 Message Date
Alexandre 5d4a9c8c58 added commentaries uwu 2025-03-24 16:44:08 +01:00
Alexandre c2cfc429ae more 2025-03-17 17:55:35 +01:00
5 changed files with 620 additions and 53 deletions

BIN
audio.wav

Binary file not shown.

View File

@ -274,7 +274,8 @@ def keep_highest(song_name, offset, songlen, segsize, count, output_name, minfre
# -------------------------------------------- Write -------------------------------------------- # # -------------------------------------------- Write -------------------------------------------- #
f = open("result_owen_2.txt", "w")
f = open("result_bad_apple[90].txt", "w")
f.write("Song name : " + song_name + "\n") f.write("Song name : " + song_name + "\n")
f.write("Start : " + str(offset) + "\n") f.write("Start : " + str(offset) + "\n")
f.write("End : " + str(offset+songlen) + "\n\n") f.write("End : " + str(offset+songlen) + "\n\n")
@ -286,6 +287,7 @@ def keep_highest(song_name, offset, songlen, segsize, count, output_name, minfre
f.close() f.close()
return (loct, locs) return (loct, locs)
def convert_to_wav(song_name:str, output_file="audio.wav") -> str: def convert_to_wav(song_name:str, output_file="audio.wav") -> str:
@ -301,48 +303,6 @@ def convert_to_wav(song_name:str, output_file="audio.wav") -> str:
return output_file return output_file
return song_name return song_name
def retrieve_all_from_song(filename, t0, t1, bpm, dta=0.001, dtf=0.01, threshold=0.06, show=True):
# dt = sample interval
# threshold is in percent
if(t1 <= t0):
print("ERROR : t1 <= t0\n")
exit(1)
# converts format to .wav
new_fn = convert_to_wav(filename)
print("Filtering song...")
#void_freq_clean(new_fn, t0, t1, dtf, 20, 20000, 0.05, "crop1.wav")
#def void_freq_clean(song_name, offset, songlen, segsize, minfreq, maxfreq, ampthr, output_name):
print("Now retrieving the frequencies")
(maxlist, maxamps) = retrieve_dominant_freqs(new_fn, t0, t1, dtf)
#def retrieve_dominant_freqs(song_name, offset, songlen, segsize):
print("Now retrieving the amplitudes")
amps = retrieve_dominant_amps(new_fn, t0, t1, dta, threshold, (4/(bpm/60))/4)
print("Len of freqs : ", len(maxlist), "|", len(maxamps))
print("Len of amps : ", len(maxlist), "|", len(amps))
maxa = amps[0]
for jj in amps:
if(jj > maxa):
maxa = jj
for i in range(len(amps)):
amps[i] = (amps[i] * 2000) / maxa
if(show):
timesF = [t0 + dtf*k for k in range(len(maxlist))]
timesA = [t0 + dta*k for k in range(len(amps))]
plt.plot(timesA, amps)
plt.plot(timesF, maxlist)
plt.show()
# free()
''' '''
# c-type # c-type
SONG_LEN = 7 SONG_LEN = 7
@ -398,17 +358,17 @@ BPM = 157
SEGSIZE = 1/(BPM/60) SEGSIZE = 1/(BPM/60)
wavved_song = convert_to_wav("songs/owen(157.00024-1008).mp3") wavved_song = convert_to_wav("songs/owen(157.00024-1008).mp3")
''' '''
'''
# Owen 2/2 # Owen 2/2
SONG_LEN = 7 SONG_LEN = 7
OFFSET = 25.466 OFFSET = 25.466
BPM = 157 BPM = 157
SEGSIZE = 1/(BPM/60) SEGSIZE = 1/(BPM/60)
wavved_song = convert_to_wav("songs/owen(157.00024-1008).mp3") wavved_song = convert_to_wav("songs/owen(157.00024-1008).mp3")
'''
''' '''
# death # death
SONG_LEN = 8 SONG_LEN = 10
OFFSET = 21.750 OFFSET = 21.750
BPM = 180 BPM = 180
SEGSIZE = 1/(BPM/60) SEGSIZE = 1/(BPM/60)
@ -416,7 +376,7 @@ wavved_song = convert_to_wav("songs/Night of Knights.mp3")
''' '''
''' '''
# Bad apple # Bad apple
SONG_LEN = 20 SONG_LEN = 120
OFFSET = 0.152 OFFSET = 0.152
BPM = 138 BPM = 138
SEGSIZE = 1/(BPM/60) SEGSIZE = 1/(BPM/60)
@ -442,10 +402,40 @@ SEGSIZE = 1/(BPM/60)
wavved_song = convert_to_wav("songs/Megalovania(240-7984)[filtered].wav") wavved_song = convert_to_wav("songs/Megalovania(240-7984)[filtered].wav")
''' '''
SONG_LEN = 0 # length of the song, in seconds
OFFSET = 0 # offset of the 1st note (aka time offset of the first red bar), in seconds
BPM = 0 # BPM
wavved_song = convert_to_wav("insert_song_name_here.wav")
# Do not touch
DIVIDER = 4 # note divider
SEGSIZE = 1/(BPM/60)
NOTE_DIST = (2**(1/4)) NOTE_DIST = (2**(1/4))
OCTAVE_DIST = 0.05 OCTAVE_DIST = 0.05
# keep_highest(song_name, offset, songlen, segsize, count, output_name, minfreq=110, maxfreq=5000, ampthr=250): # keep_highest(song_name, offset, songlen, segsize, count, output_name, minfreq=110, maxfreq=5000, ampthr=250):
(loct, locs) = keep_highest(wavved_song, OFFSET, SONG_LEN, SEGSIZE/4, 1, "Zblit.wav", minfreq=330, maxfreq=3000, ampthr=500) (loct, locs) = keep_highest(wavved_song, OFFSET, SONG_LEN, SEGSIZE/DIVIDER, 1, "Zblit.wav", minfreq=220, maxfreq=3000, ampthr=800)
'''
minfreq and maxfred are thresholds for frequency analysts (anything outside of [minfreq, maxfreq] will not be accounted for)
ampthr is a threshold for amplitude (arbitrary unit)
'''
''' you can deactivate this if you want (show timings points in terminal) '''
'''
import time
import random
loct2 = []
for k in loct:
if(type(k) == float):
loct2.append(k)
else:
loct2.append(k[0])
loct2.append(k[1])
for i in range(len(loct2)-1):
print("*"*(random.randint(10, 100)))
time.sleep(loct2[i+1]-loct2[i])
print("yipee") print("yipee")
'''

68
result_NoN.txt Normal file
View File

@ -0,0 +1,68 @@
Song name : audio.wav
Start : 21.75
End : 31.75
Hit Objects :
21.80657596371882
21.86517006802721
21.954943310657598
22.158684807256236
22.288934240362813
22.47361678004535
22.554920634920634
22.686349206349206
22.807539682539684
22.91013605442177
23.045102040816328
23.131043083900227
23.180090702947847
23.220328798185943
[23.287528344671202, 23.367142857142856]
[23.472698412698414, 23.55392290249433]
23.821655328798187
23.95299319727891
24.15141723356009
24.22986394557823
24.498219954648526
24.66047619047619
[24.78424036281179, 24.884920634920636]
25.170090702947846
25.489603174603175
25.57687074829932
25.655873015873016
25.812653061224488
[25.908027210884356, 25.956757369614515]
25.993038548752835
[26.150385487528347, 26.199002267573697]
26.305804988662132
26.492925170068027
26.652392290249434
26.81343537414966
27.013990929705216
27.16793650793651
27.28827664399093
27.49448979591837
27.838990929705215
27.88766439909297
27.953197278911563
28.156689342403627
28.287687074829932
28.502426303854875
28.686780045351476
28.83141723356009
29.16842403628118
29.285532879818593
[29.477437641723355, 29.53560090702948]
29.660725623582767
29.810306122448978
29.866689342403628
30.13770975056689
[30.484603174603173, 30.555702947845806]
30.623378684807257
30.807585034013606
30.956666666666667
31.155680272108846
31.289024943310658
31.38056689342404
31.4947052154195
31.62167800453515

510
result_bad_apple[90].txt Normal file
View File

@ -0,0 +1,510 @@
Song name : songs/Bad apple (138-152)[filtered].wav
Start : 0.152
End : 120.152
Hit Objects :
0.17748752834467119
0.6138367346938776
1.0485873015873015
1.4824761904761903
[1.5911723356009069, 1.6998571428571427]
[1.80856462585034, 1.916580498866213]
2.352963718820862
2.786183673469388
3.2216031746031746
3.4390068027210887
3.6557414965986395
4.092079365079365
4.525321995464853
[4.960752834467121, 5.0694263038548755]
[5.178133786848073, 5.286818594104308]
5.394857142857143
5.8312176870748305
6.264437641723356
6.699879818594105
6.917260770975057
7.133995464852608
7.570333333333333
8.00357596371882
8.439006802721087
8.547680272108844
[8.65639909297052, 8.765083900226756]
8.873122448979592
9.309471655328798
9.742714285714285
10.178133786848072
10.395537414965986
10.612272108843536
11.049222222222221
11.481841269841269
[11.917272108843537, 12.025945578231292]
12.134641723356008
12.243371882086167
12.35137641723356
12.788360544217687
13.223145124716552
13.655741496598639
14.090480725623582
14.526897959183673
14.960072562358276
15.394879818594104
15.829607709750567
16.264414965986397
16.69919954648526
17.13463038548753
17.352011337868483
17.568780045351474
18.00577551020408
18.44058276643991
18.874732426303854
19.30789569160998
19.744233560090706
20.179721088435375
20.61292970521542
20.831852607709752
21.04702267573696
21.48338321995465
21.919040816326532
22.35355328798186
22.788609977324263
23.223111111111113
23.655730158730158
24.09117233560091
24.30855328798186
24.52528798185941
24.96227210884354
25.396444444444445
25.83186394557823
26.264437641723358
26.69922222222222
27.13325850340136
27.278179138321995
27.42384807256236
27.569426303854875
27.858609977324264
28.003530612244898
28.440832199546485
28.874732426303854
29.310185941043084
29.74510657596372
30.17901814058957
30.61290702947846
30.839188208616783
31.047702947845806
31.264358276643993
31.48180725623583
31.916625850340136
32.35133106575964
32.57675056689342
32.78770294784581
33.22324716553288
33.657986394557824
33.98543537414966
34.09231746031746
34.527521541950115
34.742657596371885
34.960038548752834
35.397068027210885
35.83187528344671
36.266013605442176
36.699233560090704
37.13766893424037
37.570299319727894
38.004233560090704
38.22161451247165
38.438326530612244
38.87319047619048
39.310140589569166
39.74492517006803
40.17748752834467
40.61384807256236
41.047714285714285
41.191931972789114
41.48246485260771
41.625956916099774
41.77093424036281
41.91646712018141
42.36587755102041
42.68211337868481
42.789086167800455
42.96644444444445
[43.05025396825397, 43.12018594104308]
43.21083219954649
43.44029931972789
43.656897959183674
43.88133106575964
43.99519727891157
[44.12315646258504, 44.176637188208616]
44.22866666666667
44.79339455782313
44.939244897959185
45.07087755102041
45.297702947845806
[45.62798639455782, 45.735401360544216]
45.845616780045354
46.52662585034014
46.642975056689345
46.70792970521542
46.920537414965985
47.3585873015873
47.472963718820864
47.5963537414966
47.70754421768707
47.896954648526076
48.13854195011338
48.21910884353741
[48.357011337868485, 48.42557142857143]
48.56202267573696
48.82994784580499
48.872090702947844
48.98743083900227
49.10433560090703
49.33446031746032
49.44868934240363
49.501875283446715
49.85813378684807
[49.92306575963719, 49.9976462585034]
50.18484580498866
50.294369614512476
50.39786167800454
50.616308390022674
50.836943310657595
50.95396145124717
51.075707482993195
51.1850612244898
51.24770294784581
51.72557142857143
51.90008390022676
52.027793650793654
[52.24684126984127, 52.31715873015873]
52.576467120181405
52.699551020408165
52.79751020408163
53.226897959183674
53.279811791383224
[53.485956916099774, 53.586297052154194]
53.66018594104308
53.885390022675736
54.318507936507935
54.42906349206349
54.54889342403628
54.67703401360544
54.947691609977326
55.10568480725624
55.25059410430839
55.395537414965986
55.540458049886624
55.685378684807255
55.82959637188209
56.24862131519274
[56.61251020408163, 56.69918820861678]
57.13624036281179
57.433678004535146
57.57124036281179
58.00939229024944
58.43761224489796
58.72457369614513
58.873780045351474
59.09118367346939
59.30791836734694
[59.59537868480726, 59.67295238095238]
59.73084353741497
60.178111111111114
60.296399092970525
60.61291836734694
60.88961904761905
61.04768027210884
61.280458049886626
61.482498866213156
61.780854875283445
61.91586621315193
61.96143310657597
62.134687074829934
62.3554126984127
[62.64099092970522, 62.72690929705215]
62.786138321995466
63.223179138321996
63.610934240362816
63.65795238095238
63.74125170068027
64.09451700680272
64.52913151927437
64.96227210884354
65.73408616780046
65.83024263038548
66.04766893424036
66.1622380952381
66.26689795918368
66.69985714285714
66.86703401360545
67.1434739229025
67.56946031746031
67.67981179138322
68.00419954648527
68.18160317460318
68.44822448979592
68.62520861678004
68.873768707483
69.02502721088436
69.16366666666667
69.30856462585034
69.45345124716553
69.59840589569161
69.74263492063493
70.08938095238095
70.17816780045352
70.29876870748299
70.60590022675737
71.06051473922902
71.20575283446712
71.48430158730159
71.74003854875284
[71.91655782312925, 71.97755555555555]
72.35196598639456
72.58855328798187
72.78679591836735
73.00286167800454
[73.1171700680272, 73.2209455782313]
73.2855260770975
73.65791836734694
[74.09252154195012, 74.16633106575964]
74.21930158730159
74.44590022675737
74.52593424036282
74.6359455782313
74.67332653061224
75.10286167800453
75.22186394557824
75.41148979591837
75.56190929705215
75.6568866213152
75.82960770975056
76.04702267573697
76.27168253968254
76.55477777777777
76.6984172335601
76.96431292517006
77.03872335600907
77.1514784580499
77.51378004535148
77.58944897959184
78.00415419501134
[78.04103628117915, 78.13239682539682]
78.22722675736962
78.35378004535147
78.43893877551021
78.59074149659864
78.91654648526077
79.31533333333333
79.39597959183673
79.62577551020408
79.74333786848072
79.96077551020409
[80.07492517006803, 80.17744217687076]
80.44707936507936
[80.84584353741496, 80.90813378684807]
81.04762358276643
[81.2112403628118, 81.29999319727891]
81.4824081632653
81.59557142857143
81.80244217687076
81.9172947845805
82.01197732426304
82.07820181405896
82.47613832199546
82.54596825396825
[82.81203401360544, 82.87843990929706]
82.95706802721088
83.05449433106575
83.10889342403628
[83.30809977324263, 83.38039002267574]
83.65643310657596
83.8254126984127
83.89663718820862
84.00712471655329
84.09121768707483
84.4113537414966
84.52526530612245
84.96071882086167
84.99763492063492
85.04137641723356
85.09243083900226
85.39551473922903
85.5512403628118
85.83024263038548
85.93354195011338
86.18889342403628
86.27069614512472
86.47834920634921
86.57008390022676
86.6997664399093
86.91730612244898
87.08898412698413
87.13392743764173
[87.41916553287982, 87.52562811791384]
87.57074149659864
87.95809977324264
88.00561678004536
88.18167120181405
88.43901814058957
88.55092290249434
88.72456235827664
88.87378004535148
89.15734013605443
89.3085306122449
[89.58501587301588, 89.63272562358277]
89.74197732426303
89.9607074829932
90.03079818594104
90.17741950113378
[90.25142176870749, 90.31271428571429]
[90.34826984126984, 90.4104126984127]
90.61289569160998
90.92614965986395
91.06495918367347
91.15681859410431
91.42190929705215
91.51745351473923
91.65094557823129
91.91586621315193
[92.13975510204082, 92.18232879818594]
92.35209070294785
92.4284739229025
92.63357596371883
92.78540136054421
92.92682993197279
93.09414285714286
[93.13309977324263, 93.16961904761905]
93.40953968253969
93.65643310657596
93.87370068027211
94.1163537414966
94.39868934240363
94.54097959183673
94.68676190476191
94.96009523809524
[95.00154648526077, 95.03677324263039]
95.39553741496599
[95.66624036281179, 95.72544671201814]
95.83034467120181
96.11142176870749
96.26665986394558
96.66539002267574
96.84596825396825
96.98834920634921
97.42561678004535
97.46967573696145
97.58724943310658
97.79234013605442
97.85977777777778
97.92634240362811
98.00423356009071
98.1438820861678
98.43898412698412
98.57015192743765
98.82501587301587
98.87375736961451
99.0060589569161
[99.16193197278912, 99.21833786848073]
99.30859863945578
[99.53054875283446, 99.57561678004535]
99.61384807256236
[100.03252154195012, 100.10130839002268]
100.20873469387755
100.26687528344671
100.63126303854875
100.81197732426304
101.04768027210885
101.29351927437642
101.48251020408163
101.60822448979592
101.81399546485261
101.91721541950113
101.96198866213152
102.49114965986395
102.67303174603175
102.78974376417234
103.06061678004535
103.11718140589569
103.16019727891157
103.52395011337869
103.65633106575964
103.72651247165533
103.87378004535148
104.11948299319728
104.45121768707483
104.52904081632653
104.77269160997733
104.9607641723356
[105.31283900226758, 105.40313378684807]
105.83028798185941
106.12405215419501
106.26503854875284
106.38574149659864
[106.57509523809524, 106.61668253968254]
106.70138775510205
106.9542335600907
107.01044671201814
[107.15863265306123, 107.26619501133787]
107.32892743764172
107.5694149659864
[107.78690929705216, 107.88391609977324]
108.22427891156462
108.30992517006803
108.45591156462585
108.54943764172336
108.87374603174604
[108.94321315192744, 108.991410430839]
109.3085306122449
109.4493469387755
[109.53870068027211, 109.62307709750567]
109.7433605442177
[110.0261723356009, 110.10989115646258]
110.17809977324264
110.30489115646259
110.57266893424037
110.62929024943311
110.75646712018141
110.90280498866213
111.04772562358276
111.09557142857143
[111.15148979591837, 111.21918820861679]
111.48247619047619
111.62736281179139
[111.77542403628118, 111.81943764172335]
111.97551473922903
112.33339455782313
112.41687528344671
[112.51009523809523, 112.55244217687076]
112.9979410430839
113.1101746031746
113.47558276643991
113.52638775510204
113.57651247165533
113.66910884353742
113.96760090702948
114.03737414965987
114.14630839002268
114.26050340136055
114.60246485260771
114.65972108843538
114.82543537414966
115.04227210884353
115.26302040816327
115.47837188208617
115.87278231292517
116.54248752834467
116.99491383219954
[117.24726077097506, 117.29575283446712]
117.36991383219954
117.42096825396825
117.56062811791384
117.73815646258504
117.86127437641723
118.27858730158731
118.51943764172336
[118.74331519274376, 118.82907482993197]
[118.96136507936508, 119.0379977324263]
119.38922222222223
119.45943764172335
120.04720408163266

View File

@ -5,8 +5,7 @@ End : 14.984
Hit Objects : Hit Objects :
[8.078591836734693, 8.132503401360545] [8.078591836734693, 8.132503401360545]
8.204578231292517 8.204578231292517
8.288115646258504 [8.288115646258504, 8.34134693877551]
8.34134693877551
8.527968253968254 8.527968253968254
[8.879102040816326, 8.922888888888888] [8.879102040816326, 8.922888888888888]
[9.129260770975057, 9.181766439909296] [9.129260770975057, 9.181766439909296]
@ -32,8 +31,7 @@ Hit Objects :
12.076947845804987 12.076947845804987
12.293716553287982 12.293716553287982
12.344793650793651 12.344793650793651
12.503886621315193 [12.503886621315193, 12.549975056689341]
12.549975056689341
[12.88151700680272, 12.925519274376416] [12.88151700680272, 12.925519274376416]
13.12928344671202 13.12928344671202
13.183308390022676 13.183308390022676
@ -43,7 +41,8 @@ Hit Objects :
13.776233560090702 13.776233560090702
13.816392290249432 13.816392290249432
13.914839002267573 13.914839002267573
[14.015201814058956, 14.068489795918367] 14.015201814058956
14.068489795918367
14.142446712018142 14.142446712018142
14.282956916099774 14.282956916099774
14.527979591836734 14.527979591836734