table, count = GetSampleData(id)
id
. The PCM samples will be returned inside a table. The
format of the individual samples will be either 8-bit signed (ranging
from -128 to +127) or 16-bit signed (ranging from -32768 to 32767). You
can find out the sample format by querying the #ATTRTYPE
of the sample
using the GetAttribute() function. If the sample uses two channels (i.e.
stereo), the PCM data will be returned in interleaved order, i.e. left
channel sample is followed by right channel sample is followed by left
channel sample, and so on.
The second return value of this function is a counter value that
indicates the number of sample frames in the table. Be warned that this
value does not return the actual total array elements but the number of
sample frames. For stereo samples, the left and right channel samples
together form a single sample frame. Thus, if you get stereo data, there
will be twice as many samples in the table than indicated by count
because the latter counts in sample frames instead of raw samples.
If you get large sample tables from this function, please do not forget to set these tables to Nil when you no longer need them. Otherwise you will waste great amounts of memory.
To convert a table of PCM data back into a sample, you can use the CreateSample() command.