Sampler in ChucK
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
10 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. from libs.simpleosc import *
  2. import wx
  3. def sendOSCSafe(channel, data):
  4. try:
  5. sendOSCMsg(channel, data)
  6. except OSCClientError:
  7. print "OSC comms error"
  8. class OSCSlider(wx.Panel):
  9. ''' A GUI slider '''
  10. def __init__(self, parent, label, min_value=0, max_value=1, default_value=0, align=True):
  11. ''' Constructor '''
  12. wx.Panel.__init__(self, parent)
  13. sizer=wx.BoxSizer(wx.HORIZONTAL)
  14. label=wx.StaticText(self, label=label, size=(100,15) if align else None)
  15. sizer.Add(label, 0, wx.RIGHT, 10)
  16. self.slider=wx.Slider(self, value=default_value*100, minValue=min_value*100, maxValue=max_value*100)
  17. sizer.Add(self.slider, 1, wx.EXPAND)
  18. self.SetSizerAndFit(sizer)
  19. self.Bind=self.slider.Bind
  20. self.GetValue=self.slider.GetValue
  21. class CommsPanel(wx.Panel):
  22. """ OSC comms """
  23. def __init__(self, parent):
  24. wx.Panel.__init__(self, parent)
  25. sizer = wx.BoxSizer(wx.HORIZONTAL)
  26. label = wx.StaticText(self, label="Sync:")
  27. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  28. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT|wx.EXPAND, 5)
  29. choices=["Master", "Minion"]
  30. self.master= wx.ComboBox(self, choices=choices, style=wx.CB_READONLY, size=(25,25))
  31. sizer.Add(self.master, 1, wx.ALL, 3)
  32. self.master.SetValue(choices[0])
  33. self.ip=wx.TextCtrl(self, value="127.0.0.1")
  34. sizer.Add(self.ip, 0, wx.ALL, 3)
  35. self.port=wx.TextCtrl(self, value="9000")
  36. sizer.Add(self.port, 0, wx.ALL, 3)
  37. self.SetSizerAndFit(sizer)
  38. class InputPanel(wx.Panel):
  39. ''' Handle the ADC input settings '''
  40. def __init__(self, parent):
  41. ''' Constructor '''
  42. wx.Panel.__init__(self, parent)
  43. sizer = wx.BoxSizer(wx.HORIZONTAL)
  44. label = wx.StaticText(self, label="Input:")
  45. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  46. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  47. self.gain = OSCSlider(self, "Gain", default_value=.5, align=False)
  48. sizer.Add(self.gain, 1, wx.ALL, 5)
  49. self.thru = OSCSlider(self, "Thru", default_value=.5, align=False)
  50. sizer.Add(self.thru, 1, wx.ALL, 5)
  51. self.mute = wx.ToggleButton(self, 0, "Mute")
  52. #self.mute.SetValue(1)
  53. sizer.Add(self.mute, 0)
  54. self.SetSizerAndFit(sizer)
  55. self.gain.Bind(wx.EVT_SCROLL, self.update)
  56. self.thru.Bind(wx.EVT_SCROLL, self.update)
  57. self.mute.Bind(wx.EVT_TOGGLEBUTTON, self.update)
  58. self.update()
  59. def update(self, evt=None):
  60. """ Send OSC messages """
  61. gain=self.gain.slider.GetValue()/100.
  62. thru=self.thru.slider.GetValue()/100.
  63. if self.mute.GetValue(): gain, thru = 0.,0.
  64. sendOSCSafe("/input", [gain, thru])
  65. class DelayPanel(wx.Panel):
  66. ''' Handle the ADC input settings '''
  67. def __init__(self, parent):
  68. ''' Constructor '''
  69. wx.Panel.__init__(self, parent)
  70. sizer = wx.BoxSizer(wx.HORIZONTAL)
  71. label = wx.StaticText(self, label="Loop:")
  72. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  73. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  74. self.delayTime=OSCSlider(self, "Time", default_value=1, max_value=10, align=False)
  75. sizer.Add(self.delayTime, 1, wx.EXPAND|wx.ALL, 5)
  76. self.feedback=OSCSlider(self, "Hold", default_value=.99, align=False)
  77. sizer.Add(self.feedback, 1, wx.EXPAND|wx.ALL, 5)
  78. self.metronome=wx.ToggleButton(self, 0, "Click")
  79. sizer.Add(self.metronome, 0, wx.EXPAND|wx.ALL, 5)
  80. self.SetSizerAndFit(sizer)
  81. self.delayTime.Bind(wx.EVT_SCROLL, self.update)
  82. self.feedback.Bind(wx.EVT_SCROLL, self.update)
  83. self.metronome.Bind(wx.EVT_TOGGLEBUTTON, self.switchMetronome)
  84. self.update(None)
  85. def update(self, evt):
  86. """ Send OSC messages """
  87. a=self.delayTime.slider.GetValue()/100.
  88. b=self.feedback.slider.GetValue()/100.
  89. sendOSCSafe("/delay", [a, b])
  90. def switchMetronome(self, evt):
  91. """ Send OSC messages """
  92. sendOSCSafe("/metronome", [int(self.metronome.GetValue())])
  93. class ButtonArray(wx.Panel):
  94. ''' Handle the ADC input settings '''
  95. def __init__(self, parent, index):
  96. wx.Panel.__init__(self, parent)
  97. w=40
  98. sizer = wx.BoxSizer(wx.HORIZONTAL)
  99. self.record = wx.ToggleButton(self, 0, "Arm", size=(w,25))
  100. sizer.Add(self.record, 1, wx.ALL, 0)
  101. self.mute = wx.ToggleButton(self, 0, "Mute", size=(w,25))
  102. sizer.Add(self.mute, 1, wx.ALL, 0)
  103. self.clear = wx.Button(self, 0, "Clear", size=(w,25))
  104. sizer.Add(self.clear, 1, wx.ALL, 0)
  105. self.buttons=(self.record, self.mute, self.clear)
  106. self.SetSizerAndFit(sizer)
  107. class Channel(wx.Panel):
  108. """ A single channel """
  109. def __init__(self, parent, index):
  110. self.index=index
  111. wx.Panel.__init__(self, parent)
  112. sizer = wx.BoxSizer(wx.VERTICAL)
  113. #label = wx.StaticText(self, label="CH%d" % self.index)
  114. #font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  115. #sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  116. self.gain = OSCSlider(self, "Gain", default_value=1, max_value=1.3, align=False)
  117. sizer.Add(self.gain, 0, wx.ALL|wx.EXPAND, 3)
  118. self.pan = OSCSlider(self, "Pan", default_value=0, min_value=-1, max_value=1, align=False)
  119. sizer.Add(self.pan, 0, wx.ALL|wx.EXPAND, 3)
  120. self.fxsend = OSCSlider(self, "Dry/Wet", default_value=0, min_value=0, max_value=1, align=False)
  121. sizer.Add(self.fxsend, 0, wx.ALL|wx.EXPAND, 3)
  122. self.buttons=ButtonArray(self, index)
  123. self.record, self.mute, self.clear = self.buttons.buttons
  124. sizer.Add(self.buttons, 0, wx.ALL|wx.EXPAND, 3)
  125. choices=["1 bar", "2 bars", "4 bars", "Dephase", "1/2 rate"]
  126. self.speed= wx.ComboBox(self, choices=choices, style=wx.CB_READONLY, size=(25,25))
  127. self.speed.SetValue("1 bar")
  128. sizer.Add(self.speed, 0, wx.ALL|wx.EXPAND, 3)
  129. self.SetSizerAndFit(sizer)
  130. self.gain.Bind(wx.EVT_SCROLL, self.update)
  131. self.pan.Bind(wx.EVT_SCROLL, self.update)
  132. self.mute.Bind(wx.EVT_TOGGLEBUTTON, self.update)
  133. self.update()
  134. def update(self, evt=None):
  135. gain=self.gain.GetValue()/100.
  136. pan=self.pan.GetValue()/100.
  137. if self.mute.GetValue(): gain=0.0;
  138. sendOSCSafe("/channel", [self.index, gain, pan])
  139. class Mixer(wx.Panel):
  140. ''' All the channels '''
  141. def __init__(self, parent):
  142. ''' Constructor '''
  143. wx.Panel.__init__(self, parent)
  144. sizer = wx.BoxSizer(wx.HORIZONTAL)
  145. self.channels=[]
  146. for i in range(4):
  147. c=Channel(self, index=i)
  148. c.record.Bind(wx.EVT_TOGGLEBUTTON, self.switch_record)
  149. c.record.index=i
  150. c.clear.Bind(wx.EVT_BUTTON, self.clear_channel)
  151. c.clear.index=i
  152. self.channels.append(c)
  153. sizer.Add(c, 1, wx.EXPAND)
  154. self.SetSizerAndFit(sizer)
  155. def switch_record(self, evt):
  156. """ Send OSC message to switch recording channel """
  157. index = evt.GetEventObject().index
  158. value = evt.GetEventObject().GetValue()
  159. for i, c in enumerate(self.channels):
  160. c.record.SetValue(0)
  161. self.channels[index].record.SetValue(value)
  162. sendOSCSafe("/arm", [index if value else -1])
  163. def clear_channel(self, evt):
  164. """ Send OSC message to clear a channel """
  165. index = evt.GetEventObject().index
  166. sendOSCSafe("/clear", [index])
  167. class FXPanel(wx.Panel):
  168. ''' Effects chain '''
  169. def __init__(self, parent):
  170. ''' Constructor '''
  171. wx.Panel.__init__(self, parent)
  172. sizer = wx.BoxSizer(wx.HORIZONTAL)
  173. label = wx.StaticText(self, label="FX:")
  174. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  175. sizer.Add(label, 0, wx.EXPAND|wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  176. choices=["Low pass filter", "High pass filter", "Reverb"]
  177. self.fxtype= wx.ComboBox(self, choices=choices, style=wx.CB_READONLY, size=(25,25))
  178. sizer.Add(self.fxtype, 1, wx.ALL|wx.EXPAND, 5)
  179. self.fxtype.SetValue(choices[0])
  180. self.fxStrength=OSCSlider(self, "", default_value=0, align=False)
  181. sizer.Add(self.fxStrength, 2, wx.EXPAND|wx.ALL, 5)
  182. self.SetSizerAndFit(sizer)
  183. #self.update(None)
  184. """
  185. def update(self, evt):
  186. # Send OSC messages
  187. a=self.delayTime.slider.GetValue()/100.
  188. b=self.feedback.slider.GetValue()/100.
  189. sendOSCSafe("/delay", [a, b])
  190. """
  191. class OutputPanel(wx.Panel):
  192. ''' Handle the ADC input settings '''
  193. def __init__(self, parent):
  194. ''' Constructor '''
  195. wx.Panel.__init__(self, parent)
  196. sizer = wx.BoxSizer(wx.HORIZONTAL)
  197. label = wx.StaticText(self, label="Output:")
  198. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  199. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  200. self.level=OSCSlider(self, "Level", default_value=.8, align=False)
  201. sizer.Add(self.level, 2, wx.EXPAND|wx.ALL, 5)
  202. self.gauge = wx.Gauge(self, size=(40,10))
  203. sizer.Add(self.gauge, 1, wx.EXPAND|wx.ALL, 5)
  204. self.SetSizerAndFit(sizer)
  205. """
  206. def update(self, evt):
  207. a=self.delayTime.slider.GetValue()/100.
  208. b=self.feedback.slider.GetValue()/100.
  209. sendOSCSafe("/delay", [a, b])
  210. """
  211. class MainGUI(wx.Frame):
  212. """ A simple GUI to talk to Chuck """
  213. def __init__(self):
  214. """ Constructor """
  215. # Build the interface
  216. self.app = wx.App(False)
  217. self.build()
  218. def run(self): self.app.MainLoop()
  219. def update_vu(self, a,b,c,d):
  220. level=int(1000000*c[0])
  221. self.output.gauge.SetValue(level)
  222. def build(self):
  223. """ Builds the various pieces of the GUI """
  224. wx.Frame.__init__(self, None, title="DELAY LORD")
  225. self.Bind(wx.EVT_CLOSE, self.quit)
  226. # The main sizer
  227. self.mainsizer = wx.BoxSizer(wx.VERTICAL)
  228. self.commsPanel = CommsPanel(self)
  229. self.mainsizer.Add(self.commsPanel, 0, wx.EXPAND|wx.ALL, 5)
  230. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  231. self.inputPanel = InputPanel(self)
  232. self.mainsizer.Add(self.inputPanel, 0, wx.EXPAND|wx.ALL, 5)
  233. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  234. self.delayPanel = DelayPanel(self)
  235. self.mainsizer.Add(self.delayPanel, 0, wx.EXPAND|wx.ALL, 5)
  236. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  237. self.mixer = Mixer(self)
  238. self.mainsizer.Add(self.mixer, 0, wx.EXPAND|wx.ALL, 5)
  239. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  240. self.fx = FXPanel(self)
  241. self.mainsizer.Add(self.fx, 0, wx.EXPAND|wx.ALL, 5)
  242. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  243. self.output = OutputPanel(self)
  244. self.mainsizer.Add(self.output, 0, wx.EXPAND|wx.ALL, 5)
  245. # Put things together
  246. self.SetSizerAndFit(self.mainsizer)
  247. self.Show()
  248. def populate_left_panel(self):
  249. """ Populate the left panel """
  250. # Status boxes
  251. def quit(self, *args):
  252. """ Close down gracefully, and then destroy the window """
  253. self.Destroy()
  254. if __name__ == "__main__":
  255. initOSCClient(ip="127.0.0.1", port=9000)
  256. g=MainGUI()
  257. #initOSCServer(ip="127.0.0.1", port=6649, mode=0)
  258. #setOSCHandler("/vu", g.update_vu)
  259. g.run()
  260. closeOSC()