Friday, July 24, 2009

Description Continued...

auread

Read NeXT/SUN (.au) sound file

Graphical Interface

As an alternative to auread, use the Import Wizard. To activate the Import Wizard, select Import data from the File menu.

Syntax

  • y = auread('aufile')
    [y,Fs,bits] = auread('aufile')
    [...] = auread('aufile',N)
    [...] = auread('aufile',[N1,N2])
    siz = auread('aufile','size')

Description

y = auread('aufile') loads a sound file specified by the string aufile, returning the sampled data in y. The .au extension is appended if no extension is given. Amplitude values are in the range [-1,+1]. auread supports multi-channel data in the following formats:

  • 8-bit mu-law
  • 8-, 16-, and 32-bit linear
  • floating-point

[y,Fs,bits] = auread('aufile') returns the sample rate (Fs) in Hertz and the number of bits per sample (bits) used to encode the data in the file.

[...] = auread('aufile',N) returns only the first N samples from each channel in the file.

[...] = auread('aufile',[N1 N2]) returns only samples N1 through N2 from each channel in the file.

siz = auread('aufile','size') returns the size of the audio data contained in the file in place of the actual audio data, returning the vector siz = [samples channels].



auwrite

Write NeXT/SUN (.au) sound file

Syntax

  • auwrite(y,'aufile')
    auwrite(y,Fs,'aufile')
    auwrite(y,Fs,N,'aufile')
    auwrite(y,Fs,N,'method','aufile')

Description

auwrite(y,'aufile') writes a sound file specified by the string aufile. The data should be arranged with one channel per column. Amplitude values outside the range [-1,+1] are clipped prior to writing. auwrite supports multi-channel data for 8-bit mu-law, and 8- and 16-bit linear formats.

auwrite(y,Fs,'aufile') specifies the sample rate of the data in Hertz.

auwrite(y,Fs,N,'aufile') selects the number of bits in the encoder. Allowable settings are N = 8 and N = 16.

auwrite(y,Fs,N,'method','aufile') allows selection of the encoding method, which can be either mu or linear. Note that mu-law files must be 8-bit. By default, method = 'mu'.



avifile

Create a new Audio Video Interleaved (AVI) file

Syntax

  • aviobj = avifile(filename)
    aviobj =
    avifile(filename,'PropertyName',value,'PropertyName',value,...)

Description

aviobj = avifile(filename) creates an AVI file, giving it the name specified in filename, using default values for all AVI file object properties. If filename does not include an extension, avifile appends .avi to the filename. AVI is a file format for storing audio and video data.

avifile returns a handle to an AVI file object, aviobj. You use this object to refer to the AVI file in other functions. An AVI file object supports properties and methods that control aspects of the AVI file created.

aviobj = avifile(filename,'Param',Value,'Param',Value,...) creates an AVI file with the specified parameter settings. This table lists available parameters.


Parameter
Value
Default
'colormap'
An m-by-3 matrix defining the colormap to be used for indexed AVI movies, where m must be no greater than 256 (236 if using Indeo compression). You must set this parameter before calling addframe, unless you are using addframe with the MATLAB movie syntax.
There is no default colormap.
'compression'
A text string specifying which compression codec to use.


On Windows:
'Indeo3'
'Indeo5
'
'Cinepak'
'MSVC'
'None'
On Unix:
'None'
'Indeo3', on Windows. 'None' on Unix.

To use a custom compression codec, specify the four-character code that identifies the codec (typically included in the codec documentation). The addframe function reports an error if it can not find the specified custom compressor.

'fps'
A scalar value specifying the speed of the AVI movie in frames per second (fps).
15 fps
'keyframe'
For compressors that support temporal compression, this is the number of key frames per second.
2 key frames per second.
'name'
A descriptive name for the video stream. This parameter must be no greater than 64 characters long.
The default is the filename.
'quality'
A number between 0 and 100. This parameter has no effect on uncompressed movies. Higher quality numbers result in higher video quality and larger file sizes. Lower quality numbers result in lower video quality and smaller file sizes.
75

You can also use structure syntax to set AVI file object properties. For example, to set the quality property to 100 use the following syntax:

  •        aviobj = avifile(filename);
    aviobj.Quality = 100;

Example

This example shows how to use the avifile function to create the AVI file example.avi.

  • fig=figure;
    set(fig,'DoubleBuffer','on');
    set(gca,'xlim',[-80 80],'ylim',[-80 80],...
    'NextPlot','replace','Visible','off')
    mov = avifile('example.avi')
    x = -pi:.1:pi;
    radius = 0:length(x);
    for k=1:length(x)
    h = patch(sin(x)*radius(k),cos(x)*radius(k),...
    [abs(cos(x(k))) 0 0]);
    set(h,'EraseMode','xor');
    F = getframe(gca);
    mov = addframe(mov,F);
    end
    mov = close(mov);

aviinfo

Return information about an Audio Video Interleaved (AVI) file

Syntax

  • fileinfo = aviinfo(filename)

Description

fileinfo = aviinfo(filename) returns a structure whose fields contain information about the AVI file specified in the string, filename. If filename does not include an extension, then .avi is used. The file must be in the current working directory or in a directory on the MATLAB path.

The set of fields in the fileinfo structure are shown below.


Field Name
Description
AudioFormat

A string containing the name of the format used to store the audio data, if audio data is present

AudioRate

An integer indicating the sample rate in Hertz of the audio stream, if audio data is present

Filename
A string specifying the name of the file
FileModDate
A string containing the modification date of the file
FileSize
An integer indicating the size of the file in bytes
FramesPerSecond
An integer indicating the desired frames per second
Height
An integer indicating the height of the AVI movie in pixels
ImageType
A string indicating the type of image. Either 'truecolor' for a truecolor (RGB) image, or 'indexed' for an indexed image.
NumAudioChannels

An integer indicating the number of channels in the audio stream, if audio data is present

NumFrames
An integer indicating the total number of frames in the movie
NumColormapEntries

An integer specifying the number of colormap entries

Quality

A number between 0 and 100 indicating the video quality in the AVI file. Higher quality numbers indicate higher video quality; lower quality numbers indicate lower video quality. This value is not always set in AVI files and therefore may be inaccurate.

VideoCompression

A string containing the compressor used to compress the AVI file. If the compressor is not Microsoft Video 1, Run Length Encoding (RLE), Cinepak, or Intel Indeo, aviinfo returns a four-character code.

Width
An integer indicating the width of the AVI movie in pixels

aviread

Read an Audio Video Interleaved (AVI) file.

Syntax

  • mov = aviread(filename)
    mov = aviread(filename,index)

Description

mov = aviread(filename) reads the AVI movie filename into the MATLAB movie structure mov. If filename does not include an extension, then .avi is used. Use the movie function to view the movie, mov. On UNIX, filename must be an uncompressed AVI file.

mov has two fields, cdata and colormap. The content of these fields varies depending on the type of image.


Image Type
mov.cdata Field
mov.colormap Field
Truecolor

height-by-width-by-3 array

Empty

Indexed

height-by-width array

m-by-3 array


mov = aviread(filename,index) reads only the frame(s) specified by index. index can be a single index or an array of indices into the video stream. In AVI files, the first frame has the index value 1, the second frame has the index value 2, and so on.

No comments:

Post a Comment