Improve library

This commit is contained in:
Bartłomiej Pluta
2019-07-04 13:14:12 +02:00
parent f86055272e
commit 558e955d07
19 changed files with 250 additions and 138 deletions

View File

@@ -1,44 +1,60 @@
import smnp.environment.function.list as l
from smnp.environment.environment import Environment
from smnp.environment.function import synth, base, interval, note, transposer, rand, mic
from smnp.environment.function.model import Function, ONLY_FUNCTION
from smnp.note.model import Note
from smnp.library.function.combine import combine
from smnp.library.function.display import display
from smnp.library.function.exit import exit
from smnp.library.function.flat import flat
from smnp.library.function.interval import interval
from smnp.library.function.semitones import semitones
from smnp.library.function.sleep import sleep
from smnp.library.function.type import objectType
def createEnvironment():
functions = {
'exit': Function(base.exit, ONLY_FUNCTION),
'print': Function(base.display, ONLY_FUNCTION),
'read': Function(base.read, ONLY_FUNCTION),
'type': Function(base.objectType, ONLY_FUNCTION),
'sleep': Function(base.sleep, ONLY_FUNCTION),
'synth': Function(synth.synth, ONLY_FUNCTION),
'pause': Function(synth.pause, ONLY_FUNCTION),
'changeDuration': Function(note.changeDuration, ONLY_FUNCTION),
'changeOctave': Function(note.changeOctave, ONLY_FUNCTION),
'semitones': Function(interval.semitones, ONLY_FUNCTION),
'interval': Function(interval.interval, ONLY_FUNCTION),
'transpose': Function(transposer.transpose, ONLY_FUNCTION),
'transposeTo': Function(transposer.transposeTo, ONLY_FUNCTION),
'random': Function(rand.random, ONLY_FUNCTION),
# 'sample': sample,
'wait': Function(mic.wait, ONLY_FUNCTION),
'tuplet': Function(note.tuplet, ONLY_FUNCTION),
'combine': Function(l.combine, ONLY_FUNCTION),
'flat': Function(l.flat, ONLY_FUNCTION),
'debug': Function(lambda args, env: print(args), ONLY_FUNCTION),
functions = [
display,
objectType,
exit,
sleep,
semitones,
interval,
combine,
flat
]
}
methods = [
methods = {
str: {},
list: {},
float: {},
Note: {
'synth': synth.synth
},
type(None): {},
}
]
# 'exit': Function(base.exit, ONLY_FUNCTION),
# 'print': Function(base.display, ONLY_FUNCTION),
# 'read': Function(base.read, ONLY_FUNCTION),
# 'type': Function(base.objectType, ONLY_FUNCTION),
# 'sleep': Function(base.sleep, ONLY_FUNCTION),
# 'synth': Function(synth.synth, ONLY_FUNCTION),
# 'pause': Function(synth.pause, ONLY_FUNCTION),
# 'changeDuration': Function(note.changeDuration, ONLY_FUNCTION),
# 'changeOctave': Function(note.changeOctave, ONLY_FUNCTION),
# 'semitones': Function(interval.semitones, ONLY_FUNCTION),
# 'interval': Function(interval.interval, ONLY_FUNCTION),
# 'transpose': Function(transposer.transpose, ONLY_FUNCTION),
# 'transposeTo': Function(transposer.transposeTo, ONLY_FUNCTION),
# 'random': Function(rand.random, ONLY_FUNCTION),
# # 'sample': sample,
# 'wait': Function(mic.wait, ONLY_FUNCTION),
# 'tuplet': Function(note.tuplet, ONLY_FUNCTION),
# 'combine': Function(l.combine, ONLY_FUNCTION),
# 'flat': Function(l.flat, ONLY_FUNCTION),
# 'debug': Function(lambda args, env: print(args), ONLY_FUNCTION),
# methods = {
# str: {},
# list: {},
# float: {},
# Note: {
# 'synth': synth.synth
# },
# type(None): {},
# }
variables = {
"bpm": 120