add the fade-in and out to the clips
This commit is contained in:
parent
32c3a810b5
commit
53f0b71783
@ -2,8 +2,10 @@ import sqlite3
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import shutil
|
||||||
|
|
||||||
os.removedirs('clips')
|
shutil.rmtree('clips')
|
||||||
|
# os.removedirs('clips')
|
||||||
os.mkdir('clips')
|
os.mkdir('clips')
|
||||||
|
|
||||||
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
||||||
@ -40,6 +42,27 @@ for song, motif, start, duration in db.execute('''
|
|||||||
|
|
||||||
print (destination)
|
print (destination)
|
||||||
|
|
||||||
|
# trim and fade start
|
||||||
|
|
||||||
|
if start / 1000 < 2:
|
||||||
|
trim_start = 0
|
||||||
|
trim_duration = duration / 1000 + start / 1000 + 2
|
||||||
|
fade_in = 0
|
||||||
|
fade_out = 2
|
||||||
|
else:
|
||||||
|
trim_start = start / 1000 - 2
|
||||||
|
trim_duration = duration / 1000 + 4
|
||||||
|
fade_in = 2
|
||||||
|
fade_out = 2
|
||||||
|
|
||||||
|
# trim and fade end (to be continued)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# call sox
|
# call sox
|
||||||
|
|
||||||
subprocess.run(["sox", source, destination, "trim", f'{start / 1000}', f'{duration / 1000}'], check = True)
|
sox_args = [str(x) for x in ["sox", source, destination,
|
||||||
|
"trim", trim_start, trim_duration,
|
||||||
|
"fade", "t", fade_in, "-0", fade_out]]
|
||||||
|
print(' '.join(sox_args))
|
||||||
|
subprocess.run(sox_args, check = True)
|
||||||
Loading…
Reference in New Issue
Block a user