Skip to content

Commit

Permalink
we good
Browse files Browse the repository at this point in the history
  • Loading branch information
pussinboot committed Oct 24, 2015
1 parent 1e7c0b7 commit f10a563
Showing 5 changed files with 174 additions and 139 deletions.
98 changes: 49 additions & 49 deletions v0.5.0/Twitch.ini
Original file line number Diff line number Diff line change
@@ -3,72 +3,72 @@ Input Name = Twitch
Input ID = 1

[Keys]
stop = [152, 22]
r pad #1 = [152, 96]
r pad #6 = [152, 101]
play/pause = [152, 23]
l pad #1 = [151, 96]
next = [152, 19]
cycle waveform =
r pad #7 = [152, 102]
prev = [152, 18]
zoom = [183, 3]
r pad #4 = [152, 99]
l pad #5 = [151, 100]
brightness =
previous set = [151, 18]
motion up/down = [183, 53]
waveform opacity =
scale 2nd layer =
scale waveform =
rotate = [184, 3]
l pad #6 = [151, 101]
cycle waveform = [151, 16]
r pad #7 = [152, 102]
l pad #3 = [151, 98]
l pad #8 = [151, 103]
motion up/down = [183, 53]
r pad #6 = [152, 101]
rotate = [184, 3]
r pad #4 = [152, 99]
r pad #5 = [152, 100]
l pad #3 = [151, 98]
motion left/right = [184, 53]
l pad #7 = [151, 102]
next set = [151, 19]
r pad #1 = [152, 96]
r pad #8 = [152, 103]
l pad #4 = [151, 99]
prev = [152, 18]
change amplitude =
flip 2nd layer =
scale 2nd layer =
l pad #5 = [151, 100]
l pad #1 = [151, 96]
next = [152, 19]
scale waveform =
l pad #2 = [151, 97]
previous set = [151, 18]
stop = [152, 22]
zoom = [183, 3]
brightness =
l pad #7 = [151, 102]
r pad #2 = [152, 97]
change amplitude =
l pad #6 = [151, 101]
next set = [151, 19]
play/pause = [152, 23]
r pad #3 = [152, 98]
r pad #8 = [152, 103]
l pad #4 = [151, 99]

[Type]
stop = p
r pad #1 = p
r pad #6 = p
play/pause = p
l pad #1 = p
next = p
motion up/down = s
waveform opacity = o
cycle waveform = p
r pad #7 = p
prev = p
zoom = s
r pad #4 = p
l pad #5 = p
brightness = o
previous set = p
waveform opacity = o
scale 2nd layer = o
scale waveform = o
rotate = s
l pad #6 = p
l pad #3 = p
l pad #8 = p
motion up/down = s
r pad #6 = p
rotate = s
r pad #4 = p
r pad #5 = p
l pad #3 = p
motion left/right = s
l pad #7 = p
next set = p
r pad #1 = p
r pad #8 = p
l pad #4 = p
prev = p
change amplitude = o
flip 2nd layer = p
scale 2nd layer = o
l pad #5 = p
l pad #1 = p
next = p
scale waveform = o
l pad #2 = p
previous set = p
stop = p
zoom = s
brightness = o
l pad #7 = p
r pad #2 = p
change amplitude = o
l pad #6 = p
next set = p
play/pause = p
r pad #3 = p
r pad #8 = p
l pad #4 = p

72 changes: 44 additions & 28 deletions v0.5.0/mdvj.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ def __init__(self,root,mainprogram=None,path="C:/Program Files (x86)/Winamp/plug
# load saved directory, if no saved dir then run first setup (screenshot then control)
# add menu to configure input or reselect db
self.mainprogram = mainprogram
self.mainprogram.do_something = None
self.db = Database(path) # will update later to select your folder first
self.db.start()
starting_len = len(self.db)
@@ -224,31 +225,36 @@ def __init__(self):
self.savedata = self.Load()
self.input_name = None
self.directory = None

self.do_something = None
self.Setup()

while self.do_something:
self.do_something()
self.Run()

def Run(self):
self.root = tk.Tk()
self.root.title('mdvj')
self.root.resizable(0,0)
self.gui = MainGui(self.root,self,self.directory,self.input_name)
self.root.mainloop()

def Setup(self):
""" loads config if exists, otherwise guides you through setup process"""

if not self.savedata:
s = Screenshot()
self.directory = s.start()
mc = ConfigMidi()
input_store = mc.input_storage # needs rewrite to follow the use queue to update gui standard
if input_store:
self.input_name = input_store[0]
#s = Screenshot()
#self.directory = s.start()
self.do_screenshot()
self.do_config()

else:
self.directory = self.savedata['directory']
#if not self.input_name: self.input_name = self.savedata['last_device']
if not self.input_name: self.input_name = self.savedata['last_device']
#s = Screenshot()
#directory = s.start()
#print(directory)
#ConfigMidi(tk.Toplevel())
self.root = tk.Tk()
self.root.title('mdvj')
self.root.resizable(0,0)
self.gui = MainGui(self.root,self,self.directory,self.input_name)
self.root.mainloop()
self.Run()

def Load(self,filename="saved_state"):
if os.path.exists(filename):
@@ -274,23 +280,33 @@ def Save(self,filename="saved_state"):
with open(filename,'wb') as write:
pickle.dump(to_save,write)

def re_screenshot(self):
self.gui.control.close()
self.gui = None
self.root = None
s = Screenshot(first_time=False)
def do_screenshot(self,first_time=True):
s = Screenshot(first_time)
self.directory = s.start()
self.gui = MainGui(root,self,self.directory,self.input_name)

def re_configure(self):
self.gui.control.close()
self.gui = None
self.root = None
def re_screenshot(self):
self.do_something = lambda : self.do_screenshot(False)
self.gui.control.MC.endApplication()
#self.gui = None
#self.root = None

#self.gui = MainGui(root,self,self.directory,self.input_name)
def do_config(self):
mc = ConfigMidi()
mc.start()
input_store = mc.input_storage
if input_store: self.input_name = input_store[0]
self.gui = MainGui(root,self,self.directory,self.input_name)
input_store = mc.input_storage # needs rewrite to follow the use queue to update gui standard
if input_store:
self.input_name = input_store[0]

def re_configure(self):
#self.gui.control.MC.stop_midi()#close()
self.do_something = self.do_config
self.gui.control.MC.endApplication()

# self.input_name = input_store[0]
# self.gui.control.MC.set_inp(input_store[1])
#self.gui.contol.MC.resume()

#self.gui = MainGui(root,self,self.directory,self.input_name)

def main():
root = tk.Tk()
130 changes: 68 additions & 62 deletions v0.5.0/midi_config.py
Original file line number Diff line number Diff line change
@@ -9,13 +9,19 @@ class ConfigMidi:
configure midi controls
"""

def __init__(self):
self.master = tk.Tk()
self.master.wm_state('iconic')
def __init__(self,frame=None):
if not frame:
self.master = tk.Tk()
self.master.wm_state('iconic')
else:
self.master = frame
self.queue = None
self.midi_started = False
self.input_storage = None
#if not MC:
self.MC = MidiControl()
#else:
# self.MC = MC
# tk stuff
self.nb = ttk.Notebook(self.master)
self.nb.pack()
@@ -77,9 +83,9 @@ def spit_vals(self,event):

def start(self):
# if no device
device_select = DeviceSelect(self)
#device_select.focus_force()
self.master.mainloop()
device_select = self.device_selection()
device_select.focus_force()
# now start the midi thread

def config_line(self,p_frame,desc,bind,ctype,type_restrict,radio=True): #,None] # need to pass in higher level variable fxns otherwise will have weird as behavior
@@ -122,62 +128,6 @@ def config_line(self,p_frame,desc,bind,ctype,type_restrict,radio=True): #,None]
label_1.bind('<ButtonPress>',lambda event, arg=desc: self.id_midi(arg))
return line_frame


def device_selection(self):
device_dict = self.MC.collect_device_info()
inputs = [key for key in device_dict[0]]
outputs = [key for key in device_dict[1]]
device_select = tk.Toplevel()
device_select.title('select midi devices')
#device_select.focus_force()

device_select_frame = tk.Frame(device_select)
ok_frame = tk.Frame(device_select)

input_label = tk.Label(device_select_frame,text='input')
output_label = tk.Label(device_select_frame,text='output')

input_choice = tk.StringVar()
input_choice.set('-')
output_choice = tk.StringVar()
output_choice.set('-')

input_select = tk.OptionMenu(device_select_frame,input_choice,*inputs)
output_select = tk.OptionMenu(device_select_frame,output_choice,*outputs)

def return_vals():
choices = [input_choice.get(),output_choice.get()]
tor = [None, None]
if choices[0] in inputs:
tor[0] = device_dict[0][choices[0]]
if choices[1] in outputs:
tor[1] = device_dict[1][choices[1]]
device_select.destroy()
self.load(choices[0]+'.ini')
self.master.wm_state('normal')
self.input_storage = [choices[0], str(tor[0])]
self.MC.set_inp(tor[0])
self.midi_started = True
self.midi_thread = MidiClient(self,self.MC,250)
self.queue = self.midi_thread.queue
self.midi_thread.start()
self.master.update()


device_select.protocol("WM_DELETE_WINDOW",return_vals)

ok_button = tk.Button(ok_frame,text='OK',command=return_vals)
ok_button.pack()

input_label.grid(row=0,column=0)
output_label.grid(row=0,column=1)
input_select.grid(row=1,column=0)
output_select.grid(row=1,column=1)

device_select_frame.pack()
ok_frame.pack()
return device_select

def set_queue(self,queue):
self.queue = queue

@@ -276,10 +226,66 @@ def save(self):
def quit(self):
self.save()
#self.master.destroy()
class DeviceSelect:
def __init__(self,parent):
self.parent = parent
self.device_dict = self.parent.MC.collect_device_info()
self.inputs = [key for key in self.device_dict[0]]
self.outputs = [key for key in self.device_dict[1]]
self.device_select = tk.Toplevel(takefocus=True)
self.device_select.title('select midi devices')
#device_select.focus_force()

self.device_select_frame = tk.Frame(self.device_select)
self.ok_frame = tk.Frame(self.device_select)

self.input_label = tk.Label(self.device_select_frame,text='input')
self.output_label = tk.Label(self.device_select_frame,text='output')

self.input_choice = tk.StringVar()
self.input_choice.set('-')
self.output_choice = tk.StringVar()
self.output_choice.set('-')

self.input_select = tk.OptionMenu(self.device_select_frame,self.input_choice,*self.inputs)
self.output_select = tk.OptionMenu(self.device_select_frame,self.output_choice,*self.outputs)

self.device_select.protocol("WM_DELETE_WINDOW",self.return_vals)

self.ok_button = tk.Button(self.ok_frame,text='OK',command=self.return_vals)
self.ok_button.pack()

self.input_label.grid(row=0,column=0)
self.output_label.grid(row=0,column=1)
self.input_select.grid(row=1,column=0)
self.output_select.grid(row=1,column=1)

self.device_select_frame.pack()
self.ok_frame.pack()
self.device_select.mainloop()
#return device_select

def return_vals(self):
choices = [self.input_choice.get(),self.output_choice.get()]
tor = [None, None]
if choices[0] in self.inputs:
tor[0] = self.device_dict[0][choices[0]]
if choices[1] in self.outputs:
tor[1] = self.device_dict[1][choices[1]]
self.device_select.destroy()
self.parent.load(choices[0]+'.ini')
self.parent.master.wm_state('normal')
self.parent.input_storage = [choices[0], str(tor[0])]
self.parent.MC.set_inp(tor[0])
self.parent.midi_started = True
self.parent.midi_thread = MidiClient(self.parent,self.parent.MC,250)
self.parent.queue = self.parent.midi_thread.queue
self.parent.midi_thread.start()
#self.parent.master.update()

def main():
config = ConfigMidi()
return config.input_storage
#return config.input_storage


if __name__ == '__main__':
Loading

0 comments on commit f10a563

Please sign in to comment.