Mercurial > hg > ishara
diff dsp/synth/sonify_formant.m @ 34:c75bb62b90a9
Imported audio synthesis tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 19:05:05 +0000 |
parents | |
children | beb8a3f4a345 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dsp/synth/sonify_formant.m Sun Jan 20 19:05:05 2013 +0000 @@ -0,0 +1,23 @@ +% sonify_formant - sonify using formant synthesis +function Y=sonify_formant(Controllers,S,varargin) + + opts=prefs('bpm',240,'fs',11025,'buffer',0.125,'q',0.05,'cfilter',[],varargin{:}); + + CC = cellmap(@(f)f/opts.fs,Controllers); + f0 = window(map(@getf0,S)); + fx = window(map(@getfx,S)); + + if ~isempty(opts.cfilter) + f0 = filter(opts.cfilter{1},opts.cfilter{2},f0); + fx = filter(opts.cfilter{1},opts.cfilter{2},fx,[],2); + end + Y = formant_synth(256,opts.q,0.2,f0,fx); + + % rebuffer to constant size + if ~isempty(opts.buffer) + Y=windowdata(Y,ceil(opts.buffer*opts.fs)); + end + + function z=getf0(s),z=CC{s}(:,1)'; end + function z=getfx(s),z=CC{s}(:,2:end)'; end +end