annotate dsp/synth/@blit/block.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents c75bb62b90a9
children
rev   line source
samer@34 1 function [y,phi]=block(o,phi,T,cutoff,f)
samer@34 2 % block - Generate block of blit signal data
samer@34 3 %
samer@34 4 % block ::
samer@34 5 % blit ~'blit object'
samer@34 6 % 0--1 ~'initial phase (in cycles)'
samer@34 7 % N:natural ~'number of samples to compute',
samer@34 8 % 0--1 ~'normalised frequency (1=sampling freq)',
samer@34 9 % 0--0.5 ~'cutoff harmonics above this frequency [0.5]',
samer@34 10 % -> [[1,N]] ~'band-limited impulse train',
samer@34 11 % 0--1 ~'initial phase for next block'.
samer@34 12
samer@34 13 m = max(1,2*floor(cutoff/f)-1); % number of harmonics to keep
samer@34 14 y = m*f*diric(2*pi*(phi+f*(0:T-1)),m)-f;
samer@34 15 phi = mod(phi+f*T,1);
samer@34 16
samer@34 17 % If diric is not available then use this
samer@34 18 % y=zeros(1,T);
samer@34 19 % phase = pi*(phi+f*(0:T-1));
samer@34 20 % modcheck=mod(phase,pi);
samer@34 21 % I=modcheck>0.001 & modcheck<(pi-0.001);
samer@34 22 % y(~I) = f*m;
samer@34 23 % y(I) = f*sin(m*phase(I))./sin(phase(I));
samer@34 24
samer@34 25