Mercurial > hg > smallbox
diff util/classes/@audio/audio.m @ 182:f8bc99a5470c danieleb
Added test for audio buffer function
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Mon, 09 Jan 2012 12:58:00 +0000 |
parents | 1495bdfa13e9 |
children |
line wrap: on
line diff
--- a/util/classes/@audio/audio.m Thu Jan 05 15:46:13 2012 +0000 +++ b/util/classes/@audio/audio.m Mon Jan 09 12:58:00 2012 +0000 @@ -1,24 +1,37 @@ +%% AUDIO OBJECT CLASS +% Class designed to analyse and process audio signals +%% classdef audio - %% Audio object - properties - s %vector containing the audio signal - S %matrix containing frames of audio for subsequent processing - fs %sampling frequency - nBits %number of bits per sample - name %string containing the name of the audio file - format %string containing the format of the audio file - bufferOperator %struct containing the parameters of the buffer operator (used by unbuffer to invert it) + properties (SetAccess = protected) + s %vector containing the audio signal + fs %sampling frequency + nBits %number of bits per sample + name %string containing the name of the audio file + format %string containing the format of the audio file + bufferOperator %struct containing the parameters of the buffer operator + S %matrix containing frames of audio end methods %% Constructor function obj = audio(varargin) + %%% obj = audio(varargin) + % Audio object constructor. + % INPUT: either a path to an audio file, or the following + % arguments. + % - s: vector containing the audio samples + % - fs: sampling frequency + % - nBits: number of bits per sample + % - name: name of the audio object + % - format: format of the audio object + % % if no arguments are specified, prompt for the choice of an % audio file if ~nargin [fileName,pathname] = uigetfile({'*.wav; *.aiff;'},'Select an audio file'); varargin{1} = strcat(pathname,filesep,fileName); end + % if a file is specified, read it from disk if ischar(varargin{1}) [~, obj.name obj.format] = fileparts(varargin{1}); switch obj.format @@ -27,6 +40,7 @@ otherwise error('Unsupported audio format') end + % if properties are specified, set them to input values else obj.s = varargin{1}; if nargin>1, obj.fs = varargin{2}; else obj.fs = []; end