chris-ritsen / network-audio-controller

Cross-platform CLI control of Dante network audio devices without Dante Controller
The Unlicense
203 stars 21 forks source link

Lots of drops connection trouble #26

Open fadersolo opened 2 weeks ago

fadersolo commented 2 weeks ago

Just found this tool, it’s AWESOME!

When I run commands it can’t seem to find my devices most of the time. For example, if I run netaudio device list, odds are it’ll return nothing, but if I run it 4-5 times in a row some devices start to show up. This is on macOS. If I run the same command from my raspberry pi, I consistently get my full list.

Here’s my problem: I wanna run netaudio config --set-sample-rate 44100, to help me change the sample rates across the network (for everything that can). I’m not having luck.

On macOS I have to keep running over and over before it finally finds both devices and updates them:

Device not found
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Setting sample rate of Red8Pre 192.168.1.91 to 44100
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Failed to get a service by type. 
Failed to get Dante device name
Failed to get a service by type. 
Failed to get Dante channel counts
Setting sample rate of  192.168.1.91 to 44100
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Device not found
 % netaudio config --set-sample-rate 44100
Setting sample rate of MCDUDE-002 192.168.1.66 to 44100

On my raspberry, it always times out:

 % netaudio config --set-sample-rate 48000
Setting sample rate of Red8Pre 192.168.1.91 to 48000

  timeout

  timed out

  at .local/lib/python3.9/site-packages/netaudio/dante/device.py:96 in dante_command
        92│         binary_str = codecs.decode(command, "hex")
        93│ 
        94│         try:
        95│             sock.send(binary_str)
    →   96│             response = sock.recvfrom(2048)[0]
        97│         except TimeoutError:
        98│             pass
        99│ 
       100│         return response
chris-ritsen commented 2 weeks ago

That error message could be better, but basically you're required to give it a device IP or name (that is, whichever one device you're trying to change).

--device-host Specify a device to configure by network address --device-name Specify a device to configure by name

I guess I never tried it without an argument, seems like it's still attempting to do something in your examples. I should make the mDNS timeout configurable (it's currently 1.5 seconds), but if you specify the device IP it doesn't bother looking for mDNS services and just talks to the device directly. This is the fastest way to interact with devices if you're scripting things.

chris-ritsen commented 2 weeks ago

Also, I've started to implement a daemon mode that caches into redis and watches for mDNS changes on its own, so eventually the timeout won't matter.

fadersolo commented 2 weeks ago

With a lot of the commands I’ve tried, it seems like if I don’t specify a device, it tries to go through every device on my network. I can imagine that’d be crazy for some people’s setups. 😬 TBH: when it works -- as in omitting a device hits everything on the network -- it’s really nice. I can imagine myself running these sample rate switch commands often.

chris-ritsen commented 2 weeks ago

I can see the utility of setting AES67 mode or the sample rate on all devices at once, but how it works now was unintentional. I'll look into making this explicit. Setting anything on all devices in the network at once to any setting by accident is chaos I want to avoid. Please don't use this in prod yet.

fadersolo commented 2 weeks ago

You’re awesome! Like I said before, this is such a cool project! I’m grateful for the smart folks like you who know how to build tools like this.