def configureRobotization(self): self.windowWidth = SliderModel(2, 12, 1, 6, "Tamaño de la ventana") self.recyclerView.addElement( self.windowWidth ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") )
def configReverbPB(self): self.ganancia = SliderModel(0, 1, 0.01, 0.5, "Ganancia (g)") self.recyclerView.addElement( self.ganancia ) self.delay = SliderModel(5, 8000, 1, 500, "Delay (m)") self.recyclerView.addElement( self.delay ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") )
def configureFlangerOrVibrato(self): self.fm = SliderModel(0, 5, 0.01, 2.5, "Frecuencia de modulación (hz)") self.recyclerView.addElement( self.fm ) self.pm = SliderModel(0, 0.02, 0.001, 0.01, "Profundidad de modulación (s)") self.recyclerView.addElement( self.pm ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") )
def configureReverbCompleto(self): self.pFilter = SliderModel(1, 15, 1, 12, "Cantidad de Filtros en paralelo") self.recyclerView.addElement( self.pFilter ) self.combCount = SliderModel(1, 4, 1, 2, "Cantidad de Filtros en serie") self.recyclerView.addElement( self.combCount ) self.combDelay = SliderModel(100, 1000, 1, 500, "Delay filtros en serie") self.recyclerView.addElement( self.combDelay ) self.combGain = SliderModel(0, 1, 0.01, 0.5, "Ganancia filtros en serie") self.recyclerView.addElement( self.combGain ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") )
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller label = tk.Label(self, height=2, text="Configuración", font=config.LARGE_FONT) label.pack(side=tk.TOP, fill=tk.BOTH) self.filename = "" self.btnText = tk.StringVar() self.buttonSelectFile = tk.Button(self, height=2, width=44, textvariable=self.btnText, background="dodger blue", font=config.SMALL_FONT, command=self.searchFile) self.btnText.set("Seleccionar entrada") self.slider1 = SliderModel(1, 5000, 5, config.GetConfigData().FAAfreq, "Sample rate (hz)") self.slider1cont = SliderContainer(self, self.slider1) self.slider1cont.pack(side=tk.TOP, fill=tk.BOTH) self.slider1.setContainer(self.slider1cont) self.slider1.setValue(config.GetConfigData().fs) self.slider2 = SliderModel(2, 98, 1, config.GetConfigData().FAAfreq, "Sample cycle (%)") self.slider2cont = SliderContainer(self, self.slider2) #print(config.GetConfigData().SHhold) self.slider2.setContainer(self.slider2cont) self.slider2.setValue(config.GetConfigData().SHhold * 100) self.slider2cont.pack(side=tk.TOP, fill=tk.BOTH) self.buttonSelectFile.pack(side=tk.TOP, fill=tk.BOTH) for mode in Modes.getModes().modesEnabled.keys(): checkButton = tk.Checkbutton( self, text=mode, variable=Modes.getModes().modesEnabled[mode], height=3, width=44, font=config.SMALL_FONT, background="light yellow") checkButton.pack(side=tk.TOP, fill=tk.BOTH) self.loadingModel = None self.isLoading = False self.loadingModel = LoadingModel(0, 100) self.loading = LoadingContainer(self, self.loadingModel) self.loadingModel.setContainer(self.loading) self.loading.pack(side=tk.BOTTOM, fill=tk.BOTH) self.loadingModel.setOnLoadedListener(self.onDataCalc) self.button = tk.Button(self, height=1, width=44, background="pale green", text="ACEPTAR", font=config.LARGE_FONT, command=lambda: self.goToPlotMenu()) self.button.pack(side=tk.BOTTOM, fill=tk.BOTH)
class ConfigureMenu(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller label = tk.Label(self, height=2, text="Configuración", font=config.LARGE_FONT) label.pack(side=tk.TOP, fill=tk.BOTH) self.filename = "" self.btnText = tk.StringVar() self.buttonSelectFile = tk.Button(self, height=2, width=44, textvariable=self.btnText, background="dodger blue", font=config.SMALL_FONT, command=self.searchFile) self.btnText.set("Seleccionar entrada") self.slider1 = SliderModel(1, 5000, 5, config.GetConfigData().FAAfreq, "Sample rate (hz)") self.slider1cont = SliderContainer(self, self.slider1) self.slider1cont.pack(side=tk.TOP, fill=tk.BOTH) self.slider1.setContainer(self.slider1cont) self.slider1.setValue(config.GetConfigData().fs) self.slider2 = SliderModel(2, 98, 1, config.GetConfigData().FAAfreq, "Sample cycle (%)") self.slider2cont = SliderContainer(self, self.slider2) #print(config.GetConfigData().SHhold) self.slider2.setContainer(self.slider2cont) self.slider2.setValue(config.GetConfigData().SHhold * 100) self.slider2cont.pack(side=tk.TOP, fill=tk.BOTH) self.buttonSelectFile.pack(side=tk.TOP, fill=tk.BOTH) for mode in Modes.getModes().modesEnabled.keys(): checkButton = tk.Checkbutton( self, text=mode, variable=Modes.getModes().modesEnabled[mode], height=3, width=44, font=config.SMALL_FONT, background="light yellow") checkButton.pack(side=tk.TOP, fill=tk.BOTH) self.loadingModel = None self.isLoading = False self.loadingModel = LoadingModel(0, 100) self.loading = LoadingContainer(self, self.loadingModel) self.loadingModel.setContainer(self.loading) self.loading.pack(side=tk.BOTTOM, fill=tk.BOTH) self.loadingModel.setOnLoadedListener(self.onDataCalc) self.button = tk.Button(self, height=1, width=44, background="pale green", text="ACEPTAR", font=config.LARGE_FONT, command=lambda: self.goToPlotMenu()) self.button.pack(side=tk.BOTTOM, fill=tk.BOTH) def focus(self): self.loadingModel.reset() self.button.configure(state=tk.NORMAL) def searchFile(self): tk.Tk().withdraw() Modes.getModes().setFilename(filedialog.askopenfilename()) self.btnText.set("Seleccionar entrada [" + ntpath.basename(Modes.getModes().getFilename()) + "]") def goToPlotMenu(self): if Modes.getModes().getFilename() and not self.isLoading: config.GetConfigData().setFs(self.slider1.getValue()) config.GetConfigData().setSampleCycle(self.slider2.getValue()) config.GetConfigData().save() config.GetConfigData().load() self.button.configure(state=tk.DISABLED) self.isLoading = True thread = Thread(target=ProcessSignals.processSignals, args=(Modes.getModes().getFilename(), Modes.getModes().modesEnabled, self.loadingModel)) thread.start() def onDataCalc(self): self.controller.showFrame(PlotMenu) self.isLoading = False
class ParametersConfigMenu(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller self.parent = parent self.mode = getEffectsInterface().getCompleteMode() self.label = tk.Label( self, height=1, width=44, text="Configuracion de parametros - " + self.mode, font=config.LARGE_FONT, background="#ccffd5" ) self.label.pack(side=tk.TOP, fill=tk.BOTH, expand=1) self.halfContainer = tk.Frame(self) self.recyclerView = RecyclerView( self.halfContainer, controller, 400 ) tk.Frame(self.halfContainer).grid(column=0, row=0) self.recyclerView.grid(column=1, row=0) tk.Frame(self.halfContainer).grid(column=2, row=0) self.halfContainer.grid_columnconfigure(0, weight=1) self.halfContainer.grid_columnconfigure(1, weight=10) self.halfContainer.grid_columnconfigure(2, weight=1) self.halfContainer.pack(side=tk.TOP, fill=tk.BOTH) self.buttonVolver = tk.Button( self, height=1, width=44, text="Volver", font=config.LARGE_FONT, background="#ffbaae", command=self.goBack ) self.buttonVolver.pack(side=tk.TOP, expand=1, fill=tk.BOTH) def configReverbEcoSimple(self): self.ganancia = SliderModel(0, 1, 0.001, 0.999, "Ganancia (g)") self.recyclerView.addElement( self.ganancia ) self.delay = SliderModel(5, 8000, 1, 5000, "Delay (m)") self.recyclerView.addElement( self.delay ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") ) def configureReverbPlano(self): self.ganancia = SliderModel(0, 1, 0.01, 0.5, "Ganancia (g)") self.recyclerView.addElement( self.ganancia ) self.delay = SliderModel(5, 8000, 1, 500, "Delay (m)") self.recyclerView.addElement( self.delay ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") ) def configReverbPB(self): self.ganancia = SliderModel(0, 1, 0.01, 0.5, "Ganancia (g)") self.recyclerView.addElement( self.ganancia ) self.delay = SliderModel(5, 8000, 1, 500, "Delay (m)") self.recyclerView.addElement( self.delay ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") ) def configureReverbCompleto(self): self.pFilter = SliderModel(1, 15, 1, 12, "Cantidad de Filtros en paralelo") self.recyclerView.addElement( self.pFilter ) self.combCount = SliderModel(1, 4, 1, 2, "Cantidad de Filtros en serie") self.recyclerView.addElement( self.combCount ) self.combDelay = SliderModel(100, 1000, 1, 500, "Delay filtros en serie") self.recyclerView.addElement( self.combDelay ) self.combGain = SliderModel(0, 1, 0.01, 0.5, "Ganancia filtros en serie") self.recyclerView.addElement( self.combGain ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") ) def configureReverbConvolucion(self): self.fileImpulse = AskFilenameModel() self.recyclerView.addElement( self.fileImpulse ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") ) def configureRobotization(self): self.windowWidth = SliderModel(2, 12, 1, 6, "Tamaño de la ventana") self.recyclerView.addElement( self.windowWidth ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") ) def configureFlangerOrVibrato(self): self.fm = SliderModel(0, 5, 0.01, 2.5, "Frecuencia de modulación (hz)") self.recyclerView.addElement( self.fm ) self.pm = SliderModel(0, 0.02, 0.001, 0.01, "Profundidad de modulación (s)") self.recyclerView.addElement( self.pm ) self.recyclerView.addElement( SimpleButtonModel(self.sendParams, "Aceptar") ) def focus(self): self.recyclerView.clear() self.mode = getEffectsInterface().getCompleteMode() #print(self.mode) if self.mode == "Reverb Eco-simple": self.configReverbEcoSimple() elif self.mode == "Reverb Reverberador-plano": self.configureReverbPlano() elif self.mode == "Reverb Reverberador-pasa-bajos": self.configReverbPB() elif self.mode == "Reverb Reverberador-completo": self.configureReverbCompleto() elif self.mode == "Reverb Reverberador-convolucion": self.configureReverbConvolucion() elif self.mode == "Vibrato": self.configureFlangerOrVibrato() elif self.mode == "Flanger": self.configureFlangerOrVibrato() elif self.mode == "Robot": self.configureRobotization() self.label.configure( text=self.mode ) def goBack(self): getEffectsInterface().sendData("-1\n") getEffectsInterface().restart() from Menus.StartMenu import StartMenu self.controller.showFrame(StartMenu) def sendParams(self): if self.mode == "Reverb Eco-simple" or \ self.mode == "Reverb Reverberador-plano" or \ self.mode == "Reverb Reverberador-pasa-bajos": #print("sending ...") getEffectsInterface().sendParam("g", self.ganancia.getValue()) getEffectsInterface().sendParam("d", self.delay.getValue()) elif self.mode == "Reverb Reverberador-completo": getEffectsInterface().sendParam("pf", self.pFilter.getValue()) getEffectsInterface().sendParam("cc", self.combCount.getValue()) getEffectsInterface().sendParam("dc", self.combDelay.getValue()) getEffectsInterface().sendParam("gc", self.combGain.getValue()) elif self.mode == "Reverb Reverberador-convolucion": getEffectsInterface().sendData(self.fileImpulse.getFilename()) elif self.mode == "Robot": getEffectsInterface().sendParam("Ventana",self.windowWidth.getValue()) elif self.mode == "Flanger" or self.mode == "Vibrato": getEffectsInterface().sendParam("fm", self.fm.getValue()) getEffectsInterface().sendParam("pm", self.pm.getValue()) from Menus.RealtimeOrFilenameMenu import RealtimeOrFilenameMenu self.controller.showFrame(RealtimeOrFilenameMenu)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller self.parent = parent self.channel = None self.title = tk.Label(self, height=1, text="Configuración del canal X", font=config.LARGE_FONT, background="#ccffd5") self.title.pack(side=tk.TOP, fill=tk.BOTH) self.selectedText = tk.Label(self, height=1, text="Ningún instrumento seleccionado", font=config.SMALL_FONT, background="#80aaff") self.selectedText.pack(side=tk.TOP, fill=tk.BOTH) self.halfContainer = tk.Frame(self) self.recyclerView = RecyclerView(self.halfContainer, self.controller, height=360) tk.Frame(self.halfContainer).grid(column=0, row=0) self.recyclerView.grid(column=1, row=0) tk.Frame(self.halfContainer).grid(column=2, row=0) self.recyclerView.configureSeparation(70) self.halfContainer.grid_columnconfigure(0, weight=1) self.halfContainer.grid_columnconfigure(1, weight=10) self.halfContainer.grid_columnconfigure(2, weight=1) self.halfContainer.pack(side=tk.TOP, fill=tk.BOTH) self.sliderModel = SliderModel(start=0, end=100, step=1, startValue=0, title="Volumen", callOnChange=self.callOnChanged) self.volumeBar = SliderContainer(self, self.sliderModel) self.volumeBar.pack(side=tk.TOP, fill=tk.BOTH) self.buttonAceptar = tk.Button(self, height=1, width=50, text="Aceptar", font=config.LARGE_FONT, background="#ccffd5", command=self.aceptar) self.buttonAceptar.pack(side=tk.TOP, fill=tk.BOTH) self.updateInstruments() self.selectedInstrument = None
class ConfigureChannelMenu(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller self.parent = parent self.channel = None self.title = tk.Label(self, height=1, text="Configuración del canal X", font=config.LARGE_FONT, background="#ccffd5") self.title.pack(side=tk.TOP, fill=tk.BOTH) self.selectedText = tk.Label(self, height=1, text="Ningún instrumento seleccionado", font=config.SMALL_FONT, background="#80aaff") self.selectedText.pack(side=tk.TOP, fill=tk.BOTH) self.halfContainer = tk.Frame(self) self.recyclerView = RecyclerView(self.halfContainer, self.controller, height=360) tk.Frame(self.halfContainer).grid(column=0, row=0) self.recyclerView.grid(column=1, row=0) tk.Frame(self.halfContainer).grid(column=2, row=0) self.recyclerView.configureSeparation(70) self.halfContainer.grid_columnconfigure(0, weight=1) self.halfContainer.grid_columnconfigure(1, weight=10) self.halfContainer.grid_columnconfigure(2, weight=1) self.halfContainer.pack(side=tk.TOP, fill=tk.BOTH) self.sliderModel = SliderModel(start=0, end=100, step=1, startValue=0, title="Volumen", callOnChange=self.callOnChanged) self.volumeBar = SliderContainer(self, self.sliderModel) self.volumeBar.pack(side=tk.TOP, fill=tk.BOTH) self.buttonAceptar = tk.Button(self, height=1, width=50, text="Aceptar", font=config.LARGE_FONT, background="#ccffd5", command=self.aceptar) self.buttonAceptar.pack(side=tk.TOP, fill=tk.BOTH) self.updateInstruments() self.selectedInstrument = None def callOnChanged(self, value): for element in self.recyclerView.getElements(): element.setVolume(value) def configureChannel(self, channel): self.title.configure(text="Configuración del canal " + channel.getName()) self.sliderModel.setValue(channel.getVolume()) self.instrumentSelected(channel.getInstrumento()) self.channel = channel def updateInstruments(self): self.recyclerView.clear() for instrument in getInstruments().instrumentos: instrumentModel = InstrumentModel(instrument.getName()) instrumentModel.setInstrumentData(instrument) instrumentModel.setOnSelectedListener( Listener(self.instrumentSelected, instrumentModel)) self.recyclerView.addElement(instrumentModel) def instrumentSelected(self, instrumentModel): #print("Instrumento seleccionado ", instrumentModel) if instrumentModel: self.selectedText.configure(text="El instrumento " + instrumentModel.getInstrumentName() + " ha sido seleccionado") else: self.selectedText.configure(text="Ningún instrumento seleccionado") for instrument in self.recyclerView.getElements(): if instrument == instrumentModel: instrument.enable() self.selectedInstrument = instrument else: instrument.disable() def aceptar(self): self.channel.setVolume(self.sliderModel.getValue()) if self.selectedInstrument: self.channel.setInstrumento(self.selectedInstrument) self.channel.setVolume(self.sliderModel.getValue()) from Menus.MidiConfigMenu import MidiConfigMenu self.controller.showFrame(MidiConfigMenu)