BlitzMax/Modules/Audio/Audio samples

The BlitzMax audiosample module contains commands to create and load audio samples for use with the BlitzMax BRL.Audio module.

=Types=

TAudioSample
Audio sample type


 * samples
 * length
 * hertz
 * format


 * Copy
 * Convert


 * Create
 * CreateStatic

TAudioSample: Fields
Field samples:Byte Ptr

Description: Byte pointer to sample data

Field length

Description: Length, in samples, of the sample data

Field hertz

Description: Sample rate

Field format

Description: Sample format

TAudioSample: Methods
Method Copy:TAudioSample

Description: Copy audio sample

Returns: A new audio sample object

Method Convert:TAudioSample( to_format )

Description: Convert audio sample

Returns: A new audio sample object in the specified format

TAudioSample: Functions
Function Create:TAudioSample( length,hertz,format )

Description: Create an audio sample

Returns: A new audio sample object

Function CreateStatic:TAudioSample( samples:Byte Ptr,length,hertz,format )

Description: Create a static audio sample

Returns: A new audio sample object that references an existing block of memory

TAudioSampleLoader
Audio sample loader type

To create your own audio sample loaders, you should extend this type and provide a LoadAudioSample method. To add your audio sample loader to the system, simply create an instance of it using New.


 * LoadAudioSample

TAudioSampleLoader: Methods
Method LoadAudioSample:TAudioSample( stream:TStream )

Description: Load an audio sample

Returns: A new audio sample object, or Null if sample could not be loaded

Information: Extending types must implement this method.

=Functions=

CreateAudioSample
Function CreateAudioSample:TAudioSample( length,hertz,format )

Description: Create an audio sample

Returns: An audio sample object

Information: length is the number of samples to allocate for the sample. hertz is the frequency in samples per second (hz) the audio sample will be played. format should be one of:

Example: ' createaudiosample.bmx

Local sample:TAudioSample=CreateAudioSample( 32,11025,SF_MONO8 )

For Local k=0 Until 32 sample.samples[k]=Sin(k*360/32)*127.5+127.5 Next

Local sound:TSound=LoadSound( sample,True )

PlaySound(sound)

Input

CreateStaticAudioSample
Function CreateStaticAudioSample:TAudioSample( samples:Byte Ptr,length,hertz,format )

Description: Create an audio sample with existing data

Returns: An audio sample object that references an existing block of memory

Information: The memory referenced by a static audio sample is not released when the audio sample is deleted.

See CreateAudioSample for possile format values.

LoadAudioSample
Function LoadAudioSample:TAudioSample( url:Object )

Description: Load an audio sample

Returns: An audio sample object