Refactor multiple samples as SampleList
This commit is contained in:
@ -500,6 +500,11 @@ class Sample(Event):
|
|||||||
|
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
@dataclass(kw_only=True)
|
||||||
|
class SampleList(Item):
|
||||||
|
"""Class for using multiple samples"""
|
||||||
|
|
||||||
|
values: list
|
||||||
|
|
||||||
@dataclass(kw_only=True)
|
@dataclass(kw_only=True)
|
||||||
class VariableList(Item):
|
class VariableList(Item):
|
||||||
|
|||||||
@ -31,6 +31,7 @@ from .items import (
|
|||||||
Modification,
|
Modification,
|
||||||
Whitespace,
|
Whitespace,
|
||||||
Sample,
|
Sample,
|
||||||
|
SampleList
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -78,10 +79,12 @@ def resolve_item(item: Meta, options: dict):
|
|||||||
yield from resolve_item(variable, options)
|
yield from resolve_item(variable, options)
|
||||||
elif isinstance(item, VariableList):
|
elif isinstance(item, VariableList):
|
||||||
seqlist = []
|
seqlist = []
|
||||||
|
sample_list = True
|
||||||
for var in item.values:
|
for var in item.values:
|
||||||
if var.name in options:
|
if var.name in options:
|
||||||
opt_item = options[var.name]
|
opt_item = options[var.name]
|
||||||
if isinstance(opt_item, LambdaType):
|
if isinstance(opt_item, LambdaType):
|
||||||
|
sample_list = False
|
||||||
seqlist.append(
|
seqlist.append(
|
||||||
Function(
|
Function(
|
||||||
run=opt_item,
|
run=opt_item,
|
||||||
@ -100,8 +103,12 @@ def resolve_item(item: Meta, options: dict):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(opt_item, Sequence):
|
elif isinstance(opt_item, Sequence):
|
||||||
|
sample_list = False
|
||||||
seqlist.append(opt_item)
|
seqlist.append(opt_item)
|
||||||
if len(seqlist) > 0:
|
if len(seqlist) > 0:
|
||||||
|
if sample_list:
|
||||||
|
yield SampleList(values=seqlist)
|
||||||
|
else:
|
||||||
yield PolyphonicSequence(values=seqlist)
|
yield PolyphonicSequence(values=seqlist)
|
||||||
elif isinstance(item, Range):
|
elif isinstance(item, Range):
|
||||||
yield from item.evaluate(options)
|
yield from item.evaluate(options)
|
||||||
|
|||||||
Reference in New Issue
Block a user