ita_read_caf.m 919 Bytes
Newer Older
1
function result = ita_read_caf(filename,varargin)
Jan-Gerrit Richter's avatar
Jan-Gerrit Richter committed
2
%ITA_READ_FLAC - Read Core Audio Format Files
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
%   This function is completely based on the MATLAB audioread.
%
%   It returns a itaAudio object containing the files data and metadata.
%
%   See also ita_read, ita_write, audioread.

% <ITA-Toolbox>
% This file is part of the ITA-Toolbox. Some rights reserved.
% You can find the license for this m-file in the license.txt file in the ITA-Toolbox folder.
% </ITA-Toolbox>


%% Return type of data this function can read
if nargin == 0
    result{1}.extension = '.caf';
    result{1}.comment = 'Core Audio Format Files (*.caf)';
    return
end

    
if ~exist(filename,'file')
    error('ITA_READ_CAF: File does not exist');
end

try
    [data,fs] = audioread(filename);
    result = itaAudio;
    result.samplingRate = fs;
    result.timeData = data;
catch
    error('ITA_READ_CAF: Something went wrong');
end
    
end