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.

69 line
1.6KB

  1. // Effects chain
  2. Gain mixer => dac; // Main mixer
  3. adc => Gain adcThru => mixer; // Monitor the input
  4. adc => Gain feedback => DelayL delay => feedback; // Delay line
  5. delay => Gain delaySend => mixer; // Connect delay to mixer
  6. // Delay parameters
  7. 10::second => delay.max;
  8. 5::second => delay.delay;
  9. 0 => adc.gain;
  10. 1 => feedback.gain;
  11. .5 => delaySend.gain;
  12. .5 => adcThru.gain;
  13. // OSC listener class
  14. class OSCListener {
  15. fun void run(int port, string address) {
  16. OscRecv recv; port => recv.port; recv.listen();
  17. recv.event(address) @=> OscEvent oe;
  18. while (true) { oe => now; while (oe.nextMsg() != 0) { this.handle(oe); } }
  19. me.yield();
  20. }
  21. fun void handle(OscEvent oe){};
  22. }
  23. // define child class Y
  24. class InputListener extends OSCListener {
  25. fun void handle(OscEvent oe){
  26. oe.getFloat() => adc.gain;
  27. oe.getFloat() => adcThru.gain;
  28. <<< "Edit input" >>>;
  29. }
  30. }
  31. // define child class Y
  32. class DelayListener extends OSCListener
  33. {
  34. fun void handle(OscEvent oe){
  35. oe.getFloat()::second => delay.delay;
  36. oe.getFloat() => feedback.gain;
  37. <<< "Edit delay" >>>;
  38. }
  39. }
  40. // define child class Y
  41. class ChannelListener extends OSCListener
  42. {
  43. fun void handle(OscEvent oe){
  44. oe.getInt() => int channel;
  45. oe.getFloat();
  46. oe.getFloat();
  47. <<< "Edit channel" >>>;
  48. }
  49. }
  50. InputListener il;
  51. DelayListener dl;
  52. ChannelListener cl;
  53. spork ~ il.run(9000, "/input, f, f");
  54. spork ~ dl.run(9000, "/delay, f, f");
  55. spork ~ cl.run(9000, "/channel, i, f, f");
  56. // Loop forever
  57. while(true) { 1::second => now; }