A digital recording of a sound.
A Sample Item is a handle to a digital recording of a sound in memory. Samples come in two kinds:
CreateSample()
and a myriad of special purpose functions create ordinary samples.CreateDelayLine()
to create a delay line.Most sample operations can be performed on both kinds of samples.
audio
AUDIO_SAMPLE_NODE
CreateDelayLine()
CreateItem()
CreateSample()
DefineSampleHere()
LoadSample()
LoadSampleHere()
ScanSample()
DeleteDelayLine()
DeleteItem()
UnloadSample()
GetAudioItemInfo()
SetAudioItemInfo()
AttachSample()
DebugSample()
Loading:
AllocMem()
. If you supply a custom allocation function you must also provide a custom free function with AF_TAG_FREE_FUNCTION.FreeMem()
. If you supply a custom free function you must also provide a custom allocation function with AF_TAG_ALLOC_FUNCTION.CreateSample()
for more details and caveats.Note that sample data may have to be moved down two bytes to align it properly for Opera DMA. This will destroy the sample image so that it cannot be reused.
Data:
This tag, and the all the other Data tags, can be used to query or modify the data address/length of ordinary samples. They can only be used to query the address/length of a delay line.
Format:
Loops:
Tuning:
StartInstrument()
AF_TAG_PITCH tag.Multisample:
StartInstrument()
AF_TAG_PITCH tag is used to perform selection. Valid range is 0 to 127. Defaults to 0.
Sample creation tags have a lot mutual interaction. See CreateSample()
for a complete explanation of this.
There's currently no way to enforce that memory pointed to by AF_TAG_ADDRESS or file image memory used with AF_TAG_LEAVE_IN_PLACE is actually of MEMTYPE_AUDIO. Be careful.
All sample data, loop points, and lengths must be quad-byte aligned. For example, a 1-channel, 8-bit sample (which has 1 byte per frame) is only legal when the lengths and loop points are at multiples of 4 frames. For mono ADPCM samples (which have only 4 bits per frame), lengths and loop points must be at multiples of 8 frames. The Audio folio, however, does not report any kind of an error for using non-quad-byte aligned sample data. Sample addresses, lengths, and loop points, are internally truncated to quad-byte alignment when performing the DMA without warning. Misalignments may result in noise at loop points, or slight popping at the beginning and ending of sound playback. It is recommended that you pay very close attention to sample lengths and loop points when creating, converting, and compressing samples.
Setting AF_TAG_WIDTH does not set the AF_TAG_NUMBITS attribute (e.g. if you create a sample with AF_TAG_WIDTH set to 1, GetAudioItemInfo()
AF_TAG_NUMBITS will return 16). Setting AF_TAG_NUMBITS does however correctly update the AF_TAG_WIDTH field.
Attachment
, Instrument, Template, StartInstrument(), sampler.dsp, delaymono.dsp