use function for osc trigger messages
This commit is contained in:
parent
0aa1308908
commit
d8f369fe55
1 changed files with 9 additions and 15 deletions
|
@ -31,8 +31,6 @@ currentScene=-1 #keeps track of current scene
|
|||
timemultiplier=1.0 #current time multiplier for speed changes
|
||||
|
||||
topicScene=['','','','']
|
||||
valueScene=['','','','']
|
||||
valueSceneOff=[0,0,0,0]
|
||||
timemultiplierScene=[1,1,1,1] #only initializiation
|
||||
|
||||
stropheTriggered=False
|
||||
|
@ -82,18 +80,14 @@ def init():
|
|||
|
||||
#Scene 1
|
||||
topicScene[1]="/"+str(midiChannel)+"/oscplayer/strophe"
|
||||
valueScene[1]=1
|
||||
stropheTriggered=False #keep track if it is already triggered once
|
||||
|
||||
#Scene 2
|
||||
topicScene[2]="/"+str(midiChannel)+"/oscplayer/satz/?"
|
||||
valueScene[2]=1
|
||||
|
||||
valueCommulative=0
|
||||
|
||||
#Scene 3
|
||||
topicScene[3]="/"+str(midiChannel)+"/oscplayer/value/?"
|
||||
valueScene[3]=1
|
||||
timemultiplierScene[3]=60.0 / 50 / 2
|
||||
|
||||
#########
|
||||
|
@ -126,10 +120,15 @@ def init():
|
|||
|
||||
minvalues=[min([float(a) for a in x]) for x in filterEmpty(rows)]
|
||||
maxvalues=[max([float(a) for a in x]) for x in filterEmpty(rows)]
|
||||
meanvalues=[np.mean([float(a) for a in x]) for x in filterEmpty(rows)]
|
||||
|
||||
scenetimes[-1]=maxvalues[0] #take maximum value of first column (time) as endtime
|
||||
print("Scenetimes:" + str(scenetimes))
|
||||
|
||||
print("minvalues="+str(minvalues))
|
||||
print("maxvalues="+str(maxvalues))
|
||||
print("meanvalues="+str(meanvalues))
|
||||
|
||||
|
||||
|
||||
#print(np.mean(np.array((filterEmpty(rows))),axis=1)) #TODO: mittelwert ausrechnen funktioniert noch nicht
|
||||
|
@ -210,9 +209,7 @@ def update(ctime):
|
|||
_threshold=(minvalues[i+1]+(maxvalues[i+1]-minvalues[i+1])*0.2)
|
||||
print("waiting for "+str(value)+"<"+str(_threshold))
|
||||
if value<_threshold or getSceneFromTime(timeFromStart+1)!=currentScene: #trigger "randomly" or when scene is about to change
|
||||
print("OSC: "+topicScene[currentScene]+": "+str(valueScene[currentScene]))
|
||||
client.send_message(topicScene[currentScene], valueScene[currentScene])
|
||||
client.send_message(topicScene[currentScene], valueSceneOff[currentScene])
|
||||
sendOSCTrigger(topicScene[currentScene])
|
||||
stropheTriggered=True
|
||||
|
||||
if currentScene==2:
|
||||
|
@ -222,15 +219,12 @@ def update(ctime):
|
|||
if valueCommulative>100:
|
||||
valueCommulative=0 #reset
|
||||
sendvalue=int(mapRangeConstrain(value,minvalues[i+1],maxvalues[i+1],1,4))
|
||||
print("OSC: "+topicScene[currentScene].replace('?',str(sendvalue))+": "+str(valueScene[currentScene]))
|
||||
client.send_message(topicScene[currentScene].replace('?',str(sendvalue)), valueScene[currentScene])
|
||||
client.send_message(topicScene[currentScene].replace('?',str(sendvalue)), valueSceneOff[currentScene])
|
||||
sendOSCTrigger(topicScene[currentScene].replace('?',str(sendvalue)))
|
||||
|
||||
if currentScene==3:
|
||||
sendvalue=int(mapRangeConstrain(value,minvalues[i+1],maxvalues[i+1],1,40))
|
||||
print("OSC: "+str(rowid)+"/"+str(len(rows))+" t="+str(round(timeFromStart,2))+" "+topicScene[currentScene].replace('?',str(sendvalue))+": "+str(valueScene[currentScene]))
|
||||
client.send_message(topicScene[currentScene].replace('?',str(sendvalue)), valueScene[currentScene])
|
||||
client.send_message(topicScene[currentScene].replace('?',str(sendvalue)), valueSceneOff[currentScene])
|
||||
sendOSCTrigger(topicScene[currentScene].replace('?',str(sendvalue)))
|
||||
print("OSC: "+str(rowid)+"/"+str(len(rows))+" t="+str(round(timeFromStart,2)))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue