-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinit.py
More file actions
49 lines (37 loc) · 1.39 KB
/
Copy pathinit.py
File metadata and controls
49 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from glob import glob
from pydub import AudioSegment
from pydub.generators import WhiteNoise
from math import *
from random import *
import sys
if len(sys.argv) > 2:
AudioSegment.converter = sys.argv[1] #ffmpeg installation exe dir path
AudioSegment.ffmpeg = sys.argv[1] #ffmpeg installation exe dir path
AudioSegment.ffprobe = sys.argv[2] #ffprobe installation exe dir path
def calc_pan(index):
return cos(radians(index))
#playlist_songs = [AudioSegment.from_mp3(mp3_file) for mp3_file in glob("mp3/*.mp3")]
#first_song = playlist_songs.pop(0)
interval = 0.2 * 1000 # sec
song = AudioSegment.from_mp3('mp3/everlong.mp3')
song_inverted = song.invert_phase()
song.overlay(song_inverted)
splitted_song = splitted_song_inverted = []
song_start_point = 0
print "split song in part"
while song_start_point+interval < len(song):
splitted_song.append(song[song_start_point:song_start_point+interval])
song_start_point += interval
if song_start_point < len(song):
splitted_song.append(song[song_start_point:])
print "end splitting"
print "total pieces: " + str(len(splitted_song))
ambisonics_song = splitted_song.pop(0)
pan_index = 0
for piece in splitted_song:
pan_index += 5
piece = piece.pan(calc_pan(pan_index))
ambisonics_song = ambisonics_song.append(piece, crossfade=interval/50)
# lets save it!
out_f = open("compiled/everlong.mp3", 'wb')
ambisonics_song.export(out_f, format='mp3')