From 592be28469a2f71d6806605b1b930f89841f7c57 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:19:18 +0100 Subject: [PATCH] README added for levels example --- examples/levels/README.md | 16 ++++++++++++++++ examples/levels/__main__.py | 7 ++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 examples/levels/README.md diff --git a/examples/levels/README.md b/examples/levels/README.md new file mode 100644 index 0000000..9e0012b --- /dev/null +++ b/examples/levels/README.md @@ -0,0 +1,16 @@ +## About + +Prints PREFADER level values for audio device `Desktop Audio`. If mute toggled prints mute state changed notification. + +## Use + +This example assumes the existence of a `config.toml`, placed next to `__main__.py`: + +```toml +[connection] +host = "localhost" +port = 4455 +password = "mystrongpass" +``` + +Press `` to exit from the script. diff --git a/examples/levels/__main__.py b/examples/levels/__main__.py index 701b1d9..7457433 100644 --- a/examples/levels/__main__.py +++ b/examples/levels/__main__.py @@ -12,7 +12,8 @@ LEVELTYPE = IntEnum( def on_input_mute_state_changed(data): """The current program scene has changed.""" - print(f"{data.input_name} mute toggled") + if data.input_name == DEVICE: + print(f"{DEVICE} mute toggled") def on_input_volume_meters(data): @@ -21,7 +22,7 @@ def on_input_volume_meters(data): for device in data.inputs: name = device["inputName"] - if name == INPUT_DEVICE and device["inputLevelsMul"]: + if name == DEVICE and device["inputLevelsMul"]: left, right = device["inputLevelsMul"] print( f"{name} [L: {fget(left[LEVELTYPE.POSTFADER])}, R: {fget(right[LEVELTYPE.POSTFADER])}]", @@ -38,6 +39,6 @@ def main(): if __name__ == "__main__": - INPUT_DEVICE = "Desktop Audio" + DEVICE = "Desktop Audio" main()