forgive me for the long delay, I was fully pushing for the cocos 0.5 rc0

On Tue, Aug 9, 2011 at 9:20 PM, Facundo Batista <[email protected]>wrote:

> On Fri, Aug 5, 2011 at 3:52 PM, claudio canepa <[email protected]>
> wrote:
>
> > @Facundo: If you take the cocos\audio (SDL sound) approach and write down
> > some hints for other users I will buy you some beer at PyConAr 2011 .
> Deal ?
>
> Ok. Enjuewemela now uses the SDL backend (see trunk, revno 77).
>
> The most problematic stuff I faced is that in the game I play a random
> background music, so when a song finishes, I randomly chose other one
> and start to play it. But I couldn't make events work!!
>
> I heavily suspect that the event machinery doesn't really work without
> the pygame graphical environment set up (for its internal reactor, or
> something), but as in the cocos pygame stuff there's a lot of code for
> events, I kept trying.
>
>
Googling for SDL_mixer callback, the first result pointed to
http://www.kekkai.org/roger/sdl/mixer/
which uses SDL Mix_HookMusicFinished
Looking at cocos/audio/SDL/mixer.py , we have this and another similar for
sounds.
I added at the end of your sound.py the lines:

def cbak_music_finished():
     print '*** Music Finished ***'

def cbak_channel_finished(channel):
     print '*** chanel finished ***', channel

mixer.Mix_HookMusicFinished(cbak_music_finished)
mixer.Mix_ChannelFinished(cbak_channel_finished)

And running your  demo_sound.py got:

D:\cocos_pristine\enjue\enjuewemela\enjuewemela>demo_sound.py

Random music
D:\cocos_pristine\enjue\enjuewemela\enjuewemela\audio\music\Akajule
s - Gokidsgo.ogg
*** chanel finished *** 0
*** chanel finished *** 0
*** chanel finished *** 0
*** chanel finished *** 0
*** chanel finished *** 0
*** chanel finished *** 1
*** chanel finished *** 2
*** chanel finished *** 1
*** chanel finished *** 2
*** chanel finished *** 0
*** chanel finished *** 3
*** chanel finished *** 4
*** chanel finished *** 3
*** chanel finished *** 4
*** chanel finished *** 0
*** chanel finished *** 1
*** chanel finished *** 2
*** chanel finished *** 2147328000
Random music
D:\cocos_pristine\enjue\enjuewemela\enjuewemela\audio\music\Akajule
s - Gokidsgo.ogg

All but the last '*** channel...' correlates with clicks / sounds ; the last
 is music end. Dunno why  was called the channel callback and not the music
one, but at least sound termination can be detected, and the channel for
music seems detectable.

(OT: your dice seems to be a damn liar )

Anyway, I solved it using a pyglet scheduled call, so each second I
> check if the song finished, and start a new one if did. Works
> smoothly.
>
> So... Claudio:
>
> - You can test Enjuewemela with the new audio backend... just branch
> trunk, and run "python enjuewemela/demo_sound.py": you should get a
> black window with background music, with left button you get a short
> sound effect (useful to check lag between graph and audio) and with
> the right button you get a long effect (useful to see what happens
> when an effect overlaps de other).
>
> - There was a problem in cocos/audio/pygame/music.py, because the
> unpause() function called the Mix_UnpauseMusic symbol from the
> compiled library, but it really needs to call Mix_ResumeMusic. I fixed
> this in r1116 of cocos.
>
>
Thanks !!! It made to the cocos 0.5 release if any one asks.

And, going back to what dependencies have SDL audio, I noticed that it also
requires numpy. ( The INSTALL and the mirror page in the docs for 0.5 has a
revamped dependencies rundown that shows which functionality needs which
library)


> - I want to earn the promised beer! What do you mean with "some hints

for other users"?
>
>
I hoped for some hard data, and maybe  sample code, so...
You Win !!!
But, if you feel like writing a page for the programming_guide in the line
of
'A simple example for sound with SDL', with:
   motivation to use SDL over pyglet.audio ( hard dependency ?)
   your requirements  ( lean and mean play_sound , play_music ?)
   any problem ( message no sound card ?)
    sample code ( audio.py, demo_sound.py if you will ?)

... I will not dissuade you :)

And, just to clarify my understanding, each time you try the cocos sdl audio
you get 'no sound card' in the console (albeit sound plays) ?
Or it is only if you try when the sound is muted ?

cheers !

--
claudio

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en.

Reply via email to