media (lx_media.hpp)

From The Foundry MODO SDK wiki
(Redirected from ILxAudioDeviceID (index))
Jump to: navigation, search
There are security restrictions on this page


Contents

Media

This module provides a very small and simple interface for loading audio files and extracting their data. The audio file is translated into a system specific AudioID pointer which may then be passed around the system. At this level, however, manipulation is limited to startup/shutdown and sample waveform extraction.

Audio Format

8-bit PCM data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero. 16-bit PCM data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero. Stereo data is expressed in interleaved format, left channel first.

(1) SDK: Declarations

(2) SDK: Declarations
 #define LXiAUDIO_TYPE_U8        8
 #define LXiAUDIO_TYPE_I16       16
 #define LXiAUDIO_TYPE_F32       32

(3) SDK: ILxAudioLoaderTarget interface
         LXxMETHOD( LxResult,
 SetChannels) (
         LXtObjectID              self,
         unsigned                 channels);
 
         LXxMETHOD( LxResult,
 SetType) (
         LXtObjectID              self,
         unsigned                 type);
 
         LXxMETHOD( LxResult,
 SetFrequency) (
         LXtObjectID              self,
         unsigned                 frequency);
 
         LXxMETHOD( LxResult,
 SetSamples) (
         LXtObjectID              self,
         unsigned                 samples);

(4) SDK: Declarations
 #define LXu_AUDIOLOADERTARGET   "EDD92652-76A0-471B-B02C-F47CCC16A860"

(5) User Class: AudioLoaderTarget method

Empty AudioLoaderTarget Python user class.

(6) PY: AudioLoaderTarget method
 pass

Audio Interfaces

This returns the number of audio channels. 1 is mono, 2 is stereo.

(7) SDK: ILxAudio interface
         LXxMETHOD( unsigned int,
 Channels) (
         LXtObjectID              self);

This returns the sampling rate. 8 is unsigned byte (0-255), 16 is signed short (-32768 to 32767). 32 is 32 bits floating point value.

(8) SDK: ILxAudio interface
         LXxMETHOD( unsigned int,
 Type) (
         LXtObjectID              self);

Frequency of buffer in Hz.

(9) SDK: ILxAudio interface
         LXxMETHOD( unsigned int,
 Frequency) (
         LXtObjectID              self);

The triming time from start in second.

(10) SDK: ILxAudio interface
         LXxMETHOD( double,
 TrimStart) (
         LXtObjectID              self);

The time duration of buffer. This time is trimed.

(11) SDK: ILxAudio interface
         LXxMETHOD( double,
 Duration) (
         LXtObjectID              self);

Audio file and format.

(12) SDK: ILxAudio interface
         LXxMETHOD( const char *,
 Filename) (
         LXtObjectID              self);

This returns the size of buffer in byte. This is trimed.

(13) SDK: ILxAudio interface
         LXxMETHOD( unsigned int,
 Size) (
         LXtObjectID              self);

This returns the pointer of buffer. If trim start is set, it returns the offset position.

(14) SDK: ILxAudio interface
         LXxMETHOD( const void *,
 Data) (
         LXtObjectID              self);

This returns the sampling value at the time.

(15) SDK: ILxAudio interface
         LXxMETHOD( LxResult,
 Sample) (
         LXtObjectID              self,
         double                   time,
         unsigned int             type,
         void                    *value);

Seek the buffer position to the given frame.

(16) SDK: ILxAudio interface
         LXxMETHOD( void,
 Seek) (
         LXtObjectID              self,
         unsigned int             frame);

Return the current frame to read.

(17) SDK: ILxAudio interface
         LXxMETHOD( unsigned int,
 Tell) (
         LXtObjectID              self);

Read audio data to the buffer for the frames. The bytes of frames is frames * channels * bytes of type. This returns the write frames and it sets true to 'eof' if it reachs to the end of file.

(18) SDK: ILxAudio interface
         LXxMETHOD( LxResult,
 Read) (
         LXtObjectID              self,
         unsigned int            *frames,
         void                    *buff,
         int                     *eof);

(19) SDK: ILxAudio interface
         LXxMETHOD( void,
 Metrics) (
         LXtObjectID              self,
         LXtAudioMetrics         *metrics);

(20) SDK: LXtAudioMetrics struct
 unsigned int             channels;              // 1: mono, 2: stereo
 unsigned int             type;                  // bits per smaple. 8, 16 or 32 bits
 unsigned int             frequency;             // sample per second (sample rate)
 unsigned int             samples;               // total samples
 const char              *filename;              // filename

Empty Audio Python user class.

(21) PY: Audio method
 pass

This is the primary interface for audio objects, and so this the GUID specified when attempting to load or save audios.

(22) SDK: Declarations
 #define LXu_AUDIO       "ABADACB8-A93D-45B1-B776-347CBE761B13"
 #define LXa_AUDIO       "audio"

(23) User Class: Audio method

Initialize the audio object with the metrics. This must be called before writing frames. "WriteBegin" fills "frameRange" that is the start and end position in sample frames. The write data must be started from the start frame.

(24) SDK: ILxAudioWrite interface
         LXxMETHOD( LxResult,
 WriteBegin) (
         LXtObjectID              self,
         LXtAudioMetrics         *metrics,
         unsigned int            *frameRange);

Write the frame data to the object. This increments the data position. This updates "frames" with the written frames.

(25) SDK: ILxAudioWrite interface
         LXxMETHOD( LxResult,
 Write) (
         LXtObjectID              self,
         unsigned int            *frames,
         const void              *data);

This must be called after writing frames.

(26) SDK: ILxAudioWrite interface
         LXxMETHOD( LxResult,
 WriteEnd) (
         LXtObjectID              self);

Set the sampling value at the time to the object.

(27) SDK: ILxAudioWrite interface
         LXxMETHOD( LxResult,
 SetSample) (
         LXtObjectID              self,
         double                   time,
         unsigned int             type,
         const void              *value);

Set the trim time from start.

(28) SDK: ILxAudioWrite interface
         LXxMETHOD( LxResult,
 SetStart) (
         LXtObjectID              self,
         double                   start);

Set the duration to play by second.

(29) SDK: ILxAudioWrite interface
         LXxMETHOD( LxResult,
 SetDuration) (
         LXtObjectID              self,
         double                   duration);

Empty AudioWrite Python user class.

(30) PY: AudioWrite method
 pass

(31) SDK: Declarations
 #define LXu_AUDIOWRITE  "B1C160A8-6FF3-4C54-B817-8C17A49AB1D6"
 #define LXa_AUDIOWRITE  "audiowrite"

(32) User Class: AudioWrite method

Audio Device

The audio device is virtual audio device device. This provides the abstruct audio interaces. The real audio device in OS level is implemented in OPAL.

This creates the audio handle with the audio object.

(33) SDK: ILxAudioDevice interface
         LXxMETHOD( LxResult,
 Handle) (
         LXtObjectID              self,
         LXtObjectID              audio,
         void                    **ppvObj);

Stop all audio handles on the device.

(34) SDK: ILxAudioDevice interface
         LXxMETHOD( LxResult,
 StopAll) (
         LXtObjectID              self);

Play the given audio file by non blocking mode.

(35) SDK: ILxAudioDevice interface
         LXxMETHOD( LxResult,
 PlayFile) (
         LXtObjectID              self,
         const char              *filePath);

Return true if the device is in playing.

(36) SDK: ILxAudioDevice interface
         LXxMETHOD( int,
 Playing) (
         LXtObjectID              self);

Play the audio object in the limited range.

(37) SDK: ILxAudioDevice interface
         LXxMETHOD( LxResult,
 PlayRange) (
         LXtObjectID              self,
         LXtObjectID              audio,
         double                   start,
         double                   end,
         double                   volume,
         double                   pitch);

Empty AudioDevice Python user class.

(38) PY: AudioDevice method
 pass

(39) SDK: Declarations
 #define LXu_AUDIODEVICE "5CBC3BC8-95BB-4F24-B1A4-8474708EDE3A"
 #define LXa_AUDIODEVICE "audioDevice"

Audio Handle

The audio handle is a context to play audio data by the system default device. This provides the abstruct audio interaces. The real audio device in OS level is implemented in OPAL.

(40) SDK: Types
 typedef unsigned int     LXtAudioState;

The device state information.

(41) SDK: Types
 #define LXaSTATE_STOPPED                 0
 #define LXaSTATE_PLAYING                 1
 #define LXaSTATE_PAUSED                  2
 #define LXaSTATE_INITIAL                 3

This function returns the current audio object.

(42) SDK: ILxAudioHandle interface

The playback position in seconds.

(43) SDK: ILxAudioHandle interface
         LXxMETHOD( double,
 Offset) (
         LXtObjectID              self);

Set the playback position in seconds. If the offset position is out of range, this function modulos the position in loop mode, otherwise it sets to the end of data.

(44) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 SetOffset) (
         LXtObjectID              self,
         double                   offset);

Pitch multiplier.

(45) SDK: ILxAudioHandle interface
         LXxMETHOD( double,
 Pitch) (
         LXtObjectID              self);

(46) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 SetPitch) (
         LXtObjectID              self,
         double                   pitch);

Source gain.

(47) SDK: ILxAudioHandle interface
         LXxMETHOD( double,
 Volume) (
         LXtObjectID              self);

(48) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 SetVolume) (
         LXtObjectID              self,
         double                   volume);

Turn looping on (LXx_TRUE) or off (LXe_FALSE)

(49) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 Loop) (
         LXtObjectID              self);

(50) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 SetLoop) (
         LXtObjectID              self,
         unsigned int             loop);

Play the audio source. If "forward" is false, it plays to backward.

(51) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 Play) (
         LXtObjectID              self,
         int                      forward);

Stop the audio source.

(52) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 Stop) (
         LXtObjectID              self);

Pause the audio source.

(53) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 Pause) (
         LXtObjectID              self);

Resume the audio source.

(54) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 Resume) (
         LXtObjectID              self);

Returns the state of the audio device.

(55) SDK: ILxAudioHandle interface
         LXxMETHOD( LxResult,
 State) (
         LXtObjectID              self,
         LXtAudioState           *state);

(56) SDK: Declarations
 #define LXu_AUDIOHANDLE "6A7F9318-A9CF-44CA-9F71-32006102FF24"

Empty AudioHandle Python user class.

(57) PY: AudioHandle method
 pass