X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Faudio-1.1.4%2Fau.m;fp=octave_packages%2Faudio-1.1.4%2Fau.m;h=a194bfd2179d5ee660b93ee6ab6eaac38213e414;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/audio-1.1.4/au.m b/octave_packages/audio-1.1.4/au.m new file mode 100644 index 0000000..a194bfd --- /dev/null +++ b/octave_packages/audio-1.1.4/au.m @@ -0,0 +1,51 @@ +## Copyright (C) 2000 Paul Kienzle +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see . + +## y = au(x, fs, lo [, hi]) +## +## Extract data from x for time range lo to hi in milliseconds. If lo +## is [], start at the beginning. If hi is [], go to the end. If hi is +## not specified, return the single element at lo. If lo<0, prepad the +## signal to time lo. If hi is beyond the end, postpad the signal to +## time hi. + +## TODO: modify prepad and postpad so that they accept matrices. +function y=au(x,fs,lo,hi) + if nargin<3 || nargin>4, + usage("y = au(x, fs, lo [,hi])"); + endif + + if nargin<4, hi=lo; endif + if isempty(lo), + lo=1; + else + lo=fix(lo*fs/1000)+1; + endif + if isempty(hi), + hi=length(x); + else + hi=fix(hi*fs/1000)+1; + endif + if hilength(x)), y=postpad(y,length(y)+hi-length(x)); endif + else + y=x(max(lo,1):min(hi,length(x)), :); + if (lo<1), y=[zeros(size(x,2),-lo+1) ; y]; endif + if (hi>length(x)), y=[y ; zeros(size(x,2),hi-length(x))]; endif + endif +endfunction