Skip to content

Commit

Permalink
Chord associations are weird additions
Browse files Browse the repository at this point in the history
I copied the code from the addition function to solve a bug with chord
association because chord assignation is like doing weird additions. It
doesn't solve everything though.. You can still break chord assignation
in many different ways.
  • Loading branch information
Bubobubobubobubo committed Oct 31, 2022
1 parent e26a282 commit 79bb878
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 102 deletions.
5 changes: 4 additions & 1 deletion sardine/__init__.py
Expand Up @@ -36,8 +36,8 @@
from .sequences import ListParser
from .sequences.Iterators import Iterator
from .sequences.Variables import Variables
from .sequences.LexerParser.Qualifiers import qualifiers
from .sequences.Sequence import E, euclid, mod, imod, pick, text_eater
from .sequences.LexerParser.FuncLibrary import qualifiers
from .sequences import *

warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -331,6 +331,9 @@ def panic() -> None:
S("superpanic").out() # Superpanic is a synth capable of
# cutting every other synth

def print_qualities():
"""Return the list of qualifiers"""
return qualifiers

# Amphibian iterators and amphibian variables
i, v = c.iterators, c.variables
Expand Down
101 changes: 101 additions & 0 deletions sardine/sequences/LexerParser/FuncLibrary.py
Expand Up @@ -163,3 +163,104 @@ def tangent(x: list) -> list:
list: a valid pattern.
"""
return map_unary_function(tan, x)

# Qualifiers List

qualifiers = {
"dim": [0, 3, 6, 12],
"dim9": [0, 3, 6, 9, 14],
"hdim7": [0, 3, 6, 10],
"hdim9": [0, 3, 6, 10, 14],
"hdimb9": [0, 3, 6, 10, 13],
"dim7": [0, 3, 6, 9],
"7dim5": [0, 4, 6, 10],
"aug": [0, 4, 8, 12],
"augMaj7": [0, 4, 8, 11],
"aug7": [0, 4, 8, 10],
"aug9": [0, 4, 10, 14],
"maj": [0, 4, 7, 12],
"maj7": [0, 4, 7, 11],
"maj9": [0, 4, 11, 14],
"minmaj7": [0, 3, 7, 11],
"5": [0, 7, 12],
"6": [0, 4, 7, 9],
"7": [0, 4, 7, 10],
"9": [0, 4, 10, 14],
"b9": [0, 4, 10, 13],
"mM9": [0, 3, 11, 14],
"min": [0, 3, 7, 12],
"min7": [0, 3, 7, 10],
"min9": [0, 3, 10, 14],
"sus4": [0, 5, 7, 12],
"sus2": [0, 2, 7, 12],
"b5": [0, 4, 6, 12],
"mb5": [0, 3, 6, 12],
# Scales begin here
# Based on a very partial list found here:
# https://en.wikipedia.org/wiki/List_of_musical_scales_and_modes
"major": [0, 2, 4, 5, 7, 9, 11],
"minor": [0, 2, 3, 5, 7, 8, 10],
"hminor": [0, 2, 3, 5, 7, 8, 11],
"^minor": [0, 2, 3, 5, 7, 9, 11], # doesn't work
"vminor": [0, 2, 3, 5, 7, 8, 10],
"penta": [0, 2, 4, 7, 9],
"acoustic": [0, 2, 4, 6, 7, 9, 10],
"aeolian": [0, 2, 3, 5, 7, 8, 10],
"algerian": [0, 2, 3, 6, 7, 9, 11, 12, 14, 15, 17],
"superlocrian": [0, 1, 3, 4, 6, 8, 10],
"augmented": [0, 3, 4, 7, 8, 11],
"bebop": [0, 2, 4, 5, 7, 9, 10, 11],
"blues": [0, 3, 5, 6, 7, 10],
"chromatic": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
"dorian": [0, 2, 3, 5, 7, 9, 10],
"doubleharmonic": [0, 1, 4, 5, 8, 11],
"enigmatic": [0, 1, 4, 6, 8, 10, 11],
"flamenco": [0, 1, 4, 5, 7, 8, 11],
"gypsy": [0, 2, 3, 6, 7, 8, 10],
"halfdim": [0, 2, 3, 5, 6, 8, 10],
"harmmajor": [0, 2, 4, 5, 7, 8, 11],
"harmminor": [0, 2, 3, 5, 7, 8, 11],
"hirajoshi": [0, 4, 6, 7, 11],
"hungarianminor": [0, 2, 3, 6, 7, 8, 11],
"hungarianmajor": [0, 3, 4, 6, 7, 9, 10],
"in": [0, 1, 5, 7, 8],
"insen": [0, 1, 5, 7, 10],
"ionian": [0, 2, 4, 5, 7, 9, 11],
"istrian": [0, 1, 3, 4, 6, 7],
"iwato": [0, 1, 5, 6, 10],
"locrian": [0, 1, 3, 5, 6, 8, 10],
"lydianaug": [0, 2, 4, 6, 8, 9, 11],
"lydian": [0, 2, 4, 5, 7, 8, 9, 11],
"majorlocrian": [0, 2, 4, 5, 6, 8, 10],
"majorpenta": [0, 2, 4, 7, 9],
"minorpenta": [0, 3, 5, 7, 10],
"melominup": [0, 2, 3, 5, 7, 9, 11],
"melomindown": [0, 2, 3, 5, 7, 8, 10],
"mixolydian": [0, 2, 4, 5, 7, 9, 10],
"neapolitan": [0, 1, 3, 5, 7, 8, 11],
"octatonic": [0, 2, 3, 5, 6, 8, 9, 11],
"octatonic2": [0, 1, 3, 4, 6, 7, 9, 10],
"persian": [0, 1, 4, 5, 6, 8, 11],
"phrygian": [0, 1, 4, 5, 7, 8, 10],
"prometheus": [0, 2, 4, 6, 9, 10],
"harmonics": [0, 3, 4, 5, 7, 9],
"tritone": [0, 1, 4, 6, 7, 10],
"ukrainian": [0, 2, 3, 6, 7, 9, 10],
"whole": [0, 2, 4, 6, 8, 10],
"yo": [0, 3, 5, 7, 10],
"symetrical": [0, 1, 2, 6, 7, 10],
"symetrical2": [0, 2, 3, 6, 8, 10],
"messiaen1": [0, 2, 4, 6, 8, 10],
"messiaen2": [0, 1, 3, 4, 6, 7, 9, 10],
"messiaen3": [0, 2, 3, 4, 6, 7, 8, 10, 11],
"messiaen4": [0, 1, 2, 4, 6, 7, 8, 11],
"messiaen5": [0, 1, 5, 6, 7, 11],
"messiaen6": [0, 2, 4, 5, 6, 8],
"messiaen7": [0, 1, 2, 3, 5, 6, 7, 8, 9, 11],
# Structures (other musical objects)
"fourths": [0, 4, 10, 15, 20],
"fifths": [0, 7, 14, 21, 28],
"sixths": [0, 9, 17, 26, 35],
"thirds": [0, 4, 8, 12],
"octaves": [0, 12, 24, 36, 48],
}
98 changes: 0 additions & 98 deletions sardine/sequences/LexerParser/Qualifiers.py

This file was deleted.

4 changes: 2 additions & 2 deletions sardine/sequences/LexerParser/TreeCalc.py
@@ -1,6 +1,5 @@
from lark import Transformer, v_args
from typing import Union
from .Qualifiers import qualifiers
from .Utilities import zip_cycle, map_unary_function, map_binary_function
from . import FuncLibrary
from lark.lexer import Token
Expand Down Expand Up @@ -171,7 +170,8 @@ def add_qualifier(self, note, *quali):
quali = list(quali)
quali = "".join([str(x) for x in quali])
try:
return [note + x for x in qualifiers[str(quali)]]
return map_binary_function(lambda x, y: x + y, note,
FuncLibrary.qualifiers[str(quali)])
except KeyError:
return note

Expand Down
2 changes: 1 addition & 1 deletion sardine/sequences/LexerParser/grammars/proto.lark
Expand Up @@ -73,7 +73,7 @@ pattern: sum ("," sum?)* -> return_pattern
// Rules about notes /////////////////////////////////////////////////////////

?col : note
| note "@" name -> add_qualifier
| note "@" name -> add_qualifier

?note0: NOTE -> make_note

Expand Down

0 comments on commit 79bb878

Please sign in to comment.