Sampler in ChucK
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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