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.

54 lines
1.3KB

  1. // Effects chain
  2. Gain mixer => dac; // Main mixer
  3. adc => Gain adcThru => mixer; // Monitor the input
  4. adc => LiSa sample => mixer; // Sampler
  5. // TODO: turn off adcThru when recording
  6. //Times
  7. 10::second => sample.duration;
  8. 0::second => sample.recPos => sample.playPos;
  9. 1::second => sample.loopEnd => sample.loopEndRec;
  10. // Levels
  11. //0 => adc.gain;
  12. 1 => sample.feedback;
  13. .5 => sample.gain;
  14. .5 => adcThru.gain;
  15. // Start recording and playing in a loop
  16. 1 => sample.loop => sample.record => sample.play;
  17. // Listen to OSC messages
  18. OscIn oin; 9000 => oin.port;
  19. oin.listenAll();
  20. OscMsg msg;
  21. // Event loop
  22. while (true) {
  23. oin => now;
  24. while (oin.recv(msg)) {
  25. <<<msg.address>>>;
  26. if (msg.address=="/input")
  27. controlInput(msg);
  28. else if(msg.address=="/delay")
  29. controlDelay(msg);
  30. else if(msg.address=="/channel")
  31. controlChannel(msg);
  32. }
  33. }
  34. fun void controlInput(OscMsg msg){
  35. msg.getFloat(0) => adc.gain;
  36. msg.getFloat(1) => adcThru.gain;
  37. }
  38. fun void controlDelay(OscMsg msg){
  39. msg.getFloat(0)::second => sample.loopEnd => sample.loopEndRec;
  40. msg.getFloat(1) => sample.feedback;
  41. }
  42. fun void controlChannel(OscMsg msg){
  43. msg.getInt(0) => int channel;
  44. msg.getFloat(1) => sample.gain;
  45. }