This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
Plays sound files. More...
#include <ofSoundPlayer.h>

Public Member Functions | |
ofSoundPlayer () | |
void | setPlayer (std::shared_ptr< ofBaseSoundPlayer > newPlayer) |
std::shared_ptr< ofBaseSoundPlayer > | getPlayer () |
bool | load (const of::filesystem::path &fileName, bool stream=false) |
Tells the sound player which file to play. | |
OF_DEPRECATED_MSG ("Use load", bool loadSound(std::string fileName, bool stream=false)) | |
void | unload () |
Stops and unloads the current sound. | |
OF_DEPRECATED_MSG ("Use unload", void unloadSound()) | |
void | play () |
Starts playback. | |
void | stop () |
Stops playback. | |
void | setVolume (float vol) |
Sets playback volume. | |
void | setPan (float pan) |
Sets stereo pan. | |
void | setSpeed (float speed) |
Sets playback speed. | |
void | setPaused (bool paused) |
Enables pause / resume. | |
void | setLoop (bool loop) |
Sets whether to loop once the end of the file is reached. | |
void | setMultiPlay (bool multiplay) |
Enables playing multiple simultaneous copies of the sound. | |
void | setPosition (float percent) |
Sets position of the playhead within the file (aka "seeking"). | |
void | setPositionMS (int ms) |
Sets position of the playhead within the file (aka "seeking"). | |
int | getPositionMS () const |
Gets position of the playhead. | |
float | getPosition () const |
Gets position of the playhead. | |
bool | isPlaying () const |
Gets current playback state. | |
OF_DEPRECATED_MSG ("Use isPlaying", bool getIsPlaying() const) | |
float | getSpeed () const |
Gets playback speed. | |
float | getPan () const |
Gets stereo pan. | |
float | getVolume () const |
Gets current volume. | |
bool | isLoaded () const |
Queries the player to see if its file was loaded successfully. | |
![]() | |
ofBaseSoundPlayer () | |
virtual | ~ofBaseSoundPlayer () |
Protected Attributes | |
std::shared_ptr< ofBaseSoundPlayer > | player |
Detailed Description
Plays sound files.
ofSoundPlayer handles simple playback of sound files, with controls for volume, pan, speed, seeking and multiplay. This is a common cross-platform sound player interface which is inherited by each of the platform-specific sound player implementations.
Constructor & Destructor Documentation
◆ ofSoundPlayer()
ofSoundPlayer::ofSoundPlayer | ( | ) |
Member Function Documentation
◆ getPan()
|
virtual |
◆ getPlayer()
std::shared_ptr< ofBaseSoundPlayer > ofSoundPlayer::getPlayer | ( | ) |
◆ getPosition()
|
virtual |
Gets position of the playhead.
- Returns
- playhead position as a float between 0 and 1.
Implements ofBaseSoundPlayer.
◆ getPositionMS()
|
virtual |
Gets position of the playhead.
- Returns
- playhead position in milliseconds.
Implements ofBaseSoundPlayer.
◆ getSpeed()
|
virtual |
Gets playback speed.
- Returns
- playback speed (see ofSoundPlayer::setSpeed()).
Implements ofBaseSoundPlayer.
◆ getVolume()
|
virtual |
◆ isLoaded()
|
virtual |
Queries the player to see if its file was loaded successfully.
- Returns
- whether or not the player is ready to begin playback.
Implements ofBaseSoundPlayer.
◆ isPlaying()
|
virtual |
Gets current playback state.
- Returns
- true if the player is currently playing a file.
Implements ofBaseSoundPlayer.
◆ load()
|
virtual |
Tells the sound player which file to play.
Codec support varies by platform but wav, aif, and mp3 are safe.
- Parameters
-
fileName Path to the sound file, relative to your app's data folder. stream set "true" to enable streaming from disk (for large files).
Implements ofBaseSoundPlayer.
◆ OF_DEPRECATED_MSG() [1/3]
ofSoundPlayer::OF_DEPRECATED_MSG | ( | "Use isPlaying" | , |
bool getIsPlaying() const | |||
) |
◆ OF_DEPRECATED_MSG() [2/3]
ofSoundPlayer::OF_DEPRECATED_MSG | ( | "Use load" | , |
bool | loadSoundstd::string fileName, bool stream=false | ||
) |
◆ OF_DEPRECATED_MSG() [3/3]
ofSoundPlayer::OF_DEPRECATED_MSG | ( | "Use unload" | , |
void | unloadSound() | ||
) |
◆ play()
|
virtual |
Starts playback.
Implements ofBaseSoundPlayer.
◆ setLoop()
|
virtual |
Sets whether to loop once the end of the file is reached.
- Parameters
-
loop "true" to loop, default is false.
Implements ofBaseSoundPlayer.
◆ setMultiPlay()
|
virtual |
Enables playing multiple simultaneous copies of the sound.
- Parameters
-
multiplay "true" to enable, default is false.
Implements ofBaseSoundPlayer.
◆ setPan()
|
virtual |
Sets stereo pan.
- Parameters
-
pan range is -1 to 1 (-1 is full left, 1 is full right).
Implements ofBaseSoundPlayer.
◆ setPaused()
|
virtual |
Enables pause / resume.
- Parameters
-
paused "true" to pause, "false" to resume.
Implements ofBaseSoundPlayer.
◆ setPlayer()
void ofSoundPlayer::setPlayer | ( | std::shared_ptr< ofBaseSoundPlayer > | newPlayer | ) |
◆ setPosition()
|
virtual |
Sets position of the playhead within the file (aka "seeking").
- Parameters
-
percent range is 0 (beginning of file) to 1 (end of file).
Implements ofBaseSoundPlayer.
◆ setPositionMS()
|
virtual |
Sets position of the playhead within the file (aka "seeking").
- Parameters
-
ms number of milliseconds from the start of the file.
Implements ofBaseSoundPlayer.
◆ setSpeed()
|
virtual |
Sets playback speed.
- Parameters
-
speed set > 1 for faster playback, < 1 for slower playback.
Implements ofBaseSoundPlayer.
◆ setVolume()
|
virtual |
◆ stop()
|
virtual |
Stops playback.
Implements ofBaseSoundPlayer.
◆ unload()
|
virtual |
Stops and unloads the current sound.
Implements ofBaseSoundPlayer.
Member Data Documentation
◆ player
|
protected |
The documentation for this class was generated from the following files:
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/sound/ofSoundPlayer.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/sound/ofSoundPlayer.cpp