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.

52 lines
1.2KB

  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. .5 => adcThru.gain;
  13. // Start recording and playing in a loop
  14. 1 => sample.loop => sample.record => sample.play;
  15. // Listen to OSC messages
  16. OscIn oin; 9000 => oin.port;
  17. oin.listenAll();
  18. OscMsg msg;
  19. // Event loop
  20. while (true) {
  21. oin => now;
  22. while (oin.recv(msg)) {
  23. <<<msg.address>>>;
  24. if (msg.address=="/input")
  25. controlInput(msg);
  26. else if(msg.address=="/delay")
  27. controlDelay(msg);
  28. else if(msg.address=="/channel")
  29. controlChannel(msg);
  30. }
  31. }
  32. fun void controlInput(OscMsg msg){
  33. msg.getFloat(0) => adc.gain;
  34. msg.getFloat(1) => adcThru.gain;
  35. }
  36. fun void controlDelay(OscMsg msg){
  37. msg.getFloat(0)::second => sample.loopEnd => sample.loopEndRec;
  38. msg.getFloat(1) => sample.feedback;
  39. }
  40. fun void controlChannel(OscMsg msg){
  41. msg.getInt(0) => int channel;
  42. msg.getFloat(1) => sample.gain;
  43. }