# change RPI SOUND # python 2 # kll engineering 12/2014 V0.3 # thanks to help from FORUM # http://www.raspberrypi.org/forums/viewtopic.php?f=32&t=92827 # best start from terminal with: # python /home/pi/kll/python_audio/soundselect3.py # so you see OS result info, what you not see in IDLE import subprocess int_loop = 1 # menu loop def menu(): print ('''select from 0: EXIT 1: HDMI 2: A-Output 3: Default 4: VOLUME ''') return(int(input("Enter choice : "))) def volume(): V = int(input("enter volume as 0 .. 100 : ")) if ( V >= 0 ) and ( V <= 100 ): V = -10240 + V * 106 else : V = -10240 + 5300 # 50% return(V) # main while int_loop == 1: menu_choice = menu() if menu_choice == 1: subprocess.call(['amixer','cset','numid=3','2']) print "HDMI" elif menu_choice == 2: subprocess.call(['amixer','cset','numid=3','1']) print "analog jack" elif menu_choice == 3: subprocess.call(['amixer','cset','numid=3','0']) print "default" elif menu_choice == 4: subprocess.call(['amixer','cset','numid=1','--',str(volume())]) print "volume set, pls. check also from terminal: amixer ( or alsamixer) " elif menu_choice == 0: int_loop = 0 print("Ciao man...") subprocess.call(['aplay','/home/pi/python_games/badswap.wav'])