本文整理汇总了Python中mapper.device函数的典型用法代码示例。如果您正苦于以下问题:Python device函数的具体用法?Python device怎么用?Python device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了device函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: deviceLoop
def deviceLoop():
inputidx = {}
outputsigs = {}
args = []
got_new_values = [False]
def h(sig, f):
if inputidx.has_key(sig.name):
args[inputidx[sig.name]] = f
got_new_values[0] = True
dev = mapper.device("functionMapper", 9000)
inplist = set([])
outlist = set([])
while not done:
dev.poll(10)
if got_new_values[0]:
got_new_values[0] = False
try:
result = processfunc[0](*args)
if result.__class__ == int or result.__class__ == float:
outs = {'output00': result}
elif result.__class__ == list:
outs = dict([('output%02d'%i,x)
for i,x in enumrate(result)])
elif result.__class__ == dict:
outs = result
else:
outs = {}
for o in outs:
outputsigs[o].update(result[o])
except Exception, e:
print e
while not que.empty():
newinplist, newoutlist = que.get()
diff = set(newinplist).difference(inplist)
inplist.update(newinplist)
for n,i in enumerate(newinplist):
inputidx['/'+i] = n
for i in diff:
dev.add_input('/'+i, 1, 'f', None, None, None, h)
while len(args) < len(inplist):
args.append(0)
diff = set(newoutlist).difference(outlist)
outlist.update(newoutlist)
for o in diff:
outputsigs[o] = dev.add_output('/'+o, 1, 'f', None, None, None)
开发者ID:radarsat1,项目名称:libmapper-contrib,代码行数:49,代码来源:functionMapper.py
示例2: __init__
def __init__(self, hostip, myport, myip, myname, swarmSize, serialPort, serialRate, config, idrange, verbose, apiMode, ignoreUnknown = False, checkXbeeError = False ):
self.device = mapper.device("hive", 9000)
self.output_signals = []
self.hive = pydonhive.MiniHive( serialPort, serialRate, apiMode,
poll = lambda: self.device.poll(5) )
self.hive.set_id_range( idrange[0], idrange[1] )
self.hive.load_from_file( config )
self.hive.set_verbose( verbose )
self.hive.set_ignore_unknown( ignoreUnknown )
self.hive.set_check_xbee_error( checkXbeeError )
self.hive.set_newBeeAction( self.hookBeeToMapper )
self.labelbase = "minibee"
开发者ID:sensestage,项目名称:ssdn_python,代码行数:16,代码来源:lmpydonhive.py
示例3: __init__
def __init__(self, parent, title, size, colour="#DDDDE7"):
wx.Frame.__init__(self, parent, -1, title=title, size=size)
sizer = wx.BoxSizer(wx.VERTICAL)
self.dev = mapper.device("test")
pos_y = 20 # y position for labels & slides
s_label = 0 # integer which will generate incremented labels
signal_id = 0 # this will be used to set the proper mapper signal
#TODO: generate list of outputs and get their 'real' names to create the labels - duhhh
for i in range(10): # generating lables & slides list
self.slider = MyControlSlider(self, -1000, 1000, 0, pos=(45, pos_y), backColour=colour, signal_id=signal_id)
sizer.Add(wx.StaticText(self, -1, str(s_label)+".", pos =(20, pos_y)), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
s_label += 1
pos_y += 25
signal_id += 1
# mapper poll
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnTimer)
self.timer.Start(milliseconds=10, oneShot=False)
开发者ID:tiagovaz,项目名称:pyMapperGUI,代码行数:21,代码来源:test.py
示例4: __init__
def __init__(self):
#flags for program learning states
self.learning = 0
self.compute = 0
self.recurrent_flag = False; # default case is a nonrecurrent feedforward network
#number of mapper inputs and outputs
self.num_inputs = 0
self.num_outputs = 0
self.num_hidden = 0
#For the Mapper Signals
self.l_inputs = {}
self.l_outputs = {}
#For the Artificial Neural Network
self.data_input = {}
self.data_output = {}
self.learnMapperDevice = mapper.device("Implicit_LearnMapper",9002)
开发者ID:mghamsar,项目名称:PyImp,代码行数:21,代码来源:learn_gest_withInterface.py
示例5: OnMenu
def OnMenu(self, event):
objId = event.Id
if objId == 100:
self.videoEngine.quit()
self.mediagrid.Close()
if self.previewMenu.IsChecked() : self.preview.Quit()
if self.libmapper.IsChecked(): self.timer.Stop()
self.frame.Close()
if objId == 101 :
if self.secondScreen is not None:
if str(platform.system()) == "Linux":
w,h = self.secondScreen
self.videoEngine.setOutputFullscreen(w,h)
command = 'wmctrl -r "pantaliQa-output" -e 1,'+str(self.firstScreen[0])+',0,'+str(self.secondScreen[0])+','+str(self.secondScreen[1])+''
command = os.getcwd()+"/libs/scripts/move.sh "
command += str(self.firstScreen[0])+" "
command += str(self.secondScreen[0])+" "
command += str(self.secondScreen[1])
sleep(0.3)
os.system(command)
for e in range(0, len(self.layers)):
self.videoEngine.setFullscreen(e+1)
else:
print "no linux"
if objId == 102 :
if self.libmapper.IsChecked():
print "importing libmapper"
try:
import mapper
self.dev = mapper.device("pantaliQa")
self.ActivateSignals()
self.timer = wx.Timer(self, id=1)
self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
self.timer.Start(milliseconds=500, oneShot=False)
print "lib mapper is running"
except Exception, e:
print e
开发者ID:husk00,项目名称:pantaliQa,代码行数:38,代码来源:pantaliQa.py
示例6: Server
from pyo import *
import mapper
s = Server(audio="jack", sr=44100, buffersize=512).boot()
osc_bundle = ['/om1/x',
'/om1/y',
'/om1/z',
'/om2/x',
'/om2/y',
'/om2/z']
s.start()
om1_dev = mapper.device("om")
om2_dev = mapper.device("om")
om1_x = om1_dev.add_output("/x", 1, 'f', None, -1000, 1000)
om1_y = om1_dev.add_output("/y", 1, 'f', None, -1000, 1000)
om1_z = om1_dev.add_output("/z", 1, 'f', None, -1000, 1000)
om2_x = om2_dev.add_output("/x", 1, 'f', None, -1000, 1000)
om2_y = om2_dev.add_output("/y", 1, 'f', None, -1000, 1000)
om2_z = om2_dev.add_output("/z", 1, 'f', None, -1000, 1000)
def osc_handler(address, args):
if address == '/om1/x':
print args
om1_x.update(args)
elif address == '/om1/y':
开发者ID:tiagovaz,项目名称:pyMapperGUI,代码行数:30,代码来源:mapper_output.py
示例7: h
#!/usr/bin/env python
import sys, mapper
def h(sig, id, f, timetag):
try:
print 'received query response:', f
except:
print 'exception'
print sig, f
src = mapper.device("src", 9000)
outsig = src.add_output("/outsig", 1, 'f', None, 0, 1000)
outsig.set_query_callback(h)
dest = mapper.device("dest", 9000)
insig = dest.add_input("/insig", 1, 'f', None, 0, 1)
while not src.ready() or not dest.ready():
src.poll()
dest.poll(10)
monitor = mapper.monitor()
monitor.link('%s' %src.name, '%s' %dest.name)
monitor.connect('%s%s' %(src.name, outsig.name),
'%s%s' %(dest.name, insig.name),
{'mode': mapper.MO_LINEAR})
for i in range(100):
insig.update(i)
开发者ID:sofian,项目名称:libmapper,代码行数:31,代码来源:testquery.py
示例8: Server
from pyo import *
import mapper
from random import uniform
import time
s = Server(audio='jack').boot()
s.start()
a = BrownNoise()
b = Biquadx(a, freq=[200, 400, 800, 1600, 3200, 6400], q=10, type=2).out()
def freq_handler(sig, id, val, timetag):
try:
b.setFreq( val )
except:
print 'exception'
print sig, val
def setup(d):
dev_input = dev.add_input( "/Q", 1, "f", None, 1, 5, lambda s, i, f, t: b.setQ(f) )
dev_input = dev.add_input( "/pitch", 1, "f", None, 20, 15000, freq_handler )
dev = mapper.device("biquad")
setup(dev)
while 1:
dev.poll(10)
开发者ID:tiagovaz,项目名称:pyMapperGUI,代码行数:28,代码来源:test2.py
示例9: setup
print 'signal full name',sig.full_name
print 'signal is_output',sig.is_output
print 'signal length',sig.length
print 'signal type', sig.type
print 'signal is_output', sig.is_output
print 'signal unit', sig.unit
dev.set_properties({"testInt":5, "testFloat":12.7, "testString":"test",
'removed1':"shouldn't see this"})
dev.properties['testInt'] = 7
dev.set_properties({"removed1":None, "removed2":"test"})
dev.remove_property("removed2")
print 'signal properties:', sig.properties
sig.properties['testInt'] = 3
print 'signal properties:', sig.properties
dev = mapper.device("test", 9000)
setup(dev)
def db_cb(rectype, record, action):
print rectype,'callback -'
print ' record:',record
print ' action:',["MODIFY","NEW","REMOVE"][action]
mon = mapper.monitor()
mon.db.add_device_callback(lambda x,y:db_cb('device',x,y))
mon.db.add_signal_callback(lambda x,y:db_cb('signal',x,y))
mon.db.add_connection_callback(lambda x,y:db_cb('connection',x,y))
l = lambda x,y:db_cb('link',x,y)
mon.db.add_link_callback(l)
mon.db.remove_link_callback(l)
开发者ID:gautamb85,项目名称:libmapper,代码行数:31,代码来源:test.py
示例10: on_gui_change
#!/usr/bin/env python
import Tkinter
import sys
import mapper
def on_gui_change(x):
sig_out.update(int(x))
def on_mapper_change(sig, id, x, timetag):
w.set(int(x))
dev = mapper.device("tkgui", 9000)
sig_in = dev.add_input("/signal0", 1, 'i', None, 0, 100, on_mapper_change)
sig_out = dev.add_output("/signal0", 1, 'i', None, 0, 100)
master = Tkinter.Tk()
master.title("libmapper Python GUI demo")
name = Tkinter.StringVar()
name.set("Waiting for device name...")
name_known = False
label = Tkinter.Label(master, textvariable=name)
label.pack()
w = Tkinter.Scale(master, from_=0, to=100, label='signal0',
orient=Tkinter.HORIZONTAL, length=300,
command=on_gui_change)
w.pack()
开发者ID:EQ4,项目名称:libmapper,代码行数:30,代码来源:tkgui.py
示例11: Server
from pyo import *
import mapper
synth = Server().boot().start()
dev = mapper.device("synthesizer")
snd = SndTable("/Users/lyang/libmapper/cyborg/sound.wav")
env = HannTable()
g = Granulator(snd, env, pitch=1, pos=0, dur=1, grains=24, mul=.5).out()
e = Adsr(attack=2, decay=0, sustain=1, release=2, mul=.1)
e_playing = False
noise = PinkNoise(mul=e).mix(2).out()
def noise_handler(sig, id, val, timetag):
global e_playing
if val == 1 and not e_playing:
e.play()
e_playing = True
elif val == 0 and e_playing:
e.stop()
e_playing = False
def size_handler(sig, id, val, timetag):
g.setDur(val / 1000.0)
def pitch_handler(sig, id, val, timetag):
g.setPitch(val)
def pos_handler(sig, id, val, timetag):
g.setPos(val)
dev.add_input( '/noise_on', 1, 'i', None, 0, 1, noise_handler)
dev.add_input('/grain_size', 1, 'f', 'ms', 50, 700, size_handler)
开发者ID:lingxiaoyang,项目名称:cyborg-mapping,代码行数:31,代码来源:synthesis.py
示例12: on_gui_change
#!/usr/bin/env python
import Tkinter
import sys
import mapper
def on_gui_change(x):
sig_out.update(int(x))
def on_mapper_change(sig, id, x, timetag):
w.set(int(x))
dev = mapper.device("tkgui")
sig_in = dev.add_input_signal("signal", 1, 'i', None, 0, 100, on_mapper_change)
sig_out = dev.add_output_signal("signal", 1, 'i', None, 0, 100)
master = Tkinter.Tk()
master.title("libmapper Python GUI demo")
name = Tkinter.StringVar()
name.set("Waiting for device name...")
name_known = False
label = Tkinter.Label(master, textvariable=name)
label.pack()
w = Tkinter.Scale(master, from_=0, to=100, label='signal0',
orient=Tkinter.HORIZONTAL, length=300,
command=on_gui_change)
w.pack()
开发者ID:IDMIL,项目名称:libmapper,代码行数:30,代码来源:tkgui.py
示例13: DarkAtmosphere
dark1 = DarkAtmosphere()
dark2 = DarkAtmosphere()
dark3 = DarkAtmosphere()
dark4 = DarkAtmosphere()
wind = Wind(.5)
myfm = MyFM()
dark1.out()
dark2.out()
dark3.out()
dark4.out()
wind.out()
myfm.out()
dev1 = mapper.device("Dark")
dev2 = mapper.device("Dark")
dev3 = mapper.device("Dark")
dev4 = mapper.device("Dark")
# dev input 1
dev1.add_input( "/pitch1", 1, "f", "Hz", 0, 1, lambda s, i, f, t: dark1.setPitch(f, f*1.01) )
dev1.add_input( "/pitch2", 1, "f", "Hz", 0, 1, lambda s, i, f, t: dark1.setPitch(f, f*1.10) )
dev2.add_input( "/pitch1", 1, "f", "Hz", 0, 1, lambda s, i, f, t: dark2.setPitch(f, f*1.01) )
dev2.add_input( "/pitch2", 1, "f", "Hz", 0, 1, lambda s, i, f, t: dark2.setPitch(f, f*1.10) )
dev3.add_input( "/pitch1", 1, "f", "Hz", 0, 1, lambda s, i, f, t: dark3.setPitch(f, f*1.01) )
dev3.add_input( "/pitch2", 1, "f", "Hz", 0, 1, lambda s, i, f, t: dark3.setPitch(f, f*1.10) )
dev4.add_input( "/pitch1", 1, "f", "Hz", 0, 1, lambda s, i, f, t: dark4.setPitch(f, f*1.01) )
开发者ID:tiagovaz,项目名称:pyMapperGUI,代码行数:30,代码来源:mapper_input.py
示例14: int
#!/usr/bin/env python
import Tkinter, sys, math, mapper
N = int(sys.argv[1])
values = [0.5]*N
def on_sig(n,v):
values[n] = v
redraw()
dev = mapper.device("octovisualiser")
sigs = [dev.add_input_signal("arm.%d"%n, 1, 'f',
None, 0.0, 1.0,
(lambda n: lambda s,i,f,t: on_sig(n,f))(n))
for n in range(N)]
root = Tkinter.Tk()
canvas = Tkinter.Canvas(root, width=400, height=400)
canvas.pack()
def redraw():
canvas.delete("all")
radius = 150
for n in range(N):
canvas.create_line(200, 200,
200 + math.cos(float(n)/N*2*math.pi)*radius,
200 + math.sin(float(n)/N*2*math.pi)*radius,
smooth=1)
poly = []
开发者ID:IDMIL,项目名称:libmapper-contrib,代码行数:31,代码来源:octovisualiser.py
示例15: stream_block_processor
#!/usr/bin/env python
from pylab import *
from data import gestures_idmil_230811
import operations.display
import operations.classifier
import features.basic
import features.blockbased
from minibee import Minibee
import serial
dev = None
try:
import mapper
dev = mapper.device("minibee",9000)
sig_centroid = dev.add_output("/centroid", 'f')
sig_slope = dev.add_output("/slope", 'f')
except:
print 'Continuing without libmapper support.'
def stream_block_processor(t,a):
"""Break up an incoming stream into 1024-sized blocks. Add 16
extra samples to make the block-based analysis pull out a single
block properly."""
times = zeros(1024+16)
accels = zeros((1024+16,3))
pos = 0
while True:
try:
times[pos] = t
accels[pos] = a
开发者ID:radarsat1,项目名称:emergeData,代码行数:31,代码来源:realtime.py
示例16: freq_handler
import mapper
def freq_handler(sig, id, val, timetag):
pass
def setup(d):
dev_input = dev.add_input( "/Q", 1, "f", None, 1, 500, lambda s, i, f, t: freq_handler )
dev_input = dev.add_input( "/pitch", 1, "f", None, 20, 15000, freq_handler )
dev_output = dev.add_output( "/x", 1, "f", None, 20, 15000)
dev_output = dev.add_output( "/y", 1, "f", None, 20, 15000)
dev = mapper.device("device")
setup(dev)
while 1:
dev.poll(10)
开发者ID:tiagovaz,项目名称:pyMapperGUI,代码行数:16,代码来源:in_out.py
示例17: Queue
#Open Serial Port to Read Data
if OS == 'nt':
port_list = [14-1,5-1]
elif OS == 'posix':
import sys
sys.path.append("/Users/mahtab-ghamsari/Projects/Mappings/pyserial-2.5/")
port_list=['/dev/tty.usbserial-A8004lV1','/dev/tty.usbserial-AD004lUY']
from fungible_board_class import Fungible_Node
print Fungible_Node
still_alive=1
#root.after(5, ontimer)
#root.mainloop()
m_inst= mapper.device("Fungible1", 9000)
b_array={}
b_num=0
b_list=[0,1]
open_list=[]
for b_num in port_list:
try:
b_array[b_num]=Fungible_Node(b_num,115200,0.3,m_inst)
open_list.append(b_num)
except:
raise
try:
q = Queue()
print q
开发者ID:abactor,项目名称:Ballagumi-Code,代码行数:31,代码来源:test_class_working.py
示例18: h
#!/usr/bin/env python
from __future__ import print_function
import sys, mapper, random
def h(sig, id, val, timetag):
print(' handler got', sig.name, '=', val, 'at time', timetag.get_double())
srcs = [mapper.device("src"), mapper.device("src")]
outsigs = [srcs[0].add_output_signal("outsig", 1, 'i'),
srcs[1].add_output_signal("outsig", 1, 'i')]
dest = mapper.device("dest")
insig = dest.add_input_signal("insig", 1, 'f', None, None, None, h)
while not srcs[0].ready or not srcs[1].ready or not dest.ready:
srcs[0].poll(10)
srcs[1].poll(10)
dest.poll(10)
map = mapper.map(outsigs, insig)
if not map:
print('error: map not created')
else:
map.mode = mapper.MODE_EXPRESSION
map.expression = "y=x0+x1"
map.push()
while not map.ready:
srcs[0].poll(10)
srcs[1].poll(10)
开发者ID:johnty,项目名称:libmapper,代码行数:31,代码来源:testconvergent.py
示例19: elif
elif (len(sys.argv)>1):
print ("Bad Input Arguments (#inputs, #hidden nodes, #outputs)")
sys.exit(1)
else:
#number of network inputs
num_inputs=8
#number of network outputs
num_outputs=8
#number of hidden nodes
num_hidden=5
print ("No Input Arguments (#inputs, #hidden nodes, #outputs), defaulting to: " + str(num_inputs) + ", " + str(num_hidden) + ", " + str(num_outputs) )
#instatiate mapper
l_map=mapper.device("learn_mapper",9000)
l_inputs={}
l_outputs={}
l_outputs_derrivatives={}
data_input={}
data_output={}
learning = 0
compute = 0
for s_index in range(num_inputs):
data_input[s_index+10]=0.0
# data_input[s_index]=0.0
for s_index in range (num_outputs):
data_output[s_index]=0.0
开发者ID:IDMIL,项目名称:PyImp,代码行数:31,代码来源:learn_gest_withdelta(d)outputs.py
示例20:
import pygame
import mapper
pygame.joystick.init()
pygame.display.init() # stupid but must init display
j = pygame.joystick.Joystick(0)
j.init()
dev = mapper.device('joystick')
sig_button = dev.add_output('/button', 1, 'i', None, 0, 1)
sig_x = dev.add_output('/x', 1, 'f', None, -1, 1)
sig_y = dev.add_output('/y', 1, 'f', None, -1, 1)
sig_yaw = dev.add_output('/yaw', 1, 'f', None, -1, 1)
sig_pitch = dev.add_output('/pitch', 1, 'f', None, -1, 1)
while True:
dev.poll(50)
pygame.event.get()
sig_button.update(j.get_button(2))
sig_x.update(j.get_axis(0))
sig_y.update(j.get_axis(1))
sig_yaw.update(j.get_axis(2))
sig_pitch.update(j.get_axis(3))
开发者ID:lingxiaoyang,项目名称:cyborg-mapping,代码行数:23,代码来源:joystick.py
注:本文中的mapper.device函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论