def __play_music(self, dictionary):
     if time.clock() - self.previous_time > 15:
         self.__set_root_and_scale()
     FoxDot.r0 >> FoxDot.play("X...o...X..Xo...", sample=1, amp=1.2)
     FoxDot.r1 >> FoxDot.play(dictionary["consonants"], amp=0.8)
     notes = []
     for c in dictionary["pos"]["chords"]:
         notes.append(c)
     durations = []
     for d in dictionary["pos"]["chord_durations"]:
         durations.append(d)
     FoxDot.c1 >> FoxDot.scatter(notes, dur=durations)
     FoxDot.b1 >> FoxDot.dirt(dictionary["pos"]["bass_line"],
                              dur=dictionary["pos"]["bass_durations"])
예제 #2
0
    def __init__(self):
        import FoxDot

        self.lang  = FoxDot

        try:

            self.keywords = list(FoxDot.get_keywords()) + list(FoxDot.SynthDefs) + ["play"]

        except AttributeError:

            self.keywords = ['>>']

        self.re["tag_bold"] = compile_regex(self.keywords)
예제 #3
0
import threading 
import time
import time
import random
import gpt3
from pynput.keyboard import Controller, Key
import FoxDot


keyboard = Controller()
foxdotcode = FoxDot.FoxDotCode()
running, queue = [], []

prompt = '''play("si-$0-ttt-fff-iii", delay=0.05, dur=0.16, amp=[1,0.5,0.5,0.25,1])
space([1,[2,5,5,5,8]], dur=[4,4,4,2], oct=4, amp=linvar([1,3],28), drive=0.01, sus=8, chop=var([0,4],[12,6]))
play('-', sample=PRand(3), amp=2)
marimba(var([0,1],[3,4,12,3]), amp=[0.5,0.25,0.5,0.75], vib=PRand(5)/5)
bass(P[0,1,3,4,0].stutter(12), dur=[0.5,0.5,0.5,0.5,1], amp=1)
karp(P[[5,5,5,6,6],[4,4,4,6,6]].stutter(16) + var([0,PRand(3)],[3,4]), dur=0.25, oct=5, sus=3, blur=2, amp=linvar([0.25,0.5],16))
pulse(8 + var([0,2],[4,8]), amp=([0,1],[48,16]))
glass(oct=6, rate=linvar([-2,2],16), shape=0.5, amp=1.5, room=0.5)
pasha(dur=12, oct=6, vib=2, tremolo=3, amp=1)
play("@", dur=1/4, sample=P[:8].rotate([0,1,3]), rate=4, pan=-0.5)
dbass(dur=PDur(3,8), sus=2, chop=4, shape=PWhite(0,1/2), pan=PWhite(-1,1)).sometimes("offadd", 4) + var([0,2],4)
space([7,6,4,P*(2,1),0], dur=8, pan=(-1,1))
play("x-o{-[-(-o)]}", sample=0).every([28,4], "trim", 3)
blip([0, 2, [0, 1, 2]], dur=8, sus=4, room=1, oct=6) + [0,0,0,P*(2,4,3,-1)]
pluck([0, 3, 2], dur=[1/2, 1], oct=4)
pads([0, 3, 7, 8, -2], dur=[4, 8], oct=5, amp=0.7)
play("(X )( X)N{ xv[nX]}", drive=0.2, lpf=var([0,40],[28,4]), rate=PStep(P[5:8],[-1,-2],1)).sometimes("sample.offadd", 1, 0.75)
play("e", amp=var([0,1],[PRand(8,16)/2,1.5]), dur=PRand([1/2,1/4]), pan=var([-1,1],2))
예제 #4
0
import FoxDot as fd

fd.Clock.bpm = 110
fd.Root.default.set("Gb")

print(fd.SynthDefs)

fd.p1 >> fd.SynthDef('bass')([3, -1, 3, 4, 2, 0, 3, 4, 5, 0],
                             dur=[1.25, 0.25, 0.5, 2, 2, 2, 2, 2, 2, 2],
                             amp=0.5)

fd.p2 >> fd.saw(
    [4, 0, 0, 0, 1, 4, 3, 2, 1, 0, 0, 2, 1, 0, 0, 4, 3, 2, 3, 2, 1] +
    [4, 0, 0, 0, 1, 4, 3, 2, 1, 0, 0, 2, 1, 0, -1, 0],
    dur=[
        1.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1.5, 1, 0.5, 1, 0.5, 0.5, 1,
        0.5, 0.5, 0.5, 1, 1
    ] +
    [1.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1.5, 1, 0.5, 1, 0.5, 0.5, 4.5],
    amp=0.5)

fd.p3 >> fd.viola(
    [2, 1, 2, 1, 0, 1, 3, 2, 0], dur=[4, 2, 1, 1, 2, 2, 1, 1, 2], amp=0.5)

fd.d1 >> fd.play("x o [xo]xo( =)")

fd.p1.stop()
fd.p2.stop()
fd.p3.stop()
fd.d1.stop()
예제 #5
0
    def __init__(self):

        # 1. Try importing directly

        try:
            # Try importing from install

            try:

                import FoxDot

            except ImportError:

                # Import locally if not found

                from . import FoxDot

            self.lang = FoxDot

            self.imported = True

            try:

                self.keywords = list(FoxDot.get_keywords()) + list(
                    FoxDot.SynthDefs) + ["play"]

            except AttributeError:

                self.keywords = ['>>']

        except (ImportError, FileNotFoundError):

            Interpreter.__init__(self, self.path)

            self.imported = False

            self.keywords = [
                'classmethod', 'Clock', 'rFloorDiv', 'any', 'type', 'dict',
                'max_length', 'sorted', 'staticmethod', 'or',
                'loop_pattern_method', 'format', 'super', 'globals', 'rXor',
                'inf', 'PTree', 'isinstance', 'callable', 'Scale', 'PRange',
                'Div', 'PRand', 'pattern_depth', 'unicode', 'chr',
                '__import__', 'next', 'Or', 'EuclidsAlgorithm', 'FloorDiv',
                'memoryview', 'setattr', 'sum', 'import', 'sliceToRange',
                'PatternFormat', 'modi', 'Pow', 'PulsesToDurations', 'True',
                'issubclass', 'PWalk', 'cmp', 'PDelay', 'list', 'dir', 'len',
                'enumerate', 'Format', 'PTri', 'reduce', 'reload', 'PEuclid',
                'PIndex', 'PFibMod', 'divmod', 'PSquare', 'unichr', 'round',
                'map', 'long', 'Group', 'linvar', 'mapvar', 'PPairs', 'with',
                'Mod', 'None', 'locals', 'basestring', 'P10', 'PRhythm',
                'tuple', 'from', 'not', 'class', 'try', 'hasattr', 'compile',
                'PSum', 'Pvar', 'filter', 'loop_pattern_func', 'PJoin', 'bool',
                'Root', 'eval', 'for', 'Server', 'Add', 'PSq', 'str',
                'PStutter', 'get_inverse_op', 'var', 'repr', 'PChain',
                'reversed', 'hex', 'Nil', 'rSub', 'equal_values', 'if', 'all',
                'rAdd', 'return', 'PZip', 'global', 'else', 'Samples', 'print',
                'PWhite', 'file', 'ord', 'rOr', 'range', 'complex', 'PwRand',
                'PEuclid2', 'group_modi', 'Get', 'PStretch', 'asStream',
                'lambda', 'PSine', 'PDur', 'self', 'False', 'rGet', 'except',
                'PQuicken', 'zip', 'hash', 'PAlt', 'PatternContainer', 'help',
                'pow', 'PEq', 'in', 'PStep', 'iter', 'is', 'GeneratorPattern',
                'ClassPatternMethod', 'min', 'DominantPattern', 'Mul', 'when',
                'metaPattern', 'rMod', 'input', 'object', 'def', 'POperand',
                'elif', 'while', 'PNe', 'PShuf', 'xrange', 'getattr',
                'get_expanded_len', 'rPow', 'bytearray', 'asPattern', 'expvar',
                'Pattern', 'EmptyItem', 'vars', 'PZip2', 'delattr',
                'frozenset', 'property', 'execfile', 'deepcopy', 'stdout',
                'Xor', 'int', 'Sub', 'PxRand', 'PatternMethod', 'as', 'float',
                'set', '\\A\\s*@.+', 'max', 'dots', 'patternclass', 'LCM',
                'open', 'raw_input', 'PBeat', 'PGroup', 'StaticPatternMethod',
                'Convert', 'P', 'and', 'abs', 'bin', 'slice', 'id', 'rDiv',
                '>>'
            ]

        self.keyword_regex = compile_regex(self.keywords)

        self.re = {
            "tag_bold": self.find_keyword,
            "tag_italic": self.find_comment
        }
예제 #6
0
#!/usr/bin/python
"""
    Copyright Ryan Kirkbride 2015

"""

if __name__ == "__main__":

    import FoxDot
    FoxDot.start()
예제 #7
0
import FoxDot as fd

fd.Root.default.set("Ab")
fd.Clock.bpm = 90

sabi_notes = \
    [0, 2, 1, 0, 1, 2, 3, 4, 0, -1, 0,
     4, 7, 0, 4, 3, 2, 0, 2, 3, 4,
     -3, 0, 1, 0, 1, 2, 3, 4, 7, 6, 4,
     0, 4, 7, 1, 2, 3, 0, 0]
sabi_dur = \
    [1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 0.5, 0.5,
     1.5, 0.5, fd.rest(0.5), 0.5, 0.5, 0.5, fd.rest(0.5), 0.5, 0.5, 2.5,
     1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 1.25, 0.75, 0.5,
     fd.rest(1), 1, 1, 0.5, 0.5, 0.75, 0.75, 2.5]

bass_notes = \
    [0, 4, 5, 3, 0, 4, 3, 10,
     0, 4, 5, 3, 0, 4, 3, 2, 1]
bass_dur = \
    [2, 2, 2, 2, 2, 2, 2, 2,
     2, 2, 2, 2, 2, 2, 1, 1, 2]

guitar_notes = \
    [fd.P(0, 2, 4, 8), fd.P(4, 6, 8), fd.P(5, 7, 9), fd.P(3, 5, 7),
     fd.P(0, 2, 4, 8), fd.P(4, 6, 8), fd.P(3, 5, 7), fd.P(3, 5, 7),
     fd.P(0, 2, 4, 8), fd.P(4, 6, 8), fd.P(5, 7, 9), fd.P(3, 5, 7),
     fd.P(0, 2, 4, 8), fd.P(4, 6, 8),
     fd.P(3, 5, 7), fd.P(0, 2, 4), fd.P(4, 6, 8)]
guitar_dur = \
    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2]
예제 #8
0
import FoxDot as fd

fd.Root.default.set("E")
fd.Clock.bpm = 120

main_melody_notes = [4, 1, 0, -3, -1, 0, 2, 1, 0, -1]
main_melody_dur = [1.5, 1.5, 1.5, 1.5, 2.0, 1.5, 1.5, 1.5, 1.5, 2.0]

print(fd.FxList)

print(fd.SynthDefs)

print(fd.SynthDef('play2'))



fd.m1 >> fd.SynthDef('nylon')(
    main_melody_notes, dur=main_melody_dur, amp=0.2, echo=1.0, delay=(0, 1.0))
fd.m2 >> fd.SynthDef('saw')((-3, 0), dur=8, amp=0.5, lpf=2000)
fd.d1 >> fd.play("<- - - - - - - - ><x  xo  x xx o   >", sample=3)

fd.d2 >> fd.play(" x xo")

fd.m1.stop()
fd.m2.stop()
fd.d1.stop()
fd.d2.stop()
 def __init__(self):
     FoxDot.Clock.bpm = 92
     self.key = ([0, "minor"], [-5, "minor"], [5, "minor"], [-2, "major"],
                 [3, "major"], [-4, "major"], [1, "minor"])
     FoxDot.Root.default.set(self.key[0][0])
     FoxDot.Scale.default.set(self.key[0][1])
     self.previous_time = time.clock()
     self.duration_to_bass_rhythm_dictionary = {
         3: [
             0.25, 0.25,
             FoxDot.rest(0.5), 0.25,
             FoxDot.rest(0.25), 0.5, 0.25, 0.75
         ],
         4: [
             0.25, 0.25,
             FoxDot.rest(0.5), 0.25,
             FoxDot.rest(0.25), 0.25, 0.25, 0.5, 0.25
         ],
         6: [
             0.25, 0.25,
             FoxDot.rest(0.5), 0.25,
             FoxDot.rest(0.25), 0.25, 0.5, 0.75
         ],
         8: [1, 1, 0.25, 0.25,
             FoxDot.rest(0.25), 0.25, 0.25, 0.25]
     }
     self.letter_to_rhythm_dictionary = {
         "B": "$",
         "C": "E",
         "D": "%",
         "F": "G",
         "G": "A",
         "J": "L",
         "K": "#",
         "P": "P",
         "Q": "r",
         "S": "=",
         "T": "n",
         "V": "V",
         "X": "H",
         "Z": "W",
         "H": ".",
         "b": "D",
         "c": "k",
         "d": "i",
         "f": "l",
         "g": "M",
         "j": "j",
         "k": ":",
         "p": "p",
         "q": "T",
         "s": "~",
         "t": "-",
         "v": "R",
         "x": "h",
         "z": "g",
         "h": ".",
         ".": "X",
         "\"": "[xx]",
         "'": "v",
         ",": "v",
         ";": "[vx]",
         ":": "[xX]",
         "č": "S",
         "Þ": "@",
         "ṣ": "/",
         "ɸ": "\\\\",
         "ç": "I",
         "ð": "e",
         "ʃ": "o",
         " ": ""
     }
     # miscellaneous
     self.pos_to_chord_dictionary = {
         "``": 0,
         "''": 0,
         "$": 0,
         "(": 0,
         ")": 0,
         ",": 0,
         "--": 0,
         ".": 0,
         ":": 0,
         "CD": 1,
         "SYM": 2,
         "LS": 2,
         "#": 2,
         # nouns
         "NN": 3,
         "NNP": 4,
         "NNPS": 5,
         "NNS": 6,
         # genitive marker and pronouns
         "POS": 7,
         "PRP": 8,
         "PRP$": 9,
         "WP": 10,
         "WP$": 11,
         # adjectives, determiners
         "JJ": 12,
         "JJR": 13,
         "JJS": 14,
         "WDT": 15,
         "DT": 16,
         "PDT": 17,
         # adverbs
         "RB": 18,
         "RBR": 19,
         "RBS": 20,
         "WRB": 21,
         # verbs
         "VB": 22,
         "VBD": 23,
         "VBG": 24,
         "VBN": 25,
         "VBP": 26,
         "VBZ": 27,
         # fillers
         "TO": 28,
         "RP": 29,
         "EX": 30,
         # conjunction, modal auxiliary, prep
         "CC": 31,
         "IN": 32,
         "MD": 33,
         # foreign words and interjections
         "FW": 34,
         "UH": 35
     }
     self.pos_to_chord_bass_dictionary = {
         "``": 0,
         "''": 0,
         "$": 0,
         "(": 0,
         ")": 0,
         ",": 0,
         "--": 0,
         ".": 0,
         ":": 0,
         "CD": 0,
         "SYM": 0,
         "LS": 0,
         "#": 0,
         # nouns
         "NN": -4,
         "NNP": 4,
         "NNPS": 5,
         "NNS": 5,
         # genitive marker and pronouns
         "POS": -4,
         "PRP": 4,
         "PRP$": -4,
         "WP": 4,
         "WP$": -4,
         # adjectives, determiners
         "JJ": 0,
         "JJR": 1,
         "JJS": -1,
         "WDT": 2,
         "DT": 3,
         "PDT": 3,
         # adverbs
         "RB": -2,
         "RBR": -2,
         "RBS": 0,
         "WRB": 5,
         # verbs
         "VB": -3,
         "VBD": 3,
         "VBG": -3,
         "VBN": -3,
         "VBP": -3,
         "VBZ": 3,
         # fillers
         "TO": 4,
         "RP": -2,
         "EX": -2,
         # conjunction, modal auxiliary, prep
         "CC": -2,
         "IN": -2,
         "MD": -4,
         # foreign words and interjections
         "FW": 0.5,
         "UH": -0.5
     }
     self.chord_bass_to_bass_line_dictionary = {
         0: [0, 0, 1, -1, 0, -4],
         1: [1, 1, 1, 1, 0, 1, 4],
         2: [2, 2, 2, 2, 1, 9, 8],
         3: [3, 3, 4, 2, 3, 0, 1],
         4: [4, 4, 2, 2, 4, 0, 1],
         5: [5, 5, 3, 4, 5, 1],
         -1: [-1, -1, -3, -2, -1, 1],
         -2: [-2, -1, -4, 0, -1, 1],
         -3: [-3, -3, -3, -1],
         -4: [-4, -4, -4, 1, 2],
         0.5: [0.5, 1.5, 2.5, 1.5, -0.5],
         -0.5: [-0.5, 1.5, 2.5, 1.5, 0.5]
     }
     self.chord_to_voicing_dictionary = {
         # symbols
         0: (1, 2, 5),
         1: (1, 2, 5, 6),
         2: (-3, 0, 2, 4, 6),
         # nouns
         3: (4, 5, 6, 8),
         4: (4, 5, 6, 9),
         5: (0, 4, 5, 9),
         6: (0, 2, 4, 5),
         # genitive marker and pronouns
         7: (-1, 0, 1, 5),
         8: (-1, 0, 1, 5, 6),
         9: (-1, 1, 5, 6, 8),
         10: (-1, 0, 2, 4),
         11: (-1, 0, 2, 4, 5),
         # adjectives, determiners
         12: (0, 2, 4, 6, 8, 10),
         13: (1, 3, 5, 7, 9, 11),
         14: (-1, 1, 3, 5, 7, 9),
         15: (2, 4, 6, 8, 10, 12),
         16: (3, 5, 7, 9, 11, 13),
         17: (3, 5, 7, 8, 9),
         # adverbs
         18: (-5, -3, 0, 1, 2, 3, 4),
         19: (-5, -3, 0, 1),
         20: (-5, -3, 0, 2, 5),
         21: (-5, -3, 0, 2, 5, 6, 11),
         # verbs
         22: (-7, 0, 1, 2, 6),
         23: (-7, 0, 1, 2, 6, 8),
         24: (-7, 0, 1, 2, 6, 9),
         25: (-7, -1, 1, 2, 6, 7),
         26: (-7, -3, 1, 4, 6, 7),
         27: (-7, -3, 0, 2, 4, 6, 10),
         # fillers
         28: (3, 4, 5),
         29: (3, 4, 5, 9),
         30: (3, 4, 5, 10),
         # conjunctions, modal auxiliary, and prepositions
         31: (5, 6, 7),
         32: (5, 6, 7.5, 9),
         33: (5, 6, 7, 10),
         # foreign words and interjections
         34: (0.5, 2.5, 3.5, 5.5, 9.5),
         35: (-0.5, 2.5, -3.5, 5.5, 12.5)
     }
예제 #10
0
import FoxDot as fd
import numpy as np

fd.Clock.bpm = 90
fd.Root.default.set("C")

fd.SynthDefs

fd.l1 >> fd.saw([0, -2, 5, 4, 3, 4, 2, 1, 3, 2, 1],
                dur=[fd.rest(2), 1, 1, 2, 1, 1, 2, 2, 2, 1, 1])
fd.l2 >> fd.fuzz([0, -2, 5, 4, 3, 4, 2, 1, 3, 2, 1],
                 dur=[fd.rest(2), 1, 1, 2, 1, 1, 2, 2, 2, 1, 1],
                 amp=0.2,
                 oct=6)

fd.b1 >> fd.bass(
    [-4, 0, 1, 0, 0, -4, 0, -4, -5, -3, -2.5, -2, -5, -2, -5.5] +
    [-6, -4, -3.5, -3, -3, -3, 0, -3, -7, -7, -7, -3.5, -3.5, 0, -3.5],
    dur=[
        1, 0.5, 0.5, 1, 0.33, 0.17,
        fd.rest(0.33), 0.17, 1, 0.5, 0.5, 1, 0.33, 0.17, 0.5
    ],
    amp=0.6,
    oct=6)

fd.p1 >> fd.orient([(-7 - 4, 0, 2, 5), (-7 - 5, -1, 1, 4),
                    (-7 - 3, -3, 0.5, 3)] + [(-7 - 6, -4, -2, 0, 2),
                                             (-7 - 4, -4, -2, 0, 1),
                                             (-7 - 7, -3, -1.5, 1, 3),
                                             (-7 - 4.5, -4.5, -1.5, 0, 2)],
                   dur=[4, 2, 2, 2, 2, 2, 2],
예제 #11
0
import FoxDot as fd
import numpy as np

fd.Clock.bpm = 170
fd.Root.default.set("C")

fd.SynthDefs


fd.d1 >> fd.play("x    x  ")
fd.d2 >> fd.play("= = = = ")
fd.d3 >> fd.play("--------")
fd.d4 >> fd.play("  o ", sample=3)
fd.d5 >> fd.play("  -[ -][ -] - ", sample=2)

fd.d1.stop()
fd.d2.stop()
fd.d3.stop()
fd.d4.stop()
fd.d5.stop()
예제 #12
0
import FoxDot as fd

fd.Clock.bpm = 130
fd.Root.default.set("C")

fd.SynthDefs

fd.r1 >> fd.dirt([0, 3, 1.5, 3, 4, 1.5, 0, 0, 0, 1.5, 0, -1.5, 1.5, 0, 0],
                 dur=[
                     fd.rest(1), 0.5, 0.5, 1, 0.5, 0.5,
                     fd.rest(0.5), 3.5,
                     fd.rest(2), 0.5, 0.5, 0.5, 0.5,
                     fd.rest(0.5), 3.5
                 ],
                 oct=7,
                 amp=0.7)
fd.r2 >> fd.fuzz([0, 3, 1.5, 3, 4, 1.5, 0, 0, 0, 1.5, 0, -1.5, 1.5, 0, 0],
                 dur=[
                     fd.rest(1), 0.5, 0.5, 1, 0.5, 0.5,
                     fd.rest(0.5), 3.5,
                     fd.rest(2), 0.5, 0.5, 0.5, 0.5,
                     fd.rest(0.5), 3.5
                 ],
                 oct=5,
                 amp=1.0)

fd.b1 >> fd.sawbass([
    -4, 0, 0, 1.5, 0, 4, 3, -1.5, -1, 0, 0, -1.5, 0, 1.5, -1.5, 0, -1.5, -3,
    -3.5
],
                    dur=[
예제 #13
0
import FoxDot as fd
import numpy as np

fd.Clock.bpm = 90
fd.Root.default.set("C")

fd.SynthDefs

bp = [-3, -3, -3, -3, 0, 0, 3, 3, 0, 0]

fd.l1 >> fd.pulse([
    0, -2, -2, 3, 2, 1, 0, 1, 2, -3, 0, -3, -3, -2, -2, 0, 0, 0, 0, -3, -3, -2,
    -2, 0, 0, 0
],
                  dur=[
                      fd.rest(1), 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 0.5, 2,
                      fd.rest(0.25), 0.25, 0.5, 0.5, 0.5, 0.5, 0.5,
                      fd.rest(1.0),
                      fd.rest(0.25), 0.25, 0.5, 0.5, 0.5, 0.5, 0.5,
                      fd.rest(1.0)
                  ],
                  oct=5)

fd.b1 >> fd.jbass(
    [p - i for i in range(4) for p in bp],
    dur=[0.25, 0.25, 0.25, 0.25, 0.5, 0.5, 0.5, 0.5,
         fd.rest(0.5), 0.5] * 4,
    amp=0.6,
    oct=6)

fd.p1 >> fd.bell([0, (0, 3, 5), 0] * 4 + [0, (-1, 2, 4), 0] * 4 +
                 [0, (-2, 1, 3), 0] * 4 + [0, (-3, 0, 2), 0] * 4,