Loading...
Searching...
No Matches
Public Member Functions | List of all members
BSimpleGameSound Class Reference

BSimpleGameSound represents a simple sound effect that remains in memory. More...

Inherits BGameSound.

Public Member Functions

 BSimpleGameSound (const BSimpleGameSound &other)
 Copy constructor.
 
 BSimpleGameSound (const char *file, BGameSoundDevice *device=NULL)
 Creates and initializes a BSimpleGameSound object from a sound file path and prepares it to be ready for playback.
 
 BSimpleGameSound (const entry_ref *file, BGameSoundDevice *device=NULL)
 Creates and initializes a BSimpleGameSound object from a sound file's entry_ref and prepares it to be ready for playback.
 
 BSimpleGameSound (const void *data, size_t frameCount, const gs_audio_format *format, BGameSoundDevice *device=NULL)
 Creates and initializes a BSimpleGameSound object from a data buffer in memory of frameCount frames in a format.
 
virtual ~BSimpleGameSound ()
 Frees all resources associated with the object.
 
virtual BGameSoundClone () const
 Returns a copy of this BSimpleGameSound object.
 
bool IsLooping () const
 Returns whether looping is enabled or not.
 
status_t SetIsLooping (bool looping)
 Enables or disables the playback looping of the sound.
 
- Public Member Functions inherited from BGameSound
 BGameSound (BGameSoundDevice *device=NULL)
 Creates a BGameSound object.
 
virtual ~BGameSound ()
 Destroys the BGameSound object and frees the memory it uses.
 
virtual BGameSoundClone () const =0
 Pure virtual method to create a copy of the BGameSound object.
 
BGameSoundDevice * Device () const
 Returns a pointer to the sound playback device.
 
const gs_audio_format & Format () const
 Returns a gs_audio_format struct instance with the format of the sound associated with the BGameSound object.
 
gs_id ID () const
 Returns the identifier of the sound associated with the BGameSound object.
 
status_t InitCheck () const
 Verifies if the BGameSound object was successfully initialized.
 
virtual status_t StartPlaying ()
 Plays the sound in the playback device.
 
virtual bool IsPlaying ()
 Checks whether the sound is being played or not in the playback device.
 
virtual status_t StopPlaying ()
 Stops the playback of a sound currently playing.
 
status_t SetGain (float gain, bigtime_t duration=0)
 Sets the gain of the sound, that is, the amount of amplification of the input signal.
 
status_t SetPan (float pan, bigtime_t duration=0)
 Sets the panning of the sound, that is, the distribution of the audio signal anywhere in the stereophonic sound field.
 
float Gain ()
 Retrieves the current level of gain of the sound.
 
float Pan ()
 Retrieves the current value of panning of the sound.
 
virtual status_t SetAttributes (gs_attribute *attributes, size_t attributeCount)
 Sets the attributes for the current sound.
 
virtual status_t GetAttributes (gs_attribute *attributes, size_t attributeCount)
 Retrieves the attributes of the current sound.
 

Detailed Description

BSimpleGameSound represents a simple sound effect that remains in memory.

To use BSimpleGameSound is enough to create an instance of it and then call StartPlaying() to start the playback:

const char* filename = ... ;
BSimpleGameSound* sound = new BGameSound(filename);
sound->StartPlaying();
BGameSound is the base class used in the other sound classes in the kit.
Definition: GameSound.h:15
virtual status_t StartPlaying()
Plays the sound in the playback device.
BSimpleGameSound represents a simple sound effect that remains in memory.
Definition: SimpleGameSound.h:14

The device parameter in all of the constructors is currently unused and has to be defined as NULL. Its base class BGameSound takes care of that by initializing the default sound device.

Since
BeOS R4.5

Constructor & Destructor Documentation

◆ BSimpleGameSound() [1/4]

BSimpleGameSound::BSimpleGameSound ( const entry_ref file,
BGameSoundDevice *  device = NULL 
)

Creates and initializes a BSimpleGameSound object from a sound file's entry_ref and prepares it to be ready for playback.

Parameters
[in]fileAn entry_ref reference of the sound file.
[in]deviceThe sound device where the sound should be played. Setting it to NULL makes it to use the default sound device.
Since
BeOS R4.5

◆ BSimpleGameSound() [2/4]

BSimpleGameSound::BSimpleGameSound ( const char *  file,
BGameSoundDevice *  device = NULL 
)

Creates and initializes a BSimpleGameSound object from a sound file path and prepares it to be ready for playback.

Parameters
[in]fileThe filename path of the sound file.
[in]deviceThe sound device where the sound should be played. Setting it to NULL makes it to use the default sound device.
Since
BeOS R5

◆ BSimpleGameSound() [3/4]

BSimpleGameSound::BSimpleGameSound ( const void *  data,
size_t  frameCount,
const gs_audio_format *  format,
BGameSoundDevice *  device = NULL 
)

Creates and initializes a BSimpleGameSound object from a data buffer in memory of frameCount frames in a format.

Parameters
[in]dataA pointer to the sound data in memory.
[in]frameCountThe number of frames in the sound data.
[in]formatThe format of the sound data.
[in]deviceThe sound device where the sound should be played. Setting it to NULL makes it to use the default sound device.
Since
BeOS R4.5

◆ BSimpleGameSound() [4/4]

BSimpleGameSound::BSimpleGameSound ( const BSimpleGameSound other)

Copy constructor.

It creates a deep copy of the sound data in other.

Parameters
[in]otherThe other BSimpleGameSound object from where to initialize this instance.
Since
BeOS R4.5

◆ ~BSimpleGameSound()

BSimpleGameSound::~BSimpleGameSound ( )
virtual

Frees all resources associated with the object.

Since
BeOS R4.5

Member Function Documentation

◆ Clone()

BGameSound * BSimpleGameSound::Clone ( ) const
virtual

Returns a copy of this BSimpleGameSound object.

Since
BeOS R4.5

Implements BGameSound.

◆ IsLooping()

bool BSimpleGameSound::IsLooping ( ) const

Returns whether looping is enabled or not.

Return values
trueLooping is currently enabled.
falseLooping is currently disabled.
See also
SetIsLooping()
Since
BeOS R4.5

◆ SetIsLooping()

status_t BSimpleGameSound::SetIsLooping ( bool  looping)

Enables or disables the playback looping of the sound.

Parameters
[in]loopingIf it is true turns on looping, and if it is false turns it off.
Return values
B_OKThe looping was toggled on or off successfully.
B_ERRORThere was an internal error trying to find the sound data.
See also
IsLooping()
Since
BeOS R4.5