From 44d234d36ab2cf6db93e44d3207a3a3464d30f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Pluta?= Date: Sat, 13 Jul 2019 22:07:49 +0200 Subject: [PATCH] Move semitones, transpose and interval functions to standard library --- smnp/module/note/__init__.py | 4 ++-- smnp/module/note/function/interval.py | 27 -------------------------- smnp/module/note/function/semitones.py | 25 ------------------------ smnp/module/note/function/transpose.py | 22 --------------------- 4 files changed, 2 insertions(+), 76 deletions(-) delete mode 100644 smnp/module/note/function/interval.py delete mode 100644 smnp/module/note/function/semitones.py delete mode 100644 smnp/module/note/function/transpose.py diff --git a/smnp/module/note/__init__.py b/smnp/module/note/__init__.py index 30547fd..645de5d 100644 --- a/smnp/module/note/__init__.py +++ b/smnp/module/note/__init__.py @@ -1,4 +1,4 @@ -from smnp.module.note.function import transpose, semitones, interval, note +from smnp.module.note.function import note -functions = [ semitones.function, interval.function, transpose.function, note.function ] +functions = [ note.function ] methods = [] \ No newline at end of file diff --git a/smnp/module/note/function/interval.py b/smnp/module/note/function/interval.py deleted file mode 100644 index 8e117fa..0000000 --- a/smnp/module/note/function/interval.py +++ /dev/null @@ -1,27 +0,0 @@ -from smnp.function.model import Function, CombinedFunction -from smnp.function.signature import varargSignature -from smnp.note.interval import intervalToString -from smnp.note.model import Note -from smnp.type.model import Type -from smnp.type.signature.matcher.list import listOf -from smnp.type.signature.matcher.type import ofTypes - -_signature1 = varargSignature(ofTypes(Type.NOTE, Type.INTEGER)) -def _function1(env, vararg): - withoutPauses = [note.value for note in vararg if note.type == Type.NOTE] - if len(withoutPauses) < 2: - return Type.list([]) - semitones = [Note.checkInterval(withoutPauses[i-1], withoutPauses[i]) for i in range(1, len(withoutPauses))] - return Type.list([Type.string(intervalToString(s)) for s in semitones]).decompose() - - -_signature2 = varargSignature(listOf(Type.NOTE, Type.INTEGER)) -def _function2(env, vararg): - return Type.list([_function1(env, arg.value) for arg in vararg]).decompose() - - -function = CombinedFunction( - 'interval', - Function(_signature1, _function1), - Function(_signature2, _function2) -) \ No newline at end of file diff --git a/smnp/module/note/function/semitones.py b/smnp/module/note/function/semitones.py deleted file mode 100644 index 59329b1..0000000 --- a/smnp/module/note/function/semitones.py +++ /dev/null @@ -1,25 +0,0 @@ -from smnp.function.model import Function, CombinedFunction -from smnp.function.signature import varargSignature -from smnp.note.model import Note -from smnp.type.model import Type -from smnp.type.signature.matcher.list import listOf -from smnp.type.signature.matcher.type import ofTypes - -_signature1 = varargSignature(ofTypes(Type.NOTE, Type.INTEGER)) -def _function1(env, vararg): - withoutPauses = [note.value for note in vararg if note.type == Type.NOTE] - if len(withoutPauses) < 2: - return Type.list([]) - return Type.list([Type.integer(Note.checkInterval(withoutPauses[i-1], withoutPauses[i])) for i in range(1, len(withoutPauses))]).decompose() - - -_signature2 = varargSignature(listOf(Type.NOTE, Type.INTEGER)) -def _function2(env, vararg): - return Type.list([_function1(env, arg.value) for arg in vararg]).decompose() - - -function = CombinedFunction( - "semitones", - Function(_signature1, _function1), - Function(_signature2, _function2), -) \ No newline at end of file diff --git a/smnp/module/note/function/transpose.py b/smnp/module/note/function/transpose.py deleted file mode 100644 index b3799bd..0000000 --- a/smnp/module/note/function/transpose.py +++ /dev/null @@ -1,22 +0,0 @@ -from smnp.function.model import CombinedFunction, Function -from smnp.function.signature import varargSignature -from smnp.type.model import Type -from smnp.type.signature.matcher.list import listOf -from smnp.type.signature.matcher.type import ofTypes - -_signature1 = varargSignature(ofTypes(Type.INTEGER, Type.NOTE), ofTypes(Type.INTEGER)) -def _function1(env, value, vararg): - transposed = [Type.note(arg.value.transpose(value.value)) if arg.type == Type.NOTE else arg for arg in vararg] - return Type.list(transposed).decompose() - - -_signature2 = varargSignature(listOf(Type.INTEGER, Type.NOTE), ofTypes(Type.INTEGER)) -def _function2(env, value, vararg): - return Type.list([_function1(env, value, arg.value) for arg in vararg]).decompose() - - -function = CombinedFunction( - 'transpose', - Function(_signature1, _function1), - Function(_signature2, _function2) -)