annotate dsp/synth/noodle.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents beb8a3f4a345
children
rev   line source
samer@34 1 function y=noodle(Pitch,Dur,N,varargin)
samer@34 2 % noodle - noodle with arbitrary note durations and meter
samer@34 3 %
samer@34 4 % noodle ::
samer@34 5 % seq(natural) ~'sequence of top-line pitches in semitones',
samer@34 6 % seq(nonneg) ~'sequence of durations',
samer@34 7 % natural ~'bass note duration multiplier',
samer@34 8 % options {
samer@34 9 % decay1 :: real /8000 ~'time constant for melody decay';
samer@34 10 % decay2 :: real /1600 ~'time constant for bass decay';
samer@34 11 % period :: real /1600 ~'samples per metrical unit';
samer@34 12 % buffer :: nonneg /0.4 ~'duration of buffers in seconds'
samer@34 13 % }
samer@34 14 % -> seq([[1,N]]) ~'sequence of audio buffers'.
samer@34 15
samer@37 16 opts=options('bpm',120,'buffer',0.4, ...
samer@34 17 'decay1',8000,'decay2',1600, ...
samer@34 18 'attack1', 16, 'attack2', 16, ...
samer@34 19 'release1', 64, 'release2', 64, ...
samer@34 20 'transpose',-5, ...
samer@34 21 'fs',11025, ...
samer@34 22 'betap1',[2.2,8], ...
samer@34 23 'betap2',[1.1,12], ...
samer@34 24 varargin{:});
samer@34 25
samer@34 26 env = { ...
samer@34 27 envadr(opts.attack1,opts.decay1,opts.release1), ...
samer@34 28 envadr(opts.attack2,opts.decay2,opts.release1) };
samer@34 29
samer@34 30 s1=sonify(Pitch,Dur,opts,'env',env{1},'betap',opts.betap1);
samer@34 31 s2=sonify(Pitch-12,N,opts,'env',env{2},'betap',opts.betap2);
samer@34 32 y=0.27*s1+0.50*s2;
samer@34 33
samer@34 34
samer@34 35