Exemple #1
0
from smnp.function.model import Function, CombinedFunction
from smnp.function.signature import varargSignature
from smnp.module.synth.function import compile
from smnp.module.synth.lib.wave import play
from smnp.type.model import Type
from smnp.type.signature.matcher.list import listOf
from smnp.type.signature.matcher.type import ofTypes, ofType

_signature1 = varargSignature(listOf(Type.NOTE, Type.INTEGER))


def _function1(env, notes):
    wave = compile.__function1(notes)
    play(wave)


_signature2 = varargSignature(ofTypes(Type.NOTE, Type.INTEGER))


def _function2(env, notes):
    wave = compile.__function2(notes)
    play(wave)


_signature3 = varargSignature(listOf(Type.NOTE, Type.INTEGER),
                              ofType(Type.MAP))


def _function3(env, config, notes):
    wave = compile.__function3(config, notes)
    play(wave)
Exemple #2
0
from smnp.function.model import Function
from smnp.function.signature import varargSignature
from smnp.type.signature.matcher.type import allTypes

_signature = varargSignature(allTypes())


def _function(env, vararg):
    print("".join([arg.stringify() for arg in vararg]), end="")


function = Function(_signature, _function, 'print')
Exemple #3
0
from smnp.function.model import Function, CombinedFunction
from smnp.function.signature import varargSignature, signature
from smnp.type.model import Type
from smnp.type.signature.matcher.list import listOfMatchers, listMatches
from smnp.type.signature.matcher.type import allTypes, ofTypes

_signature1 = varargSignature(
    listMatches(
        ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.BOOL, Type.TYPE),
        allTypes()))


def _function1(env, vararg):
    map = {}
    for entry in vararg:
        key, value = entry.value
        map[key] = value

    return Type.map(map)


_signature2 = signature(
    listOfMatchers(
        listMatches(
            ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.BOOL,
                    Type.TYPE), allTypes())))


def _function2(env, list):
    map = {}
    for entry in list.value: