Mercurial > hg > ishara
view audio/jsndfile.m @ 53:3ba80c9914ff
Minor doc fix, added .class to .hgignore
author | samer |
---|---|
date | Mon, 02 Feb 2015 10:47:55 +0000 |
parents | 3cedfd4549ef |
children |
line wrap: on
line source
% jsndfile - audio signal from audio file using JavaSound only % jsndfile :: path, options(sndstream) -> signal(C,R). % % NB: Javazoom MP3 decoder does not get the length of the signal right. function s=jsndfile(file,varargin) string=sprintf('jsndfile(''%s'')',file); if strncmp(file,'http://',7) mkstream = @(q)urlstream(file,q); else mkstream = @(q)filestream(file,q); end s=sndstream(mkstream,'stringfn',@()string,varargin{:}); end function [str,cleanup]=filestream(file,q) jf=jfile(file); if ~jf.exists(), error(sprintf('File %s does not exist',file)); end if ~q, fprintf('Opening sound file: %s\n',file); end str=austream(java.io.FileInputStream(jf)); cleanup=@nop; end function [str,cleanup]=urlstream(url,q) jurl=java.net.URL(url); % if ~jf.exists(), error(sprintf('File %s does not exist',file)); end if ~q, fprintf('Opening URL: %s\n',url); end str=austream(jurl.openStream()); cleanup=@nop; end