Home  |  Overview  |  Documentation |  Download |  MATLAB API |  HowTo... |  FAQ |  Feedback

MATLAB Support

Overview

The SFS MATLAB API allows MATLAB programmers access to the rich data structures of SFS files and through them to the acquisition, signal processing, editing and display functions of SFS. The SFS MATLAB API allows scripts to be written in MATLAB to list the contents of SFS files, to read, write and create data sets. A utility program matlabex allows MATLAB functions to be called from the command line in the same way as other SFS programs.

Download and Installation

Version 2 supports 32-bit and 64-bit MATLAB!

Version 2.00 of the SFS MATLAB API can be downloaded from:

To install:

API Functions

The following functions are available in SFS MATLAB API:

FunctionDescription
sfsfile Performs file-level operations on SFS files. Test existence of SFS file, create new file, empty file, get list of file contents.
sfsgetitem Reads the contents of an SFS item into MATLAB. sfsgetitem returns the item header in a MATLAB structure and the data set as a MATLAB array. Information about the size, structure and provenenance of the item is present in the header structure.
sfsnewitem Creates a new empty SFS item consisting of a header structure and a data set in a form compatible with sfsputitem().
sfsputitem Writes the contents of a supplied header structure and data set to an SFS file as a new item.

Type help sfsgetitem etc at the MATLAB prompt to get more information about function use. There is a separate documentation file for the MATLABEX program.

API Example

Here is an example of the SFS MATLAB API being used


function sfsfilter(fname,item,hertz,ftype)
% SFSFILTER Applies a filter to a speech signal
%
%   SFSFILTER(fname,item,hertz,ftype) applies an 8th-order
%   Butterworth filter to the speech signal 'item' in the SFS
%   file fname.  The hertz parameter gives the cut-off frequency
%   (or frequencies) in hertz.  The ftype parameter selects the
%   filter type from: 'low'=low-pass, 'high'=high-pass, 'band'=
%   band-pass, 'stop'=band-stop.  The filtered speech is saved
%   back into the SFS file.
%
%   For example:
%      sfsfilter('file.sfs','1.01',1000,'low');
%      sfsfilter('file.sfs','sp',[1000 2000],'band');

%
% get item from SFS file (h=header, d=data set)
%
[h,d]=sfsgetitem(fname,item);
%
% make filter (uses butter() design from signal-processing toolbox)
%
if strcmp(ftype,'low') | strcmp(ftype,'band')
    [b,a]=butter(8,2*hertz*h.frameduration);
else
    [b,a]=butter(8,2*hertz*h.frameduration,ftype);
end;
%
% make a new item header as copy of input item header
%
oh=sfsnewitem(h.datatype,h.frameduration,h.offset,h.framesize,h.numframes);
%
% create a suitable processing history string
%
if (length(hertz)==2)
    oh.history=sprintf('matlab/SP(%d.%02d;script=signalfilter,hertz=%g:%g,ftype=%s)',...
    	h.datatype,h.subtype,hertz(1),hertz(2),ftype);
else
    oh.history=sprintf('matlab/SP(%d.%02d;script=signalfilter,hertz=%g,ftype=%s)',...
    	h.datatype,h.subtype,hertz,ftype);
end;
%
% apply filter to input signal
%
od=filter(b,a,d);
%
% save filtered signal to file
%
sfsputitem(fname,oh,od);

Feedback

Please send suggestions for improvements and reports of program faults to SFS@phon.ucl.ac.uk.

Please note that we are unable to provide help with the use of this software. <


Some other pages on our site you may enjoy:

CochSim - Cochlear Simulation teaching tool

CochSim is a dynamic simulation of the time and frequency analysis performed by the ear. Sound signals such as sinewaves, pulse trains, sawtooth waves and vowels can be fed into an auditory filterbank and the output monitored in a moving animated display. The program shows the vibration of the oval window and the basilar membrane, the haircell activity against filter frequency and time, and an average excitation pattern across the cochlea. More information.

RTSPECT - Real-time Waveform and Spectrum Display

RTSPECT is a free program for displaying a real-time waveform and spectrum display of an audio signal on Windows computers. More information.