openframeworks / openframeworks/openFrameworks
ofSoundPlayer::setVolume(float) doesn't behave similarly on OS X and linux
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Expected behavior: on OSX, when setVolume(x) is called with x negative, the volume is set to 0.
Bug: on Linux (ubuntu), negative arguments are discarded but the previous valid volume is kept.
A simple fix could be to constrain* the given volume:
https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/sound/ofSoundPlayer.cpp#L118
Here is a suggestion:
void ofSoundPlayer::setVolume(float vol){
if( player ){
if (vol < 0) vol = 0; // XXX suggestion
if (vol > 1) vol = 1; // XXX suggestion (optional)
player->setVolume(vol);
}
}
Let me know if a pull request with these suggestions would be useful.
Cedric.
*vol range is 0 to 1:
https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/sound/ofSoundPlayer.h#L103
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in libs/openFrameworks/sound/ofSoundPlayer.cpp at ofSoundPlayer::setVolume(float), then check the declared 0-to-1 range in libs/openFrameworks/sound/ofSoundPlayer.h. Compare the OS X and Linux behavior for negative and above-range values; done means invalid volumes are handled consistently without retaining a previous valid volume.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100