Debian Codegraph @

src/Scripts/Color Organ/color-controller.py

raw symbols SCIP
1 # Demonstarion of Qt integration with csound over CsoundQt python API
2
3 # read cuurent RGB values from Qt color dialog as control values for sound
4 # csound code in "rgb-widgets.csd" must be in the same directory as the python script
5 # Tarmo Johannes [email protected]
6
7 from PythonQt.Qt import *
8
9 def getColors(currentColor): # write the current RGB values as floats 0..1 to according channels of "rgb-widgets.csd"
10 q.setChannelValue("red",currentColor.redF(),csd)
11 q.setChannelValue("green",currentColor.greenF(),csd)
12 q.setChannelValue("blue",currentColor.blueF(),csd)
13
14 # main-----------
15 cdia = QColorDialog() #create QColorDiaog object
16 csd=q.loadDocument("rgb-widgets.csd") # get the index of csd. Returns the index if already open.
17 if ( csd == -1): # report error, if opening failed
18 print("Could not find rgb-widgets.csd. Exiting")
19 exit(-1)
20 q.setDocument(csd)# set focus to the csd
21 cdia.connect(SIGNAL("currentColorChanged(QColor)"),getColors) # create connection between color changes in the dialog window and function getColors
22 cdia.show() # show the dialog window,
23 q.play(csd) # and play the csd
24
25
26
27