本文整理汇总了Python中mido.open_output函数的典型用法代码示例。如果您正苦于以下问题:Python open_output函数的具体用法?Python open_output怎么用?Python open_output使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了open_output函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __new__
def __new__(cls, port_name=None):
"""Open a named port."""
if MidiPort.__instance is None:
if port_name is not None:
MidiPort.__instance = mido.open_output(port_name)
else:
MidiPort.__instance = mido.open_output()
return MidiPort.__instance
开发者ID:generalelectrix,项目名称:color_organist,代码行数:8,代码来源:organ.py
示例2: __init__
def __init__(self, input=None, output=None):
if input is None:
try:
input = mido.open_input('Launchpad S', callback=True)
except IOError:
input = mido.open_input('Launchpad S MIDI 1', callback=True)
if output is None:
try:
output = mido.open_output('Launchpad S')
except IOError:
output = mido.open_output('Launchpad S MIDI 1')
super(LaunchpadS, self).__init__(input, output)
开发者ID:RocketScienceAbteilung,项目名称:git-grid,代码行数:13,代码来源:launchpad.py
示例3: __init__
def __init__(self, target=MIDIOUT_DEFAULT):
self.midi = None
self.debug = False
ports = mido.get_output_names()
if len(ports) == 0:
raise Exception("No MIDI output ports found")
for name in ports:
if name == target:
isobar.log("Found MIDI output (%s)" % name)
self.midi = mido.open_output(name)
if self.midi is None:
print "Could not find MIDI target %s, using default" % target
self.midi = mido.open_output()
开发者ID:RocketScienceAbteilung,项目名称:isobar,代码行数:15,代码来源:midi.py
示例4: __init__
def __init__(self, input_midi_port, output_midi_port, texture_type,
passthrough=True):
self._texture_type = texture_type
self._passthrough = passthrough
# When `passthrough` is True, this is the set of open MIDI note pitches.
self._open_notes = set()
# This lock is used by the serialized decorator.
self._lock = threading.RLock()
# A dictionary mapping a string-formatted mido.Messages to a condition
# variable that will be notified when a matching messsage is received,
# ignoring the time field.
self._signals = {}
# A dictionary mapping integer control numbers to most recently-received
# integer value.
self._control_values = {}
# Threads actively being used to capture incoming messages.
self._captors = []
# Potentially active player threads.
self._players = []
self._metronome = None
# Open MIDI ports.
self._inport = (
input_midi_port if isinstance(input_midi_port, mido.ports.BaseInput)
else mido.open_input(
input_midi_port,
virtual=input_midi_port not in get_available_input_ports()))
self._outport = (
output_midi_port if isinstance(output_midi_port, mido.ports.BaseOutput)
else mido.open_output(
output_midi_port,
virtual=output_midi_port not in get_available_output_ports()))
# Start processing incoming messages.
self._inport.callback = self._timestamp_and_handle_message
开发者ID:danabo,项目名称:magenta,代码行数:35,代码来源:midi_hub.py
示例5: Run
def Run(fi, minnote=21, maxnote=108, forcelowest=False, minvelocity=64, maxvelocity=115, timingdivisor=127, shortestnoteon=0.00390625, step=3, mono=True, microgranny=True, sendCC=True, sendsamplechange=True, loop=False):
if minnote < 0:
print("Negative minimum note")
minnote = 0
if maxnote >127:
print("Maximum note too high")
maxnote = 127
if maxnote < minnote or minnote > maxnote:
print("Maxnote and minnote swapped")
hold = maxnote
maxnote = minnote
minnote = hold
##open file as a byte array
with open(fi, "rb") as inFile:
f = inFile.read()
b = bytearray(f)
##send midi
with mido.open_output() as o:
if(loop):
while True:
print("looping")
Play(o, b,minnote,maxnote, forcelowest, minvelocity, maxvelocity, timingdivisor,shortestnoteon,step,mono,microgranny,sendCC,sendsamplechange)
else:
Play(o, b,minnote,maxnote,forcelowest, minvelocity, maxvelocity,timingdivisor,shortestnoteon,step,mono,microgranny,sendCC,sendsamplechange)
开发者ID:inkrh,项目名称:Utilities,代码行数:30,代码来源:FileToMidi.py
示例6: Run
def Run():
global mt
global nvalue
global pnvalue
with mido.open_output(autoreset = True) as o:
with mido.open_input() as i:
while True:
for message in i:
if message.type == 'control_change':## and not message.control == 13:
print("in : " + str(message))
Translate(message,o)
if 'note' in mt:
if not pnvalue == nvalue:
mo = mido.Message(mt,note = nvalue, velocity = 100)
print("out : " + str(mo))
o.send(mo)
pnvalue = nvalue
##microgranny tends not to respond to off or time, or anything it doesn't like
if 'off'in mt:
mt = ''
o.send(mido.Message('note_off',note = pnvalue))
o.send(mido.Message('note_off',note=nvalue))
print("out : note_off")
o.reset()
o.panic()
ManualPanic(o)
开发者ID:inkrh,项目名称:Utilities,代码行数:28,代码来源:KaossilatorToMidiNote.py
示例7: open_output
def open_output(self):
if self.backend == 'mido':
if self.debug>0:
print('------ OUTPUT ------')
for port in mido.get_output_names():
print(port)
print('-------------------------')
try:
self.outputport = mido.open_output(self.config.get('midi', 'device'))
print "Connected to MIDI output"
except:
print "Error: cannot connect to MIDI output"
raise RuntimeError("Error: cannot connect to MIDI output")
elif self.backend == 'midiosc':
try:
self.outputport = OSC.OSCClient()
self.outputport.connect((self.config.get('midi','hostname'), self.config.getint('midi','port')))
print "Connected to OSC server"
except:
print "Error: cannot connect to OSC server"
raise RuntimeErrror("cannot connect to OSC server")
else:
print 'Error: unsupported backend: ' + self.backend
raise RuntimeError('unsupported backend: ' + self.backend)
开发者ID:neuroidss,项目名称:eegsynth,代码行数:26,代码来源:EEGsynth.py
示例8: main
def main():
output_name = ''
input_name = ''
device_names = mido.get_input_names()
for device_name in device_names:
# FIXME: Heuristic to get our USB stick device
if '-' in device_name and 'Through' not in device_name:
output_name = device_name
break
else:
print "No appropriate MIDI device. MIDI device names: ", device_names
return
print "Connected devices: ", device_names
print "Opening device: ", output_name
# or, with mido.open_ioport(output_name) as iop:
with mido.open_output(output_name) as output:
with mido.open_input(output_name, callback=print_message) as inp:
#msg = mido.Message('sysex', data=[10]) Set type to digital output
#msg = mido.Message('sysex', data=[101]) # send watchdog timer reset
#msg = mido.Message('sysex', data=[99]) # Request device type
msg = mido.Message('sysex', data=[77]) # Request device name
#msg = mido.Message('sysex', data=[54,1,2,3,4]) # Set device name to '0x010203'
#msg = mido.Message('note_on')
print "sending msg: ", msg
output.send(msg);
print "waiting for response message"
time.sleep(1) # Pause while we get MIDO callback print-outs
print "script done"
开发者ID:grassyhilltop,项目名称:blocktopus,代码行数:30,代码来源:midi_msg.py
示例9: __init__
def __init__(self, _save_path, songfile, _plyr_ctrls):
super(PlayerThread, self).__init__()
self.name = 'Player'
self.stoprequest = threading.Event()
self.plyr_ctrls = _plyr_ctrls
self.chan_roles = [0 for i in range(10)]
self.plyr_ctrls['songfile'] = songfile
self.midifile = MidiFile(_save_path + songfile)
# 0 - drum fill
self.counter = [0 for i in range(4)]
self.wt = WolfTonesSong()
self.save_path = _save_path
self.load_song(songfile)
self.alt_meas = []
#get the portname (system specific)
env = socket.gethostname()
if(env == 'record_synth'):
names = str(mido.get_output_names())
ports = names.split(',')
sobj = re.search(r'Synth input port \(\d*:0\)', ports[0], flags=0)
portname = sobj.group()
if(env == 'colinsullivan.me'):
#dummy port for testing on a headless server with no audio
portname = 'Midi Through:Midi Through Port-0 14:0'
self.outport = mido.open_output(portname, autoreset=True)
开发者ID:csully220,项目名称:rcrd_synth,代码行数:26,代码来源:player.py
示例10: __init__
def __init__(self, loop, scale, bpm=120, midi_port=u"TiMidity port 0", midi_chan=1):
self.loop = loop
self.scale = scale
self.bpm = 60 / bpm
self.start = True
# initialize midi output
self.midi_output = mido.open_output(midi_port)
self.midi_output.send(mido.Message("program_change", program=midi_chan))
开发者ID:rgarcia-herrera,项目名称:RiboSonic,代码行数:9,代码来源:__init__.py
示例11: __init__
def __init__(self, input_midi_port, output_midi_port):
self._inport = mido.open_input(input_midi_port)
self._outport = mido.open_output(output_midi_port)
# This lock is used by the serialized decorator.
self._lock = threading.RLock()
self._control_cvs = dict()
self._player = None
self._capture_start_time = None
self._sequence_start_time = None
开发者ID:ml-lab,项目名称:magenta,代码行数:9,代码来源:midi.py
示例12: __init__
def __init__(self):
QtGui.QWidget.__init__(self)
try:
self.output = mido.open_output(self.outputPort)
except IOError:
print ("sorry; couldn't setup MIDI player")
print ("perhapsoverruling outputPort (currently {0} will help".format(self.outputPort))
self.output = None
dbg_print('MidiPlayer:__init__', self.output)
开发者ID:papahippo,项目名称:abcraft,代码行数:9,代码来源:midiplayer.py
示例13: __init__
def __init__(self, input=None, output=None):
if input is None:
try:
input = mido.open_input(
'Ableton Push User Port',
callback=True)
except IOError:
input = mido.open_input('Ableton Push MIDI 2', callback=True)
if output is None:
try:
output = mido.open_output('Ableton Push User Port')
except IOError:
output = mido.open_output('Ableton Push MIDI 2')
self.lights = lights((8, 8))
self.buttons = buttons((8, 8))
super(Push, self).__init__(input, output)
开发者ID:RocketScienceAbteilung,项目名称:git-grid,代码行数:18,代码来源:push.py
示例14: __init__
def __init__(self, daemonize=False, buflen=80):
self.scrollwheel = 0
self.buflen = buflen
self.lines = collections.deque([''] * self.buflen)
self.lock = threading.Lock()
try:
# Ports on MAC OSX
self.output = mido.open_output('Ableton Push User Port')
self.input = mido.open_input('Ableton Push User Port',
callback=self.callback)
except IOError:
# Ports on Arch Linux
self.output = mido.open_output('Ableton Push MIDI 2')
self.input = mido.open_input('Ableton Push MIDI 2',
callback=self.callback)
while True:
line = sys.stdin.readline()
if not line:
# EOF from STDIN
break
# We need to use mutex because concurrent reads and writes on
# dequeue (scrolling while there is new text coming in from stdin)
# will issue warnings.
self.lock.acquire()
self.lines.append(line)
self.lines.popleft()
self.lock.release()
self.redraw()
# Do not quit process if running daemonized
# This enables scrolling for one-show piping to Push
#
# e.g. ping www.google.de | pushcat is scrollable as long as ping runs
# ls | pushcat is not scrollable as ls immediately terminates
# ls | pushcat -d enables scrolling
if daemonize:
while True:
try:
time.sleep(0.1)
except KeyboardInterrupt:
sys.exit(0)
开发者ID:RocketScienceAbteilung,项目名称:git-grid,代码行数:44,代码来源:__init__.py
示例15: say
def say(message, times = 1):
message = message + " "
with mido.open_output(CONTROLLER) as output:
print("saying \"{}\"".format(message))
delay = lambda: sleep(0.25)
for i in range(0,times):
for frame in text_to_bitmap(message):
send_lights_to_output(frame, output)
delay()
delay()
开发者ID:MrTomWhite,项目名称:literal-dj-sona,代码行数:10,代码来源:lighter.py
示例16: open_pair
def open_pair(input, output):
if not isinstance(input, mido.ports.BaseInput):
state.inp = mido.open_input([i for i in mido.get_input_names() if i.lower().startswith(input.lower())][0])
else:
state.inp = input
if not isinstance(output, mido.ports.BaseOutput):
state.out = mido.open_output([i for i in mido.get_output_names() if i.lower().startswith(output.lower())][0])
else: state.out = output
setup_threads()
state.metronome = Metronome()
开发者ID:fwilson42,项目名称:mt2,代码行数:10,代码来源:mt2.py
示例17: __init__
def __init__(self, turtle, devname, cb=False):
self.turtle = turtle
if cb:
self.midi_in = mido.open_input(devname, callback=self.midi_callback)
else:
self.midi_in = mido.open_input(devname)
self.midi_out = mido.open_output(devname)
self.rgb = True
self.size = 1
self._update_rgb_indicator()
开发者ID:micolous,项目名称:mixtrack-hacks,代码行数:10,代码来源:etch-a-sketch.py
示例18: __init__
def __init__(self, input_midi_ports, output_midi_ports, texture_type,
passthrough=True, playback_channel=0, playback_offset=0.0):
self._texture_type = texture_type
self._passthrough = passthrough
self._playback_channel = playback_channel
self._playback_offset = playback_offset
# When `passthrough` is True, this is the set of open MIDI note pitches.
self._open_notes = set()
# This lock is used by the serialized decorator.
self._lock = threading.RLock()
# A dictionary mapping a compiled MidiSignal regex to a condition variable
# that will be notified when a matching messsage is received.
self._signals = {}
# A dictionary mapping a compiled MidiSignal regex to a list of functions
# that will be called with the triggering message in individual threads when
# a matching message is received.
self._callbacks = collections.defaultdict(list)
# A dictionary mapping integer control numbers to most recently-received
# integer value.
self._control_values = {}
# Threads actively being used to capture incoming messages.
self._captors = []
# Potentially active player threads.
self._players = []
self._metronome = None
# Open MIDI ports.
if input_midi_ports:
for port in input_midi_ports:
if isinstance(port, mido.ports.BaseInput):
inport = port
else:
virtual = port not in get_available_input_ports()
if virtual:
tf.logging.info(
"Opening '%s' as a virtual MIDI port for input.", port)
inport = mido.open_input(port, virtual=virtual)
# Start processing incoming messages.
inport.callback = self._timestamp_and_handle_message
else:
tf.logging.warn('No input port specified. Capture disabled.')
self._inport = None
outports = []
for port in output_midi_ports:
if isinstance(port, mido.ports.BaseInput):
outports.append(port)
else:
virtual = port not in get_available_output_ports()
if virtual:
tf.logging.info(
"Opening '%s' as a virtual MIDI port for output.", port)
outports.append(mido.open_output(port, virtual=virtual))
self._outport = mido.ports.MultiPort(outports)
开发者ID:cghawthorne,项目名称:magenta,代码行数:55,代码来源:midi_hub.py
示例19: main
def main():
with open('a.csv','r') as csvfile:
reader=csv.reader(csvfile)
flag=0
c=0.0
t0=0
next(reader)
next(reader)
tmp=[(float(x),float(y)) for x,y,z1,z2,z3 in reader]
timelist,pitchlist=zip(*tmp)
a=69
with mido.open_output('LoopBe Internal MIDI') as mid:
#track=mido.midifiles.MidiTrack()
#mid.tracks.append(track)
mid.send(mido.Message('program_change',program=53,time=0.0))
#pitchlist=butter_lowpass_filter(pitchlist,5,50,5)
#filtered = scipy.signal.medfilt
#pitchlist=butter_lowpass_filter(pitchlist,5,100,1)
#pitchlist=butter_lowpass_filter(pitchlist,5,100,3)
#if 0:
for row in list(zip(timelist,pitchlist))[3:-15]:
row=list(row)
#print(row)
b=pitch(float(row[1]))
if b>100: continue
if not sticky(b,float(row[1]),a,0.8):
if flag:
sleep((float(row[0])-t0)/10)
mid.send(mido.Message('note_off',note=round(a,0),
time=float(row[0])-t0))
else:
t0=float(row[0])
flag=1
t0=float(row[0])
#last_state=(2**((round(b,0)-69)/120)*440)
print(row[0],int(round(a,0)),int(round(b,0)))
a=round(b,0)
mid.send(mido.Message('note_on',note=round(b),
time=float(row[0])-t0))
#timelist.append(float(row[0])-t0)
#pitchlist.append(float(row[1]))
#plt.plot(timelist,pitchlist)
threshold = 0.5
timelist=np.asarray(timelist[30:])
pitchlist=np.asarray(pitchlist[30:])
#deltas = periods(timelist, pitchlist, threshold)
#print(timelist,pitchlist,deltas)
plt.plot(timelist,pitchlist)
#trans_times = butter_lowpass_filter(pitchlist,5,100,3)
#print(trans_times)
#plt.plot(timelist,trans_times,'r')
#plt.plot(trans_times, threshold * np.ones_like(trans_times))
plt.show()
开发者ID:tamyiuchau,项目名称:Miku-Miku-Sing,代码行数:54,代码来源:midi_v3.py
示例20: _sendMidi
def _sendMidi(note, velocity, length, device):
velocity = int(round(velocity * 127))
note = int(note)
dsp.log(device)
out = mido.open_output(device)
msg = mido.Message('note_on', note=note, velocity=velocity)
out.send(msg)
dsp.delay(length)
msg = mido.Message('note_off', note=note, velocity=0)
out.send(msg)
开发者ID:bensteinberg,项目名称:pippi,代码行数:12,代码来源:io.py
注:本文中的mido.open_output函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论