Index

Package: Cache

Description

private package Audio_Players.Cache is
Copyright (c) 2012 Kevin Wellwood All rights reserved. This source code is distributed under the Modified BSD License. For terms and conditions, see license.txt.

Classes

Sound (abstract)

type Sound is abstract new Limited_Object with private;

Ancestors:

Immediate Children:

Audio_Players.Cache.Mp3_Sound
Audio_Players.Cache.Sample_Sound

Primitive operations:

Construct (Inherited)
Construct
Delete (Inherited)
To_String (Inherited)
Represents a sound effect/music loaded from a file that can be played once or in a loop. This is a specific instance of a played sound that can be started and stopped. It is backed by an audio resource that contains the audio data.

Types

A_Sound

type A_Sound is access all Sound'Class;

Subprograms & Entries

Get_Filename

function Get_Filename
( this: not null access Sound'Class ) return String;
Returns the name of the file that the Sound was loaded from.

Is_Done

function Is_Done
( this: not null access Sound'Class ) return Boolean;
Returns True if the sound finished playing or it has been stopped.

Play (abstract)

procedure Play
( this: access Sound;
looping: Boolean ) is abstract;
Starts playing the sound. If 'looping' is True, the sound will automatically loop when it finishes and will repeat until explicitly stopped.

Poll (abstract)

procedure Poll
( this: access Sound ) is abstract;
Polls the Sound object to maintain the stream of audio it must send to the audio hardware. This should be called approximately every 100ms.

Stop (abstract)

procedure Stop
( this: access Sound ) is abstract;
Stops playing the sound if it is playing.

Load_Sound

function Load_Sound
( filename: String ) return A_Sound;
Loads a sound to be played. Sound objects are backed by cached Audio_Resource data so they can be played instantly without waiting to load or decode anything. An exception is raised on error.

Unload_Sound

procedure Unload_Sound
( snd: in out A_Sound );
Discards a sound instance when it is no longer being played. It's Audio_Resource's reference count will decrease.