-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrecorder.py
36 lines (31 loc) · 865 Bytes
/
recorder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time
import rtmidi
#import from parrentdir
import sys
import os
import inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from CK_rec.setup import Setup
from CK_rec.rec_classes import CK_rec
# Start the Device
codeK = Setup()
myPort = codeK.perform_setup()
codeK.open_port(myPort)
on_id = codeK.get_device_id()
print('your note on id is: ', on_id)
# record
midiRec = CK_rec(myPort, on_id, debug=False)
codeK.set_callback(midiRec)
# Loop to program to keep listening for midi input
try:
while True:
time.sleep(0.001)
except KeyboardInterrupt:
print('')
finally:
name = input('\nsave midi recording as? (leaving the name blank discards the recording): ')
if name != "":
midiRec.saveTrack(name)
codeK.end()