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.

пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // TODO: turn off adcThru when recording
  2. // TODO: Effects break panning for some unknown reason
  3. // TODO: currently I don't turn ADC thru back on after recording
  4. // Effects chain with limiters, reverb, filters
  5. NRev reverb => LPF lpf => Dyno outputLimiter => dac;
  6. outputLimiter.limit();
  7. reverb @=> UGen @ outputWet; // Reference to wet output
  8. outputLimiter @=> UGen @ outputDry; // Reference to dry output
  9. outputLimiter @=> UGen @ mainOutput; // Reference to main output
  10. // Capture mic/line in and monitor through DAC. Limit
  11. adc => Dyno inputLimiter => Gain adcThru => mainOutput; // Monitor input
  12. inputLimiter.limit();
  13. inputLimiter @=> UGen @ mainInput;
  14. // Default parameters
  15. .5 => adcThru.gain;
  16. 10000 => lpf.freq;
  17. 1::second => dur loopTime;
  18. // Plug in the pedals
  19. LoopPedal pedals[4];
  20. for( 0 => int i; i < pedals.cap(); i++ ) {
  21. pedals[i].recordFrom(mainInput);
  22. pedals[i].outputTo(outputWet, outputDry);
  23. }
  24. // Start listening to OSC messages
  25. OscIn oin; 9000 => oin.port;
  26. oin.listenAll();
  27. OscMsg msg;
  28. // Event loop
  29. while (true) {
  30. oin => now;
  31. while (oin.recv(msg)) {
  32. if (msg.address=="/input") {
  33. msg.getFloat(0) => adc.gain;
  34. msg.getFloat(1) => adcThru.gain;
  35. }
  36. else if(msg.address=="/delay") {
  37. msg.getFloat(0)::second => loopTime;
  38. msg.getFloat(1) => float feedback;
  39. for( 0 => int i; i < pedals.cap(); i++ ) {
  40. pedals[i].setLoopPoint(loopTime);
  41. pedals[i].setFeedback(feedback);
  42. }
  43. }
  44. else if(msg.address=="/channel") {
  45. msg.getInt(0) => int i;
  46. pedals[i].setGain(msg.getFloat(1));
  47. pedals[i].setPan(msg.getFloat(2));
  48. pedals[i].setWet(msg.getFloat(3));
  49. }
  50. else if(msg.address=="/arm") {
  51. msg.getInt(0) => int channel;
  52. for( 0 => int i; i < pedals.cap(); i++ ) { pedals[i].arm(i==channel); }
  53. }
  54. else if(msg.address=="/metronome") {
  55. //msg.getInt(0) => metronomeLevel;
  56. }
  57. else if(msg.address=="/clear") {
  58. msg.getInt(0) => int channel;
  59. pedals[channel].clear();
  60. }
  61. else if(msg.address=="/fx") {
  62. (100+msg.getFloat(0)*10000) => lpf.freq;
  63. msg.getFloat(1) => reverb.mix;
  64. }
  65. else if(msg.address=="/master") {
  66. msg.getFloat(0) => mainOutput.gain;
  67. }
  68. }
  69. }
  70. public class LoopPedal
  71. {
  72. // We are wrapping a live sampler, LiSa
  73. LiSa sample;
  74. sample => Gain wet;
  75. sample => Gain dry;
  76. // Setup
  77. 10::second => sample.duration; // Allocate max 10 secs of memory
  78. 0::second => sample.recPos => sample.playPos;
  79. 1.0 => sample.feedback;
  80. 1 => sample.loop;
  81. setLoopPoint(1::second);
  82. setWet(0.5);
  83. public void setLoopPoint( dur length ) { length => sample.loopEnd => sample.loopEndRec; }
  84. public void setFeedback( float fb ) { fb => sample.feedback; }
  85. public void setGain( float gain ) { gain => sample.gain; }
  86. public void setPan( float pan ) { } //pan => panner.pan; }
  87. public void setWet( float ratio ) { ratio => wet.gain; 1-ratio => dry.gain;}
  88. public void clear() { sample.clear(); }
  89. public void recordFrom(UGen ugen) { ugen => sample; }
  90. public void outputTo(UGen wetSink, UGen drySink) {
  91. 1 => sample.play;
  92. wet => wetSink;
  93. dry => drySink;
  94. }
  95. public void arm(int value) {
  96. 0 => adcThru.gain;
  97. sample.playPos() => sample.recPos;
  98. value => sample.record;
  99. }
  100. }
  101. /*
  102. // Start the metronome and the vu meter (optional)
  103. //0 => int metronomeLevel;
  104. //spork ~plip();
  105. //spork ~vu_meter();
  106. fun void vu_meter()
  107. {
  108. // Analysis stuff
  109. adc => FFT fft =^ RMS rms => blackhole;
  110. 1<<12 => int fftsize;
  111. fftsize => fft.size;
  112. Windowing.hann(fftsize) => fft.window;
  113. // Comms
  114. OscOut xmit; xmit.dest( "localhost", 6649 );
  115. // Infinite loop: get RMS and send to GUI
  116. while(true)
  117. {
  118. rms.upchuck() @=> UAnaBlob blob;
  119. xmit.start("/vu");
  120. blob.fval(0) => xmit.add;
  121. xmit.send();
  122. fft.size()::samp => now;
  123. }
  124. }
  125. // TODO timing here should be done using events
  126. fun void metronome()
  127. {
  128. SinOsc s => dac;
  129. 0.01::second => dur plipTime;
  130. while(true){
  131. for( 0 => int i; i < 4; i++ ) {
  132. if (i==0){2000 => s.freq;} else {1000 => s.freq;}
  133. .1*metronomeLevel => s.gain;
  134. plipTime => now;
  135. 0 => s.gain;
  136. loopTime/4 - plipTime => now;
  137. }
  138. }
  139. }
  140. */