annotate dsp/synth/@hardsync/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 [x,phi]=block(o,phi0,N,f0,f1)
|
samer@34
|
2 % block - Generate block of hardsync signal data
|
samer@34
|
3 %
|
samer@34
|
4 % block ::
|
samer@34
|
5 % hardsync,
|
samer@34
|
6 % 0--1 ~'initial phase of master'
|
samer@34
|
7 % N:natural ~'number of samples to compute',
|
samer@34
|
8 % 0--1 ~'normalised frequency of master (1=sampling freq)',
|
samer@34
|
9 % 0--1 ~'normalised frequency of slave (1=sampling freq)',
|
samer@34
|
10 % -> [[1,N]] ~'signal data',
|
samer@34
|
11 % 0--1 ~'initial phase for next block'.
|
samer@34
|
12
|
samer@34
|
13 x=zeros(1,N);
|
samer@34
|
14 l0=round(1/f0);
|
samer@34
|
15
|
samer@34
|
16 j=1; T=round(l0*(1-mod(phi0,1)));
|
samer@34
|
17 phi1=f1*mod(phi0,1);
|
samer@34
|
18
|
samer@34
|
19 while j<=N && T<=N
|
samer@34
|
20 M=T-j+1;
|
samer@34
|
21 x(j:T)=phi1+f1*(0:M-1);
|
samer@34
|
22 j=T+1;
|
samer@34
|
23 T=T+l0;
|
samer@34
|
24 phi1=0;
|
samer@34
|
25 end
|
samer@34
|
26 phi0=0;
|
samer@34
|
27
|
samer@34
|
28 M=N-j+1;
|
samer@34
|
29 x(j:N)=phi1+f1*(0:M-1);
|
samer@34
|
30 phi1=phi1+f1*M;
|
samer@34
|
31 phi0=f0*M;
|
samer@34
|
32
|
samer@34
|
33
|