Remove 'synth' method and fix mapping string to note pitch
This commit is contained in:
@@ -1,25 +1,13 @@
|
||||
from smnp.function.model import CombinedFunction, Function
|
||||
from smnp.function.signature import varargSignature
|
||||
from smnp.module.synth.lib.player import playNotes
|
||||
from smnp.function.model import Function
|
||||
from smnp.function.signature import signature
|
||||
from smnp.module.synth.lib.player import play
|
||||
from smnp.type.model import Type
|
||||
from smnp.type.signature.matcher.list import listOf
|
||||
from smnp.type.signature.matcher.type import ofTypes
|
||||
from smnp.type.signature.matcher.type import ofType
|
||||
|
||||
_signature1 = varargSignature(ofTypes(Type.NOTE, Type.INTEGER))
|
||||
def _function1(env, vararg):
|
||||
notes = [arg.value for arg in vararg]
|
||||
_signature = signature(ofType(Type.NOTE))
|
||||
def _function(env, note):
|
||||
bpm = env.findVariable('bpm')
|
||||
playNotes(notes, bpm.value)
|
||||
play(note.value, bpm.value)
|
||||
|
||||
|
||||
_signature2 = varargSignature(listOf(Type.NOTE, Type.INTEGER))
|
||||
def _function2(env, vararg):
|
||||
for arg in vararg:
|
||||
_function1(env, arg.value)
|
||||
|
||||
|
||||
function = CombinedFunction(
|
||||
'synth',
|
||||
Function(_signature1, _function1),
|
||||
Function(_signature2, _function2)
|
||||
)
|
||||
function = Function(_signature, _function, 'synthNote')
|
||||
@@ -44,7 +44,7 @@ class NotePitch(Enum):
|
||||
if string.lower() in stringToPitch:
|
||||
return stringToPitch[string.lower()]
|
||||
|
||||
if string.upper() in NotePitch:
|
||||
if string.upper() in NotePitch.__members__:
|
||||
return NotePitch[string.upper()]
|
||||
|
||||
raise NoteException(f"Note '{string}' does not exist")
|
||||
|
||||
Reference in New Issue
Block a user