Home > voicebox > readflac.m

readflac

PURPOSE ^

READWAV Read a .FLAC format sound file [Y,FS]=(FILENAME,MODE)

SYNOPSIS ^

function [y,fs]=readflac(filename,mode)

DESCRIPTION ^

READWAV  Read a .FLAC format sound file [Y,FS]=(FILENAME,MODE)

 Input Parameters:

    FILENAME gives the name of the file (with optional .WAV extension) or alternatively
                 can be the FIDX output from a previous call to READWAV
    MODE        specifies the following (*=default):

    Scaling: 's'    Auto scale to make data peak = +-1
             'r'    Raw unscaled data (integer values)
             'q'    Scaled to make 0dBm0 be unity mean square
             'p' *     Scaled to make +-1 equal full scale
             'o'    Scale to bin centre rather than bin edge (e.g. 127 rather than 127.5 for 8 bit values)
                     (can be combined with n+p,r,s modes)
             'n'    Scale to negative peak rather than positive peak (e.g. 128.5 rather than 127.5 for 8 bit values)
                     (can be combined with o+p,r,s modes)

 FLAC (Free lossless audio codec) is a compressed audio file format described here:
 http://flac.sourceforge.net/

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [y,fs]=readflac(filename,mode)
0002 %READWAV  Read a .FLAC format sound file [Y,FS]=(FILENAME,MODE)
0003 %
0004 % Input Parameters:
0005 %
0006 %    FILENAME gives the name of the file (with optional .WAV extension) or alternatively
0007 %                 can be the FIDX output from a previous call to READWAV
0008 %    MODE        specifies the following (*=default):
0009 %
0010 %    Scaling: 's'    Auto scale to make data peak = +-1
0011 %             'r'    Raw unscaled data (integer values)
0012 %             'q'    Scaled to make 0dBm0 be unity mean square
0013 %             'p' *     Scaled to make +-1 equal full scale
0014 %             'o'    Scale to bin centre rather than bin edge (e.g. 127 rather than 127.5 for 8 bit values)
0015 %                     (can be combined with n+p,r,s modes)
0016 %             'n'    Scale to negative peak rather than positive peak (e.g. 128.5 rather than 127.5 for 8 bit values)
0017 %                     (can be combined with o+p,r,s modes)
0018 %
0019 % FLAC (Free lossless audio codec) is a compressed audio file format described here:
0020 % http://flac.sourceforge.net/
0021 
0022 %      Copyright (C) Mike Brookes 2008
0023 %      Version: $Id: readflac.m 8483 2016-09-13 15:48:05Z dmb $
0024 %
0025 %   VOICEBOX is a MATLAB toolbox for speech processing.
0026 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 %   This program is free software; you can redistribute it and/or modify
0030 %   it under the terms of the GNU General Public License as published by
0031 %   the Free Software Foundation; either version 2 of the License, or
0032 %   (at your option) any later version.
0033 %
0034 %   This program is distributed in the hope that it will be useful,
0035 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0036 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0037 %   GNU General Public License for more details.
0038 %
0039 %   You can obtain a copy of the GNU General Public License from
0040 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0041 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 if nargin<2
0044     mode='p';
0045 else
0046     mode = [mode(:).' 'p'];
0047 end
0048 dirt=voicebox('dir_temp');
0049 [fnp,fnn,fne]=fileparts(filename);
0050 filetemp=fullfile(dirt,[fnn '.wav']);
0051 doscom=['"' voicebox('flac') '"' ' -d -f -o "' filetemp '" "' filename '"'];
0052 %                     fprintf(1,'Executing: %s\n',doscom);
0053 [doss,dosr]=dos(doscom); % run the program
0054 if doss % test for errors
0055     error(sprintf('Error running DOS command: %s',doscom));
0056 end
0057 if exist(filetemp)~=2
0058     error(sprintf('No output file from: %s',doscom));
0059 end
0060 [y,fs]=readwav(filetemp,mode);
0061 doscom=['del /f "' filetemp '"'];
0062 if dos(doscom) % run the program
0063     error(sprintf('Error running DOS command: %s',doscom));
0064 end

Generated on Tue 10-Oct-2017 08:30:10 by m2html © 2003