2020-05-20 19:33:05 +02:00
|
|
|
from pycaw.pycaw import AudioUtilities
|
|
|
|
from pprint import pprint
|
|
|
|
import serial
|
|
|
|
import serial.tools.list_ports
|
|
|
|
import time
|
|
|
|
|
|
|
|
def main():
|
|
|
|
print ("Starting Arduino Mixer...\n")
|
|
|
|
|
|
|
|
# Get audio sessions
|
|
|
|
sessions = AudioUtilities.GetAllSessions()
|
|
|
|
print (str(len(sessions)) + " audio sessions found:")
|
|
|
|
for session in sessions:
|
|
|
|
volume = session.SimpleAudioVolume
|
|
|
|
print (" " + str(session.Process))
|
|
|
|
|
|
|
|
# Init serial connection
|
|
|
|
ports = serial.tools.list_ports.comports()
|
|
|
|
if len(ports) == 0:
|
|
|
|
print("\nNo Serial ports Available")
|
|
|
|
exit()
|
|
|
|
else:
|
|
|
|
print ("\nSerial ports Available:")
|
|
|
|
for port, desc, hwid in sorted(ports):
|
|
|
|
print(" {}: {} [{}]".format(port, desc, hwid))
|
|
|
|
|
|
|
|
board = serial.Serial()
|
|
|
|
board.baudrate = 115200
|
|
|
|
board.port = input("\nSelect COM port: ")
|
|
|
|
board.open()
|
|
|
|
|
2020-05-20 23:06:03 +02:00
|
|
|
print ("Waiting for arduino...")
|
2020-05-20 19:33:05 +02:00
|
|
|
time.sleep(5)
|
2020-05-20 23:06:03 +02:00
|
|
|
board.write("<HELLO>".encode("utf-8"))
|
|
|
|
board.write("<COUNT,3>".encode("utf-8"))
|
|
|
|
board.write("<GETVOL,50>".encode("utf-8"))
|
|
|
|
board.write("<NAME,Test>".encode("utf-8"))
|
2020-05-20 19:33:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|