ImportAudio

Description

Imports an audio file into current scene. Puts the new Audio source into the audio source list of the given model. If there is no Mixer object in the current model, then it is added (so it can contain the audio source).

Note: Supported audio file formats include the Microsoft's Audio Video Interleave (.avi), the Apple Audio Interchange File Format (.aif, .aiff, or .aifc), Quicktime formats (.mov and .qt), and WAV files (.wav)

This command supports downloading files off the internet. If the filename specified is a URL then the file is downloaded locally before the command is executed.

Warning: You must have an audio source file on disk to execute this command.

Scripting Syntax

oReturn = ImportAudio( Model, [FileName], [Name] );

Return Value

Returns the new audio Source.

Parameters

Parameter Type Description
Model String The model into which to import the audio.
FileName String Full path to the file to import.

Returns an error if the file specified is not an audio file.

Default Value: File browser pops up

Name String The name to use for the new audio source.

Default Value: File name

Examples

VBScript Example

'---------------------------------------------------------

' This example shows how to import audio files into a 

' model. Note: You must choose an audio source from a 

' dialog box in this example

'---------------------------------------------------------

' First create a model to hold the sound clip.

dim oModel

SICreateModel , "AudioModel", , oModel

logmessage oModel + " model created."

' Now import an audio source file.

dim oAudioSource, Fullname, Filename, SamplingRate, ChannelCnt, Duration

set oAudioSource = ImportAudio( oModel, , "Sound" )

' Now display information about the clip created.

Fullname = GetValue( oAudioSource.FullName )

Filename = GetValue( oAudioSource.FileName )

SamplingRate = GetValue( oAudioSource.SamplingRate )

ChannelCnt = GetValue( oAudioSource.ChannelCount )

Duration = GetValue( oAudioSource.Duration )

logmessage "Audio source created: " & Fullname

logmessage "Audio filename      : " & Filename

logmessage "Audio Sampling Rate : " & CInt(SamplingRate)

logmessage "Audio Channel Count : " & CInt(ChannelCnt)

logmessage "Audio Duration      : " & Duration

'---------------------------------------------------------

' Output from this script:

'INFO : "Audio source created: Sources.Sound"

'INFO : "Audio filename      : <filename>"

'INFO : "Audio Sampling Rate : <sampling rate>"

'INFO : "Audio Channel Count : <channel count>"

'INFO : "Audio Duration      : <duration (sec.)>"

'---------------------------------------------------------

See Also

AddAudioClip