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