view 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
line wrap: on
line source
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=options('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;