Emanuele Lapponi commited on
Commit
499849b
Β·
1 Parent(s): a0a7a38

:sparkles: make it less shit

Browse files
Files changed (1) hide show
  1. app.py +41 -25
app.py CHANGED
@@ -8,19 +8,24 @@ from audio_recorder_streamlit import audio_recorder
8
  import pedalboard as pb
9
 
10
 
11
- def stretch(audio, factor, buffer=[]):
 
12
  for s in audio:
13
  for _ in range(factor):
14
  buffer.append(s)
15
- return buffer
16
 
17
 
18
- def destretcher(audio, buffer=[]):
19
- for i, s in enumerate(audio):
20
- if i % 100 == 0:
21
- for _ in range(10):
22
- buffer.append([0, 0])
23
- return buffer
 
 
 
 
24
 
25
  st.title("πŸ‘Ή Sound Refuckulator")
26
 
@@ -43,33 +48,44 @@ else:
43
 
44
 
45
  if audio.any():
 
46
  cols = st.columns(5)
47
  chunk_dividend = cols[0].slider("πŸ«€ Chunkizer", 16, 128, step=16)
48
- stretch_factor = cols[1].slider("🧌 Trollizer", 1, 10, 1)
49
- prob = cols[2].slider("🀑 Impredictidiblize", 0, 100, 0)
50
  sr_factor = cols[3].slider("πŸƒβ€β™€οΈ Chirpidize", 1, 16, 1)
51
- rev_size = cols[4].slider("πŸš› Hugermaker", 0.0, 0.99, 0.0)
52
- delay = pb.Pedalboard([pb.Delay(delay_seconds=0.01, feedback=0.6)])
 
 
 
 
 
53
  reverb = pb.Pedalboard([pb.Reverb(room_size=rev_size)])
54
- chorus = pb.Pedalboard([pb.Chorus()])
55
- pshifter = pb.Pedalboard([pb.PitchShift(-12)])
 
 
 
56
  processed = []
57
  chunk_dividend = sorted(np.random.randint(audio.shape[0], size=chunk_dividend))
58
  for i, chunk in enumerate(np.array_split(audio, chunk_dividend)):
59
- if np.random.randint(100) < prob*2:
60
- chunk = reverb(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob else chunk
61
- chunk = delay(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob else chunk
62
- chunk = chorus(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob else chunk
63
- chunk = pshifter(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob else chunk
64
- chunk = chunk + chunk if np.random.randint(100) < prob/2 else chunk
65
- chunk = stretch(chunk, stretch_factor) if np.random.randint(100) < prob else chunk
66
- chunk = destretcher(chunk) if np.random.randint(100) < prob else chunk
 
 
67
  processed += [s for s in chunk]
68
 
69
  processed = np.array(processed)
70
  reverb = pb.Pedalboard([pb.Reverb(room_size=0.3)])
71
- reverbered = reverb(processed, sr, reset=False)
72
  compressor = pb.Pedalboard([pb.Limiter(threshold_db=-1)])
73
- compressed = compressor(processed, sr, reset=False)
74
 
75
- st.audio(compressed.T, sample_rate=sr * sr_factor)
 
8
  import pedalboard as pb
9
 
10
 
11
+ def stretch(audio, factor):
12
+ buffer = []
13
  for s in audio:
14
  for _ in range(factor):
15
  buffer.append(s)
16
+ return np.array(buffer)
17
 
18
 
19
+ def fix_pops(chunk):
20
+ chunk = np.array(chunk)
21
+ print(type(chunk), type(chunk[0]), type(chunk[-1]))
22
+ # print(chunk[0].shape, chunk[-1].shape)
23
+ print(chunk[0], chunk[-1])
24
+ chunk[:, 0] = fix_pops_channel(chunk[:, 0])
25
+ chunk[:, 1] = fix_pops_channel(chunk[:, 1])
26
+
27
+ return chunk
28
+
29
 
30
  st.title("πŸ‘Ή Sound Refuckulator")
31
 
 
48
 
49
 
50
  if audio.any():
51
+ st.audio(audio.T, sample_rate=sr)
52
  cols = st.columns(5)
53
  chunk_dividend = cols[0].slider("πŸ«€ Chunkizer", 16, 128, step=16)
54
+ prob = cols[1].slider("🀑 Impredictidiblize", 0, 100, 0)
55
+ stretch_factor = cols[2].slider("🧌 Trollizer", 0, 10, 0)
56
  sr_factor = cols[3].slider("πŸƒβ€β™€οΈ Chirpidize", 1, 16, 1)
57
+ rev_size = cols[4].slider("πŸš› Hugermaker", 0.0, 0.09, 0.0)
58
+ delay_macro = cols[0].slider("πŸͺ Spaceometer", 0.01, 0.09, 0.0)
59
+ rounder = cols[1].slider("πŸ€” Rounder", 0, 100, 0)
60
+ pshift = cols[2].slider("😱 Tonermaker", 0, 1, 0)
61
+ reverse = cols[3].slider("🧢 Revolver", 0, 1, 0)
62
+ reps = cols[4].slider("🫣 Repetizer", 0, 3, 0)
63
+ delay = pb.Pedalboard([pb.Delay(delay_seconds=delay_macro, feedback=delay_macro*5)])
64
  reverb = pb.Pedalboard([pb.Reverb(room_size=rev_size)])
65
+ chorus = pb.Pedalboard([pb.Chorus(rate_hz=rounder)])
66
+ pshifter7 = pb.Pedalboard([pb.PitchShift(-7)])
67
+ pshifter3 = pb.Pedalboard([pb.PitchShift(-3)])
68
+ pshifter5 = pb.Pedalboard([pb.PitchShift(-5)])
69
+ pshifter12 = pb.Pedalboard([pb.PitchShift(-12)])
70
  processed = []
71
  chunk_dividend = sorted(np.random.randint(audio.shape[0], size=chunk_dividend))
72
  for i, chunk in enumerate(np.array_split(audio, chunk_dividend)):
73
+ chunk = stretch(chunk, stretch_factor) if np.random.randint(100) < prob and stretch_factor else chunk
74
+ chunk = reverb(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob and rev_size else chunk
75
+ chunk = delay(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob and delay_macro else chunk
76
+ chunk = chorus(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob and rounder else chunk
77
+ chunk = pshifter7(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
78
+ chunk = pshifter3(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
79
+ chunk = pshifter5(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
80
+ chunk = pshifter12(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
81
+ chunk = chunk * reps if np.random.randint(100) < prob and reps else chunk
82
+ chunk = np.flip(chunk) if np.random.randint(100) < prob and reverse else chunk
83
  processed += [s for s in chunk]
84
 
85
  processed = np.array(processed)
86
  reverb = pb.Pedalboard([pb.Reverb(room_size=0.3)])
87
+ # processed = reverb(processed, sr, reset=False)
88
  compressor = pb.Pedalboard([pb.Limiter(threshold_db=-1)])
89
+ processed = compressor(processed, sr, reset=False)
90
 
91
+ st.audio(processed.T, sample_rate=sr * sr_factor)