class SoundFileObject: def __init__(self, id, filename, loopmode=0, transpo=1, gain=0, playing=0, directout=True, startpoint=0, endpoint=-1, crossfade=5, channel=0): interpTime = QLiveLib.getVar("globalInterpTime") self.id = id self.filename = filename sndfolder = os.path.join(QLiveLib.getVar("projectFolder"), "sounds") info = sndinfo(os.path.join(sndfolder, self.filename)) if info is None: self.valid = False self.duration = -1 self.sndchnls = -1 else: self.valid = True self.duration = info[1] self.sndchnls = info[3] self.loopmode = loopmode self.transpo = transpo self.gain = gain self.playing = playing self.directout = directout self.startpoint = startpoint self.endpoint = self.duration self.crossfade = crossfade self.channel = channel self.transpox = interpTime self.gainx = interpTime self.transpoDict = None self.gainDict = None self.showInterp = 0 self.playerRef = None self.transpoAutoWindow = None self.gainAutoWindow = None self.cues = {} self.copied = {} currentCue = QLiveLib.getVar("CuesPanel").getCurrentCue() self.addCue(0) self.addCue(currentCue) def setPlayerRef(self, obj): if obj is None: self.playerRef = None else: self.playerRef = weakref.ref(obj) def openTranspoAutomationWindow(self): parent = QLiveLib.getVar("MainWindow") title = "Transpo Automations on Soundfile %d" % (self.id+1) self.transpoAutoWindow = AutomationWindow(parent, title, self, self.closeTranspoWindow, self.setAutoTranspo) if self.transpoDict is not None: self.transpoAutoWindow.setAttributes(self.transpoDict) def closeTranspoWindow(self): self.transpoAutoWindow = None def openGainAutomationWindow(self): parent = QLiveLib.getVar("MainWindow") title = "Gain Automations on Soundfile %d" % (self.id+1) self.gainAutoWindow = AutomationWindow(parent, title, self, self.closeGainWindow, self.setGainTranspo) if self.gainDict is not None: self.gainAutoWindow.setAttributes(self.gainDict) def closeGainWindow(self): self.gainAutoWindow = None def setShowInterp(self, x): self.showInterp = x def getShowInterp(self): return self.showInterp def getAttributes(self): if self.transpoAutoWindow is not None: transpoDict = self.transpoAutoWindow.getAttributes() else: if self.transpoDict is not None: transpoDict = self.transpoDict else: transpoDict = None if self.gainAutoWindow is not None: gainDict = self.gainAutoWindow.getAttributes() else: if self.gainDict is not None: gainDict = self.gainDict else: gainDict = None return copy.deepcopy({ ID_COL_FILENAME: self.filename, ID_COL_LOOPMODE: self.loopmode, ID_COL_TRANSPO: self.transpo, ID_COL_GAIN: self.gain, ID_COL_PLAYING: self.playing, ID_COL_DIRECTOUT: self.directout, ID_COL_STARTPOINT: self.startpoint, ID_COL_ENDPOINT: self.endpoint, ID_COL_CROSSFADE: self.crossfade, ID_COL_CHANNEL: self.channel, ID_COL_TRANSPOX: self.transpox, ID_COL_GAINX: self.gainx, ID_TRANSPO_AUTO: transpoDict, ID_GAIN_AUTO: gainDict }) def setAttributes(self, dict): interpTime = QLiveLib.getVar("globalInterpTime") dict = copy.deepcopy(dict) self.filename = dict[ID_COL_FILENAME] self.loopmode = dict[ID_COL_LOOPMODE] self.transpo = dict[ID_COL_TRANSPO] self.gain = dict[ID_COL_GAIN] self.playing = dict[ID_COL_PLAYING] self.directout = dict[ID_COL_DIRECTOUT] self.startpoint = dict[ID_COL_STARTPOINT] self.endpoint = dict[ID_COL_ENDPOINT] self.crossfade = dict[ID_COL_CROSSFADE] self.channel = dict[ID_COL_CHANNEL] self.transpox = dict.get(ID_COL_TRANSPOX, interpTime) self.gainx = dict.get(ID_COL_GAINX, interpTime) self.transpoDict = dict.get(ID_TRANSPO_AUTO, None) self.gainDict = dict.get(ID_GAIN_AUTO, None) if self.transpoDict is not None: if self.transpoAutoWindow is not None: self.transpoAutoWindow.setAttributes(self.transpoDict) if self.gainDict is not None: if self.gainAutoWindow is not None: self.gainAutoWindow.setAttributes(self.gainDict) def copy(self, obj): self.setAttributes(copy.deepcopy(obj.getAttributes())) self.currentCue = obj.getCurrentCue() self.setCues(copy.deepcopy(obj.getCues())) def setCurrentCue(self, x): self.currentCue = x def getCurrentCue(self): return self.currentCue def loadCue(self, x): if x in self.cues: self.setAttributes(self.cues[x]) else: c = x while (c >= 0): if c in self.cues: self.setAttributes(self.cues[c]) break c -= 1 self.currentCue = x if self.playerRef is not None: player = self.playerRef() player.setAttributes(self.getAttributes()) def delCue(self, x): del self.cues[x] for i in range(x+1, len(self.cues)): if i in self.cues: self.cues[i-1] = self.cues[i] del self.cues[i] def saveCue(self): self.cues[self.currentCue] = self.getAttributes() def addCue(self, x): self.currentCue = x self.saveCue() def copyCue(self): self.copied = self.getAttributes() def pasteCue(self): self.cues[self.currentCue] = copy.deepcopy(self.copied) self.setAttributes(self.cues[self.currentCue]) if self.playerRef is not None: player = self.playerRef() player.setAttributes(self.getAttributes()) def getCues(self): return self.cues def setCues(self, cues): self.cues = cues def setGlobalInterpTime(self, value, allcues, meth): if allcues: if meth == 0: for key in self.cues.keys(): self.cues[key][ID_COL_TRANSPOX] = value self.cues[key][ID_COL_GAINX] = value elif meth == 1: for key in self.cues.keys(): tr = self.cues[key][ID_COL_TRANSPOX] gain = self.cues[key][ID_COL_GAINX] tr += value if tr > INTERPTIME_MAX: tr = INTERPTIME_MAX gain += value if gain > INTERPTIME_MAX: gain = INTERPTIME_MAX self.cues[key][ID_COL_TRANSPOX] = tr self.cues[key][ID_COL_GAINX] = gain elif meth == 2: for key in self.cues.keys(): tr = self.cues[key][ID_COL_TRANSPOX] gain = self.cues[key][ID_COL_GAINX] tr -= value if tr < INTERPTIME_MIN: tr = INTERPTIME_MIN gain -= value if gain < INTERPTIME_MIN: gain = INTERPTIME_MIN self.cues[key][ID_COL_TRANSPOX] = tr self.cues[key][ID_COL_GAINX] = gain else: if meth == 0: self.cues[self.currentCue][ID_COL_TRANSPOX] = value self.cues[self.currentCue][ID_COL_GAINX] = value elif meth == 1: tr = self.cues[self.currentCue][ID_COL_TRANSPOX] gain = self.cues[self.currentCue][ID_COL_GAINX] tr += value if tr > INTERPTIME_MAX: tr = INTERPTIME_MAX gain += value if gain > INTERPTIME_MAX: gain = INTERPTIME_MAX self.cues[self.currentCue][ID_COL_TRANSPOX] = tr self.cues[self.currentCue][ID_COL_GAINX] = gain elif meth == 2: tr = self.cues[self.currentCue][ID_COL_TRANSPOX] gain = self.cues[self.currentCue][ID_COL_GAINX] tr -= value if tr < INTERPTIME_MIN: tr = INTERPTIME_MIN gain -= value if gain < INTERPTIME_MIN: gain = INTERPTIME_MIN self.cues[self.currentCue][ID_COL_TRANSPOX] = tr self.cues[self.currentCue][ID_COL_GAINX] = gain self.transpox = self.cues[self.currentCue][ID_COL_TRANSPOX] self.gainx = self.cues[self.currentCue][ID_COL_GAINX] def isValid(self): return self.valid def getChnls(self): return self.sndchnls def getId(self): return self.id def setId(self, x): self.id = x def setPlayerAttribute(self, id, value): if self.playerRef is not None: player = self.playerRef() player.setAttribute(id, value) def getFilename(self): return self.filename def setLoopMode(self, x): self.loopmode = x self.setPlayerAttribute(ID_COL_LOOPMODE, x) def getTranspo(self): return self.transpo def setTranspo(self, x): self.transpo = x self.setPlayerAttribute(ID_COL_TRANSPO, x) def getTranspox(self): return self.transpox def setTranspox(self, x): self.transpox = x self.setPlayerAttribute(ID_COL_TRANSPOX, x) def getGain(self): return self.gain def setGain(self, x): self.gain = x self.setPlayerAttribute(ID_COL_GAIN, x) def getGainx(self): return self.gainx def setGainx(self, x): self.gainx = x self.setPlayerAttribute(ID_COL_GAINX, x) def getPlaying(self): return self.playing def setPlaying(self, x): self.playing = x self.setPlayerAttribute(ID_COL_PLAYING, x) def getDirectOut(self): return self.directout def setDirectOut(self, x): self.directout = x self.setPlayerAttribute(ID_COL_DIRECTOUT, x) def getStartPoint(self): return self.startpoint def setStartPoint(self, x): self.startpoint = x self.setPlayerAttribute(ID_COL_STARTPOINT, x) def getEndPoint(self): return self.endpoint def setEndPoint(self, x): self.endpoint = x self.setPlayerAttribute(ID_COL_ENDPOINT, x) def getCrossfade(self): return self.crossfade def setCrossfade(self, x): self.crossfade = x self.setPlayerAttribute(ID_COL_CROSSFADE, x) def getDuration(self): return self.duration def setChannel(self, x): self.channel = x self.setPlayerAttribute(ID_COL_CHANNEL, x) def getChannel(self): return self.channel def setAutoTranspo(self, dict): self.setPlayerAttribute(ID_TRANSPO_AUTO, dict) def setGainTranspo(self, dict): self.setPlayerAttribute(ID_GAIN_AUTO, dict)
class SliderWidget(wx.Panel): def __init__(self, parent, parameters, fxbox): wx.Panel.__init__(self, parent) self.SetBackgroundColour(BACKGROUND_COLOUR) interpTime = QLiveLib.getVar("globalInterpTime") self.fromUser = False self.midiscanning = False self.parameters = parameters self.fxbox = fxbox self.name = parameters[0] self.sizer = wx.BoxSizer(wx.VERTICAL) self.slider = QLiveControlKnob(self, parameters[2], parameters[3], parameters[1], label=parameters[0], log=parameters[5], outFunction=self.outputValue, editFunction=self.showAutomationWindow) self.sizer.Add(self.slider, 0, wx.ALL, 5) self.interpKnob = QLiveControlKnob( self, INTERPTIME_MIN, INTERPTIME_MAX, interpTime, label=parameters[0], log=True, outFunction=self.outputInterpValue, outOnShiftFunction=self.onChangeAllInterp, backColour=CONTROLSLIDER_BACK_COLOUR_INTERP) self.sizer.Add(self.interpKnob, 0, wx.ALL, 5) self.interpKnob.Hide() self.automationDict = None self.automationWindow = None self.SetSizer(self.sizer) def setEnable(self, state): self.slider.setEnable(state) self.interpKnob.setEnable(state) def revertMidiAssignation(self): self.midiscanning = False QLiveLib.getVar("MidiServer").ctlscan(None) self.slider.setMidiLearn(False) QLiveLib.getVar("MidiServer").unbind("ctls", self.slider.midictl, self.midi) self.slider.setMidiCtl(None) def handleMidiScan(self): if not self.midiscanning: self.midiscanning = True QLiveLib.getVar("MidiServer").ctlscan(self.getMidiScan) self.slider.setMidiLearn(True) else: self.midiscanning = False QLiveLib.getVar("MidiServer").ctlscan(None) self.slider.setMidiLearn(False) def getMidiScan(self, ctlnum, midichnl): self.assignMidiCtl(ctlnum) self.slider.setMidiLearn(False) def assignMidiCtl(self, ctlnum): interpTime = QLiveLib.getVar("globalInterpTime") self.slider.setMidiCtl(ctlnum) QLiveLib.getVar("MidiServer").bind("ctls", ctlnum, self.midi) self.setInterpValue(interpTime, True) def midi(self, value): v = rescale(value, 0, 127, self.parameters[2], self.parameters[3], ylog=self.parameters[5]) self.slider.SetValue(v, True) def getMidiBinding(self): return self.slider.midictl def setMidiBinding(self, ctlnum): if ctlnum is not None: self.assignMidiCtl(ctlnum) def showAutomationWindow(self, state): parent = self.GetParent().GetParent() if state: title = "Automations on Parameter < %s >" % self.name self.automationWindow = AutomationWindow( parent, title, self, self.closeAutomationWindow, self.outputAutomationValues) if self.automationDict is not None: self.automationWindow.setAttributes(self.automationDict) else: if self.automationWindow: self.automationWindow.Destroy() self.automationWindow = None def closeAutomationWindow(self): self.automationWindow = None self.setShowEdit(0) def outputAutomationValues(self, dict): self.fxbox.setAutomationValues(self.name, dict) def getAutomationValues(self): if self.automationWindow is not None: automationDict = self.automationWindow.getAttributes() else: if self.automationDict is not None: automationDict = self.automationDict else: automationDict = None return automationDict def setAutomationValues(self, automationDict): self.automationDict = automationDict if self.automationDict is not None: self.outputAutomationValues(self.automationDict) if self.automationWindow is not None: self.automationWindow.setAttributes(self.automationDict) def setAutoPlay(self, state): self.slider.setAutoPlay(state) self.interpKnob.setAutoPlay(state) def setShowEdit(self, state): self.slider.setShowEdit(state) self.interpKnob.setShowEdit(state) def outputValue(self, value): self.fxbox.setParamValue(self.name, value, self.fromUser) self.fromUser = True def setValue(self, value, propagate=False): self.fromUser = False self.slider.SetValue(value, propagate) def getValue(self): return self.slider.GetValue() def outputInterpValue(self, value): self.fxbox.setInterpValue(self.name, value) def onChangeAllInterp(self, value): self.GetParent().GetParent().onChangeAllInterp(value) def setInterpValue(self, value, propagate=False): self.interpKnob.SetValue(value, propagate) def getInterpValue(self): return self.interpKnob.GetValue() def setShowMorph(self, bool): if bool: self.slider.Hide() self.interpKnob.Show() else: self.slider.Show() self.interpKnob.Hide() self.Layout()
class SoundFileObject: def __init__(self, id, filename, loopmode=0, transpo=1, gain=0, playing=0, directout=True, startpoint=0, endpoint=-1, crossfade=5, channel=0): interpTime = QLiveLib.getVar("globalInterpTime") self.id = id self.filename = filename sndfolder = os.path.join(QLiveLib.getVar("projectFolder"), "sounds") info = sndinfo(os.path.join(sndfolder, self.filename)) if info is None: self.valid = False self.duration = -1 self.sndchnls = -1 else: self.valid = True self.duration = info[1] self.sndchnls = info[3] self.loopmode = loopmode self.transpo = transpo self.gain = gain self.playing = playing self.directout = directout self.startpoint = startpoint self.endpoint = self.duration self.crossfade = crossfade self.channel = channel self.transpox = interpTime self.gainx = interpTime self.transpoDict = None self.gainDict = None self.showInterp = 0 self.playerRef = None self.transpoAutoWindow = None self.gainAutoWindow = None self.cues = {} self.copied = {} currentCue = QLiveLib.getVar("CuesPanel").getCurrentCue() self.addCue(0) self.addCue(currentCue) def setPlayerRef(self, obj): if obj is None: self.playerRef = None else: self.playerRef = weakref.ref(obj) def openTranspoAutomationWindow(self): parent = QLiveLib.getVar("MainWindow") title = "Transpo Automations on Soundfile %d" % (self.id + 1) self.transpoAutoWindow = AutomationWindow(parent, title, self, self.closeTranspoWindow, self.setAutoTranspo) if self.transpoDict is not None: self.transpoAutoWindow.setAttributes(self.transpoDict) def closeTranspoWindow(self): self.transpoAutoWindow = None def openGainAutomationWindow(self): parent = QLiveLib.getVar("MainWindow") title = "Gain Automations on Soundfile %d" % (self.id + 1) self.gainAutoWindow = AutomationWindow(parent, title, self, self.closeGainWindow, self.setAutoGain) if self.gainDict is not None: self.gainAutoWindow.setAttributes(self.gainDict) def closeGainWindow(self): self.gainAutoWindow = None def setShowInterp(self, x): self.showInterp = x def getShowInterp(self): return self.showInterp def getAttributes(self): if self.transpoAutoWindow is not None: transpoDict = self.transpoAutoWindow.getAttributes() else: if self.transpoDict is not None: transpoDict = self.transpoDict else: transpoDict = None if self.gainAutoWindow is not None: gainDict = self.gainAutoWindow.getAttributes() else: if self.gainDict is not None: gainDict = self.gainDict else: gainDict = None return copy.deepcopy({ ID_COL_FILENAME: self.filename, ID_COL_LOOPMODE: self.loopmode, ID_COL_TRANSPO: self.transpo, ID_COL_GAIN: self.gain, ID_COL_PLAYING: self.playing, ID_COL_DIRECTOUT: self.directout, ID_COL_STARTPOINT: self.startpoint, ID_COL_ENDPOINT: self.endpoint, ID_COL_CROSSFADE: self.crossfade, ID_COL_CHANNEL: self.channel, ID_COL_TRANSPOX: self.transpox, ID_COL_GAINX: self.gainx, ID_TRANSPO_AUTO: transpoDict, ID_GAIN_AUTO: gainDict }) def setAttributes(self, dict): interpTime = QLiveLib.getVar("globalInterpTime") dict = copy.deepcopy(dict) self.filename = dict[ID_COL_FILENAME] self.loopmode = dict[ID_COL_LOOPMODE] self.transpo = dict[ID_COL_TRANSPO] self.gain = dict[ID_COL_GAIN] self.playing = dict[ID_COL_PLAYING] self.directout = dict[ID_COL_DIRECTOUT] self.startpoint = dict[ID_COL_STARTPOINT] self.endpoint = dict[ID_COL_ENDPOINT] self.crossfade = dict[ID_COL_CROSSFADE] self.channel = dict[ID_COL_CHANNEL] self.transpox = dict.get(ID_COL_TRANSPOX, interpTime) self.gainx = dict.get(ID_COL_GAINX, interpTime) self.transpoDict = dict.get(ID_TRANSPO_AUTO, None) self.gainDict = dict.get(ID_GAIN_AUTO, None) if self.transpoDict is not None: if self.transpoAutoWindow is not None: self.transpoAutoWindow.setAttributes(self.transpoDict) if self.gainDict is not None: if self.gainAutoWindow is not None: self.gainAutoWindow.setAttributes(self.gainDict) def copy(self, obj): self.setAttributes(copy.deepcopy(obj.getAttributes())) self.currentCue = obj.getCurrentCue() self.setCues(copy.deepcopy(obj.getCues())) def setCurrentCue(self, x): self.currentCue = x def getCurrentCue(self): return self.currentCue def loadCue(self, x): if x in self.cues: self.setAttributes(self.cues[x]) else: c = x while (c >= 0): if c in self.cues: self.setAttributes(self.cues[c]) break c -= 1 self.currentCue = x if self.playerRef is not None: player = self.playerRef() player.setAttributes(self.getAttributes()) def delCue(self, x): del self.cues[x] for i in range(x + 1, len(self.cues)): if i in self.cues: self.cues[i - 1] = self.cues[i] del self.cues[i] def saveCue(self): self.cues[self.currentCue] = self.getAttributes() def addCue(self, x): self.currentCue = x self.saveCue() def copyCue(self): self.copied = self.getAttributes() def pasteCue(self): self.cues[self.currentCue] = copy.deepcopy(self.copied) self.setAttributes(self.cues[self.currentCue]) if self.playerRef is not None: player = self.playerRef() player.setAttributes(self.getAttributes()) def getCues(self): return self.cues def setCues(self, cues): self.cues = cues def setGlobalInterpTime(self, value, allcues, meth): if allcues: if meth == 0: for key in self.cues.keys(): self.cues[key][ID_COL_TRANSPOX] = value self.cues[key][ID_COL_GAINX] = value elif meth == 1: for key in self.cues.keys(): tr = self.cues[key][ID_COL_TRANSPOX] gain = self.cues[key][ID_COL_GAINX] tr += value if tr > INTERPTIME_MAX: tr = INTERPTIME_MAX gain += value if gain > INTERPTIME_MAX: gain = INTERPTIME_MAX self.cues[key][ID_COL_TRANSPOX] = tr self.cues[key][ID_COL_GAINX] = gain elif meth == 2: for key in self.cues.keys(): tr = self.cues[key][ID_COL_TRANSPOX] gain = self.cues[key][ID_COL_GAINX] tr -= value if tr < INTERPTIME_MIN: tr = INTERPTIME_MIN gain -= value if gain < INTERPTIME_MIN: gain = INTERPTIME_MIN self.cues[key][ID_COL_TRANSPOX] = tr self.cues[key][ID_COL_GAINX] = gain else: if meth == 0: self.cues[self.currentCue][ID_COL_TRANSPOX] = value self.cues[self.currentCue][ID_COL_GAINX] = value elif meth == 1: tr = self.cues[self.currentCue][ID_COL_TRANSPOX] gain = self.cues[self.currentCue][ID_COL_GAINX] tr += value if tr > INTERPTIME_MAX: tr = INTERPTIME_MAX gain += value if gain > INTERPTIME_MAX: gain = INTERPTIME_MAX self.cues[self.currentCue][ID_COL_TRANSPOX] = tr self.cues[self.currentCue][ID_COL_GAINX] = gain elif meth == 2: tr = self.cues[self.currentCue][ID_COL_TRANSPOX] gain = self.cues[self.currentCue][ID_COL_GAINX] tr -= value if tr < INTERPTIME_MIN: tr = INTERPTIME_MIN gain -= value if gain < INTERPTIME_MIN: gain = INTERPTIME_MIN self.cues[self.currentCue][ID_COL_TRANSPOX] = tr self.cues[self.currentCue][ID_COL_GAINX] = gain self.transpox = self.cues[self.currentCue][ID_COL_TRANSPOX] self.gainx = self.cues[self.currentCue][ID_COL_GAINX] def isValid(self): return self.valid def getChnls(self): return self.sndchnls def getId(self): return self.id def setId(self, x): self.id = x def setPlayerAttribute(self, id, value): if self.playerRef is not None: player = self.playerRef() player.setAttribute(id, value) def getFilename(self): return self.filename def setLoopMode(self, x): self.loopmode = x self.setPlayerAttribute(ID_COL_LOOPMODE, x) def getTranspo(self): return self.transpo def setTranspo(self, x): self.transpo = x self.setPlayerAttribute(ID_COL_TRANSPO, x) def getTranspox(self): return self.transpox def setTranspox(self, x): self.transpox = x self.setPlayerAttribute(ID_COL_TRANSPOX, x) def getGain(self): return self.gain def setGain(self, x): self.gain = x self.setPlayerAttribute(ID_COL_GAIN, x) def getGainx(self): return self.gainx def setGainx(self, x): self.gainx = x self.setPlayerAttribute(ID_COL_GAINX, x) def getPlaying(self): return self.playing def setPlaying(self, x): self.playing = x self.setPlayerAttribute(ID_COL_PLAYING, x) def getDirectOut(self): return self.directout def setDirectOut(self, x): self.directout = x self.setPlayerAttribute(ID_COL_DIRECTOUT, x) def getStartPoint(self): return self.startpoint def setStartPoint(self, x): self.startpoint = x self.setPlayerAttribute(ID_COL_STARTPOINT, x) def getEndPoint(self): return self.endpoint def setEndPoint(self, x): self.endpoint = x self.setPlayerAttribute(ID_COL_ENDPOINT, x) def getCrossfade(self): return self.crossfade def setCrossfade(self, x): self.crossfade = x self.setPlayerAttribute(ID_COL_CROSSFADE, x) def getDuration(self): return self.duration def setChannel(self, x): self.channel = x self.setPlayerAttribute(ID_COL_CHANNEL, x) def getChannel(self): return self.channel def setAutoTranspo(self, dict): self.transpoDict = dict self.setPlayerAttribute(ID_TRANSPO_AUTO, dict) def setAutoGain(self, dict): self.gainDict = dict self.setPlayerAttribute(ID_GAIN_AUTO, dict)