forked from jwdj/EasyABC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
midiplayer.py
82 lines (57 loc) · 1.61 KB
/
midiplayer.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from __future__ import unicode_literals
class EventHook(object):
def __init__(self):
self.__handlers = []
def __iadd__(self, handler):
self.__handlers.append(handler)
return self
def __isub__(self, handler):
self.__handlers.remove(handler)
return self
def fire(self, *args, **keywargs):
for handler in self.__handlers:
handler(*args, **keywargs)
def clearObjectHandlers(self, obj):
self.__handlers = [h for h in self.__handlers if getattr(h, '__self__', False) != obj]
class MidiPlayer(object):
def __init__(self):
super(MidiPlayer, self).__init__()
self.OnAfterStop = EventHook()
self.OnAfterLoad = EventHook()
self._loop_midi_playback = False
@property
def is_playing(self):
return False
@property
def is_paused(self):
return False
@property
def loop_midi_playback(self):
return self._loop_midi_playback
def set_loop_midi_playback(self, value):
self._loop_midi_playback = value
@property
def supports_tempo_change_while_playing(self):
return False
@property
def unit_is_midi_tick(self):
return False
def Play(self):
pass
def Stop(self):
pass
def Pause(self):
pass
def Load(self, path):
return True
def Length(self):
return 0
def Seek(self, pos_in_ms):
pass
def Tell(self):
return 0
def dispose(self):
pass
class DummyMidiPlayer(MidiPlayer):
def __init__(self):
super(DummyMidiPlayer, self).__init__()