Sampler in ChucK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. from libs.simpleosc import *
  2. import wx
  3. class OSCSlider(wx.Panel):
  4. ''' A GUI slider '''
  5. def __init__(self, parent, label, min_value=0, max_value=1, default_value=0, align=True):
  6. ''' Constructor '''
  7. wx.Panel.__init__(self, parent)
  8. sizer=wx.BoxSizer(wx.HORIZONTAL)
  9. label=wx.StaticText(self, label=label, size=(100,15) if align else None)
  10. sizer.Add(label, 0, wx.RIGHT, 10)
  11. self.slider=wx.Slider(self, value=default_value*100, minValue=min_value*100, maxValue=max_value*100)
  12. sizer.Add(self.slider, 1, wx.EXPAND)
  13. self.SetSizerAndFit(sizer)
  14. self.Bind=self.Bind
  15. class CommsPanel(wx.Panel):
  16. """ OSC comms """
  17. def __init__(self, parent):
  18. wx.Panel.__init__(self, parent)
  19. sizer = wx.BoxSizer(wx.HORIZONTAL)
  20. label = wx.StaticText(self, label="Sync:")
  21. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  22. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT|wx.EXPAND, 5)
  23. self.master = wx.ToggleButton(self, 1, "Master/Minion")
  24. sizer.Add(self.master, 0, wx.ALL, 3)
  25. self.ip=wx.TextCtrl(self, value="127.0.0.1")
  26. sizer.Add(self.ip, 0, wx.ALL, 3)
  27. self.port=wx.TextCtrl(self, value="9000")
  28. sizer.Add(self.port, 0, wx.ALL, 3)
  29. self.SetSizerAndFit(sizer)
  30. class InputPanel(wx.Panel):
  31. ''' Handle the ADC input settings '''
  32. def __init__(self, parent):
  33. ''' Constructor '''
  34. wx.Panel.__init__(self, parent)
  35. sizer = wx.BoxSizer(wx.HORIZONTAL)
  36. label = wx.StaticText(self, label="Line In:")
  37. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  38. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  39. self.gain = OSCSlider(self, "Gain", default_value=.5, align=False)
  40. sizer.Add(self.gain, 1, wx.ALL, 5)
  41. self.thru = OSCSlider(self, "Thru", default_value=.5, align=False)
  42. sizer.Add(self.thru, 1, wx.ALL, 5)
  43. self.mute = wx.ToggleButton(self, 1, "Mute")
  44. self.mute.SetValue(1)
  45. sizer.Add(self.mute, 0)
  46. self.SetSizerAndFit(sizer)
  47. self.gain.Bind(wx.EVT_SCROLL, self.update)
  48. self.thru.Bind(wx.EVT_SCROLL, self.update)
  49. self.mute.Bind(wx.EVT_TOGGLEBUTTON, self.update)
  50. self.update()
  51. def update(self, evt=None):
  52. """ Send OSC messages """
  53. gain=self.gain.slider.GetValue()/100.
  54. thru=self.thru.slider.GetValue()/100.
  55. if self.mute.GetValue(): gain, thru = 0.,0.
  56. try:
  57. sendOSCMsg("/input", [gain, thru])
  58. except OSCClientError:
  59. pass
  60. class DelayPanel(wx.Panel):
  61. ''' Handle the ADC input settings '''
  62. def __init__(self, parent):
  63. ''' Constructor '''
  64. wx.Panel.__init__(self, parent)
  65. sizer = wx.BoxSizer(wx.VERTICAL)
  66. label = wx.StaticText(self, label="Delay lines:")
  67. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  68. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  69. self.delayTime=OSCSlider(self, "Delay time (s)", default_value=1, max_value=10)
  70. sizer.Add(self.delayTime, 0, wx.EXPAND|wx.ALL, 5)
  71. self.feedback=OSCSlider(self, "Feedback", default_value=.99)
  72. sizer.Add(self.feedback, 0, wx.EXPAND|wx.ALL, 5)
  73. self.SetSizerAndFit(sizer)
  74. self.delayTime.Bind(wx.EVT_SCROLL, self.update)
  75. self.feedback.Bind(wx.EVT_SCROLL, self.update)
  76. self.update(None)
  77. def update(self, evt):
  78. """ Send OSC messages """
  79. a=self.delayTime.slider.GetValue()/100.
  80. b=self.feedback.slider.GetValue()/100.
  81. try:
  82. sendOSCMsg("/delay", [a, b])
  83. except OSCClientError:
  84. pass
  85. class Channel(wx.Panel):
  86. """ A single channel """
  87. def __init__(self, parent, index):
  88. self.index=index
  89. wx.Panel.__init__(self, parent)
  90. sizer = wx.BoxSizer(wx.VERTICAL)
  91. label = wx.StaticText(self, label="CH%d" % self.index)
  92. font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
  93. sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
  94. self.gain = OSCSlider(self, "Gain", default_value=0, align=False)
  95. sizer.Add(self.gain, 0, wx.ALL|wx.EXPAND, 3)
  96. self.pan = OSCSlider(self, "Pan", min_value=-1, max_value=1, default_value=0, align=False)
  97. sizer.Add(self.pan, 0, wx.ALL|wx.EXPAND, 3)
  98. self.record = wx.ToggleButton(self, 1, "Arm")
  99. sizer.Add(self.record, 0, wx.ALL|wx.EXPAND if index==0 else wx.ALL|wx.EXPAND, 3)
  100. self.mute = wx.ToggleButton(self, 1, "Mute")
  101. sizer.Add(self.mute, 0, wx.ALL|wx.EXPAND, 3)
  102. self.clear = wx.Button(self, 1, "Clear")
  103. sizer.Add(self.clear, 0, wx.ALL|wx.EXPAND, 3)
  104. self.SetSizerAndFit(sizer)
  105. self.gain.Bind(wx.EVT_SCROLL, self.update)
  106. self.pan.Bind(wx.EVT_SCROLL, self.update)
  107. self.mute.Bind(wx.EVT_TOGGLEBUTTON, self.update)
  108. def update(self, evt):
  109. print "Channel %d: send gain, pan, mute" % self.index
  110. class Mixer(wx.Panel):
  111. ''' All the channels '''
  112. def __init__(self, parent):
  113. ''' Constructor '''
  114. wx.Panel.__init__(self, parent)
  115. sizer = wx.BoxSizer(wx.HORIZONTAL)
  116. self.channels=[]
  117. for i in range(4):
  118. c=Channel(self, index=i)
  119. c.record.Bind(wx.EVT_TOGGLEBUTTON, self.switch_record)
  120. c.record.index=i
  121. c.clear.Bind(wx.EVT_BUTTON, self.clear_channel)
  122. self.channels.append(c)
  123. sizer.Add(c, 1, wx.EXPAND)
  124. self.SetSizerAndFit(sizer)
  125. def switch_record(self, evt):
  126. """ Send OSC message to switch recording channel """
  127. index = evt.GetEventObject().index
  128. value = evt.GetEventObject().GetValue()
  129. for i, c in enumerate(self.channels):
  130. c.record.SetValue(0)
  131. self.channels[index].record.SetValue(value)
  132. def clear_channel(self, evt):
  133. """ Send OSC message to clear a channel """
  134. pass
  135. class MainGUI(wx.Frame):
  136. """ A simple GUI to talk to Chuck """
  137. def __init__(self):
  138. """ Constructor """
  139. # Build the interface
  140. self.app = wx.App(False)
  141. self.build()
  142. self.app.MainLoop()
  143. def build(self):
  144. """ Builds the various pieces of the GUI """
  145. wx.Frame.__init__(self, None, title="DELAY LORD")
  146. self.Bind(wx.EVT_CLOSE, self.quit)
  147. # The main sizer
  148. self.mainsizer = wx.BoxSizer(wx.VERTICAL)
  149. self.commsPanel = CommsPanel(self)
  150. self.mainsizer.Add(self.commsPanel, 0, wx.EXPAND|wx.ALL, 5)
  151. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  152. self.inputPanel = InputPanel(self)
  153. self.mainsizer.Add(self.inputPanel, 0, wx.EXPAND|wx.ALL, 5)
  154. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  155. self.delayPanel = DelayPanel(self)
  156. self.mainsizer.Add(self.delayPanel, 0, wx.EXPAND|wx.ALL, 5)
  157. line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 1)
  158. self.mixer = Mixer(self)
  159. self.mainsizer.Add(self.mixer, 1, wx.EXPAND|wx.ALL, 5)
  160. # Put things together
  161. self.SetSizerAndFit(self.mainsizer)
  162. self.Show()
  163. def populate_left_panel(self):
  164. """ Populate the left panel """
  165. # Status boxes
  166. def quit(self, *args):
  167. """ Close down gracefully, and then destroy the window """
  168. self.Destroy()
  169. if __name__ == "__main__":
  170. initOSCClient(ip="127.0.0.1", port=9000)
  171. g=MainGUI()
  172. closeOSC()