Forum Archive

question on undocumented sound.Player class

wradcliffe

I just ran into the SoundDemo.py sample and believe I could use the looping feature. I am unpacking soundfonts into wav files and most of these require looping to be played correctly. The demo code at https://gist.github.com/omz/10023837 shows looping across the whole file, but sound font sounds mostly loop from an offset (some #frames) into the sound till the end. Have you considered having a loop start and end value in your new API? Also - the sample as written does not generate any sound under the current beta. Might be due to caf file location changes under IOS8 but no error is thrown.

JadedTuna

Just tried this script on iPad 3 with stable Pythonista build (1.5 I think?). Seems to work just fine.

dgelessus

Yeah, the script depends on Pythonista.app being located in ~, which is no longer the case with iOS 8 and any version above 1.5. Here's a fixed version of the line with the sound.Player constructor:

self.player = sound.Player(os.path.expanduser(os.path.join(os.path.dirname(os.__file__), "../Beep.caf")))

(Owch, my ears. Running this script with headphones on is a bad idea.)