Move 'note' module
This commit is contained in:
22
smnp/module/note/function/tuplet.py
Normal file
22
smnp/module/note/function/tuplet.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from smnp.library.model import CombinedFunction, Function
|
||||
from smnp.library.signature import signature, listOf, ofTypes, varargSignature
|
||||
from smnp.type.model import Type
|
||||
|
||||
|
||||
_signature1 = varargSignature(ofTypes(Type.NOTE), ofTypes(Type.INTEGER), ofTypes(Type.INTEGER))
|
||||
def _function1(env, n, m, vararg):
|
||||
t = [Type.note(arg.value.withDuration(int(arg.value.duration * n.value / m.value))) for arg in vararg]
|
||||
return Type.list(t).decompose()
|
||||
|
||||
|
||||
|
||||
_signature2 = signature(ofTypes(Type.INTEGER), ofTypes(Type.INTEGER), listOf(Type.NOTE))
|
||||
def _function2(env, n, m, notes):
|
||||
return _function1(env, n, m, notes.value)
|
||||
|
||||
|
||||
function = CombinedFunction(
|
||||
'tuplet',
|
||||
Function(_signature1, _function1),
|
||||
Function(_signature2, _function2)
|
||||
)
|
||||
Reference in New Issue
Block a user