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

edit

TAudioSample

edit

Audio sample type

Fields
  • samples
  • length
  • hertz
  • format
Methods
  • Copy
  • Convert
Functions
  • Create
  • CreateStatic

TAudioSample: Fields

edit
samples

Field samples:Byte Ptr

Description: Byte pointer to sample data

length

Field length

Description: Length, in samples, of the sample data

hertz

Field hertz

Description: Sample rate

format

Field format

Description: Sample format

TAudioSample: Methods

edit
Copy

Method Copy:TAudioSample()

Description: Copy audio sample

Returns: A new audio sample object

Convert

Method Convert:TAudioSample( to_format )

Description: Convert audio sample

Returns: A new audio sample object in the specified format

TAudioSample: Functions

edit
Create

Function Create:TAudioSample( length,hertz,format )

Description: Create an audio sample

Returns: A new audio sample object

CreateStatic

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

edit

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.

Methods
  • LoadAudioSample

TAudioSampleLoader: Methods

edit
LoadAudioSample

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

edit

CreateAudioSample

edit

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:

Format Description
&SF_MONO8 Mono unsigned 8 bit
&SF_MONO16LE Mono signed 16 bit little endian
&SF_MONO16BE Mono signed 16 bit big endian
&SF_STEREO8 Stereo unsigned 8 bit
&SF_STEREO16LE Stereo signed 16 bit little endian
&SF_STEREO16BE Stereo 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

CreateStaticAudioSample

edit

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

edit

Function LoadAudioSample:TAudioSample( url:Object )

Description: Load an audio sample

Returns: An audio sample object