コード例 #1
0
ファイル: tracks.py プロジェクト: ppaez/alsaseq
def parsecommand():
    "Read on letter from stdin."
    global ritmos, nritmo, tempo, split, waitingforsplit
    global voz1, voz2, pgmchangevoz1, pgmchangevoz2
    if not playing:
        if letra == "p":
            playback()
        elif letra == "o":
            seq.read(ruta)
            print("read", ruta)
        elif letra == "s":
            seq.write(ruta)
            print("saved", ruta)
        elif letra == "t":
            enabledisabletracks()
        elif letra == "k":
            print("hit keyboard split point:", end=" ")
            waitingforsplit = 1
        elif letra == "v":
            voz1 = int(input())
            pgmchangevoz1 = alsamidi.pgmchangeevent(0, voz1)
            alsaseq.output(pgmchangevoz1)
            print("voice 1:", voz1)
        elif letra == "b":
            voz2 = int(input())
            pgmchangevoz2 = alsamidi.pgmchangeevent(1, voz2)
            if voz2:
                alsaseq.output(pgmchangevoz2)
            print("voice 2:", voz2)
    else:
        if letra == "p":
            stop()
        elif letra == "r":
            ritmos = pista.lee("main.pat")
            for i, x in enumerate(ritmos):
                print("{:2} {}".format(i, x[0]))
            drums(ritmos[nritmo], tempo, compases)
        elif letra in "0123456789":
            nritmo = int(letra)
            print("{:2} {}".format(nritmo, ritmos[nritmo][0]))
        elif letra == "n":
            number = int(input())
            if number < len(ritmos):
                nritmo = number
                print("{:2} {}".format(nritmo, ritmos[nritmo][0]))
        elif letra == "t":
            tempo = int(input())
            print("tempo:", tempo)
コード例 #2
0
ファイル: tracks.py プロジェクト: rendaw/alsaseq
def parsecommand():
    'Read on letter from stdin.'
    global ritmos, nritmo, tempo, split, waitingforsplit
    global voz1, voz2, pgmchangevoz1, pgmchangevoz2
    if not playing:
        if letra == 'p':
            playback()
        elif letra == 'o':
            seq.read(ruta)
            print('read', ruta)
        elif letra == 's':
            seq.write(ruta)
            print('saved', ruta)
        elif letra == 't':
            enabledisabletracks()
        elif letra == 'k':
            print('hit keyboard split point:', end=' ')
            waitingforsplit = 1
        elif letra == 'v':
            voz1 = int(input())
            pgmchangevoz1 = alsamidi.pgmchangeevent(0, voz1)
            alsaseq.output(pgmchangevoz1)
            print('voice 1:', voz1)
        elif letra == 'b':
            voz2 = int(input())
            pgmchangevoz2 = alsamidi.pgmchangeevent(1, voz2)
            if voz2:
                alsaseq.output(pgmchangevoz2)
            print('voice 2:', voz2)
    else:
        if letra == 'p':
            stop()
        elif letra == 'r':
            ritmos = pista.lee('main.pat')
            for i, x in enumerate(ritmos):
                print('{:2} {}'.format(i, x[0]))
            drums(ritmos[nritmo], tempo, compases)
        elif letra in '0123456789':
            nritmo = int(letra)
            print('{:2} {}'.format(nritmo, ritmos[nritmo][0]))
        elif letra == 'n':
            number = int(input())
            if number < len(ritmos):
                nritmo = number
                print('{:2} {}'.format(nritmo, ritmos[nritmo][0]))
        elif letra == 't':
            tempo = int(input())
            print('tempo:', tempo)
コード例 #3
0
ファイル: zynthian_midi.py プロジェクト: zynthian/zynthian-ui
	def set_midi_preset(self, chan, msb, lsb, prg):
		logging.info("Set MIDI CH " + str(chan) + ", Bank MSB: " + str(msb) + ", Bank LSB: " + str(lsb) + ", Program: " + str(prg))
		self.bank_msb_selected[chan]=msb
		self.bank_lsb_selected[chan]=lsb
		self.prg_selected[chan]=prg
		self.set_midi_control(chan,0,msb)
		self.set_midi_control(chan,32,lsb)
		event=alsamidi.pgmchangeevent(chan, prg)
		alsaseq.output(event)
コード例 #4
0
ファイル: zynthian_midi.py プロジェクト: eriser/zynthian
 def set_midi_instr(self, chan, msb, lsb, prg):
     print("Set MIDI CH " + str(chan) + ", Bank MSB: " + str(msb) +
           ", Bank LSB: " + str(lsb) + ", Program: " + str(prg))
     self.bank_msb_selected[chan] = msb
     self.bank_lsb_selected[chan] = lsb
     self.prg_selected[chan] = prg
     self.set_midi_control(chan, 0, msb)
     self.set_midi_control(chan, 32, lsb)
     event = alsamidi.pgmchangeevent(chan, prg)
     alsaseq.output(event)
コード例 #5
0
ファイル: aseqplay.py プロジェクト: rendaw/alsaseq
def main(dest_client, file_name, display=False):
    seq = alsamidi.Seq()
    seq.read(file_name)
    events = alsamidi.merge(seq.tracks)
    seq.info()

    print(len(events), 'events')
    alsaseq.client('aseqplay', 0, 1, 1)
    alsaseq.connectto(0, dest_client, 0)

    for channel in range(16):
        alsaseq.output(alsamidi.pgmchangeevent(channel, 0))

    alsaseq.start()

    for event in events:
        if display:
            print(event)
        alsaseq.output(event)

    alsaseq.syncoutput()
コード例 #6
0
ファイル: pista.py プロジェクト: ppaez/alsaseq
def construye( ritmo, tempo, compases, start=0 ):
    'Construye lista de eventos a partir de ritmo.'

    def itotiempo( i ):
        'Regresa tiempo dentro del compas.'
        return i * tbeat * numerador / numbeats + start
    
    tbeat = int( 60. / tempo * 1000 )
    numerador = ritmo[ 1 ][ 0 ]
    numbeats = ritmo[ 1 ][ 1]
    inicios = list(map( itotiempo, list(range( numbeats * compases)) ))
    duracion = int( tbeat * 0.9 )
    instrumentos = ritmo[ 2 ]
    
    eventos = []
    for ch, pgm, timbre, vel, notas in instrumentos:
        if pgm:
            eventos.append( alsamidi.pgmchangeevent( ch, pgm, start=0 ) )
        for ibeat, nota in enumerate( notas * compases ):
            if nota != ' ':
                eventos.append( alsamidi.noteevent( ch, timbre, vel, 
                        inicios[ ibeat ], duracion ) )
    return eventos
コード例 #7
0
def construye(ritmo, tempo, compases, start=0):
    'Construye lista de eventos a partir de ritmo.'

    def itotiempo(i):
        'Regresa tiempo dentro del compas.'
        return i * tbeat * numerador / numbeats + start

    tbeat = int(60. / tempo * 1000)
    numerador = ritmo[1][0]
    numbeats = ritmo[1][1]
    inicios = list(map(itotiempo, list(range(numbeats * compases))))
    duracion = int(tbeat * 0.9)
    instrumentos = ritmo[2]

    eventos = []
    for ch, pgm, timbre, vel, notas in instrumentos:
        if pgm:
            eventos.append(alsamidi.pgmchangeevent(ch, pgm, start=0))
        for ibeat, nota in enumerate(notas * compases):
            if nota != ' ':
                eventos.append(
                    alsamidi.noteevent(ch, timbre, vel, inicios[ibeat],
                                       duracion))
    return eventos
コード例 #8
0
ファイル: tracks.py プロジェクト: ppaez/alsaseq
        elif letra == "n":
            number = int(input())
            if number < len(ritmos):
                nritmo = number
                print("{:2} {}".format(nritmo, ritmos[nritmo][0]))
        elif letra == "t":
            tempo = int(input())
            print("tempo:", tempo)


rechazados = (alsaseq.SND_SEQ_EVENT_CLOCK, alsaseq.SND_SEQ_EVENT_SENSING)
alsaseq.client("ReproductorGrabador", 1, 1, 1)
alsaseq.connectfrom(0, source_cliente, 0)
alsaseq.connectto(1, dest_cliente, 0)
alsaseq.start()
pgmchangevoz1 = alsamidi.pgmchangeevent(0, voz1)
pgmchangevoz2 = alsamidi.pgmchangeevent(1, voz2)
alsaseq.output(pgmchangevoz1)
if voz2:
    alsaseq.output(pgmchangevoz2)

nlibres = 100
import kbhit

kbhit.unbuffer_stdin()
vivo = 1
seq = alsamidi.Seq()
try:
    fd = alsaseq.fd()
    thso = threading.Thread(target=supplyoutput)
    thso.start()
コード例 #9
0
ファイル: test_alsamidi.py プロジェクト: ppaez/alsaseq
    def test_scheduled(self):
        from alsamidi import pgmchangeevent

        data = (1, 0, 0, 0, 0, 9)
        expected = (11, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
        self.assertEqual(expected, pgmchangeevent(1, 9, 1000))
コード例 #10
0
ファイル: test_alsamidi.py プロジェクト: ppaez/alsaseq
    def test_sent_directly(self):
        from alsamidi import pgmchangeevent

        data = (1, 0, 0, 0, 0, 9)
        expected = (11, 1, 0, 253, (0, 0), (0, 0), (0, 0), data)
        self.assertEqual(expected, pgmchangeevent(1, 9))
コード例 #11
0
ファイル: test-alsaseq.py プロジェクト: eriser/zynthian
#    This changes the center frequency of the resonance.
#
# 4) Resonance Bandwidth (Sound control 9) (no. 78)
#    This changes the bandwidth of the resonance.
#--------------------------------------

alsaseq.client('ZynthianGUI', 0, 1, True)
alsaseq.connectto(0, 128, 0)
alsaseq.connectto(0, 130, 0)
alsaseq.connectto(0, 131, 0)
alsaseq.start()

time.sleep(1)

# Instrument Select
event = alsamidi.pgmchangeevent(0, 0)
alsaseq.output(event)

# Raw Note ON:
alsaseq.output((6, 1, 0, 0, (0, 0), (0, 0), (0, 0), (0, 70, 127, 0, 100)))

# Note ON Event
event = alsamidi.noteonevent(0, 66, 120)
alsaseq.output(event)

control = 74
for i in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15):
    value = i * 16
    alsaseq.output((alsaseq.SND_SEQ_EVENT_CONTROLLER, 1, 0, 0, (0, 0), (0, 0),
                    (0, 0), (0, 0, 0, 0, control, value)))
    time.sleep(0.04)
コード例 #12
0
ファイル: alsaseq_chprg.py プロジェクト: eriser/zynthian
#!/usr/bin/python

import sys
import alsaseq
import alsamidi

alsaseq.client('ZynthianGUI', 0, 1, True)
alsaseq.connectto( 0, 128, 0 )
alsaseq.connectto( 0, 130, 0 )
alsaseq.connectto( 0, 131, 0 )
alsaseq.start()

# Instrument Select
note=sys.argv[1]
print "Program " + note
event=alsamidi.pgmchangeevent(0, int(note))
alsaseq.output(event)

コード例 #13
0
ファイル: test-alsaseq.py プロジェクト: eriser/zynthian
#    This changes the center frequency of the resonance.
#
# 4) Resonance Bandwidth (Sound control 9) (no. 78)
#    This changes the bandwidth of the resonance.
# --------------------------------------

alsaseq.client("ZynthianGUI", 0, 1, True)
alsaseq.connectto(0, 128, 0)
alsaseq.connectto(0, 130, 0)
alsaseq.connectto(0, 131, 0)
alsaseq.start()

time.sleep(1)

# Instrument Select
event = alsamidi.pgmchangeevent(0, 0)
alsaseq.output(event)

# Raw Note ON:
alsaseq.output((6, 1, 0, 0, (0, 0), (0, 0), (0, 0), (0, 70, 127, 0, 100)))

# Note ON Event
event = alsamidi.noteonevent(0, 66, 120)
alsaseq.output(event)

control = 74
for i in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15):
    value = i * 16
    alsaseq.output((alsaseq.SND_SEQ_EVENT_CONTROLLER, 1, 0, 0, (0, 0), (0, 0), (0, 0), (0, 0, 0, 0, control, value)))
    time.sleep(0.04)
コード例 #14
0
ファイル: zynthian_midi.py プロジェクト: zynthian/zynthian-ui
	def set_midi_prg(self, chan, prg):
		logging.info("Set MIDI CH " + str(chan) + ", Program: " + str(prg))
		self.prg_selected[chan]=prg
		event=alsamidi.pgmchangeevent(chan, prg)
		alsaseq.output(event)
コード例 #15
0
ファイル: zynthian_midi.py プロジェクト: eriser/zynthian
 def set_midi_prg(self, chan, prg):
     print("Set MIDI CH " + str(chan) + ", Program: " + str(prg))
     self.prg_selected[chan] = prg
     event = alsamidi.pgmchangeevent(chan, prg)
     alsaseq.output(event)
コード例 #16
0
ファイル: alsaseq_chprg.py プロジェクト: eriser/zynthian
#!/usr/bin/python

import sys
import alsaseq
import alsamidi

alsaseq.client('ZynthianGUI', 0, 1, True)
alsaseq.connectto(0, 128, 0)
alsaseq.connectto(0, 130, 0)
alsaseq.connectto(0, 131, 0)
alsaseq.start()

# Instrument Select
note = sys.argv[1]
print "Program " + note
event = alsamidi.pgmchangeevent(0, int(note))
alsaseq.output(event)
コード例 #17
0
ファイル: tracks.py プロジェクト: rendaw/alsaseq
        elif letra == 'n':
            number = int(input())
            if number < len(ritmos):
                nritmo = number
                print('{:2} {}'.format(nritmo, ritmos[nritmo][0]))
        elif letra == 't':
            tempo = int(input())
            print('tempo:', tempo)


rechazados = (alsaseq.SND_SEQ_EVENT_CLOCK, alsaseq.SND_SEQ_EVENT_SENSING)
alsaseq.client('ReproductorGrabador', 1, 1, 1)
alsaseq.connectfrom(0, source_cliente, 0)
alsaseq.connectto(1, dest_cliente, 0)
alsaseq.start()
pgmchangevoz1 = alsamidi.pgmchangeevent(0, voz1)
pgmchangevoz2 = alsamidi.pgmchangeevent(1, voz2)
alsaseq.output(pgmchangevoz1)
if voz2:
    alsaseq.output(pgmchangevoz2)

nlibres = 100
import kbhit
kbhit.unbuffer_stdin()
vivo = 1
seq = alsamidi.Seq()
try:
    fd = alsaseq.fd()
    thso = threading.Thread(target=supplyoutput)
    thso.start()
    thri = threading.Thread(target=retrieveinput)