Name
LoadSample -- load a sample
Synopsis
[id] = LoadSample(id, filename$[, table])
Function
This function loads the sample specified by filename$ into memory and assigns the identifier id to it. If you pass Nil in id, LoadSample() will automatically choose an identifier and return it.

Sample formats that are supported on all platforms are RIFF WAVE, IFF 8SVX, IFF 16SV, and sample formats you have a plugin for. Depending on the platform Hollywood is running on, more sample formats might be supported. For example, on Amiga compatible systems Hollywood will be able to open all sample formats you have datatypes for as well.

Starting with Hollywood 6.0, this function accepts an optional table argument which allows you to pass additional parameters:

Loader:
This tag allows you to specify one or more format loaders that should be asked to load this sample. This must be set to a string containing the name(s) of one or more loader(s). Defaults to the loader set using SetDefaultLoader(). See Loaders and adapters for details. (V6.0)

Adapter:
This tag allows you to specify one or more file adapters that should be asked to open the specified file. This must be set to a string containing the name(s) of one or more adapter(s). Defaults to the adapter set using SetDefaultAdapter(). See Loaders and adapters for details. (V6.0)

UserTags:
This tag can be used to specify additional data that should be passed to loaders and adapters. If you use this tag, you must set it to a table of key-value pairs that contain the additional data that should be passed to plugins. See User tags for details. (V10.0)

This command is also available from the preprocessor: Use @SAMPLE to preload samples!

Please note that this function loads sample data completely into memory. If you plan to play long samples, you should better use OpenMusic() which buffers only small portions of the sound data in memory.

Inputs
id
identifier for the sample or Nil for auto id selection
filename$
file to load
table
optional: table configuring further options (see above) (V6.0)
Results
id
optional: identifier of the sample; will only be returned when you pass Nil as argument 1 (see above)
Example
LoadSample(1, "Sound/Samples/WahWah.wav")
PlaySample(1)
WaitSampleEnd(1)
FreeSample(1)
The above code loads the sample "Sound/Samples/WahWah.wav", plays it, waits for it to end and frees it.

Show TOC