diff --git a/docs/pentlyas.md b/docs/pentlyas.md index e1fd61e..121206f 100644 --- a/docs/pentlyas.md +++ b/docs/pentlyas.md @@ -155,9 +155,11 @@ cannot, as it controls the length of the sound effect. Place a vertical line (`|`, Shift+backslash) before the part of the pitch or timbre that you want to loop. Otherwise, the last step is looped. +Steps of an envelope are separated by spaces is one word. A step +can be repeated with a colon and an integer: `8:3` means `8 8 8`. By default, a sound effect plays one step every frame, which is 60 -steps per second. But this can be slowed down with `rate 2` through -`rate 16`. +steps per second on NTSC or 50 on PAL. To slow this down, use +`rate 2` through `rate 16` Sound effect names are exported with the `PE_` prefix, such as `PE_closed_hihat`. Use these values with `pently_start_sound`. @@ -174,7 +176,7 @@ Examples: pitch 10 0 sfx tri_kick on triangle - volume 15 15 15 2 2 + volume 15:3 2 2 pitch e' c' a f# e Drums diff --git a/src/musicseq.pently b/src/musicseq.pently index af1d6d6..8c9d0c7 100644 --- a/src/musicseq.pently +++ b/src/musicseq.pently @@ -43,12 +43,12 @@ sfx quiethat on noise timbre | 0 1 sfx openhat on noise - volume 6 5 4 4 3 3 3 2 2 2 1 1 1 1 1 + volume 6 5 4 4 3:3 2:3 1:5 pitch 12 timbre | 0 1 sfx snarehat on noise - volume 6 5 4 4 3 3 3 2 2 2 1 1 1 1 1 + volume 12 10 8 6 3:3 2:3 1:5 pitch 4 10 10 12 timbre 0 0 | 0 1 @@ -81,11 +81,11 @@ sfx stickshatlo on noise timbre 1 sfx longkick on noise - volume 12 11 10 9 8 7 6 4 3 3 2 2 2 1 1 1 1 + volume 12 11 10 9 8 7 6 4 3 3 2:3 1:4 pitch 10 0 sfx longsnare on noise - volume 12 11 10 9 8 7 6 4 3 3 2 2 2 1 1 1 1 + volume 12 11 10 9 8 7 6 4 3 3 2:3 1:4 pitch 4 10 drum kick kick @@ -139,7 +139,7 @@ instrument dut instrument feat_wah volume 8 8 7 7 6 6 5 5 5 4 4 4 3 decay 1 - timbre 2 2 2 2 2 2 1 1 1 1 1 1 0 + timbre 2:6 1:6 0 instrument feat_power timbre 0 @@ -160,7 +160,7 @@ instrument bf98_osti detached instrument orchhit - volume 8 8 8 7 7 7 6 6 6 5 5 5 4 4 4 3 3 3 2 2 2 1 1 1 0 + volume 8:3 7:3 6:3 5:3 4:3 3:3 2:3 1:3 0 timbre 1 pitch | 12 0 -12 diff --git a/tools/pentlyas.py b/tools/pentlyas.py index 4e94028..dde5f62 100755 --- a/tools/pentlyas.py +++ b/tools/pentlyas.py @@ -523,12 +523,28 @@ def set_volume(self, volumes, linenum=None): raise ValueError("volume steps must be 0 to 15") self.volume, self.volume_linenum = volumes, linenum + @staticmethod + def expand_runs(words): + if isinstance(words, str): + words = words.split() + words = [word.rsplit(":", 1) for word in words] + # words is [[word], [word, "runlength"], [word], ...] + words = [(word[0], int(word[1]) if len(word) > 1 else 1) + for word in words] + # words is [(word, runlength), ...] + words = [word + for word, runlength in words + for i in range(runlength)] + return words + @staticmethod def pipesplit(words): pipesplit = ' '.join(words).split('|', 1) - out = pipesplit[0].split() + pipesplit = [PentlyEnvelopeContainer.expand_runs(part) + for part in pipesplit] + out = pipesplit[0] if len(pipesplit) > 1: - afterloop = pipesplit[1].split() + afterloop = pipesplit[1] looplen = len(afterloop) out.extend(afterloop) else: @@ -1430,8 +1446,8 @@ def add_volume(self, words): if len(words) < 2: raise ValueError("volume requires at least one step") obj = self.cur_obj[1] - obj.set_volume([int(x) for x in words[1:] if x != '|'], - linenum=self.linenum) + vols = [int(x) for x in obj.expand_runs(words[1:]) if x != '|'] + obj.set_volume(vols, linenum=self.linenum) def add_decay(self, words): self.ensure_in_object('decay', 'instrument')