grainBuf nc tr dur sndbuf rate pos interp pan envbuf Granular synthesis with sound stored in a buffer nc - the number of channels to output. If 1, mono is returned and pan is ignored. tr - a kr or ar trigger to start a new grain. If ar, grains after the start of the synth are sample accurate. The following args are polled at grain creation time dur - size of the grain. sndbuf - the buffer holding an audio signal rate - the playback rate of the sampled sound pos - the playback position for the grain to start with (0 is beginning, 1 is end of file) interp - the interpolation method used for pitchshifting grains. 1 = no interpolation. 2 = linear. 4 = cubic interpolation (more computationally intensive). pan - a value from -1 to 1. Determines where to pan the output in the same manner as PanAz. envb - the buffer number containing a signal to use for the grain envelope. -1 uses a built-in Hanning envelope. > import Sound.SC3.Monadic > let { fn = "/home/rohan/audio/metal.wav" > ; b = 10 > ; e = -1 > ; x = mouseX KR (-1) 1 Linear 0.1 > ; y = mouseY KR 10 45 Linear 0.1 > ; i = impulse KR y 0 > ; r n = linLin n (-1) 1 0.5 2 > ; p n = linLin n (-1) 1 0 1 > ; g n1 n2 = grainBuf 2 i 0.1 b (r n1) (p n2) 2 x e } > in withSC3 (\fd -> do { send fd (b_allocRead 10 fn 0 0) > ; n1 <- lfNoise1 KR 500 > ; n2 <- lfNoise2 KR 0.1 > ; play fd (out 0 (g n1 n2)) })