[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Granular synthesis software

Does anyone know of any freely available code for granular synthesis -
pref. in Matlab, but C++ or Visual Basic would also be OK.  Any leads are
Basic granular synthesis is actually pretty easy in matlab, make a
sparse matrix, scatter grains randomly in it and then do an inverse
STFT.  Here's some quick and dirty code.  You can easily extend it to
control other parameters as well by changing the way you construct y.


bw = 20; % Bandwidth (in FFT bins)
bc = 30; % Freq center (in FFT bins)
d = .5; % Grain density
sz = 512; % FFT size
l = 1000; % FFT frame length

% Make grains
y = sparse( ...
 round( (bw/4)*randn( 1, d*l)+bc), ...
 round( linspace( 1, l, d*l)), ...
 randn( 1, d*l));
y(sz/2+1,l) = 0;

h = hanning( sz);
s = zeros( l*(sz/4)+sz, 1);
for i = 1:l
 z = full( [y(:,i); y(end-1:-1:2,i)]);
 s((i-1)*(sz/4)+1:(i-1)*(sz/4)+sz) = ...
  s((i-1)*(sz/4)+1:(i-1)*(sz/4)+sz) + h.*real( ifft( z));

soundsc( s, 44100)