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

Feat/fairlight mixer send levels #148

Closed keith8496 closed 1 year ago

keith8496 commented 1 year ago

Audio levels are opt-in via start and stop commands. This is consistent with LibATEM and ATEM Software Control. Default to off.

I haven't looked at audio level support for classic audio. I don't have an ATEM device to test against. I am testing Fairlight audio against an ATEM 1 M/E Constellation HD.

The lead devs should discuss whether they want audio levels sent in the existing "stateChanged" event or a new "levelChanged" event. I've tested both methods. The event fires many times per second, so I created the event "levelChanged" to avoid sending the whole state over-and-over again. I'm happy to use "stateChanged" if that's what the devs prefer.

From issue #99:

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

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

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.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 81.81% and project coverage change: -0.02% :warning:

Comparison is base (005f0d5) 86.22% compared to head (16613f9) 86.21%. Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #148 +/- ## ========================================== - Coverage 86.22% 86.21% -0.02% ========================================== Files 177 180 +3 Lines 5708 5760 +52 Branches 941 946 +5 ========================================== + Hits 4922 4966 +44 - Misses 764 772 +8 Partials 22 22 ``` | [Files Changed](https://app.codecov.io/gh/nrkno/sofie-atem-connection/pull/148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nrkno) | Coverage Δ | | |---|---|---| | [src/atem.ts](https://app.codecov.io/gh/nrkno/sofie-atem-connection/pull/148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nrkno#diff-c3JjL2F0ZW0udHM=) | `20.24% <20.00%> (-0.01%)` | :arrow_down: | | [...nds/Fairlight/FairlightMixerMasterLevelsCommand.ts](https://app.codecov.io/gh/nrkno/sofie-atem-connection/pull/148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nrkno#diff-c3JjL2NvbW1hbmRzL0ZhaXJsaWdodC9GYWlybGlnaHRNaXhlck1hc3RlckxldmVsc0NvbW1hbmQudHM=) | `100.00% <100.00%> (ø)` | | | [...mands/Fairlight/FairlightMixerSendLevelsCommand.ts](https://app.codecov.io/gh/nrkno/sofie-atem-connection/pull/148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nrkno#diff-c3JjL2NvbW1hbmRzL0ZhaXJsaWdodC9GYWlybGlnaHRNaXhlclNlbmRMZXZlbHNDb21tYW5kLnRz) | `100.00% <100.00%> (ø)` | | | [...nds/Fairlight/FairlightMixerSourceLevelsCommand.ts](https://app.codecov.io/gh/nrkno/sofie-atem-connection/pull/148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nrkno#diff-c3JjL2NvbW1hbmRzL0ZhaXJsaWdodC9GYWlybGlnaHRNaXhlclNvdXJjZUxldmVsc0NvbW1hbmQudHM=) | `100.00% <100.00%> (ø)` | | | [src/commands/Fairlight/index.ts](https://app.codecov.io/gh/nrkno/sofie-atem-connection/pull/148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nrkno#diff-c3JjL2NvbW1hbmRzL0ZhaXJsaWdodC9pbmRleC50cw==) | `100.00% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/nrkno/sofie-atem-connection/pull/148/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nrkno)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.