reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofSoundPlayer.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofSoundBaseTypes.h"
4#include "ofConstants.h"
5
7void ofSoundStopAll();
8
10void ofSoundShutdown();
11
14void ofSoundSetVolume(float vol);
15
17void ofSoundUpdate();
18
26float * ofSoundGetSpectrum(int nBands);
27
28
37public:
39
40 void setPlayer(std::shared_ptr<ofBaseSoundPlayer> newPlayer);
41 std::shared_ptr<ofBaseSoundPlayer> getPlayer();
42
49 bool load(const of::filesystem::path& fileName, bool stream = false);
50 OF_DEPRECATED_MSG("Use load",bool loadSound(std::string fileName, bool stream = false));
51
53 void unload();
54 OF_DEPRECATED_MSG("Use unload",void unloadSound());
55
57 void play();
58
60 void stop();
61
64 void setVolume(float vol);
65
68 void setPan(float pan);
69
72 void setSpeed(float speed);
73
76 void setPaused(bool paused);
77
80 void setLoop(bool loop);
81
84 void setMultiPlay(bool multiplay);
85
88 void setPosition(float percent);
89
92 void setPositionMS(int ms);
93
96 int getPositionMS() const;
97
100 float getPosition() const;
101
104 bool isPlaying() const;
105 OF_DEPRECATED_MSG("Use isPlaying",bool getIsPlaying() const);
106
109 float getSpeed() const;
110
113 float getPan() const;
114
117 float getVolume() const;
118
121 bool isLoaded() const;
122
123protected:
124 std::shared_ptr<ofBaseSoundPlayer> player;
125
126};
Definition ofSoundBaseTypes.h:161
Plays sound files.
Definition ofSoundPlayer.h:36
void setPan(float pan)
Sets stereo pan.
Definition ofSoundPlayer.cpp:167
void play()
Starts playback.
Definition ofSoundPlayer.cpp:146
std::shared_ptr< ofBaseSoundPlayer > getPlayer()
Definition ofSoundPlayer.cpp:116
ofSoundPlayer()
Definition ofSoundPlayer.cpp:104
OF_DEPRECATED_MSG("Use load", bool loadSound(std::string fileName, bool stream=false))
std::shared_ptr< ofBaseSoundPlayer > player
Definition ofSoundPlayer.h:124
bool isLoaded() const
Queries the player to see if its file was loaded successfully.
Definition ofSoundPlayer.cpp:248
void setPosition(float percent)
Sets position of the playhead within the file (aka "seeking").
Definition ofSoundPlayer.cpp:202
void stop()
Stops playback.
Definition ofSoundPlayer.cpp:153
float getPan() const
Gets stereo pan.
Definition ofSoundPlayer.cpp:266
OF_DEPRECATED_MSG("Use isPlaying", bool getIsPlaying() const)
void setPlayer(std::shared_ptr< ofBaseSoundPlayer > newPlayer)
Definition ofSoundPlayer.cpp:111
int getPositionMS() const
Gets position of the playhead.
Definition ofSoundPlayer.cpp:225
bool load(const of::filesystem::path &fileName, bool stream=false)
Tells the sound player which file to play.
Definition ofSoundPlayer.cpp:121
float getVolume() const
Gets current volume.
Definition ofSoundPlayer.cpp:275
void setMultiPlay(bool multiplay)
Enables playing multiple simultaneous copies of the sound.
Definition ofSoundPlayer.cpp:195
void setLoop(bool loop)
Sets whether to loop once the end of the file is reached.
Definition ofSoundPlayer.cpp:188
bool isPlaying() const
Gets current playback state.
Definition ofSoundPlayer.cpp:234
void setPositionMS(int ms)
Sets position of the playhead within the file (aka "seeking").
Definition ofSoundPlayer.cpp:209
void setVolume(float vol)
Sets playback volume.
Definition ofSoundPlayer.cpp:160
void setPaused(bool paused)
Enables pause / resume.
Definition ofSoundPlayer.cpp:181
float getPosition() const
Gets position of the playhead.
Definition ofSoundPlayer.cpp:216
void setSpeed(float speed)
Sets playback speed.
Definition ofSoundPlayer.cpp:174
OF_DEPRECATED_MSG("Use unload", void unloadSound())
void unload()
Stops and unloads the current sound.
Definition ofSoundPlayer.cpp:134
float getSpeed() const
Gets playback speed.
Definition ofSoundPlayer.cpp:257
float * ofSoundGetSpectrum(int nBands)
Gets a frequency spectrum sample, taking all current sound players into account.
Definition ofSoundPlayer.cpp:90
void ofSoundStopAll()
Stops all active sound players on FMOD-based systems (windows, osx).
Definition ofSoundPlayer.cpp:52
void ofSoundShutdown()
Cleans up FMOD (windows, osx).
Definition ofSoundPlayer.cpp:80
void ofSoundUpdate()
Call in your app's update() to update FMOD-based sound players.
Definition ofSoundPlayer.cpp:72
void ofSoundSetVolume(float vol)
Sets global volume for FMOD-based sound players (windows, osx).
Definition ofSoundPlayer.cpp:61