[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
appreciated.
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.
Paris
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;
% Do ISTFT
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));
end
soundsc( s, 44100)