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.

106 lines
5.2KB

  1. (
  2. /*
  3. This is the interface and score for [___south america___] miscellany.
  4. In performace, text (words, phrases, numbers, dates, etc.) are read from a travel journal.
  5. When reading, press the record button to bring the audio into the system.
  6. All parameters in the GUI are free to manipulate.
  7. */
  8. var length, recbuf, feedbackbuf, timebuf, envbuf, sinebus, grainbus, feedbackbus;
  9. length = 60; recbuf = Buffer.alloc(s, s.sampleRate * length); feedbackbuf = Buffer.alloc(s, s.sampleRate * length);
  10. timebuf = Buffer.alloc(s, 2000); envbuf = Buffer.loadCollection(s, Array.fill(1024, {1}));
  11. sinebus = Bus.audio(s); grainbus = Bus.audio(s); feedbackbus = Bus.audio(s);
  12. SynthDef(\rec,{
  13. var in, trig, step, time;
  14. in = SoundIn.ar(0); trig = KeyState.kr(65, 0, 1, 0);
  15. step = Stepper.kr(trig, 0, 0, 2000, 1); time = Integrator.kr(trig / s.sampleRate * s.options.blockSize).trunc(0.1);
  16. BufWr.kr(time, timebuf.bufnum, step);
  17. RecordBuf.ar(in, recbuf.bufnum, Latch.kr(time, trig), 1, 0, trig, 0, 0, trig);
  18. RecordBuf.ar(in, feedbackbuf.bufnum, Latch.kr(time, trig), 1, 0, trig, 0, 0, trig);
  19. SendTrig.kr(trig, 0, step);
  20. }).add;
  21. SynthDef(\play, { |num = 0 step = 0 min = 2 max = 5 grainprob = 0.1 fbprob = 0.1 delaytime = 0.02 fbc = 50, blur = 0|
  22. var trig, rand, pos, dur, env, blurenv, grain, sineout, grainout, fbtrig, feedbackout;
  23. trig = Impulse.kr(LocalIn.kr(1, 0.1).reciprocal);
  24. rand = TRand.kr(0, step, trig).trunc; pos = BufRd.kr(1, timebuf.bufnum, rand);
  25. dur = BufRd.kr(1, timebuf.bufnum, rand + 1) - pos;
  26. env = GrainBuf.ar(1, trig, dur, envbuf, 1, 0, 1, 0, envbuf);
  27. //blurenv = EnvGen.kr(Env.xyc([[0, 0, (blur - 1).abs * -500],
  28. // [0.5, 1, (blur - 1).abs * 500], [1, 0, (blur - 1).abs * 500]]), env, timeScale: dur);
  29. grain = GrainBuf.ar(1, trig, dur, recbuf, 1, pos / 60, 1, 0, envbuf) * env.lag(blur * 0.1);
  30. sineout = SinOsc.ar(50, 1.0.rand) * (env - 1).abs.lag(blur * 0.5);
  31. grainout = grain * (TRand.kr(0, 1, trig) < Latch.kr(grainprob, trig));
  32. fbtrig = TRand.kr(0, 1, trig) < Latch.kr(fbprob, trig);
  33. feedbackout = CombC.ar(fbtrig * grain, 0.1, delaytime, fbc * env.lag(0, blur * 50)) * (fbtrig * env).lag(0, blur * 50);
  34. Out.ar(grainbus, grainout); Out.ar(sinebus, sineout); Out.ar(feedbackbus, feedbackout);
  35. LocalOut.kr(TRand.kr(0, max - min, trig).trunc(0.1) + min + Select.kr(step > num + 1, [DC.kr(0.1), dur]));
  36. Poll.kr(trig, blur, \test);
  37. }).add;
  38. SynthDef(\out, {|recamp = 1 fbamp = 1 sinamp = 0.5|
  39. Out.ar([0, 1], (Clip.ar(In.ar(sinebus), -1, 1) * sinamp) + (In.ar(grainbus) * recamp) + (In.ar(feedbackbus) * fbamp ));
  40. }).add;
  41. SynthDef(\bass, {
  42. Out.ar([0, 1], CombC.ar(SinOsc.ar(50) * KeyState.kr(56, 0, 1), 0.02, 0.02, 25))
  43. }).add;
  44. )
  45. (
  46. var bass, out, players, labels, sliders, win, count = 0, record, saturate;
  47. Synth(\rec);
  48. bass = Synth(\bass);
  49. out = Synth.tail(s, \out);
  50. players = List.new();
  51. sliders = List.new();
  52. win = Window("[___South America___] miscellany", Rect(128, 64, 475, 240));
  53. win.view.decorator=FlowLayout(win.view.bounds); win.view.decorator.gap=2@2;
  54. labels = [" min grain gap ", " max grain gap ", " grain prob ", " feedback prob ", " delay time ", " fbc ", " blur "];
  55. labels.do({|l| sliders.add(EZSlider(win, 450@16, l, labelWidth: 110))});
  56. sliders[0].controlSpec = ControlSpec(0, 2, \lin, 0, 2, ""); sliders[0].value = 2;
  57. sliders[0].action = {|ez| if(ez.value > sliders[1].value, {sliders[1].valueAction = ez.value});
  58. players.do({|i| i.set(\min, ez.value)})};
  59. sliders[1].controlSpec = ControlSpec(0, 5, \lin, 0, 5, ""); sliders[1].value = 5;
  60. sliders[1].action = {|ez| if(ez.value < sliders[0].value, {sliders[0].valueAction = ez.value});
  61. players.do({|i| i.set(\max, ez.value)})};
  62. sliders[2].controlSpec = ControlSpec(0, 1, \lin, 0, 0.1, ""); sliders[2].value = 0.1;
  63. sliders[2].action = {|ez| players.do({|i| i.set(\grainprob, ez.value)})};
  64. sliders[3].controlSpec = ControlSpec(0, 1, \lin, 0, 0.1, ""); sliders[3].value = 0.1;
  65. sliders[3].action = {|ez| players.do({|i| i.set(\fbprob, ez.value)})};
  66. sliders[4].controlSpec = ControlSpec(0.02, 0.03, \lin, 0, 0.02, ""); sliders[4].value = 0.02;
  67. sliders[4].action = {|ez| (players.size() / 3).do({|i| players[i].set(\delaytime, ez.value)})};
  68. sliders[5].controlSpec = ControlSpec(0, 50, \lin, 0, 50, ""); sliders[5].value = 50;
  69. sliders[5].action = {|ez| players.do({|i| i.set(\fbc, ez.value)})};
  70. sliders[6].controlSpec = ControlSpec(0, 1, \lin, 0, 0, ""); sliders[6].value = 0;
  71. sliders[6].action = {|ez| players.do({|i| i.set(\blur, ez.value)})};
  72. EZSlider(win, 450@16," grain amp ", ControlSpec(0, 1, \lin, 0, 1, ""),
  73. {|ez| out.set(\recamp, ez.value)}, labelWidth: 110);
  74. EZSlider(win, 450@16," sin amp ", ControlSpec(0, 1, \lin, 0, 0.5, ""),
  75. {|ez| out.set(\sinamp, ez.value)}, labelWidth: 110);
  76. EZSlider(win, 450@16," feedback amp ", ControlSpec(0, 1, \lin, 0, 1, ""),
  77. {|ez| out.set(\fbamp, ez.value)}, labelWidth: 110);
  78. record = Button(win, Rect(0, 0, 375, 50)).states_([["record", Color.black, Color.red]]);
  79. saturate = Button(win, Rect(0, 0, 75, 50)).states_([["saturate", Color.black, Color.red]]);
  80. OSCFunc({ arg msg, time;
  81. count = count + 1; players.add(Synth(\play, [\num, count,
  82. \min, sliders[0].value, \max, sliders[1].value, \grainprob, sliders[2].value, \fbprob, sliders[3].value,
  83. \delaytime, sliders[4].value, \fbc, sliders[5].value, \blur, sliders[6].value]));
  84. players.do({|i| i.set(\step, msg[3])});
  85. },'/tr', s.addr);
  86. win.front;
  87. )