def show(self): super().show() try: if self.smf_player == None: self.smf_player = libsmf.addSmf() libsmf.attachPlayer(self.smf_player) self.zyngui.zynautoconnect() except: pass
def start_recording(self): if not libsmf.isRecording(): logging.info("STARTING NEW MIDI RECORD ...") if self.smf_recorder == None: self.smf_recorder = libsmf.addSmf() libsmf.attachRecorder(self.smf_recorder) self.zyngui.zynautoconnect() sleep(0.1) libsmf.unload(self.smf_recorder) libsmf.startRecording() self.update_list() return True else: return False
def export_smf(self, params): smf = libsmf.addSmf() tempo = libseq.getTempo() libsmf.addTempo(smf, 0, tempo) ticks_per_step = libsmf.getTicksPerQuarterNote( smf) / libseq.getStepsPerBeat() for step in range(libseq.getSteps()): time = int(step * ticks_per_step) for note in range(128): duration = libseq.getNoteDuration(step, note) if duration == 0: continue duration = int(duration * ticks_per_step) velocity = libseq.getNoteVelocity(step, note) libsmf.addNote(smf, 0, time, duration, self.channel, note, velocity) libsmf.setEndOfTrack(smf, 0, int(libseq.getSteps() * ticks_per_step)) zynsmf.save( smf, "/zynthian/zynthian-my-data/capture/pattern%d_%s.mid" % (self.pattern, datetime.now()))
def get_filelist(self, src_dir): res = {} for f in sorted(os.listdir(src_dir)): fpath = join(src_dir, f) fname = f[:-4] fext = f[-4:].lower() if isfile(fpath) and fext in ('.mid'): res[fname] = {'fpath': fpath, 'ext': fext} smf = libsmf.addSmf() for fname in res: try: zynsmf.load(smf, res[fname]['fpath']) res[fname]['length'] = libsmf.getDuration(smf) except Exception as e: res[fname]['length'] = 0 logging.warning(e) libsmf.removeSmf(smf) return res
def setUpClass(self): global smf smf = libsmf.addSmf()