BGameSound is the base class used in the other sound classes in the kit. More...
Inherited by BSimpleGameSound, and BStreamingGameSound.
Public Member Functions | |
BGameSound (BGameSoundDevice *device=NULL) | |
Creates a BGameSound object. | |
virtual | ~BGameSound () |
Destroys the BGameSound object and frees the memory it uses. | |
virtual BGameSound * | Clone () 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. | |
Playback | |
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. | |
Sound Attributes | |
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. | |
BGameSound is the base class used in the other sound classes in the kit.
This class is not meant to be used directly. Any of the derived classes should be used instead.
BGameSound::BGameSound | ( | BGameSoundDevice * | device = NULL | ) |
Creates a BGameSound object.
The device parameter is currently unused and has to be defined as NULL
. Currently the class itself will retrieve the default device.
[in] | device | The sound device to be used. |
|
virtual |
Destroys the BGameSound object and frees the memory it uses.
It releases any buffer connected to the game sound device and then releases the device itself.
|
pure virtual |
Pure virtual method to create a copy of the BGameSound object.
Implemented in BFileGameSound.
BGameSoundDevice * BGameSound::Device | ( | ) | const |
Returns a pointer to the sound playback device.
const gs_audio_format & BGameSound::Format | ( | ) | const |
Returns a gs_audio_format struct instance with the format of the sound associated with the BGameSound object.
float BGameSound::Gain | ( | ) |
Retrieves the current level of gain of the sound.
If there is no sound initialized, by default it returns 0.0.
|
virtual |
Retrieves the attributes of the current sound.
attributes is a pre-allocated array of gs_attribute structures, with the "attribute" field of each one pre-filled with the desired attribute's identifier, for which the information is going to be retrieved.
[out] | attributes | The gs_attribute list where to save the attributes. |
[in] | attributeCount | The number of items in the attributes list. |
B_OK | The attributes were retrieved successfully. |
B_ERROR | The BGameSound's sound was not initialized. |
gs_id BGameSound::ID | ( | ) | const |
Returns the identifier of the sound associated with the BGameSound object.
status_t BGameSound::InitCheck | ( | ) | const |
Verifies if the BGameSound object was successfully initialized.
|
virtual |
Checks whether the sound is being played or not in the playback device.
true | The sound is currently being played. |
false | The sound is not being played. |
float BGameSound::Pan | ( | ) |
Retrieves the current value of panning of the sound.
If there is no sound initialized, by default it returns 0.0.
|
virtual |
Sets the attributes for the current sound.
[in] | attributes | An array of the group of attributes to be applied to the sound. |
[in] | attributeCount | The number of those attributes. |
B_OK | The attributes were applied successfully, or no error. |
B_ERROR | The BGameSound's sound was not initialized. |
others | Depending on the type of attribute. |
Sets the gain of the sound, that is, the amount of amplification of the input signal.
The gain is represented as a proportion, from 0.0 as the lowest to 1.0 as the highest level of gain.
A non-zero duration makes the transition from the current gain to the new gain take place over time in the amount set (in microseconds). If it is 0
, the change occurs immediately instead.
[in] | gain | Level of sound gain. |
[in] | duration | Duration of transition from the older gain level to the newer level. |
B_OK | The gain was applied successfully. |
B_BAD_VALUE | An out-of-bounds value for the gain was provided (not being 0.0 <= gain <= 1.0). |
Sets the panning of the sound, that is, the distribution of the audio signal anywhere in the stereophonic sound field.
A value of pan of -1.0 sets the sound at the most left side, 0.0 at the front, and 1.0 at the most right side.
A non-zero duration makes the transition from the current pan to the new pan take place over time in the amount set (in microseconds). If it is 0
, the change occurs immediately instead.
[in] | pan | Level of panning. |
[in] | duration | Duration of transition from the older panning value to the newer value. |
B_OK | The pan was applied successfully. |
B_ERROR | The BGameSound's sound was not initialized. |
B_BAD_VALUE | An out-of-bounds value for the pan was provided (not being -1.0 <= pan <= 1.0). |
|
virtual |
Plays the sound in the playback device.
B_OK | Playback started successfully. |
Reimplemented in BFileGameSound.
|
virtual |
Stops the playback of a sound currently playing.
B_OK | The sound stopped playing. |
Reimplemented in BFileGameSound.