Copyright © 2005-2020 MultiMedia Soft

SoundComposer.ItemSoundFileMemoryRawAdd method

Previous pageReturn to chapter overviewNext page

Remarks

 

Adds a sound stored inside a memory buffer, or a given range within the sound, containing RAW audio data to the audio stream previously created through the SoundComposer.SessionCreate method.

After the item has been added to the session, its raw setting can be obtained at a later time through the SoundComposer.ItemSoundFileRawInfoGet method.

 

In case the raw sound should be stored inside a file on disk use the SoundComposer.ItemSoundFileRawAdd method.

 

IMPORTANT NOTE: Items added through this method will not be saved into the destination XML file when the SoundComposer.SessionSave method is invoked.

 

For further details about sound composing see the the SoundComposerMan class and the How to compose a sound tutorial.

 

 

Syntax

 

[Visual Basic]

Public Function ItemSoundFileMemoryRawAdd (

nPlayerIndex as Int16,

strFriendlyName as String,

nChannel as Int16,

pBuffer() as Byte,

nBufferLength as Long,

nEncodeMode as enumRAWEncodeModes,

bIsBigEndian as Boolean,

nFrequency as Int32,

nChannels as Int32,

bDownMixToMono as bool,

nOffsetMs as Int32,

nStartPositionMs as Int32,

nEndPositionMs as Int32,

ByRef nUniqueId as Int32

) as enumErrorCodes


 

[C#]

public enumErrorCodes ItemSoundFileMemoryRawAdd (

Int16 nPlayerIndex,

string strFriendlyName,

Int16 nChannel,

byte[] pBuffer,

Int32 nBufferLength,

enumRAWEncodeModes nEncodeMode,

bool bIsBigEndian,

Int32 nFrequency,

Int32 nChannels,

bool bDownMixToMono,

Int32 nOffsetMs,

Int32 nStartPositionMs,

Int32 nEndPositionMs,

ref Int32 nUniqueId

);


 

[C++]

public: enumErrorCodes ItemSoundFileMemoryRawAdd (

Int16 nPlayerIndex,

string strFriendlyName,

Int16 nChannel,

unsigned char __gc[] pBuffer,

Int32 nBufferLength,

enumRAWEncodeModes nEncodeMode,

bool bIsBigEndian,

Int32 nFrequency,

Int32 nChannels,

bool bDownMixToMono,

Int32 nOffsetMs,

Int32 nStartPositionMs,

Int32 nEndPositionMs,

Int32 __gc  *nUniqueId

);


 

Parameter

Description

 

 

nPlayerIndex

Number representing the zero-based index of the player that owns the sound composer session

strFriendlyName

Friendly name of the item

nChannel

Mono channel or stereo channel pair of the audio stream that will reproduce the item.

This parameter is ignored when the sound file is added in "append mode" after a previous call to the SoundComposer.ItemAppendNext method.

 

Due to the fact that the audio stream previously created through the SoundComposer.SessionCreate method could be multi-channel, this would be the behaviour when a sound file item is added:

 

if the sound file has one single channel (Mono) or two channels (Stereo), its mapping on the audio stream would be in two possible ways:
if the bDownMixToMono parameter is set to "true" the sound file is downmixed to mono and mapped on the audio stream inside the channel identified by the nChannel parameter
if the bDownMixToMono parameter is set to "false" the nChannel parameter, instead of representing the index of a mono channel, represents the index of the stereo channel pair (*) on which the sound file item is mapped: for Mono sound files the stream will be duplicated on both channels.
if the sound file has more than two channels (multi-channel), its mapping on the audio stream would be in two possible ways:
if the bDownMixToMono parameter is set to "true" the sound file is downmixed to mono and mapped on the audio stream inside the channel identified by the nChannel parameter
if the bDownMixToMono parameter is set to "false" the sound file is in any case downmixed to stereo and the nChannel parameter, instead of representing the index of a mono channel, represents the index of the stereo channel pair (*) on which the sound file item is mapped.

 

(*) If for example the audio stream previously created through the SoundComposer.SessionCreate method should have 8 channels (7.1 multi-channel), stereo channels pairs would be mapped as follows:

- stereo channel pair 0 would group mono channels 0 and 1

- stereo channel pair 1 would group mono channels 2 and 3

- stereo channel pair 2 would group mono channels 4 and 5

- stereo channel pair 3 would group mono channels 6 and 7

pBuffer

Input buffer containing the original sound

nBufferLength

Length of the input buffer expressed in bytes

nEncodeMode

Encode mode used to encode the RAW file.

Supported values are the following:

Mnemonic constant

Numeric value

Meaning

RAW_ENCODE_PCM_U8

0

RAW PCM 8 bits Unsigned

RAW_ENCODE_PCM_S8

1

RAW PCM 8 bits Signed

RAW_ENCODE_PCM_S16

2

RAW PCM 16 bits Signed

RAW_ENCODE_PCM_S24

3

RAW PCM 24 bits Signed

RAW_ENCODE_PCM_S32

4

RAW PCM 32 bits Signed

RAW_ENCODE_FLOAT32

5

RAW 32 bits floating point

RAW_ENCODE_G711_ULAW

6

RAW G711 U-LAW

RAW_ENCODE_G711_ALAW

7

RAW G711 A-LAW

RAW_ENCODE_GSM_610

8

RAW GSM 6.10

RAW_ENCODE_DIALOGIC_VOX

9

RAW Dialogic ADPCM VOX

bIsBigEndian

Boolean flag that specifies if bits order inside the RAW file are little-endian or big-endian

Supported values are the following:

Mnemonic Value

Meaning

false

The RAW file is encoded using little-endian

true

The RAW file is encoded using big-endian

nFrequency

Sample rate of the RAW file (e.g. 44100)

nChannels

Number of channels of the RAW file: for example, 1 for Mono or 2 for Stereo, 6 for 5.1 formats and so on

bDownMixToMono

Boolean flag specifying if there is the need of a downmix in order to store a stereo sound file into a mono channel of the stream.

Supported values are the following:

Mnemonic Value

Meaning

false

Keep stereo channels separated

true

Downmix stereo channels to mono

 

This parameter is ignored when the sound file is added in "append mode" after a previous call to the SoundComposer.ItemAppendNext method.

nOffsetMs

Offset of the item, expressed in milliseconds, respect to the beginning of the audio stream (in case the stream should be in stopped state) or respect to the current playback position (in case the stream should be already in playback state).

This parameter is ignored when the sound file is added in "append mode" after a previous call to the SoundComposer.ItemAppendNext method.

nStartPositionMs

The start position, expressed in milliseconds, where the sound file loading will occur. Set this value to 0 for loading from the beginning of the sound.

nEndPositionMs

The end position, expressed in milliseconds, where the sound file loading will occur. Set this value to -1 for loading till the sound end.

nUniqueId

Reference to a value that, on return from the method call, will contain the unique identifier of the newly added element: this unique identifier will be used in order to invoke further methods related to the use of this specific element:

 

- SoundComposer.ItemFriendlyNameGet to obtain the friendly name of the item

- SoundComposer.ItemFriendlyNameSet to obtain the friendly name of the item

- SoundComposer.ItemContentGet to obtain contents of the item

- SoundComposer.ItemInfoGet to obtain various information about the item

- SoundComposer.ItemAmplitudeSet to modify the amplitude of the item

- SoundComposer.ItemChannelSet to modify the channel of of the audio stream that will reproduce the item

- SoundComposer.ItemRemove to remove the item from the sound composition

- SoundComposer.ItemOffsetSet to modify the offset, expressed in milliseconds, of the item respect to the beginning of the audio stream

- SoundComposer.ItemTypeGet to obtain the item's type

 

 

Return value

 

Value

Meaning

 

 

Negative value

An error occurred (see the LastError property for further error details)

enumErrorCodes.NOERROR (0)

The method call was successful.