@@ -523,12 +523,28 @@ def set_volume(self, volumes, linenum=None):
523523 raise ValueError ("volume steps must be 0 to 15" )
524524 self .volume , self .volume_linenum = volumes , linenum
525525
526+ @staticmethod
527+ def expand_runs (words ):
528+ if isinstance (words , str ):
529+ words = words .split ()
530+ words = [word .rsplit (":" , 1 ) for word in words ]
531+ # words is [[word], [word, "runlength"], [word], ...]
532+ words = [(word [0 ], int (word [1 ]) if len (word ) > 1 else 1 )
533+ for word in words ]
534+ # words is [(word, runlength), ...]
535+ words = [word
536+ for word , runlength in words
537+ for i in range (runlength )]
538+ return words
539+
526540 @staticmethod
527541 def pipesplit (words ):
528542 pipesplit = ' ' .join (words ).split ('|' , 1 )
529- out = pipesplit [0 ].split ()
543+ pipesplit = [PentlyEnvelopeContainer .expand_runs (part )
544+ for part in pipesplit ]
545+ out = pipesplit [0 ]
530546 if len (pipesplit ) > 1 :
531- afterloop = pipesplit [1 ]. split ()
547+ afterloop = pipesplit [1 ]
532548 looplen = len (afterloop )
533549 out .extend (afterloop )
534550 else :
@@ -1430,8 +1446,8 @@ def add_volume(self, words):
14301446 if len (words ) < 2 :
14311447 raise ValueError ("volume requires at least one step" )
14321448 obj = self .cur_obj [1 ]
1433- obj . set_volume ( [int (x ) for x in words [1 :] if x != '|' ],
1434- linenum = self .linenum )
1449+ vols = [int (x ) for x in obj . expand_runs ( words [1 :]) if x != '|' ]
1450+ obj . set_volume ( vols , linenum = self .linenum )
14351451
14361452 def add_decay (self , words ):
14371453 self .ensure_in_object ('decay' , 'instrument' )
0 commit comments