def execute(self, writeStream = True, fileOut = False): print(self.score.form) #melody melody_hz, melody = self.leadObj.convert(self.score.melodyLine) melody = self.fxObj.Set(melody, self.setting_preset["lead"]["presetName"], **self.setting_preset["lead"]["presetArgs"]) #melody2 melody2_hz, melody2 = self.lead2Obj.convert(self.score.melodyLine) melody2 = self.fxObj.Set(melody2, self.setting_preset["lead2"]["presetName"], **self.setting_preset["lead2"]["presetArgs"]) #subMelody subMelody_hz, subMelody = self.subLeadObj.convert(self.score.melodyLine2) subMelody = self.fxObj.Set(subMelody, self.setting_preset["subLead"]["presetName"], **self.setting_preset["subLead"]["presetArgs"]) #bass bass_hz, bass = self.bassObj.convert(self.score.bassLine) bass = self.fxObj.Set(bass, self.setting_preset["bass"]["presetName"], **self.setting_preset["bass"]["presetArgs"]) #bass2 bass2_hz, bass2 = self.bass2Obj.convert(self.score.bassLine) bass2 = self.fxObj.Set(bass2, self.setting_preset["bass2"]["presetName"], **self.setting_preset["bass2"]["presetArgs"]) #voicing voicing_hz, voicing = self.voiceObj.convertPoly(self.score.voiceProg) voicing = self.fxObj.Set(voicing, self.setting_preset["voice"]["presetName"], **self.setting_preset["voice"]["presetArgs"]) #voicing2 voicing2_hz, voicing2 = self.voice2Obj.convertPoly(self.score.voiceProg) voicing2 = self.fxObj.Set(voicing2, self.setting_preset["voice2"]["presetName"], **self.setting_preset["voice2"]["presetArgs"]) #kick kick_hz, kick = self.kickObj.convertPerc(self.score.drumObj.kick, self.setting_asyn["kick"]["constHz"]) kick = self.fxObj.Set(kick, self.setting_preset["kick"]["presetName"], **self.setting_preset["kick"]["presetArgs"]) #voicing2 = self.volCtrl.sidechain(voicing2, self.bpm, kick_hz) #melody = self.volCtrl.fourBeat(melody, self.bpm, 0.0, 2.0) #Kick2 kick2_hz, kick2 = self.kick2Obj.convert(self.score.drumObj.kick) kick2 = self.fxObj.Set(kick2, self.setting_preset["kick2"]["presetName"], **self.setting_preset["kick2"]["presetArgs"]) #snare snare_hz, snare = self.snareObj.convertPerc(self.score.drumObj.snare, self.setting_asyn["snare"]["constHz"]) snare = self.fxObj.Set(snare, self.setting_preset["snare"]["presetName"], **self.setting_preset["snare"]["presetArgs"]) #snare2 snare2_hz, snare2 = self.snare2Obj.convert(self.score.drumObj.snare) snare2 = self.fxObj.Set(snare2, self.setting_preset["snare2"]["presetName"], **self.setting_preset["snare2"]["presetArgs"]) #hihat hihat_hz, hihat = self.hihatObj.convertPerc(self.score.drumObj.hihat, self.setting_asyn["hihat"]["constHz"]) hihat = self.fxObj.Set(hihat, self.setting_preset["hihat"]["presetName"], **self.setting_preset["hihat"]["presetArgs"]) #hihat2 hihat2_hz, hihat2 = self.hihat2Obj.convert(self.score.drumObj.hihat) hihat2 = self.fxObj.Set(hihat2, self.setting_preset["hihat2"]["presetName"], **self.setting_preset["hihat2"]["presetArgs"]) #fx1 fx1_hz, fx1 = self.fx1Obj.convert(self.score.effectsObj.pt1) fx1 = self.fxObj.Set(fx1, self.setting_preset["fx1"]["presetName"], **self.setting_preset["fx1"]["presetArgs"]) #fx2 fx2_hz, fx2 = self.fx2Obj.convert(self.score.effectsObj.pt2) fx2 = self.fxObj.Set(fx2, self.setting_preset["fx2"]["presetName"], **self.setting_preset["fx2"]["presetArgs"]) #fx3 fx3_hz, fx3 = self.fx3Obj.convert(self.score.effectsObj.pt3) fx3 = self.fxObj.Set(fx3, self.setting_preset["fx3"]["presetName"], **self.setting_preset["fx3"]["presetArgs"]) #fx4 fx4_hz, fx4 = self.fx4Obj.convert(self.score.effectsObj.pt4) fx4 = self.fxObj.Set(fx4, self.setting_preset["fx4"]["presetName"], **self.setting_preset["fx4"]["presetArgs"]) # bass = self.volCtrl.sidechain(bass, self.bpm, kick_hz) #bass = self.volCtrl.feedIn2(bass, self.bpm, [self.score.form[3], self.score.form[5]-16 ], [self.score.form[5]-16, self.score.form[5]] , [0.3, 0.99]) bass2 = self.volCtrl.sidechain(bass2, self.bpm, kick_hz) #bass2 = self.volCtrl.feedIn2(bass2, self.bpm, [self.score.form[3], self.score.form[5]-16 ], [self.score.form[5]-16, self.score.form[5]], [0.3, 0.99]) """ 長さ確認 """ print("melody : ", len(melody), len(self.score.melodyLine)) print("melody2 : ", len(melody2)) print("subMelody : ", len(subMelody)) print("bass : ", len(bass), len(self.score.bassLine)) print("bass2 : ", len(bass2)) print("voicing : ", len(voicing)) print("voicing2 : ", len(voicing2)) print("kick : ", len(kick ), len(self.score.drumObj.kick)) print("kick2 : ", len(kick2)) print("snare : ", len(snare)) print("snare2 : ", len(snare2)) print("hihat : ", len(hihat)) print("hihat2 : ", len(hihat2)) print("fx1 : ", len(fx1)) print("fx2 : ", len(fx2)) print("fx3 : ", len(fx3)) print("fx4 : ", len(fx4)) #bass:merge bass = func.add_stereo([bass, bass2], [self.volume["bass"]["bass"], self.volume["bass"]["bass2"]]) bass = self.filCtrl.lowfi_stereo(bass, self.bpm, [self.score.form[1]], [self.score.form[3]] ,'bandpass' ,[[1000,5000]]) bass = self.volCtrl.feedIn_stereo(bass, self.bpm, [self.score.form[3], self.score.form[5]-16 ], [self.score.form[5]-16, self.score.form[5]], ['liner','tanh'], [0.3, 0.99]) #harm : merge harm = func.add_stereo([voicing, voicing2, melody, melody2, subMelody], \ [ self.volume["harm"]["voicing"], self.volume["harm"]["voicing2"], self.volume["harm"]["melody"], self.volume["harm"]["melody2"], self.volume["harm"]["subMelody"] ]) #harm = self.volCtrl.ending(harm , 15) harm = self.filCtrl.lowfi_stereo(harm, self.bpm, [self.score.form[1]], [self.score.form[4]] ,'bandpass' ,[[400,4000]]) harm = self.volCtrl.fourBeat_stereo(harm, self.bpm, [self.score.form[5]], [self.score.form[8]], [0.0], [3.0]) #harm = self.volCtrl.feedIn_stereo(harm, self.bpm, [self.score.form[3], self.score.form[5]-16 ], [self.score.form[5]-16, self.score.form[5]], ['liner','tanh'], [0.3, 0.99]) #snare = self.volCtrl.feedIn2(snare, self.bpm, [self.score.form[2], self.score.form[3]-16 ], [self.score.form[3]-16, self.score.form[3]] , [0.3, 0.99]) #snare2 = self.volCtrl.feedIn2(snare2, self.bpm, [self.score.form[2], self.score.form[3]-16 ], [self.score.form[3]-16, self.score.form[3]] , [0.3, 0.99]) #drums : merge drums = func.add_stereo([kick, kick2, snare, snare2, hihat, hihat2], \ [ self.volume["drums"]["kick"], self.volume["drums"]["kick2"], self.volume["drums"]["snare"], self.volume["drums"]["snare2"], self.volume["drums"]["hihat"], self.volume["drums"]["hihat2"] ]) #drums = self.volCtrl.ending(drums , 15) drums = self.volCtrl.feedIn_stereo(drums, self.bpm, [self.score.form[3], self.score.form[5]-16, self.score.form[7]], [self.score.form[5]-16, self.score.form[5], self.score.form[8]], ['liner','tanh','tanh'], [0.3, 0.99, 0.2]) drums = self.filCtrl.lowfi_stereo(drums, self.bpm, [self.score.form[1]], [self.score.form[3]] ,'bandpass' ,[[3000,10000]]) #fx : merge fx = func.add_stereo([fx1, fx2, fx3, fx4], \ [ self.volume["fx"]["fx1"], self.volume["fx"]["fx2"], self.volume["fx"]["fx3"], self.volume["fx"]["fx4"] ]) fx = self.volCtrl.feedIn_stereo(fx, self.bpm, [self.score.form[3], self.score.form[5]-16 ], [self.score.form[5]-16, self.score.form[5]], ['liner','liner'], [0.6, 0.99]) #all : merge wave = func.add([harm, bass, drums, fx], \ [ self.volume["master"]["harm"], self.volume["master"]["bass"], self.volume["master"]["drums"], self.volume["master"]["fx"] ]) #To Binary wave_bin = func.toBytes(wave) if writeStream: import pyaudio self.format = pyaudio.paInt32 self.o = self.audio.open(format=self.format, channels=self.channels, rate=self.rate, output=True) self.o.write(wave_bin) if fileOut: dt = datetime.now().strftime("%Y%m%d_%H%M%S") fileName = self.scoreName + '_' + self.settingName + '_' + str(self.bpm) + '__' + dt + '.wav' waveFile = wv.open(self.outputDir + fileName , 'wb') waveFile.setnchannels(self.channels) waveFile.setsampwidth(self.sampwidth) waveFile.setframerate(self.rate) waveFile.writeframes(wave_bin) waveFile.close()
def execute(self, writeStream=True, fileOut=False): melody = self.leadObj.convert(self.score.melodyLine) melody = self.dist.hardClipping(melody, 10) melody = self.comp.sigmoid(melody, 1) melody = self.delay.reverb(melody, 0.9) melody2 = self.lead2Obj.convert(self.score.melodyLine) melody2 = self.dist.hardClipping(melody2, 9) bass = self.bassObj.convert(self.score.bassLine) bass = self.dist.hardClipping(bass, 3) bass = self.comp.sigmoid(bass, 3) #voicing2 = self.voice2Obj.convert(self.score.drumObj.kick) voicing = self.voiceObj.convertPoly(self.score.voiceProg) voicing = self.dist.hardClipping(voicing, 1) bass = self.comp.sigmoid(bass, 1) kick = self.kickObj.convert(self.score.drumObj.kick) #convertPerc(50) kick = self.dist.hardClipping(kick, 0.2) #kick = self.delay.delay(kick) kick = self.amp.maxStd(kick) #kick = self.comp.sigmoid(kick,5) kick2 = self.kick2Obj.convert(self.score.drumObj.kick) #snare = self.snareObj.convertPerc(self.score.drumObj.snare, 40) #snare = self.dist.hardClipping(snare,0.1) #snare = self.amp.maxStd(snare) snare = self.snareObj.convert(self.score.drumObj.snare) snare2 = self.snare2Obj.convert(self.score.drumObj.snare) fx1 = self.fx1Obj.convert(self.score.effectsObj.pt1) fx1 = self.dist.hardClipping(fx1, 4) fx1 = self.delay.reverb(fx1, 0.8) fx4 = self.fx4Obj.convert(self.score.effectsObj.pt4) fx4 = self.dist.hardClipping(fx4, 4) fx4 = self.delay.reverb(fx4, 0.8) hihat = self.hihatObj.convertPerc(self.score.drumObj.hihat, 800) hihat2 = self.hihat2Obj.convert(self.score.drumObj.hihat) drums = func.add([kick, kick2, fx1, snare, snare2, fx4, hihat, hihat2], [4.0, 4.0, 1.0, 1.0 / 2, 2.0, 1.0, 4.0, 4.0]) #drums = self.amp.threeSigma(drums, 10) #drums = self.dist.hardClipping(drums,0.4) drums = self.comp.sigmoid(drums, 2) #drums = self.amp.threeSigma(drums,10) drums = self.delay.reverb(drums, 0.3) drums = self.comp.sigmoid(drums, 1) #drums = self.vcf(drums, aSynthe.FilterName.bandpass, [1,800]) #wave = drums wave = func.add([drums, bass, voicing, melody, melody2], [30.0, 4.0, 5.0, 12, 3.5]) wave_bin = func.toBytes(wave) if writeStream: self.o.write(wave_bin) if fileOut: dt = datetime.now().strftime("%Y%m%d_%H%M%S") fileName = self.scoreName + '_' + str( self.bpm) + '__' + dt + '.wav' waveFile = wv.open(self.outputDir + fileName, 'wb') waveFile.setnchannels(self.channels) waveFile.setsampwidth(self.sampwidth) waveFile.setframerate(self.rate) waveFile.writeframes(wave_bin) waveFile.close()
def execute(self, writeStream=True, fileOut=False): melody = self.leadObj.convert(self.score.melodyLine) melody = self.dist.hardClipping(melody, 10) melody = self.comp.sigmoid(melody, 1) melody = self.delay.reverb(melody, 0.9) melody2 = self.lead2Obj.convert(self.score.melodyLine) melody2 = self.dist.hardClipping(melody2, 9) melody2 = self.tre.am(melody2, 0.4, 1 / (60.0 / self.bpm)) bass = self.bassObj.convert(self.score.bassLine) bass = self.dist.hardClipping(bass, 3) bass = self.comp.sigmoid(bass, 3) bass = func.add([self.vib.sine(bass, depth=1.0 / 2, freq=0.3), bass], [1.0, 1.0]) voicing = self.voiceObj.convertPoly(self.score.voiceProg) voicing = self.dist.hardClipping(voicing, 2) voicing = func.add( [self.vib.sine(voicing, depth=3, freq=0.1), voicing], [1.0, 1.0]) kick = self.kickObj.convertPerc(self.score.drumObj.kick, 50) kick = self.dist.hardClipping(kick, 0.2) #kick = self.delay.delay(kick) kick = self.amp.maxStd(kick) #kick = self.comp.sigmoid(kick,5) kick2 = self.kick2Obj.convert(self.score.drumObj.kick) #snare = self.snareObj.convertPerc(self.score.drumObj.snare, 40) #snare = self.dist.hardClipping(snare,0.1) #snare = self.amp.maxStd(snare) snare = self.snareObj.convertPerc(self.score.drumObj.snare, 40) snare2 = self.snare2Obj.convert(self.score.drumObj.snare) hihat = self.hihatObj.convertPerc(self.score.drumObj.hihat, 800) hihat2 = self.hihat2Obj.convert(self.score.drumObj.hihat) fx1 = self.fx1Obj.convert(self.score.effectsObj.pt1) fx1 = self.dist.hardClipping(fx1, 4) fx1 = self.delay.reverb(fx1, 0.8) fx2 = self.fx2Obj.convert(self.score.effectsObj.pt2) fx3 = self.fx3Obj.convert(self.score.effectsObj.pt3) fx3 = self.dist.hardClipping(fx3, 4) fx3 = self.delay.reverb(fx3, 0.8) #fx4 = self.fx4Obj.convert(self.score.effectsObj.pt4) harm = func.add([bass, voicing, melody, melody2], [1.25, 1.5, 4.5, 1.0]) #harm = func.add([self.vib.sine(harm, depth = 1, freq = 0.3), harm], [1.0, 1.0]) harm = self.volCtrl.ending(harm, 15) drums = func.add([kick, kick2, snare, snare2, hihat, hihat2], [2.0, 5.0, 1.0, 3.0, 1.0, 2.0]) drums = self.comp.sigmoid(drums, 2) drums = self.delay.reverb(drums, 0.5) drums = self.comp.sigmoid(drums, 1) drums = self.volCtrl.ending(drums, 15) fx = func.add([fx1, fx2, fx3], [1.0, 1.0, 1.0]) fx = self.tre.am(fx, 0.3, 0.5) wave = func.add([harm, drums, fx], [2, 2.2, 2]) #wave = self.vib.sine(wave, depth = 4, freq = 0.8) #wave_vib = self.vib.sine(wave, 0.5, 0.4) #wave = func.add([wave, wave_vib], [1, 1]) wave_bin = func.toBytes(wave) if writeStream: self.o.write(wave_bin) if fileOut: dt = datetime.now().strftime("%Y%m%d_%H%M%S") fileName = self.scoreName + '_' + str( self.bpm) + '__' + dt + '.wav' waveFile = wv.open(self.outputDir + fileName, 'wb') waveFile.setnchannels(self.channels) waveFile.setsampwidth(self.sampwidth) waveFile.setframerate(self.rate) waveFile.writeframes(wave_bin) waveFile.close()
def execute(self, writeStream=True, fileOut=False): #melody #melody_hz, melody = self.leadObj.convert(self.score.melodyLine) #melody = self.fxObj.Set(melody, self.setting_preset["lead"]["presetName"], **self.setting_preset["lead"]["presetArgs"]) #melody2 #melody2_hz, melody2 = self.lead2Obj.convert(self.score.melodyLine) #melody2 = self.fxObj.Set(melody2, self.setting_preset["lead2"]["presetName"], **self.setting_preset["lead2"]["presetArgs"]) #bass bass_hz, bass = self.bassObj.convert(self.score.bassLine) bass = self.fxObj.Set(bass, self.setting_preset["bass"]["presetName"], **self.setting_preset["bass"]["presetArgs"]) #bass2 #bass2_hz, bass2 = self.bass2Obj.convert(self.score.bassLine) #bass2 = self.fxObj.Set(bass2, self.setting_preset["bass2"]["presetName"], **self.setting_preset["bass2"]["presetArgs"]) #voicing #voicing_hz, voicing = self.voiceObj.convertPoly(self.score.voiceProg) #voicing = self.fxObj.Set(voicing, self.setting_preset["voice"]["presetName"], **self.setting_preset["voice"]["presetArgs"]) #voicing2 #voicing2_hz, voicing2 = self.voice2Obj.convertPoly(self.score.voiceProg) #voicing2 = self.fxObj.Set(voicing2, self.setting_preset["voice2"]["presetName"], **self.setting_preset["voice2"]["presetArgs"]) #kick kick_hz, kick = self.kickObj.convertPerc( self.score.drumObj.kick, self.setting_asyn["kick"]["constHz"]) kick = self.fxObj.Set(kick, self.setting_preset["kick"]["presetName"], **self.setting_preset["kick"]["presetArgs"]) #bass = self.volCtrl.sidechain(bass, self.bpm, kick_hz) #Kick2 #kick2_hz, kick2 = self.kick2Obj.convert(self.score.drumObj.kick) #kick2 = self.fxObj.Set(kick2, self.setting_preset["kick2"]["presetName"], **self.setting_preset["kick2"]["presetArgs"]) #snare snare_hz, snare = self.snareObj.convertPerc( self.score.drumObj.snare, self.setting_asyn["snare"]["constHz"]) snare = self.fxObj.Set(snare, self.setting_preset["snare"]["presetName"], **self.setting_preset["snare"]["presetArgs"]) #snare2 #snare2_hz, snare2 = self.snare2Obj.convert(self.score.drumObj.snare) #snare2 = self.fxObj.Set(snare2, self.setting_preset["snare2"]["presetName"], **self.setting_preset["snare2"]["presetArgs"]) #hihat hihat_hz, hihat = self.hihatObj.convertPerc( self.score.drumObj.hihat, self.setting_asyn["hihat"]["constHz"]) hihat = self.fxObj.Set(hihat, self.setting_preset["hihat"]["presetName"], **self.setting_preset["hihat"]["presetArgs"]) #hihat2 #hihat2_hz, hihat2 = self.hihat2Obj.convert(self.score.drumObj.hihat) #hihat2 = self.fxObj.Set(hihat2, self.setting_preset["hihat2"]["presetName"], **self.setting_preset["hihat2"]["presetArgs"]) #fx1 #fx1_hz, fx1 = self.fx1Obj.convert(self.score.effectsObj.pt1) #fx1 = self.fxObj.Set(fx1, self.setting_preset["fx1"]["presetName"], **self.setting_preset["fx1"]["presetArgs"]) #fx2 #fx2_hz, fx2 = self.fx2Obj.convert(self.score.effectsObj.pt2) #fx2 = self.fxObj.Set(fx1, self.setting_preset["fx2"]["presetName"], **self.setting_preset["fx2"]["presetArgs"]) #fx3 #fx3_hz, fx3 = self.fx3Obj.convert(self.score.effectsObj.pt3) #fx3 = self.fxObj.Set(fx3, self.setting_preset["fx3"]["presetName"], **self.setting_preset["fx3"]["presetArgs"]) #fx4 #fx4_hz, fx4 = self.fx4Obj.convert(self.score.effectsObj.pt4) #fx4 = self.fxObj.Set(fx4, self.setting_preset["fx4"]["presetName"], **self.setting_preset["fx4"]["presetArgs"]) #harm : merge """ harm = func.add_stereo([bass, bass2, voicing, voicing2, melody, melody2], \ [ self.volume["harm"]["bass"], self.volume["harm"]["bass2"], self.volume["harm"]["voicing"], self.volume["harm"]["voicing2"], self.volume["harm"]["melody"], self.volume["harm"]["melody2"] ]) #harm = self.volCtrl.ending(harm , 15) """ #drums : merge """ drums = func.add_stereo([kick, kick2, snare, snare2, hihat, hihat2], \ [ self.volume["drums"]["kick"], self.volume["drums"]["kick2"], self.volume["drums"]["snare"], self.volume["drums"]["snare2"], self.volume["drums"]["hihat"], self.volume["drums"]["hihat2"] ]) #drums = self.volCtrl.ending(drums , 15) """ drums = func.add_stereo([kick, snare, hihat], \ [ self.volume["drums"]["kick"], self.volume["drums"]["snare"], self.volume["drums"]["hihat"] ]) #fx : merge """ fx = func.add_stereo([fx1, fx2, fx3, fx4], \ [ self.volume["fx"]["fx1"], self.volume["fx"]["fx2"], self.volume["fx"]["fx3"], self.volume["fx"]["fx4"] ]) #fx = self.fxObj.Set(fx, "tremolo", **{"depth":2.0}) #もしかしたら利きすぎかもしれない """ #all : merge """ wave = func.add([harm, drums, fx], \ [ self.volume["master"]["harm"], self.volume["master"]["drums"], self.volume["master"]["fx"] ]) """ wave = func.add([drums, bass], [1, 1]) #To Binary wave_bin = func.toBytes(wave) if writeStream: self.o.write(wave_bin) if fileOut: dt = datetime.now().strftime("%Y%m%d_%H%M%S") fileName = self.scoreName + '_' + str( self.bpm) + '__' + dt + '.wav' waveFile = wv.open(self.outputDir + fileName, 'wb') waveFile.setnchannels(self.channels) waveFile.setsampwidth(self.sampwidth) waveFile.setframerate(self.rate) waveFile.writeframes(wave_bin) waveFile.close()