Hi Nick (I repost my answer because I just got a notification about its being
to big)
The problem is that LS won‘t start any longer when I add the cod to the liq
file.
Even if I only add
IsStarted = false
it doesn‘t work anymore.
What I have now is (I took out the = you‘d put after def dostartup() becuase I
thought it‘s a typo?):
#!/usr/bin/liquidsoap
# set the path and permissions for the logfile
set("log.file.path","/var/log/liquidsoap/phono.log")
set("log.file.perms",777)
#set("log.unix_timestamps",true)
#input from soundcard
phono = input.alsa(bufferize=true,fallible=false,device="hw:0")
isStarted = false
def dostartup()
# We have started playing, so set the flag
isStarted := true
end
def handler()
if !isStarted then
system("/etc/liquidsoap/shut_on_blank.sh")
end
end
source = on_blank(
max_blank=60.0,
on_noise=dostartup,
handler,
phono
)
#stream it to local icecast, default port and password
output.icecast(%ogg(%flac(samplerate=44100,channels=2,compression=5,bits_per_sample=16)),
mount="/phono", name="Phono", format="audio/ogg", description="Turntable
FLAC", url="http://192.168.178.200”", genre = "Misc", source)
Regards
Martin
> Am 06.12.2017 um 22:49 schrieb Nicholas Vrtis <[email protected]>:
>
> Yes.. what you have should work. Didn't include the source statement in my
> notes, since I was just trying to give the example on how to set/access
> variables in functions.
>
> Nick
>
>> On Wed, Dec 6, 2017 at 4:36 PM, Martin Knapp <[email protected]> wrote:
>> Thanks Nick, but isn‘t the on_noise part lacking in your suggestion, the one
>> that is meant to trigger dostartup?
>> Could it be integrated this way?
>>
>> source = on_blank(
>> max_blank=60.0,
>> on_noise=dostartup,
>> handler,
>> phono
>> )
>>
>> Regards
>> Martin
>>
>>> Am 06.12.2017 um 22:02 schrieb Nicholas Vrtis <[email protected]>:
>>>
>>> Hi Martin..
>>>
>>> Try this:
>>>
>>> In the mainline of your script.
>>> isStarted = false
>>>
>>> def dostartup() =
>>> # We have started playing, so set the flag
>>> isStarted := true
>>> end
>>>
>>> def handler()
>>> if !isStarted then
>>> system("/etc/liquidsoap/shut_on_blank.sh")
>>> end
>>> end
>>>
>>> basically, when you want to set an external value from within a function
>>> you use := instead of just =
>>> when you want to reference it, put a ! (exclamation point) in front it of.
>>>
>>> (and for 'completeness' you use something like this if you want it in
>>> quotes "#{!alsaDevice}" )
>>>
>>> Nick
>>>
>>>> On Wed, Dec 6, 2017 at 3:07 PM, Martin Knapp <[email protected]> wrote:
>>>> Thanks again Nick, I really appreciate your help - and I feel pretty
>>>> ashamed for not having found the documentation you‘ve pointed me to.
>>>> Delaying shutdown with max_blank works perfectly, even with higher values
>>>> (600) Regarding on_noise and the variables, I‘ve spent a couple of hours
>>>> studying the documentation and the sample code, but didn‘t get very far.
>>>> It‘s not trivial for a non-programmer like me with only some superficial
>>>> php and perl knowledges. But I‘ll keep on trying.
>>>> Thanks & best regards
>>>> Martin
>>>>
>>>>> Am 05.12.2017 um 22:41 schrieb Nicholas Vrtis <[email protected]>:
>>>>>
>>>>> Martin,
>>>>>
>>>>> If you look at the documentation for on_blank
>>>>> (http://liquidsoap.info/doc-dev/reference.html#on_blank), you can set the
>>>>> on_blank(max_blank=40.0, handler, phono)
>>>>>
>>>>> Note that max_blank takes a float, or you need the period.
>>>>>
>>>>> You can also specify an on_noise=dostartup
>>>>>
>>>>> So, what I would do is have the 'handler' check a Boolean to make sure
>>>>> the song has started, and only shutdown if it has.
>>>>>
>>>>> Then in the dostartup function, I would change the Boolean so that when
>>>>> 'handler' is called the next time (which would be after the end of the
>>>>> song), it would issue the shutdown.
>>>>>
>>>>> Check some of the examples on how to get and set a variable within
>>>>> functions.
>>>>>
>>>>> Nick
>>>>>
>>>>>
>>>>>> On Tue, Dec 5, 2017 at 5:22 AM, Martin Knapp <[email protected]>
>>>>>> wrote:
>>>>>> Hi,
>>>>>> it works! 30 seconds after finishing the playback the Raspi shuts down -
>>>>>> thanks again, Nick!
>>>>>> I imagine that 30 sec. is the default value. It's a little short,
>>>>>> however, when it comes to jumping of the sofa, running to the turntable
>>>>>> and put another record to play ;)
>>>>>> I've read that with Liquidsoap's blank operators you can fine-tune the
>>>>>> length and threshold parameters.
>>>>>> I have been trying to do so with on_blank, following the samples for
>>>>>> skip_blank etc.:
>>>>>>
>>>>>> source = on_blank(handler,length=120.,phono)
>>>>>>
>>>>>> The result is that Liquidsoap doesn't start any longer.
>>>>>>
>>>>>> Hence my questions (it seems that bthere is no documentation on the
>>>>>> on_blank params?):
>>>>>> 1. How can I define the minimum length a blank must have in order to be
>>>>>> recognized as such?
>>>>>> 2. How can I avoid that the shutdown script is triggered after starting
>>>>>> the Raspi and before any record has been played, e.g. in cases that it
>>>>>> takes longer to find the record, clean it etc.?
>>>>>>
>>>>>> In other words: The perfect setup for this vinyl streamer would be:
>>>>>> - Start the Raspi
>>>>>> - Liquidsoap is waiting (indefinitely) for the first record to be played
>>>>>> - Liquidsoap triggers the shutdown script after the amount of time
>>>>>> defined for on_blank recognition.
>>>>>> Thanks & best regards
>>>>>> Martin
>>>>>>
>>>>>>
>>>>>>> Am 04.12.2017 um 12:35 schrieb Nicholas Vrtis:
>>>>>>> It looks like you are trying to output the source 'phono', but it is
>>>>>>> the source 'source' that has the 'on_blank'.
>>>>>>> It might be helpful to see the log to see what it happening, and to put
>>>>>>> a print in the on blank handler to make sure it is actually being
>>>>>>> triggered.
>>>>>>>
>>>>>>> Nick
>>>>>>>
>>>>>>> On Mon, Dec 4, 2017 at 4:36 AM, Federico Allegretti
>>>>>>> <[email protected]> wrote:
>>>>>>>> And how do you resolve?
>>>>>>>>
>>>>>>>> Il 01/dic/2017 01:15 PM, "Martin Knapp" <[email protected]> ha
>>>>>>>> scritto:
>>>>>>>>> Hi,
>>>>>>>>> Please apologize if I bring my question (below) up again, It seems
>>>>>>>>> that I just can't resolve the on_blank issue by myself. I would be
>>>>>>>>> very grateful for being pointed to some additional information and/or
>>>>>>>>> examples (if they exist).
>>>>>>>>> Regards
>>>>>>>>> Martin
>>>>>>>>>
>>>>>>>>>> Am 23.11.2017 um 21:19 schrieb Martin Knapp:
>>>>>>>>>> Good morning everybody,
>>>>>>>>>> in the Slimdevices forums (LMS, squeezelite etc.) we've been looking
>>>>>>>>>> for a way to shut down a Raspberry Pi automatically after playing
>>>>>>>>>> some music when no sound is detected on the sound card any longer.
>>>>>>>>>> This can be helpful in our cases where we are recording or streaming
>>>>>>>>>> "vinyl" from vintage turntables into a multiroom enabled system like
>>>>>>>>>> LMS.
>>>>>>>>>> For creating and transmitting the vinyl stream (FLAC), I use
>>>>>>>>>> Liquidsoap and Icecast. That works pretty fine, and I'm very
>>>>>>>>>> thankful for having discovered Liquidsoap.
>>>>>>>>>> My recipe is:
>>>>>>>>>>
>>>>>>>>>> #!/usr/bin/liquidsoap
>>>>>>>>>> # set the path and permissions for the logfile
>>>>>>>>>> set("log.file.path","/var/log/liquidsoap/phono.log")
>>>>>>>>>> set("log.file.perms",777)
>>>>>>>>>> #set("log.unix_timestamps",true)
>>>>>>>>>> #input from soundcard
>>>>>>>>>> phono = input.alsa(bufferize=true,fallible=false,device="hw:0")
>>>>>>>>>> #stream it to local icecast, default port and password
>>>>>>>>>> output.icecast(%ogg(%flac(samplerate=44100,channels=2,compression=5,bits_per_sample=16)),
>>>>>>>>>> mount="/phono", name="Phono", format="audio/ogg",
>>>>>>>>>> description="Turntable FLAC", url="http://192.168.178.200”",
>>>>>>>>>> genre = "Misc", phono)
>>>>>>>>>>
>>>>>>>>>> Now we have been looking at the on_blank operator described in
>>>>>>>>>> http://liquidsoap.fm/doc-dev/blank.html, which seems to be able to
>>>>>>>>>> do the job of shutting down the Pi after finishing the playback of a
>>>>>>>>>> vinyl record. I created a shut down script (shut_on_blank.sh, owner:
>>>>>>>>>> root) and tried to insert:
>>>>>>>>>>
>>>>>>>>>> def handler()
>>>>>>>>>> system("/etc/liquidsoap/shut_on_blank.sh")
>>>>>>>>>> end
>>>>>>>>>> source = on_blank(handler,phono)
>>>>>>>>>>
>>>>>>>>>> into the .liq file above, but the result was that the entire stream
>>>>>>>>>> generation didn't work any longer.
>>>>>>>>>>
>>>>>>>>>> What am I doing wrong?
>>>>>>>>>>
>>>>>>>>>> The second question that arose was whether the length of the blank
>>>>>>>>>> to be detected as such can be configured with on_blank, too - as it
>>>>>>>>>> seems to be possible with max_blank= for strip_blank. When searching
>>>>>>>>>> through the mailing list, I also found a post saying that the
>>>>>>>>>> default threshold for blank detection is -40db, and that it can be
>>>>>>>>>> adjusted - but not how/where. It seems that we weren't able to find
>>>>>>>>>> further information on this in the docs.
>>>>>>>>>>
>>>>>>>>>> Thanks for your help & best regards
>>>>>>>>>> Martin
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users