Python Forum

Full Version: Is there a simplified way to achieve this
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,
Wondering if there is a better way to achieve this? In an ideal world the level value would count down -1000 to -6000 over 2 seconds.
I'm a complete noob with this. I'm trying to control an audio console with this code.
Thanks
Andrew.

#Set channel 6 to -60

s.sendall("set MIXER:Current/InCh/Fader/Level 5 0 -1000\n".encode())
time.sleep(.500)
s.sendall("set MIXER:Current/InCh/Fader/Level 5 0 -2000\n".encode())
time.sleep(.500)
s.sendall("set MIXER:Current/InCh/Fader/Level 5 0 -4000\n".encode())
time.sleep(.500)
s.sendall("set MIXER:Current/InCh/Fader/Level 5 0 -5000\n".encode())
time.sleep(.500)
s.sendall("set MIXER:Current/InCh/Fader/Level 5 0 -6000\n".encode())
Use a for loop with range
for value in range(-1000, -7000, -1000):
    print(f'set MIXER:Current/InCh/Fader/Level 5 0 {value}\n')
Output:
set MIXER:Current/InCh/Fader/Level 5 0 -1000 set MIXER:Current/InCh/Fader/Level 5 0 -2000 set MIXER:Current/InCh/Fader/Level 5 0 -3000 set MIXER:Current/InCh/Fader/Level 5 0 -4000 set MIXER:Current/InCh/Fader/Level 5 0 -5000 set MIXER:Current/InCh/Fader/Level 5 0 -6000