annotate dsp/synth/unbuffer_nu.m @ 61:eff6bddf82e3
tip
Finally implemented perceptual brightness thing.
author |
samer |
date |
Sun, 11 Oct 2015 10:20:42 +0100 |
parents |
9e7be347b3a0 |
children |
|
rev |
line source |
samer@34
|
1 % unbuffer_nu - Non-uniform hop overlap and add
|
samer@34
|
2 %
|
samer@34
|
3 % unbuffer_nu ::
|
samer@34
|
4 % seq([[1,_]]) ~'sequence of overlapping frames',
|
samer@34
|
5 % seq(natural) ~'sequence of hop sizes'
|
samer@34
|
6 % -> seq([[1,_]]) ~'sequence of de-overlapped frames'.
|
samer@34
|
7
|
samer@34
|
8 function Y=unbuffer_nu(X,hop)
|
samer@36
|
9 Y=zipaccum(@olap,[],hop,X);
|
samer@34
|
10
|
samer@34
|
11 function [y,s1]=olap(hop,x,s)
|
samer@34
|
12 ls=length(s);
|
samer@34
|
13 lx=length(x);
|
samer@34
|
14 if lx>=hop
|
samer@34
|
15 if ls>=hop
|
samer@34
|
16 % NB: this will fail if ls>lx, but this shouldn't happen since ls<=lx-hop
|
samer@34
|
17 y=(x(1:hop)+s(1:hop))';
|
samer@34
|
18 s1=[s(hop+1:ls)+x(hop+1:ls);x(ls+1:end)];
|
samer@34
|
19 else
|
samer@34
|
20 y=[x(1:ls)+s;x(ls+1:hop)]';
|
samer@34
|
21 s1=x(hop+1:end);
|
samer@34
|
22 end
|
samer@34
|
23 else
|
samer@34
|
24 if ls>=hop
|
samer@34
|
25 y=[s(1:lx)+x;s(lx+1:hop)]';
|
samer@34
|
26 s1=s(hop+1:end);
|
samer@34
|
27 else
|
samer@34
|
28 y=zeros(1,hop);
|
samer@34
|
29 y(1:ls)=y(1:ls)+s';
|
samer@34
|
30 y(1:lx)=y(1:lx)+x';
|
samer@34
|
31 end
|
samer@34
|
32 end
|
samer@34
|
33 end
|
samer@34
|
34 end
|
samer@34
|
35
|