WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Solved] how to detect audio playback using only alsa, without pulseaudio  (Read 8334 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Hi GNUser
... The approach in reply #25 is working reliably and I can understand it, so I'm perfectly happy with it.
That's OK, I was just curious if it worked.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Hi jazzbiker
Straight from:
Code: [Select]
dd --helpIt says (emphasis mine):
Quote
  skip=N          skip N ibs-sized blocks at start of input
and:
Quote
  bs=BYTES        read and write up to BYTES bytes at a time (default: 512);
                          overrides ibs and obs

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Hi, Rich!
Thanks for reminder, i was trying to guess, what is looking suspicious in the command I proposed. Those 1100 are 1K+ header + extra samples, which were to be cut by dd, precise number not significant. I don't believe, that cmp was making mistakes, wrong output meant something was wrong with the input data.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Hi jazzbiker
... I don't believe, that cmp was making mistakes, wrong output meant something was wrong with the input data.
Agreed.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Hi, guys!
Those alsa config, which I've found seems too complicated. Additional module to be loaded, long chain of plugins... Of course it works, but I was anxious about the shorter way. If it is not interesting for You, please don't read this post ;)

So, alsa have the plugin, which can write raw headerless data directly into file. And even more, this data can be redirected to the executable,  .asoundrc attached. As seen, default device data are passed directly to /home/tc/c/vmeter/vmeter binary through the pipe. vmeter source attached. It keeps file /tmp/volume in accordance with the current signal volume of the alsa output. This file can be monitored in any desirable way, for example

w h i l e    t r u e
d o
      r e a d     N < /tmp/volume
      e c h o    $N
      s l e e p   1
d o n e

Must say, that assumptions are made about data format and channels number - signed 16-bit numbers and 2 channels.