sofie-atem-connection icon indicating copy to clipboard operation
sofie-atem-connection copied to clipboard

Read audio signal levels

Open SNRSE opened this issue 3 years ago • 5 comments

  • I'm submitting a ... [ ] bug report [ ] feature request [ ] question about the decisions made in the repository [ X] question about how to use this project

  • Summary I want to listen to the Atem so i can get the current level of an audio input.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

SNRSE avatar Jan 01 '21 22:01 SNRSE

Are you wanting the current signal level, or the current fader level? For fairlight or classic audio?

I dont think this library has any support for signal levels yet, but fader levels are all on the state object

Julusian avatar Jan 02 '21 17:01 Julusian

Hi yes i want the current Signal Level to do some autoswitching.

SNRSE avatar Jan 02 '21 17:01 SNRSE

yeah, so this isnt currently supported. No reason other than it hasnt been requested/needed before.

It won't be too hard to do, just a bit of thought to now throw out too many updates that could impact other code which listens on the state

Julusian avatar Jan 02 '21 18:01 Julusian

i’m also super interested in this feature! Since it’s likely a relatively uncommon use case I wouldn’t mind having to explicitly opt in to get the audio level events from the library to avoid flooding everyone else.

aaronpk avatar Jan 13 '21 16:01 aaronpk

For Video Follow Audio (which is why this is being requested), you could get away with having "Peak" value in the state and a Clear Peak method. This would make it easy for apps to detect when a threshold audio level had been reached and clear the peak value once they had switched input based on peak level.

imorrish avatar Jun 01 '21 18:06 imorrish

I would love to see audio signal levels implemented. For my use-case, I'm trying to build a web-based dashboard to bring numerous pieces of our livestream workflow together in once place.

It looks like audio levels have been added to LibAtem since this issue was last discussed.

I believe this turns the audio level feature on and off. It's opt-in. Off by default. https://github.com/LibAtem/LibAtem/blob/master/LibAtem/Commands/Audio/Fairlight/FairlightMixerSendLevelsCommand.cs

This looks like it receives the master levels: https://github.com/LibAtem/LibAtem/blob/master/LibAtem/Commands/Audio/Fairlight/FairlightMixerMasterLevelsCommand.cs

And the source levels: https://github.com/LibAtem/LibAtem/blob/master/LibAtem/Commands/Audio/Fairlight/FairlightMixerSourceLevelsCommand.cs

FWIW, this has been implemented in PyATEM, although I think he's got a bug in his conversion from raw data to decibels. I've been experimenting with his project. The additional load added by the audio levels seems insignificant on a 2013 MacMini running Ubuntu Server 22.04 LTS. https://github.com/git-2-github/martijnbraam-pyatem

keith8496 avatar Jul 06 '23 03:07 keith8496

I have an experimental branch with Fairlight audio signals for the devs' consideration. It's "alpha" quality at this point, not pull request ready. This is my first time working with Typescript and my first time building with Yarn.

I used the LibAtem resources described above. Audio levels are opt-in with commands to turn them on and off. This is consistent with LibAtem and I believe the official SDK.

I've tried two versions of this. The first version adds audio levels to state under fairlight.master.levels and fairlight.inputs.[i].sources.[s].levels. This triggers stateChanged events many times a second (as you would expect). It might not be a good option. The second version moves audio levels to their own levelChanged event. At this point I figure I should stop and ask if the devs if they have any feedback.

https://github.com/keith8496/sofie-atem-connection/tree/feat/FairlightMixerSendLevels

keith8496 avatar Jul 10 '23 18:07 keith8496

Hi @keith8496! Thanks for looking into this! Could you open a pull request from that branch? That way it's easier for us to provide feedback on the code.

We might be a bit slow replying during the next few weeks as most of the devs are on vacation.

nytamin avatar Jul 10 '23 18:07 nytamin

Yes, thank you.

keith8496 avatar Jul 10 '23 18:07 keith8496

This has been implemented for fairlight in #148

Julusian avatar Aug 27 '23 21:08 Julusian