Open thiagohersan opened 11 years ago
yes android sound is super limited, there's things that are ridiculous like you can only setSpeed to x2 max or .5 min and depending if you are using soundpool or mediaplayer you have some other limitations like you can't get the position or set the speed.
there's a c api using openSL it's only supported from 2.3 but i think it could be ok to move to that now since most phones have newer operating systems. but haven't really tested yet and don't know if it would be as limited as the current one anyway. for some devices you can use openMAX which should have more options but i think it's only really a few devices that support it
yeah...
and thinking about it, when you have many samples being played at the same time in one SoundPool, at different speeds, what would getPosition mean? Position of the last sample triggered? position of the sample that will finish last? It's not clear.
But getIsPlaying()
could work (right now it also doesn't work with SoundPool, it always returns true).
Would keeping track of duration and time ourselves, and making getIsPlaying()
work a little better for SoundPool be interesting? Or is it too much of a hack?
yes in the desktop gePosition on multiplay returns the position of the last one i think. I don't think trying to implement getIsPlaying is a good idea, it'll be really hacky and not very reliable for long samples. the basicsoundplayer we are implementing here: https://github.com/openframeworks/openFrameworks/pull/1626 solves all this but it's still too slow for mobile platforms. i think the best solution would be to try openSL.
This is what I found while running the androidSoundPlayerExample: for each of the 3 audio players, at any given time, either
setSpeed( )
works, orgetPosition( )
works, but never both.I think it has to do with the
stream
variable and multiplay functionality. And whether the sound is beng played with theMediaPlayer
object, or theSoundPool
.Looking at getPosition() you can see that if
stream
is not true, and we're using aSoundPool
, it always returns zero for the position.And in setSpeed(...), if
stream
is true, and we're using aMediaPlayer
, it doesn't really use thespeed
variable anywhere.Is this some limitation of Android? MediaPlayer doesn't seem to have a setSpeed method, and SoundPool doesn't have a getPosition...