media (lx_media.hpp)

From The Foundry MODO SDK wiki
(Redirected from LXu AUDIOWRITE (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: LXiAUDIO_CHAN_MONO, etc. defines

(2) SDK: LXiAUDIO_TYPE_U8, etc. defines
 #define LXiAUDIO_TYPE_U8        8
 #define LXiAUDIO_TYPE_I16       16
 #define LXiAUDIO_TYPE_F32       32

(3) SDK: AudioLoaderTarget::SetChannels, etc.
         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: LXu_AUDIOLOADERTARGET define
 #define LXu_AUDIOLOADERTARGET   "EDD92652-76A0-471B-B02C-F47CCC16A860"

(5) SDK: empty AudioLoaderTarget User Class

Empty AudioLoaderTarget Python user class.

(6) PY: empty AudioLoaderTarget user class
 pass

Audio Interfaces

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

(7) SDK: Audio::Channels
         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: Audio::Type
         LXxMETHOD( unsigned int,
 Type) (
         LXtObjectID              self);

Frequency of buffer in Hz.

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

The triming time from start in second.

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

The time duration of buffer. This time is trimed.

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

Audio file and format.

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

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

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

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

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

This returns the sampling value at the time.

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

Seek the buffer position to the given frame.

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

Return the current frame to read.

(17) SDK: Audio::Tell
         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: Audio::Read
         LXxMETHOD( LxResult,
 Read) (
         LXtObjectID              self,
         unsigned int            *frames,
         void                    *buff,
         int                     *eof);

(19) SDK: Audio::Metrics
         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: empty Audio user class
 pass

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

(22) SDK: LXu_AUDIO, etc. defines
 #define LXu_AUDIO       "ABADACB8-A93D-45B1-B776-347CBE761B13"
 #define LXa_AUDIO       "audio"

(23) SDK: empty Audio User Class

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: AudioWrite::WriteBegin
         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: AudioWrite::Write
         LXxMETHOD( LxResult,
 Write) (
         LXtObjectID              self,
         unsigned int            *frames,
         const void              *data);

This must be called after writing frames.

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

Set the sampling value at the time to the object.

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

Set the trim time from start.

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

Set the duration to play by second.

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

Empty AudioWrite Python user class.

(30) PY: empty AudioWrite user class
 pass

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

(32) SDK: empty AudioWrite User Class

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: AudioDevice::Handle
         LXxMETHOD( LxResult,
 Handle) (
         LXtObjectID              self,
         LXtObjectID              audio,
         void                    **ppvObj);

Stop all audio handles on the device.

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

Play the given audio file by non blocking mode.

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

Return true if the device is in playing.

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

Play the audio object in the limited range.

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

Empty AudioDevice Python user class.

(38) PY: empty AudioDevice user class
 pass

(39) SDK: LXu_AUDIODEVICE, etc. defines
 #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: LXtAudioState typedef (types)
 typedef unsigned int     LXtAudioState;

The device state information.

(41) SDK: LXaSTATE_STOPPED, etc. defines (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: AudioHandle::Audio

The playback position in seconds.

(43) SDK: AudioHandle::Offset
         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: AudioHandle::SetOffset
         LXxMETHOD( LxResult,
 SetOffset) (
         LXtObjectID              self,
         double                   offset);

Pitch multiplier.

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

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

Source gain.

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

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

Turn looping on (LXx_TRUE) or off (LXe_FALSE)

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

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

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

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

Stop the audio source.

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

Pause the audio source.

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

Resume the audio source.

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

Returns the state of the audio device.

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

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

Empty AudioHandle Python user class.

(57) PY: empty AudioHandle user class
 pass