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