nrkno / sofie-atem-connection

Sofie ATEM Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
129 stars 36 forks source link

Read audio signal levels #99

Closed SNRSE closed 1 year ago

SNRSE commented 3 years ago
Julusian commented 3 years ago

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

SNRSE commented 3 years ago

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

Julusian commented 3 years ago

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

aaronpk commented 3 years ago

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.

imorrish commented 3 years ago

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.

keith8496 commented 1 year ago

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 commented 1 year ago

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

nytamin commented 1 year ago

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.

keith8496 commented 1 year ago

Yes, thank you.

Julusian commented 1 year ago

This has been implemented for fairlight in #148