1 from calfbox
import cbox
4 def cmd_dumper(cmd
, fb
, args
):
5 print ("%s(%s)" % (cmd
, ",".join(list(map(repr,args
)))))
9 cbox
.Config
.add_section("drumpattern:pat1", """
10 title=Straight - Verse
20 bd_trigger=9... .... 9.6. ....
21 sd_trigger=.... 9..5 .2.. 9...
22 hh_trigger=9353 7353 7353 73.3
23 ho_trigger=.... .... .... ..3.
26 cbox
.Config
.set("io", "use_usb", 0)
27 cbox
.start_audio(cmd_dumper
)
30 Document
= cbox
.Document
32 status
= cbox
.JackIO
.status()
33 client_name
= status
.client_name
34 print ("Client name: %s" % client_name
)
35 print ("Audio inputs: %d, outputs: %d" % (status
.audio_inputs
, status
.audio_outputs
))
36 print ("Sample rate: %d frames/sec" % (status
.sample_rate
))
37 print ("JACK period: %d frames" % (status
.buffer_size
))
38 uuid
= cbox
.JackIO
.create_midi_output('drums')
39 cbox
.JackIO
.autoconnect_midi_output(uuid
, '*alsa_pcm:.*')
40 cbox
.JackIO
.rename_midi_output(uuid
, 'kettles')
42 uuid_in
= cbox
.JackIO
.create_midi_input('extra')
43 cbox
.JackIO
.autoconnect_midi_input(uuid_in
, '*alsa_pcm:.*')
44 cbox
.JackIO
.rename_midi_input(uuid_in
, 'extra_port')
46 uuid2
= cbox
.JackIO
.create_midi_output('violins')
48 status
= cbox
.JackIO
.status()
49 print ("Before deleting, MIDI outputs: %s" % status
.midi_output
)
51 cbox
.JackIO
.delete_midi_output(uuid2
)
52 status
= cbox
.JackIO
.status()
53 print ("After deleting, MIDI outputs: %s" % status
.midi_output
)
55 print ("Physical audio inputs: %s" % (",".join(cbox
.JackIO
.get_ports(".*", cbox
.JackIO
.AUDIO_TYPE
, cbox
.JackIO
.PORT_IS_SOURCE | cbox
.JackIO
.PORT_IS_PHYSICAL
))))
56 print ("Physical audio outputs: %s" % (",".join(cbox
.JackIO
.get_ports(".*", cbox
.JackIO
.AUDIO_TYPE
, cbox
.JackIO
.PORT_IS_SINK | cbox
.JackIO
.PORT_IS_PHYSICAL
))))
57 print ("Physical MIDI inputs: %s" % (",".join(cbox
.JackIO
.get_ports(".*", cbox
.JackIO
.MIDI_TYPE
, cbox
.JackIO
.PORT_IS_SOURCE | cbox
.JackIO
.PORT_IS_PHYSICAL
))))
58 print ("Physical MIDI outputs: %s" % (",".join(cbox
.JackIO
.get_ports(".*", cbox
.JackIO
.MIDI_TYPE
, cbox
.JackIO
.PORT_IS_SINK | cbox
.JackIO
.PORT_IS_PHYSICAL
))))
60 inputs
= cbox
.JackIO
.get_ports(".*", cbox
.JackIO
.AUDIO_TYPE
, cbox
.JackIO
.PORT_IS_SOURCE | cbox
.JackIO
.PORT_IS_PHYSICAL
)
61 outputs
= cbox
.JackIO
.get_ports(".*", cbox
.JackIO
.AUDIO_TYPE
, cbox
.JackIO
.PORT_IS_SINK | cbox
.JackIO
.PORT_IS_PHYSICAL
)
62 cbox
.JackIO
.port_connect(inputs
[0], outputs
[0])
63 cbox
.JackIO
.port_connect(inputs
[1], outputs
[1])
65 scene
= Document
.get_scene()
67 instrument
= scene
.add_new_instrument_layer("test_sampler", "sampler").get_instrument()
68 pgm_no
= instrument
.engine
.get_unused_program()
69 pgm
= instrument
.engine
.load_patch_from_file(pgm_no
, 'synthbass.sfz', 'SynthBass')
70 instrument
.engine
.set_patch(1, pgm_no
)
71 instrument
.engine
.set_patch(10, pgm_no
)
73 song
= Document
.get_song()
74 track
= song
.add_track()
75 track
.set_external_output(uuid
)
76 print ("Track outputs to: %s:%s" % (client_name
, track
.status().external_output
))
77 pattern
= song
.load_drum_pattern("pat1")
78 track
.add_clip(0, 0, pattern
.status().loop_end
, pattern
)
79 song
.set_loop(0, pattern
.status().loop_end
)
80 song
.update_playback()
86 events
= cbox
.get_new_events()