~ubuntu-branches/ubuntu/wily/octave-ltfat/wily

« back to all changes in this revision

Viewing changes to inst/blockproc/blockread.m

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Rafael Laboissiere
  • Date: 2015-07-18 23:36:41 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20150718233641-jhuf3f551a3523qc
Tags: 2.1.0+dfsg-1
* Team upload.

[ Rafael Laboissiere ]
* Imported Upstream version 2.1.0+dfsg
* d/rules: Prevent unit testing on armhf and mips.
  This avoids FTBFS on theses architectures (see Bug#765545).
* Unit testing does not need X-window anymore
  + d/rules: Do not use xfvb-run to run the tests.
  + d/control: Drop xauth, xvfb, and gnuplot-nox from Build-Depends.
    Also, the versioned dependency on octave-pkg-dev is relaxed.
* Drop .jar file from upstream tarball, complying with the Debian Policy
  + d/copyright: Exclude file blockproc.jar
  + d/rules: Add get-orig-source target
  + d/watch: Mangle upstream version to cope with "+dfsg" tag
* Build blockproc.jar, which is deleted from the upstream tarball
  + d/rules: Add commands for building blockproc.jar
  + d/control: Build-depend on default-jdk
  + d/p/fix-path-of-included-makefile.patch: New patch
* Bump Standard-Versions to 3.9.6 (no changes needed)
* d/p/autoload-yes.patch: Remove patch (deprecated upstream)
* Bump Build-Depends on octave to >> 4.0.0~rc4-1 (for sndfile support)
* d/check.m: Avoid verbose output of unit tests
* d/watch: Add the repacksuffix option
* d/p/add-hardening-flags.patch: Drop patch (applied upstream)
* d/p/fix-path-of-included-makefile.patch: Drop patch (applied upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
%@deftypefn {Function} blockread
4
4
%@verbatim
5
5
%BLOCKREAD Read one block from input
6
 
%   Usage: blockread(L)
 
6
%   Usage: f=blockread(L)
7
7
%       
8
8
%   Input parameters:
9
9
%      L    : Number of samples.
11
11
%      f     : Samples.
12
12
%      valid : Input data valid flag.
13
13
%
 
14
%   f=BLOCKREAD(L) reads next L audio samples according to source 
 
15
%   specified in BLOCK. f is a LxW matrix, where columns are
 
16
%   channels in the stream. 
 
17
%
 
18
%   [f,valid]=blockrad(...) does the same and in addition it returns valid*
 
19
%   flag, which is set to 1, except for the last block of the stream (e.g.
 
20
%   at the end of a file).
 
21
%
14
22
%   Function also control the playback, so it does not have to rely on
15
23
%   whether the user called BLOCKPLAY.
16
24
17
25
%   Block streaming uses several buffers to compensate for the processing
18
26
%   delay variation. 
 
27
%
 
28
%
19
29
%@end verbatim
20
 
%@strong{Url}: @url{http://ltfat.sourceforge.net/doc/blockproc/blockread.php}
 
30
%@strong{Url}: @url{http://ltfat.github.io/doc/blockproc/blockread.html}
 
31
%@seealso{block, blockplay}
21
32
%@end deftypefn
22
33
 
23
 
% Copyright (C) 2005-2014 Peter L. Soendergaard <soender@users.sourceforge.net>.
24
 
% This file is part of LTFAT version 2.0.1
 
34
% Copyright (C) 2005-2015 Peter L. Soendergaard <peter@sonderport.dk>.
 
35
% This file is part of LTFAT version 2.1.0
25
36
%
26
37
% This program is free software: you can redistribute it and/or modify
27
38
% it under the terms of the GNU General Public License as published by
36
47
% You should have received a copy of the GNU General Public License
37
48
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
38
49
 
 
50
% AUTHOR: Zdenek Prusa
 
51
 
39
52
persistent Lwav;
40
53
persistent clearStr;
41
54
persistent readTime;
199
212
elseif isa(source,'function_handle')
200
213
   % Number of wav samples (is chached, since it is a disk read operation)
201
214
   Lwav = block_interface('getLs'); 
 
215
   % Internal data pointer for audio data
 
216
   pos = block_interface('getDatapos') +1; 
 
217
   block_interface('setDatapos',pos+L-1);
202
218
    
203
219
   % Determine valid samples
204
220
   endSample = min(pos + L - 1, Lwav(1));
205
221
   %f = cast(wavread(source,[pos, endSample]),block_interface('getClassId'));
206
 
   f = source(pos,endSample);
 
222
   f = cast(source(pos,endSample),classid);
207
223
   % Pad with zeros if some samples are missing
208
224
   if (pos + L - 1) >= Lwav(1)
209
225
      ftmp = zeros(L,Lwav(2),classid);
211
227
      f = ftmp;
212
228
      % Rewind if loop option was set.
213
229
      if block_interface('getIsLoop')
214
 
         block_interface('setPos',0);
 
230
         block_interface('setDatapos',0);
215
231
         % Throw away stored overlaps.
216
232
         if ~isempty(block_interface('getAnaOverlap'))
217
233
            block_interface('setAnaOverlap',[]);
259
275
          while(playrec('isFinished', pageId) == 0), end;
260
276
       end
261
277
   end
 
278
%%%
 
279
%% {'rec',...} Recording while playing
 
280
%
 
281
elseif iscell(source)
 
282
   recChanList = block_interface('getRecChanList');
 
283
   playChanList = block_interface('getPlayChanList');
 
284
   if do_updateBAR || do_updateGUI
 
285
      readTime = toc(t2);
 
286
   end
 
287
   
 
288
   source = source{2};
 
289
   Lwav = block_interface('getLs'); 
 
290
   
 
291
   % Issue reading buffers up to max
 
292
   while block_interface('getEnqBufCount') <= block_interface('getBufCount')
 
293
       % Internal data pointer for audio data
 
294
       pos = block_interface('getDatapos') +1; 
 
295
       block_interface('setDatapos',pos+L-1);
 
296
 
 
297
       % Determine valid samples
 
298
       endSample = min(pos + L - 1, Lwav(1));
 
299
       %f = cast(wavread(source,[pos, endSample]),block_interface('getClassId'));
 
300
       fin = source(pos,endSample);
 
301
       % Pad with zeros if some samples are missing
 
302
       if (pos + L - 1) >= Lwav(1)
 
303
          ftmp = zeros(L,Lwav(2),classid);
 
304
          ftmp(1:size(fin,1),:) = fin;
 
305
          fin = ftmp;
 
306
          % Rewind if loop option was set.
 
307
          if block_interface('getIsLoop')
 
308
             block_interface('setDatapos',0);
 
309
             % Throw away stored overlaps.
 
310
             if ~isempty(block_interface('getAnaOverlap'))
 
311
                block_interface('setAnaOverlap',[]);
 
312
             end
 
313
             if ~isempty(block_interface('getSynOverlap'))
 
314
                block_interface('setSynOverlap',[]);
 
315
             end
 
316
          else
 
317
             valid = 0;
 
318
          end
 
319
       end
 
320
 
 
321
       % Broadcast single input channel to all output chanels.
 
322
       if size(fin,2)==1
 
323
          fin = repmat(fin,1,numel(playChanList));
 
324
       end
 
325
       % Play and record
 
326
       block_interface('pushPage',playrec('playrec', fin, playChanList, -1,...
 
327
                       recChanList));
 
328
                   
 
329
   end
 
330
   
 
331
   pageList = block_interface('getPageList');
 
332
   % Block until the first page is loaded
 
333
   while(playrec('isFinished', pageList(1)) == 0)
 
334
   end
 
335
   % Read the data. Cast to the specified type
 
336
   f = cast(playrec('getPlayrec',pageList(1)),classid);
 
337
   % Delete page
 
338
   playrec('delPage', pageList(1));
 
339
   % Throw away the page id
 
340
   block_interface('popPage');
262
341
end
263
342
 
264
343
if ~is_offline