Hi,

I've come back to this thread, which was apparently very frustrating
to Marcin. I have ran a few experiments and my conclusion is that
there isn't any bug here, just a tricky situation (of couse, it'd be
nice to find ways to present and document things so that users
understand more easily what's going on). I did my tests on the latest
SVN version, but it should apply equally well on 0.9.2 and even before
that.

First, I'll repeat what I said in my previous message: transitions in
switch-like operators are always supported, for any child source,
including input.http(). The problematic things with http is operators
such as cross() and smart_cross() (and the derived operators
crossfade() and smart_crossfade()) which make a transition between two
consecutive tracks of the _same_ source.

Now, my experiments confirmed what Romain suspected: at the time when
live_out_transition() is triggered, the isn't any remaining data in
the HTTP input's buffer, that's why the transition doesn't make any
sense.

> def live_out_transition(a, b)
>  log("Live out transition")
>  add(normalize=false, [ sequence([blank(duration=2.5),
> fade.initial(duration=5.,b) ]), fade.final(duration=5.,a) ])
> end
> [...]
> But when I type live.stop, after a few seconds sound source
> changes, with no crossfade, and there's no "Live out transition" in the 
> logfile.

In my case the transition is triggered, I see the log. But the rest is
as you say, which is normal when the transition is instantiated with a
source "a" which has nothing to stream anymore: a blank of 2.5
seconds, then a fade in to the normal music source.

So, what's the solution? A pleasant solution would be to use the
"before" parameter, to trigger the transition _before_ the end of the
stream. Unfortunately, as the doc says, this is still experimental,
and doesn't work in a number of situations. (In general, it's hard to
predict the future... in a fallback(), we could see in advance that
we'll switch to another child, but in a general switch() we cannot
know too well what will be the values of the predicates.) Anyway,
"before" doesn't work in that situation.

Another solution is to trigger the switch manually independently of
the live.start/stop. Here's how I did it:

flag = "/tmp/flag"
radio = switch(transitions=[live_in_transition, live_out_transition],
               track_sensitive = false,
               [ ({test_process("test -f #{flag}")},live),
                 ({true},music) ] )

Now, radio isn't a fallback anymore, it relies on a test to switch to
live. In a shell, if you "touch /tmp/flag", you enable the switch to
the live stream -- as soon as it becomes ready; If you "rm /tmp/flag"
you trigger the transition to the other source.

You'll see that it works pretty well, _if_ the live stream is always
running. If you stop it after the end of the transition, some "old"
data will remain in the buffer and show up later, which is ugly. To
avoid this, we'll change the live_out transition, so that it entirely
consumes the buffer.

def live_out_transition(a, b)
 log("Live out transition")
 add(normalize=false, [
     sequence([blank(duration=2.5),fade.initial(duration=5.,b)]),
     fade.out(duration=5.,a) ])
end

Now, if you live.stop without deleting /tmp/flag, you have the same
problem as reported in the first mail. However, if you delete
/tmp/flag before that the buffer empties, it will transition nicely.
It also works well if you delete the flag before calling live.stop. In
a nutshell, do the two things pretty much at the same time, the exact
order doesn't matter, and it'll work like a charm.

Hope that helps!
-- 
David

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to