Gibt es mittlerweile überhaupt eine vernünftige Möglichkeit die Lautstärke mehreren Liedern anzupassen?
#!/usr/bin/env python
from Tkinter import *
import tkSnack
import time
IN = "in.wav"
OUT = "out.wav"
TESTNUM = 50000
root = Tk()
tkSnack.initializeSnack(root)
mysound = tkSnack.Sound(load = IN)
samples = mysound.length()
def cut(a):
if a > 32767:
a = 32767
if a < - 32767:
a = - 32767
return(a)
def Getn(a):
if a < 0:
a = - a
if a < 1500:
n = 6.
if a > 10000:
n = 1.
if a >= 1500 and a <= 10000:
n = -1./1700 * a + 117. / 17.
# 5000
n = - 1. / 700. * a + 57. / 7.
return (n)
def test(x):
t = 0
for i in range(TESTNUM):
a = int(mysound.sample(x + i).split(" ")[0])
b = int(mysound.sample(x + i).split(" ")[1])
if a > 10000 or b > 10000:
t = 1
break
return(t)
x = 0
acttime = time.time()
hours = str(time.localtime(acttime)[3])
mins = str(time.localtime(acttime)[4])
if len(mins) == 1:
mins = "0" + mins
print "Start time: " + hours + ":" + mins + "."
y = 0
print str(y) + " %"
while x < samples:
a = int(mysound.sample(x).split(" ")[0])
b = int(mysound.sample(x).split(" ")[1])
na = Getn(a)
nb = Getn(b)
if int(float(x) / float(samples) * 100.) != y:
y = int(float(x) / float(samples) * 100.)
print str(y) + " %"
if na == 1. or nb == 1.:
if test(x) == 1:
x += TESTNUM
continue
a = int(a * na)
b = int(b * nb)
a = cut(a)
b = cut(b)
mysound.sample(x, a, b)
x += 1
mysound.write(OUT)
print "Ok."
acttime = time.time()
hours = str(time.localtime(acttime)[3])
mins = str(time.localtime(acttime)[4])
if len(mins) == 1:
mins = "0" + mins
print "End time: " + hours + ":" + mins + "."
sox in.wav out.wav vol 6 amplitude 0.5