Name
hw_AddSample -- create a new sample (V11.0)
Synopsis
int error = hw_AddSample(lua_State *L, lua_ID *id, struct
                hwAddSampleCtrl *ctrl, struct hwTagList *tags);
Library
sound

Function
This function can be used to create a new sample and make it available to the Hollywood script. You have to pass the desired object identifier for the sample as a lua_ID. See Object identifiers for details. The actual sample data and format is passed via a pointer to a struct hwAddSampleCtrl which must contain all required information. struct hwAddSampleCtrl looks like this:

 
struct hwAddSampleCtrl
{
    APTR Data;     // [in]
    int Samples;   // [in]
    int Channels;  // [in]
    int Bits;      // [in]
    int Frequency; // [in]
    ULONG Flags;   // [in]
};

You need to provide the following information in this structure:

Data:
This must be set to a pointer to a memory buffer containing the raw PCM data for the sample.

Samples:
This must be set to the number of samples in Data. Note that this must be specified in PCM frames, not in bytes.

Channels:
The number of channels in the PCM data. Must be either 1 or 2.

Bits:
The bit depth of the PCM data. Must be either 8 or 16.

Frequency:
The playback frequency for the PCM data in Hertz, e.g. 44100.

Flags:
A combination of the following flags describing additional properties of the sample:

HWSNDFLAGS_BIGENDIAN
The PCM samples are stored in big endian format. This flag is only meaningful if the bit depth is 16.

HWSNDFLAGS_SIGNEDINT
The PCM samples are stored as signed integers.

HWSNDFLAGS_SOFTWARE
A software sample shall be created.

You can free samples by calling the hw_FreeSample() function.

Designer compatibility
Unsupported

Inputs
L
pointer to the lua_State
id
object identifier for the new sample
ctrl
pointer to a struct hwAddSampleCtrl containing the sample data and format
Results
error
error code or 0 on success

Show TOC