summaryrefslogtreecommitdiff
path: root/macros/buffer.sci
blob: 5cc480a07e95b3d2ca51b7da800279b1b16e5e08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function [y, z, opt] = buffer (x, n, p, opt)
//This function buffers the given data into a matrix of signal frames
//Calling Sequence
//[y] = buffer (x, n)
//[y] = buffer (x, n, p)
//[y] = buffer (x, n, p)
//[y, z, opt] = buffer (...)
//Parameters 
//x: Data to be buffered
//n: Positive integer equal to number of rows in the produced data buffer
//p: Integer less than n, default value 0
//opt: In case of overlap, it can be a vector of length p or the string "nodelay", In case of underlap, it is an integer between 0 and p
//Description
//This function buffers the given data into a matrix of signal frames
//Examples
//buffer(1,3,2)
//ans =
//   0   0
//   0   1
//   1   0
//This function is being called from Octave

funcprot(0);
lhs = argn(1)
rhs = argn(2)
if (rhs < 2 | rhs > 4)
error("Wrong number of input arguments.")
end

select(rhs)
	
	case 2 then
		if(lhs==1)
		y = callOctave("buffer",x,n)
		elseif(lhs==3)
		[y,z,opt] = callOctave("buffer",x,n)
		else
		error("Wrong number of output argments.")
		end

	case 3 then
		if(lhs==1)
		y = callOctave("buffer",x,n,p)
		elseif(lhs==3)
		[y,z,op] = callOctave("buffer",x,n,p)
		else
		error("Wrong number of output argments.")
	       	end
	case 4 then
		if(lhs==1)
		y = callOctave("buffer",x,n,p,opt)
		elseif(lhs==3)
		[y,z,opt] = callOctave("buffer",x,n,p,opt)
		else
		error("Wrong number of output argments.")
	       	end
	end
endfunction