BRL.AudioSample: Functions Types Modinfo Source  

Audio samples

The BlitzMax audiosample module contains commands to create and load audio samples to be used with the BlitzMax Audio module.

Functions

Function CreateAudioSample:TAudioSample( length,hertz,format )
ReturnsAn audio sample object.
DescriptionCreate an audio sample.
Informationlength 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:

FormatDescription
SF_MONO8Mono unsigned 8 bit
SF_MONO16LEMono signed 16 bit little endian
SF_MONO16BEMono signed 16 bit big endian
SF_STEREO8Stereo unsigned 8 bit
SF_STEREO16LEStereo signed 16 bit little endian
SF_STEREO16BEStereo signed 16 bit big endian
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

Function CreateStaticAudioSample:TAudioSample( samples:Byte Ptr,length,hertz,format )
ReturnsAn audio sample object that references an existing block of memory.
DescriptionCreate an audio sample with existing data.
InformationThe memory referenced by a static audio sample is not released when the audio sample is deleted. format should be one of:

FormatDescription
SF_MONO8Mono unsigned 8 bit
SF_MONO16LEMono signed 16 bit little endian
SF_MONO16BEMono signed 16 bit big endian
SF_STEREO8Stereo unsigned 8 bit
SF_STEREO16LEStereo signed 16 bit little endian
SF_STEREO16BEStereo signed 16 bit big endian


Function LoadAudioSample:TAudioSample( url:Object )
ReturnsAn audio sample object.
DescriptionLoad an audio sample.

Types

Type TAudioSample
DescriptionAudio sample type.
Field format
DescriptionSample format.
Field hertz
DescriptionSample rate.
Field length
DescriptionLength, in samples, of the sample data.
Field samples:Byte Ptr
DescriptionByte pointer to sample data.
Method Convert:TAudioSample( to_format )
ReturnsA new audio sample object in the specified format.
DescriptionConvert audio sample.
Method Copy:TAudioSample()
ReturnsA new audio sample object.
DescriptionCopy audio sample.
Function Create:TAudioSample( length,hertz,format )
ReturnsA new audio sample object.
DescriptionCreate an audio sample.
Function CreateStatic:TAudioSample( samples:Byte Ptr,length,hertz,format )
ReturnsA new audio sample object that references an existing block of memory.
DescriptionCreate a static audio sample.

Type TAudioSampleLoader
DescriptionAudio sample loader type.
InformationTo 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.
Method LoadAudioSample:TAudioSample( stream:TStream ) Abstract
ReturnsA new audio sample object, or Null if sample could not be loaded.
DescriptionLoad an audio sample.
InformationExtending types must implement this method.

Module Information

Version1.04
AuthorMark Sibly
LicenseBlitz Shared Source Code
CopyrightBlitz Research Ltd
ModserverBRL
History1.04 Release
HistoryChannelsPerSample array added