Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Carrier tone to speakers
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
DeadlySyns
n00b
n00b


Joined: 14 May 2021
Posts: 8

PostPosted: Fri May 21, 2021 12:36 pm    Post subject: Carrier tone to speakers Reply with quote

Issue:

I use a home theater system for my computer speakers (I'm a bit of an audiophile). When there is no signal going to the receiver (SPDIF optical), it resets down to 2-channel stereo. I have five speakers and two subs (5.2), so I must change the mode each time I listen to music.

Solution?

I'd like some method to emit a continuous muted background tone to the receiver that my music will just overpower in the correct mode so that I no longer have to reset the settings each time I wish to listen to music. I know this won't survive sleep/reboot, so disregard those variables.

Any ideas on how to accomplish this?
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Fri May 21, 2021 1:40 pm    Post subject: Reply with quote

Maybe it's just an energy saving setting that turns off the data stream in the SPDIF optical channel?

Last edited by mike155 on Fri May 21, 2021 1:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ralphred
Guru
Guru


Joined: 31 Dec 2013
Posts: 466

PostPosted: Fri May 21, 2021 1:40 pm    Post subject: Reply with quote

How long does it take to reset, and what backend system are you using on the PC (alsa pulse etc), it might just be a client disconnect timeout forcing the defaulting to stereo.

You can use ffmpeg to create waveforms and drop them into a wav
Code:
ffmpeg -f lavfi -i "sine=frequency=400:sample_rate=48000:duration=10" ~/.keep_alive.wav

From there you can run it through an editor and attenuate it. The main question is what can you send to the amp that it will recognise as a signal, but won't annoy the local fauna (yourself included).

Once you get "a signal" and how frequently it needs to be sent, crafting some script to run at boot or login to send it shouldn't be hard.
Something simple would be
Code:
#!/bin/bash
#keep_alive-sender.sh
while aplay -D [pcm] -C [channels] ~/.keep_alive.wav
do sleep [some time in seconds]
done
because that script won't exit until the sound system shuts down (or when aplay fails for some other reason), you need a wrapper to prevent it stalling other things if you run it as a login script
Code:
#!/bin/bash
#keep_alive-wrapper.sh
[path to]/keep_alive-sender.sh &
echo $! >~/.keep_alive-sender.pid

This also stores the PID of your keep_alive-sender.sh process, so you could run
Code:
cat ~/.keep_alive-sender.pid|xargs kill -SIGKILL
at logout so it won't stall that process either.
Back to top
View user's profile Send private message
DeadlySyns
n00b
n00b


Joined: 14 May 2021
Posts: 8

PostPosted: Fri May 21, 2021 2:12 pm    Post subject: Reply with quote

Ralphred wrote:
How long does it take to reset, and what backend system are you using on the PC (alsa pulse etc), it might just be a client disconnect timeout forcing the defaulting to stereo.

You can use ffmpeg to create waveforms and drop them into a wav
Code:
ffmpeg -f lavfi -i "sine=frequency=400:sample_rate=48000:duration=10" ~/.keep_alive.wav

From there you can run it through an editor and attenuate it. The main question is what can you send to the amp that it will recognise as a signal, but won't annoy the local fauna (yourself included).

Once you get "a signal" and how frequently it needs to be sent, crafting some script to run at boot or login to send it shouldn't be hard.
Something simple would be
Code:
#!/bin/bash
#keep_alive-sender.sh
while aplay -D [pcm] -C [channels] ~/.keep_alive.wav
do sleep [some time in seconds]
done
because that script won't exit until the sound system shuts down (or when aplay fails for some other reason), you need a wrapper to prevent it stalling other things if you run it as a login script
Code:
#!/bin/bash
#keep_alive-wrapper.sh
[path to]/keep_alive-sender.sh &
echo $! >~/.keep_alive-sender.pid

This also stores the PID of your keep_alive-sender.sh process, so you could run
Code:
cat ~/.keep_alive-sender.pid|xargs kill -SIGKILL
at logout so it won't stall that process either.


This is a great write up and I will use it as my guide for implementation.

I can keep the volume muted, it's just inefficient to press 6 buttons to change sound modes when the computer should be able to keep it alive for me.
Back to top
View user's profile Send private message
Ralphred
Guru
Guru


Joined: 31 Dec 2013
Posts: 466

PostPosted: Fri May 21, 2021 2:31 pm    Post subject: Reply with quote

The only downside to aplay is it's native "alsa only" support. As pulseaudio has a habit of taking exclusive control over alsa hardware it helps to add
Code:
pcm.pulse {
        type pulse
        hint.description "ALSA to Pulse Link"
}

ctl.pulse {
        type pulse
}
to your ~/.asoundrc then you can invoke with "aplay -D pcm:pulse ..." and avoid any "device in use" related issues.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54028
Location: 56N 3W

PostPosted: Fri May 21, 2021 4:02 pm    Post subject: Reply with quote

DeadlySyns,

You may find that playing silence works to keep the stream open

/etc/local.d/play_silence.start:

#!/bin/bash

# due to a kernel bug, alsa takes a few seconds to open a
# stream to HDMI (all digital?) outputs, so the first
# few seconds of everything are lost.

# the work around is to continuosly play silence
# so that the sound stream is never closed.
aplay -c2 -r48000 -fS16_LE < /dev/zero &


That's only two channels, you can have more.

The 5.10 kernel, and later, has a config option for this.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Ralphred
Guru
Guru


Joined: 31 Dec 2013
Posts: 466

PostPosted: Mon Jun 21, 2021 3:49 pm    Post subject: Reply with quote

I now it's a bit aged now, but I was reading this over the weekend, and remembered this thread.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum