samer@34: function y=noodle(Pitch,Dur,N,varargin) samer@34: % noodle - noodle with arbitrary note durations and meter samer@34: % samer@34: % noodle :: samer@34: % seq(natural) ~'sequence of top-line pitches in semitones', samer@34: % seq(nonneg) ~'sequence of durations', samer@34: % natural ~'bass note duration multiplier', samer@34: % options { samer@34: % decay1 :: real /8000 ~'time constant for melody decay'; samer@34: % decay2 :: real /1600 ~'time constant for bass decay'; samer@34: % period :: real /1600 ~'samples per metrical unit'; samer@34: % buffer :: nonneg /0.4 ~'duration of buffers in seconds' samer@34: % } samer@34: % -> seq([[1,N]]) ~'sequence of audio buffers'. samer@34: samer@37: opts=options('bpm',120,'buffer',0.4, ... samer@34: 'decay1',8000,'decay2',1600, ... samer@34: 'attack1', 16, 'attack2', 16, ... samer@34: 'release1', 64, 'release2', 64, ... samer@34: 'transpose',-5, ... samer@34: 'fs',11025, ... samer@34: 'betap1',[2.2,8], ... samer@34: 'betap2',[1.1,12], ... samer@34: varargin{:}); samer@34: samer@34: env = { ... samer@34: envadr(opts.attack1,opts.decay1,opts.release1), ... samer@34: envadr(opts.attack2,opts.decay2,opts.release1) }; samer@34: samer@34: s1=sonify(Pitch,Dur,opts,'env',env{1},'betap',opts.betap1); samer@34: s2=sonify(Pitch-12,N,opts,'env',env{2},'betap',opts.betap2); samer@34: y=0.27*s1+0.50*s2; samer@34: samer@34: samer@34: