def system_exclusive(self, data): """ data: list of values in range(128) """ sysex_len = writeVar(len(data) + 1) self.event_slice( chr(SYSTEM_EXCLUSIVE) + sysex_len + data + chr(END_OFF_EXCLUSIVE))
def system_exclusive(self, data): """ data: list of values in range(128) """ sysex_len = writeVar(len(data)+1) self.event_slice(chr(SYSTEM_EXCLUSIVE) + sysex_len + data + chr(END_OFF_EXCLUSIVE))
def meta_slice(self, meta_type, data_slice): """ Writes a meta event. Whatever that is. Parameters ---------- meta_type : data_slice : """ # EDIT: added try / except for debugging purposes! TG # try: # slc = fromBytes([META_EVENT, meta_type]) + \ # writeVar(len(data_slice)) + data_slice # # self.event_slice(slc) # except: # pass # Original code: slc = fromBytes([META_EVENT, meta_type]) + \ writeVar(len(data_slice)) + data_slice self.event_slice(slc)
def meta_slice(self, meta_type, data_slice): """ Writes a meta event """ slc = fromBytes([META_EVENT, meta_type]) + \ writeVar(len(data_slice)) + data_slice self.event_slice(slc)
def end_of_track(self): """ Writes the track to the buffer. """ raw = self.raw_out raw.writeSlice(TRACK_HEADER) track_data = self._current_track_buffer.getvalue() # wee need to know size of track data. eot_slice = writeVar(self.rel_time()) + fromBytes([META_EVENT, END_OF_TRACK, 0]) raw.writeBew(len(track_data)+len(eot_slice), 4) # then write raw.writeSlice(track_data) raw.writeSlice(eot_slice)
def writeVarLen(self, value): "Writes a variable length word to the file" var = self.writeSlice(writeVar(value))