annotate soxnorm.py @ 25:4a4bd554b4c1 tip

Closing this sub branch.
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Mon, 25 Mar 2013 14:02:54 +0000
parents 032bc65ebafc
children
rev   line source
gyorgy@0 1 import dircache, subprocess, random
gyorgy@0 2 from math import sin, cos, pi
gyorgy@0 3
gyorgy@0 4 sourceDir = '.'
gyorgy@0 5
gyorgy@0 6 def getFilesWav():
gyorgy@0 7 _dirlist = dircache.listdir(sourceDir)
gyorgy@0 8 dirlist = []
gyorgy@0 9 for item in _dirlist:
gyorgy@0 10 if item.split('.')[-1] == 'wav' and item.split('.')[0].split('_')[-1] != 'pad':
gyorgy@0 11 dirlist.append(item)
gyorgy@0 12 return dirlist
gyorgy@0 13
gyorgy@0 14
gyorgy@0 15 def getFilesPad():
gyorgy@0 16 _dirlist = dircache.listdir(sourceDir + '/padded')
gyorgy@0 17 dirlist = []
gyorgy@0 18 for item in _dirlist:
gyorgy@0 19 if item.split('.')[-1] == 'wav' and item.split('.')[0].split('_')[-1] == 'pad':
gyorgy@0 20 dirlist.append('./padded/%s'%item)
gyorgy@0 21 return dirlist
gyorgy@0 22
gyorgy@0 23
gyorgy@0 24 def soxNorm(infile):
gyorgy@0 25 outfile = "%s%s" %("_", infile)
gyorgy@0 26 com = "sox %s %s gain -n -6" %(infile, outfile)
gyorgy@0 27 print com
gyorgy@0 28 proc = subprocess.Popen(com,shell= True)
gyorgy@0 29 proc.wait()
gyorgy@0 30
gyorgy@0 31
gyorgy@0 32
gyorgy@0 33
gyorgy@0 34 #-----------FX
gyorgy@0 35
gyorgy@0 36
gyorgy@0 37 def mwChorus(infile):
gyorgy@0 38 outfile = infile.split('.')[0] + '_chorus' + '.wav'
gyorgy@0 39 com = 'MissWatson -plugin=aufx:bbMC:beBU -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 40 print com
gyorgy@0 41 proc = subprocess.Popen(com,shell= True)
gyorgy@0 42 proc.wait()
gyorgy@0 43
gyorgy@0 44
gyorgy@0 45 def soxPad(infile):
gyorgy@0 46 outfile = infile.split('.')[0] + '_pad' + '.wav'
gyorgy@0 47 com = "sox %s %s pad 0 3" %(infile, outfile)
gyorgy@0 48 print com
gyorgy@0 49 proc = subprocess.Popen(com,shell= True)
gyorgy@0 50 proc.wait()
gyorgy@0 51
gyorgy@0 52 def mwDelay(infile):
gyorgy@0 53 outfile = infile.split('.')[0] + '_echo' + '.wav'
gyorgy@0 54 com = 'MissWatson -plugin=aufx:Pong:ExSl -parameter=0:0.2,1:40,2:-0.25,3:1,4:0.8,5:8000,6:0.01,7:0,8:0,9:0 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 55 print com
gyorgy@0 56 proc = subprocess.Popen(com,shell= True)
gyorgy@0 57 proc.wait()
gyorgy@0 58
gyorgy@0 59 def mwDistortion(infile):
gyorgy@0 60 outfile = infile.split('.')[0] + '_distortion' + '.wav'
gyorgy@0 61 com = 'MissWatson -plugin=aufx:afs1:Aura -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 62 print com
gyorgy@0 63 proc = subprocess.Popen(com,shell= True)
gyorgy@0 64 proc.wait()
gyorgy@0 65
gyorgy@0 66 def mwLoPass(infile):
gyorgy@0 67 outfile = infile.split('.')[0] + '_lopass' + '.wav'
gyorgy@0 68 com = 'MissWatson -plugin=aumf:FSim:FabF -parameter=1:0.5,5:2 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 69 print com
gyorgy@0 70 proc = subprocess.Popen(com,shell= True)
gyorgy@0 71 proc.wait()
gyorgy@0 72
gyorgy@0 73 def mwHiPass(infile):
gyorgy@0 74 outfile = infile.split('.')[0] + '_hipass' + '.wav'
gyorgy@0 75 com = 'MissWatson -plugin=aumf:FSim:FabF -parameter=1:0.5,4:1,5:2 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 76 print com
gyorgy@0 77 proc = subprocess.Popen(com,shell= True)
gyorgy@0 78 proc.wait()
gyorgy@0 79
gyorgy@0 80 def mwBandPass(infile):
gyorgy@0 81 outfile = infile.split('.')[0] + '_bandpass' + '.wav'
gyorgy@0 82 com = 'MissWatson -plugin=aumf:FSim:FabF -parameter=1:0.5,4:2,5:2 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 83 print com
gyorgy@0 84 proc = subprocess.Popen(com,shell= True)
gyorgy@0 85 proc.wait()
gyorgy@0 86
gyorgy@0 87
gyorgy@0 88 def mwCompressor(infile):
gyorgy@0 89 outfile = infile.split('.')[0] + '_compressor' + '.wav'
gyorgy@0 90 com = 'MissWatson -plugin=aufx:dcmp:appl -parameter=0:-41,1:36,2:1,3:-120,4:0.03,5:0.03,6:0 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 91 print com
gyorgy@0 92 proc = subprocess.Popen(com,shell= True)
gyorgy@0 93 proc.wait()
gyorgy@0 94
gyorgy@0 95 def mwComb(infile):
gyorgy@0 96 outfile = infile.split('.')[0] + '_comb' + '.wav'
gyorgy@0 97 com = 'MissWatson -plugin=aufx:CmFB:MNor -parameter=0:420,1:1,2:1,3:75,4:100,5:0 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 98 print com
gyorgy@0 99 proc = subprocess.Popen(com,shell= True)
gyorgy@0 100 proc.wait()
gyorgy@0 101
gyorgy@0 102 def mwLeslie(infile):
gyorgy@0 103 outfile = infile.split('.')[0] + '_leslie' + '.wav'
gyorgy@0 104 com = 'MissWatson -plugin=aufx:mdaH:mdaX -parameter=0:2,1:50,2:60,3:70:4:60,5:70,6:450,7:0,8:50 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 105 print com
gyorgy@0 106 proc = subprocess.Popen(com,shell= True)
gyorgy@0 107 proc.wait()
gyorgy@0 108
gyorgy@0 109 def mwRingMod(infile):
gyorgy@0 110 outfile = infile.split('.')[0] + '_ringmod' + '.wav'
gyorgy@0 111 com = 'MissWatson -plugin=aufx:mdaR:mdaX -parameter=0:1000,1:0,2:0 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 112 print com
gyorgy@0 113 proc = subprocess.Popen(com,shell= True)
gyorgy@0 114 proc.wait()
gyorgy@0 115
gyorgy@0 116 def mwFuzz(infile):
gyorgy@0 117 outfile = infile.split('.')[0] + '_fuzz' + '.wav'
gyorgy@0 118 com = 'MissWatson -plugin=aufx:Pass:AuDa -parameter=0:0.4,1:14000,2:-5,3:1 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 119 print com
gyorgy@0 120 proc = subprocess.Popen(com,shell= True)
gyorgy@0 121 proc.wait()
gyorgy@0 122
gyorgy@0 123 def soxGain(infile):
gyorgy@0 124 outfile = infile.split('.')[0] + '_gain' + '.wav'
gyorgy@0 125 com = "sox %s %s gain 5.8" %(infile, outfile)
gyorgy@0 126 print com
gyorgy@0 127 proc = subprocess.Popen(com,shell= True)
gyorgy@0 128 proc.wait()
gyorgy@0 129
gyorgy@0 130 def mwBitCrush(infile):
gyorgy@0 131 outfile = infile.split('.')[0] + '_bitcrush' + '.wav'
gyorgy@0 132 com = 'MissWatson -plugin=aufx:CRS1:Togu -parameter=1:0.25,2:0.5,3:0.5,4:1,5:0.5,6:0,7:0 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 133 print com
gyorgy@0 134 proc = subprocess.Popen(com,shell= True)
gyorgy@0 135 proc.wait()
gyorgy@0 136
gyorgy@0 137 def mwMonoPhaser(infile):
gyorgy@0 138 outfile = infile.split('.')[0] + '_monophaser' + '.wav'
gyorgy@0 139 com = 'MissWatson -plugin=aufx:Phas:ExSl -parameter=0:0.85,1:0.75,2:0,3:1500,4:7000,5:10,6:0 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 140 print com
gyorgy@0 141 proc = subprocess.Popen(com,shell= True)
gyorgy@0 142 proc.wait()
gyorgy@0 143
gyorgy@0 144 def mwStereoPhaser(infile):
gyorgy@0 145 outfile = infile.split('.')[0] + '_stereophaser' + '.wav'
gyorgy@0 146 com = 'MissWatson -plugin=aufx:Phas:ExSl -parameter=0:0.85,1:0.75,2:0,3:1500,4:7000,5:10,6:0.3 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 147 print com
gyorgy@0 148 proc = subprocess.Popen(com,shell= True)
gyorgy@0 149 proc.wait()
gyorgy@0 150
gyorgy@0 151
gyorgy@0 152 def soxSpeedUp(infile):
gyorgy@0 153 outfile = infile.split('.')[0] + '_speedup' + '.wav'
gyorgy@0 154 com = "sox %s %s speed 1.2" %(infile, outfile)
gyorgy@0 155 print com
gyorgy@0 156 proc = subprocess.Popen(com,shell= True)
gyorgy@0 157 proc.wait()
gyorgy@0 158
gyorgy@0 159
gyorgy@0 160 def soxSpeedDown(infile):
gyorgy@0 161 outfile = infile.split('.')[0] + '_speeddown' + '.wav'
gyorgy@0 162 com = "sox %s %s speed 0.8" %(infile, outfile)
gyorgy@0 163 print com
gyorgy@0 164 proc = subprocess.Popen(com,shell= True)
gyorgy@0 165 proc.wait()
gyorgy@0 166
gyorgy@0 167
gyorgy@0 168 def mwDoppler(infile):
gyorgy@0 169 outfile = infile.split('.')[0] + '_doppler' + '.wav'
gyorgy@0 170 com = 'sox %s -n stat' %infile
gyorgy@0 171 #print com
gyorgy@0 172 #proc = subprocess.Popen(com,shell= True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
gyorgy@0 173 #proc.wait()
gyorgy@0 174 #output = proc.stdout.read()
gyorgy@0 175 #output = output.split('):')
gyorgy@0 176 #output = output[1].split('Scaled')
gyorgy@0 177 length = 600 #float(output[0]) * 100
gyorgy@0 178
gyorgy@0 179 print length
gyorgy@0 180 com = 'MissWatson -plugin=aufx:DPAS:ksWV -parameter=5:%f -input-file=%s -output-file=%s' %(length, infile, outfile)
gyorgy@0 181 print com
gyorgy@0 182 proc = subprocess.Popen(com,shell= True)
gyorgy@0 183 proc.wait()
gyorgy@0 184
gyorgy@0 185
gyorgy@0 186
gyorgy@0 187 def soxTremolo(infile):
gyorgy@0 188 outfile = infile.split('.')[0] + '_tremolo' + '.wav'
gyorgy@0 189 com = "sox %s %s tremolo 6 75" %(infile, outfile)
gyorgy@0 190 print com
gyorgy@0 191 proc = subprocess.Popen(com,shell= True)
gyorgy@0 192 proc.wait()
gyorgy@0 193
gyorgy@0 194
gyorgy@0 195 def mwVibrato(infile):
gyorgy@0 196 outfile = infile.split('.')[0] + '_vibrato' + '.wav'
gyorgy@0 197 com = 'MissWatson -plugin=aumf:MAe8:Meld -parameter=0:0.15,1:0.78,3:0.12 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 198 print com
gyorgy@0 199 proc = subprocess.Popen(com,shell= True)
gyorgy@0 200 proc.wait()
gyorgy@0 201
gyorgy@0 202
gyorgy@0 203 def soxPan(infile):
gyorgy@0 204 _p = random.random() * 0.7 + 0.2
gyorgy@0 205 p = pi * (_p + 2) / 4
gyorgy@0 206 i = random.choice([-1, 1])
gyorgy@0 207 l = i * (cos(p) + sin(p))
gyorgy@0 208 r = i * (cos(p) - sin(p))
gyorgy@0 209 print [l, r]
gyorgy@0 210 outfile = infile.split('.')[0] + '_pan' + '.wav'
gyorgy@0 211 com = "sox %s %s remix 1v%f 2v%f" %(infile, outfile, l, r)
gyorgy@0 212 print com
gyorgy@0 213 proc = subprocess.Popen(com,shell= True)
gyorgy@0 214 proc.wait()
gyorgy@0 215
gyorgy@0 216
gyorgy@0 217 def mwReverb(infile):
gyorgy@0 218 outfile = infile.split('_pad.')[0] + '_reverb' + '.wav'
gyorgy@0 219 com = 'MissWatson -plugin=aufx:JzR3:DreP -parameter=0:0,1:0.86,2:20,3:75,4:1,5:1 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 220 print com
gyorgy@0 221 proc = subprocess.Popen(com,shell= True)
gyorgy@0 222 proc.wait()
gyorgy@0 223
gyorgy@0 224
gyorgy@0 225 def mlabRobot(infile):
gyorgy@0 226 outfile = infile.split('.')[0] + '_robot' + '.wav'
gyorgy@0 227 com = '''matlab -nodesktop -nosplash - nojvm -r "robotization('%s','%s')"'''%(infile, outfile)
gyorgy@0 228 print com
gyorgy@0 229 proc = subprocess.Popen(com,shell= True)
gyorgy@0 230 proc.wait()
gyorgy@0 231
gyorgy@0 232
gyorgy@0 233 def mlabWhisper(infile):
gyorgy@0 234 outfile = infile.split('.')[0] + '_whisper' + '.wav'
gyorgy@0 235 com = '''matlab -nodesktop -nosplash - nojvm -r "whisperization('%s','%s')"'''%(infile, outfile)
gyorgy@0 236 print com
gyorgy@0 237 proc = subprocess.Popen(com,shell= True)
gyorgy@0 238 proc.wait()
gyorgy@0 239
gyorgy@0 240 def mwEnhancer(infile):
gyorgy@0 241 outfile = infile.split('.')[0] + '_enhancer' + '.wav'
gyorgy@0 242 com = 'MissWatson -plugin=aufx:SPVT:SPL1 -parameter=2:0.75,3:0.75,4:0.5,5:0.6,6:0.75,7:0.75,8:0.7,9:0,10:0.5 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 243 print com
gyorgy@0 244 proc = subprocess.Popen(com,shell= True)
gyorgy@0 245 proc.wait()
gyorgy@0 246
gyorgy@0 247 def mwFlanger(infile):
gyorgy@0 248 outfile = infile.split('.')[0] + '_flanger' + '.wav'
gyorgy@0 249 com = 'MissWatson -plugin=aufx:Flan:Togu -parameter=1:0.5,2:0,3:0.75,4:0.6,5:0,6:0.75,7:1,8:0.55 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 250 print com
gyorgy@0 251 proc = subprocess.Popen(com,shell= True)
gyorgy@0 252 proc.wait()
gyorgy@0 253
gyorgy@0 254 def mwGraindelay(infile):
gyorgy@0 255 outfile = infile.split('_pad.')[0] + '_graindelay' + '.wav'
gyorgy@0 256 com = 'MissWatson -plugin=aumf:+bub:SDHKu -parameter=0:233,1:48,2:85,3:18,4:50,6:0,7:0,8:0,10:20000,11:0,12:70 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 257 print com
gyorgy@0 258 proc = subprocess.Popen(com,shell= True)
gyorgy@0 259 proc.wait()
gyorgy@0 260
gyorgy@0 261
gyorgy@0 262
gyorgy@0 263
gyorgy@0 264 def mwPitchUp(infile):
gyorgy@0 265 outfile = infile.split('.')[0] + '_pitchup' + '.wav'
gyorgy@0 266 com = 'MissWatson -plugin=aufx:shft:Awsh -parameter=0:300,1:0,2:0,3:3,4:8 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 267 print com
gyorgy@0 268 proc = subprocess.Popen(com,shell= True)
gyorgy@0 269 proc.wait()
gyorgy@0 270
gyorgy@0 271 #def mwPitchDown(infile):
gyorgy@0 272 # outfile = infile.split('.')[0] + '_pitchdown' + '.wav'
gyorgy@0 273 # com = 'MissWatson -plugin=aufx:shft:Awsh -parameter=0:-300,1:0,2:0,3:3,4:8 -input-file=%s -output-file=%s' %(infile, outfile)
gyorgy@0 274 # print com
gyorgy@0 275 # proc = subprocess.Popen(com,shell= True)
gyorgy@0 276 # proc.wait()
gyorgy@0 277
gyorgy@0 278 wav_files = getFilesWav()
gyorgy@0 279 #wav_files = getFilesPad()
gyorgy@0 280 print wav_files
gyorgy@0 281
gyorgy@0 282 for item in wav_files:
gyorgy@0 283 #print item
gyorgy@0 284 #soxNorm(item)
gyorgy@0 285 #mwChorus(item)
gyorgy@0 286 #soxPad(item)
gyorgy@0 287 #mwDelay(item)
gyorgy@0 288 #mwDistortion(item)
gyorgy@0 289 #mwLoPass(item)
gyorgy@0 290 #mwHiPass(item)
gyorgy@0 291 #mwBandPass(item)
gyorgy@0 292 #mwCompressor(item)
gyorgy@0 293 #mwComb(item)
gyorgy@0 294 #mwLeslie(item)
gyorgy@0 295 #mwRingMod(item)
gyorgy@0 296 #mwFuzz(item)
gyorgy@0 297 #soxGain(item)
gyorgy@0 298 #mwBitCrush(item)
gyorgy@0 299 #mwMonoPhaser(item)
gyorgy@0 300 #mwStereoPhaser(item)
gyorgy@0 301
gyorgy@0 302 #soxSpeedUp(item)
gyorgy@0 303 #soxSpeedDown(item)
gyorgy@0 304
gyorgy@0 305 #mwDoppler(item)
gyorgy@0 306 #soxTremolo(item)
gyorgy@0 307 #mwVibrato(item)
gyorgy@0 308
gyorgy@0 309 #soxPan(item)
gyorgy@0 310 #mwReverb(item)
gyorgy@0 311 #mlabRobot(item)
gyorgy@0 312 #mlabWhisper(item)
gyorgy@0 313
gyorgy@0 314 #mwEnhancer(item)
gyorgy@0 315 #mwFlanger(item)
gyorgy@0 316 #mwGraindelay(item)
gyorgy@0 317
gyorgy@0 318 mwPitchUp(item)
gyorgy@0 319 ##mwPitchDown(item)
gyorgy@0 320
gyorgy@0 321
gyorgy@0 322
gyorgy@0 323
gyorgy@0 324
gyorgy@0 325
gyorgy@0 326
gyorgy@0 327
gyorgy@0 328