def print_general_data(self, sample_list=None, full=False, _out=sys.stdout): """create the "overview" file (sample and pattern lists) sample_list is a list of pattern numbers associated with the drum samples to print on this event, e.g. ((1, 'b'), (2, 's'), (4, 'bs'), (7, 'bsh')) so this can be used to determine if it's a drum instrument printseq indicates the sequence to print these top to bottom e.g. 'hsb' stream is a file-like object to write the output to """ if sample_list is None: sample_list = [] drumsamples = [x for x, y in sample_list] data = shared.build_header("module", self.filename, self.name.rstrip(chr(0))) instruments = [] self.pattern_data = {} self.playseqs = collections.defaultdict(list) for sampseq, sample_data in self.samples.items(): sample_name = sample_data[0] sample_string = '' sample_number = sampseq + 1 if sample_list: for sampnum, sampstr in sample_list: if sampnum == sample_number: sample_string = sampstr.join((' (', ')')) instruments.append((sample_number, sample_name + sample_string)) if sample_number not in drumsamples: self.remove_duplicate_patterns(sample_number) self.remove_duplicate_drum_patterns(sample_list) data.extend(shared.build_inst_list(instruments)) if not full: data.extend(shared.build_patt_header()) for sample_number, sample_name in instruments: if sample_number not in drumsamples: data.extend( shared.build_patt_list(sample_number, sample_name, self.playseqs[sample_number])) if 'drums' in self.playseqs: data.extend( shared.build_patt_list('', 'Drums', self.playseqs['drums'])) for text in data: print(text.rstrip(), file=_out)
def print_general_data(self, full=False, stream=sys.stdout): """create the "overview" file (sample and pattern lists) """ data = shared.build_header("module", self.filename) data.extend(shared.build_inst_list([(x, '{} (chn. {})'.format(y[0], y[1])) for x, y in self.instruments.items()])) if self.weirdness: data.extend([''] + [x for x in self.weirdness]) if not full: data.extend(shared.build_patt_header()) for track, patterns in self.pattern_lists.items(): patt_list = [] i = 0 for seq, num in patterns: while seq > i: patt_list.append(-1) i += 1 if seq == i: patt_list.append(num + 1) i += 1 data.extend(shared.build_patt_list(track, self.instruments[track][0], patt_list)) for item in data: print(item.rstrip(), file=stream)
def print_general_data(self, sample_list=None, full=False, _out=sys.stdout): """create the "overview" file (sample and pattern lists) """ if sample_list is None: sample_list = [] data = shared.build_header("project", self.filename) data.extend( shared.build_inst_list([(i + 1, x) for i, x in enumerate(self.tracknames)])) if not full: data.extend(shared.build_patt_header()) for i, x in enumerate(self.tracknames): data.extend( shared.build_patt_list(i + 1, x, self.patternlists_split[x])) if self.bbtracknames: bb_inst = [] for i, x in enumerate(self.bbtracknames): y = '' for ins, lett in sample_list: if ins == x: y = lett break if y: y = y.join(('(', ')')) bb_inst.append((i + 1, ' '.join((x, y)))) data.extend( shared.build_inst_list(bb_inst, "Beat/Bassline instruments:")) if not full: data.extend( shared.build_patt_header("Beat/Bassline patterns:")) data.extend( shared.build_patt_list('', '', [x[1] for x in self.bbpatternlist])) for line in data: print(line.rstrip(), file=_out)
def print_general_data(self, sample_list=None, full=False, _out=sys.stdout): """create the "overview" file (sample and pattern lists) """ if sample_list is None: drumsamples = sample_list = [] else: drumsamples = [x for x, y in sample_list] data = shared.build_header("module", self.filename, self.songdesc) instruments = [] self.playseqs = collections.defaultdict(list) for sampseq, sample in enumerate(self.samplenames): sample_name = sample[1] sample_string = '' sample_number = sampseq + 1 # start met 1 ipv 0 if sample_list: for sampnum, sampstr in sample_list: if sampnum == sample_number: sample_string = sampstr.join((' (', ')')) instruments.append((sample_number, sample_name + sample_string)) if sample_number not in drumsamples: self.remove_duplicate_patterns(sampseq) if drumsamples: self.remove_duplicate_drum_patterns(sample_list) data.extend(shared.build_inst_list(instruments)) if not full: data.extend(shared.build_patt_header()) for sample_number, sample_name in instruments: if sample_number not in drumsamples: data.extend(shared.build_patt_list(sample_number, sample_name, self.playseqs[sample_number])) if 'drums' in self.playseqs: data.extend(shared.build_patt_list('', 'Drums', self.playseqs['drums'])) for text in data: print(text.rstrip(), file=_out)
def print_general_data(self, full=False, stream=sys.stdout): """create the "overview" file (sample and pattern lists) """ data = shared.build_header("project", self.filename) data.extend( shared.build_inst_list([ (x, y) for x, y in sorted(self.instruments.items()) ])) if not full: data.extend(shared.build_patt_header()) for item, value in self.pattern_list.items(): patt_list = [y for x, y in value] data.extend( shared.build_patt_list(item, self.instruments[item], patt_list)) for line in data: print(line.rstrip(), file=stream)
def print_general_data(self, sample_list=None, full=False, _out=sys.stdout): """create the "overview" file (sample and pattern lists) """ if sample_list is None: sample_list = [] drumsamples = [x for x, y in sample_list] data = shared.build_header("module", self.filename) instruments = [] self.playseqs = collections.defaultdict(list) for sampseq, sample in enumerate(self.samplenames): sample_name = sample[1] sample_string = '' sample_number = sampseq + 1 if sample_list: for sampnum, sampstr in sample_list: if sampnum == sample_number: sample_string = sampstr.join((' (', ')')) instruments.append((sample_number, sample_name + sample_string)) if sample_number not in drumsamples: self.remove_duplicate_patterns(sample_number) if drumsamples: self.remove_duplicate_drum_patterns(sample_list) data.extend(shared.build_inst_list(instruments)) # pattern lengtes voor alle playseqs aanvullen ## combined_playseqs = collections.defaultdict(list) maxlen = max((len(x) for x in self.playseqs.values())) if maxlen != min((len(x) for x in self.playseqs.values())): print('Alarm! Niet alle tracks hebben evenveel pattern events', file=_out) pattlens = [0] * (maxlen) for sampnum, playseq in self.playseqs.items(): for ix, pattnum in enumerate(playseq): if pattnum != -1: pattlen = self.pattern_data[sampnum][pattnum - 1]['len'] if pattlens[ix] == 0: pattlens[ix] = pattlen elif pattlens[ix] != pattlen: print( 'Alarm! Verschillende lengtes voor pattern event', ix, file=_out) self.pattern_lengths = pattlens self.full_length = sum((x for x in self.pattern_lengths)) if not full: data.extend(shared.build_patt_header()) for sample_number, sample_name in instruments: if sample_number not in drumsamples: data.extend( shared.build_patt_list(sample_number, sample_name, self.playseqs[sample_number])) if 'drums' in self._pattern_list: data.extend( shared.build_patt_list('', 'Drums', self.playseqs['drums'])) for text in data: print(text.rstrip(), file=_out)