CreateMemblockFromSound

Description

Creates a memblock from a loaded sound file. The sound file must have been loaded with LoadSound and is unaffected by this command. The first 2 bytes of the memlbock store the number of channels (1 or 2 supported), the next 2 bytes store the bits per sample (8 or 16 supported), the next 4 bytes store the samples per second, for example 44100. The next 4 bytes are the number of frames in the sound data, the size of the sound data in bytes can be calculated from this with the formula numFrames*(bitsPerSample/8)*channels. In a 2 channel sound a frame contains 2 samples, one for each channel. In a mono sound a frame contains 1 sample. The rest of the memblock is raw sound data, for example in an 8bit stereo sound with 3 frames the raw data would look like this. byte offset 0 = Frame 1, left channel data byte offset 1 = Frame 1, right channel data byte offset 2 = Frame 2, left channel data byte offset 3 = Frame 2, right channel data byte offset 4 = Frame 3, left channel data byte offset 5 = Frame 3, right channel data The duration of the sound can be calculated with the following formula, numFrames/samplesPerSecond. This command does not work with sound instance IDs, only sound file IDs. Returns an ID that can be used to reference this memblock in other commands.

Definition

integer CreateMemblockFromSound( soundID )

CreateMemblockFromSound( memID, soundID )

Parameters