[89ea83]: demos / demo_blockproc_basicloop.m Maximize Restore History

Download this file

demo_blockproc_basicloop.m    37 lines (32 with data), 870 Bytes

 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
function demo_blockproc_basicloop(source,varargin)
%DEMO_BLOCKPROC_BASICLOOP Basic real-time audio manipulation
% Usage: demo_blockproc_basicloop('gspi.wav')
%
% For additional help call |demo_blockproc_basicloop| without arguments.
%
% The demo runs simple playback loop allowing to set gain in dB.
%
if demo_blockproc_header(mfilename,nargin)
return;
end
% Basic Control pannel (Java object)
p = blockpanel({
{'GdB','Gain',-20,20,0,21},...
});
bufLen = 1024;
% Setup blocktream
if isoctave
block(source,varargin{:},'L',bufLen);
else
block(source,varargin{:},'loadind',p,'L',bufLen);
end
flag = 1;
%Loop until end of the stream (flag) and until panel is opened
while flag && p.flag
gain = blockpanelget(p,'GdB');
gain = 10^(gain/20);
[f,flag] = blockread();
blockplay(f*gain);
end
blockdone();
p.close();