File: __init__.py

package info (click to toggle)
python-renardo-lib 0.9.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,220 kB
  • sloc: python: 10,999; sh: 34; makefile: 7
file content (189 lines) | stat: -rw-r--r-- 5,920 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import os
import sys

# Anything that needs to be updated

from importlib import reload
from renardo_gatherer import get_samples_dir_path

# Check for OS -> mac, linux, win

SYSTEM  = 0
WINDOWS = 0
LINUX   = 1
MAC_OS  = 2

if sys.platform.startswith('darwin'):

    SYSTEM = MAC_OS

    # Attempted fix for some Mac OS users

    try:
        import matplotlib
        matplotlib.use('TkAgg')
    except ImportError:
        pass

elif sys.platform.startswith('win'):

    SYSTEM = WINDOWS

elif sys.platform.startswith('linux'):

    SYSTEM = LINUX

# Directory informations

USER_CWD     = os.path.realpath(".")
FOXDOT_ROOT  = os.path.realpath(__file__ + "/../../")
FOXDOT_ICON  = os.path.realpath(FOXDOT_ROOT + "/Workspace/img/icon.ico")
FOXDOT_ICON_GIF = os.path.realpath(FOXDOT_ROOT + "/Workspace/img/icon.gif")
FOXDOT_HELLO = os.path.realpath(FOXDOT_ROOT + "/Workspace/img/hello.txt")
FOXDOT_STARTUP_PATH = os.path.realpath(FOXDOT_ROOT + "/Custom/startup.py")
# FOXDOT_SND = SAMPLES_FOLDER_PATH / 'foxdot_default'
FOXDOT_SND = get_samples_dir_path()
# FOXDOT_LOOP = SAMPLES_FOLDER_PATH / 'foxdot_default' / '_loop_'
FOXDOT_LOOP  = "_loop_"
# FOXDOT_LOOP  = os.path.realpath(FOXDOT_ROOT + "/../../renardo_samples/_loop_/")

SCLANG_EXEC   = 'sclang.exe' if SYSTEM == WINDOWS else 'sclang'
SYNTHDEF_DIR  = os.path.realpath(FOXDOT_ROOT + "/osc/scsyndef/")
EFFECTS_DIR   = os.path.realpath(FOXDOT_ROOT + "/osc/sceffects/")
ENVELOPE_DIR  = os.path.realpath(FOXDOT_ROOT + "/osc/scenvelopes/")
TUTORIAL_DIR  = os.path.realpath(FOXDOT_ROOT + "/demo/")
RECORDING_DIR = os.path.realpath(FOXDOT_ROOT + "/rec/")

FOXDOT_OSC_FUNC     = os.path.realpath(FOXDOT_ROOT + "/osc/OSCFunc.scd")
FOXDOT_STARTUP_FILE = os.path.realpath(FOXDOT_ROOT + "/osc/Startup.scd")
FOXDOT_BUFFERS_FILE = os.path.realpath(FOXDOT_ROOT + "/osc/Buffers.scd")
FOXDOT_EFFECTS_FILE = os.path.realpath(FOXDOT_ROOT + "/osc/Effects.scd")
FOXDOT_INFO_FILE    = os.path.realpath(FOXDOT_ROOT + "/osc/Info.scd")
FOXDOT_RECORD_FILE  = os.path.realpath(FOXDOT_ROOT + "/osc/Record.scd")
FOXDOT_TEMP_FILE    = os.path.realpath(FOXDOT_ROOT + "/Workspace/tmp/tempfile.txt")

# If the tempfile doesn't exist, create it

if not os.path.isfile(FOXDOT_TEMP_FILE):
    try:
        with open(FOXDOT_TEMP_FILE, "w") as f:
            pass
    except FileNotFoundError:
        pass

def GET_SYNTHDEF_FILES():
    return [os.path.realpath(SYNTHDEF_DIR + "/" + path) for path in os.listdir(SYNTHDEF_DIR)]

def GET_FX_FILES():
    return [os.path.realpath(EFFECTS_DIR + "/" + path) for path in os.listdir(EFFECTS_DIR)]

def GET_TUTORIAL_FILES():
    return [os.path.realpath(TUTORIAL_DIR + "/" + path) for path in sorted(os.listdir(TUTORIAL_DIR))]

# Set Environment Variables

try:
    reload(conf) # incase of a reload
except NameError:
    from renardo_lib.Settings import conf

FOXDOT_CONFIG_FILE  = conf.filename
    
ADDRESS                   = conf.ADDRESS
PORT                      = conf.PORT
PORT2                     = conf.PORT2
FONT                      = conf.FONT
SC3_PLUGINS               = conf.SC3_PLUGINS
MAX_CHANNELS              = conf.MAX_CHANNELS
GET_SC_INFO               = conf.GET_SC_INFO
USE_ALPHA                 = conf.USE_ALPHA
ALPHA_VALUE               = conf.ALPHA_VALUE
MENU_ON_STARTUP           = conf.MENU_ON_STARTUP
TRANSPARENT_ON_STARTUP    = conf.TRANSPARENT_ON_STARTUP
RECOVER_WORK              = conf.RECOVER_WORK
CHECK_FOR_UPDATE          = conf.CHECK_FOR_UPDATE
LINE_NUMBER_MARKER_OFFSET = conf.LINE_NUMBER_MARKER_OFFSET
AUTO_COMPLETE_BRACKETS    = conf.AUTO_COMPLETE_BRACKETS
CPU_USAGE                 = conf.CPU_USAGE
CLOCK_LATENCY             = conf.CLOCK_LATENCY
FORWARD_ADDRESS           = conf.FORWARD_ADDRESS
FORWARD_PORT              = conf.FORWARD_PORT
SAMPLES_PACK_NUMBER       = conf.SAMPLES_PACK_NUMBER

if conf.SAMPLES_DIR is not None and conf.SAMPLES_DIR != "":

    FOXDOT_SND = os.path.realpath(conf.SAMPLES_DIR)

def get_timestamp():
    import time
    return time.strftime("%Y%m%d-%H%M%S")

# Name of SamplePlayer and LoopPlayer SynthDef

class _SamplePlayer:
    names = ('play1', 'play2',)
    def __eq__(self, other):
        return other in self.names
    def __ne__(self, other):
        return other not in self.names

class _LoopPlayer:
    names = ("loop", "gsynth", 'stretch')
    def __eq__(self, other):
        return other in self.names
    def __ne__(self, other):
        return other not in self.names

class _MidiPlayer:
    name = "MidiOut"
    def __eq__(self, other):
        return other == self.name
    def __ne__(self, other):
        return other != self.name

SamplePlayer = _SamplePlayer()
LoopPlayer   = _LoopPlayer()
MidiPlayer   = _MidiPlayer()


# OSC Information

OSC_MIDI_ADDRESS = "/foxdot_midi"

# Colours

class COLOURS:
    plaintext       = conf.plaintext
    background      = conf.background
    functions       = conf.functions
    key_types       = conf.key_types
    user_defn       = conf.user_defn
    other_kws       = conf.other_kws
    comments        = conf.comments
    numbers         = conf.numbers
    strings         = conf.strings
    dollar          = conf.dollar
    arrow           = conf.arrow
    players         = conf.players
    kick            = conf.kick
    various         = conf.various
    vocal           = conf.vocal
    bell            = conf.bell
    hihat           = conf.hihat
    clap            = conf.clap
    snap            = conf.snap
    shaker          = conf.shaker
    tambourine       = conf.tambourine
    crash           = conf.crash
    cymbal          = conf.cymbal
    soundfx         = conf.soundfx
    tom             = conf.tom
    noise           = conf.noise
    ride            = conf.ride
    perc            = conf.perc
    snare           = conf.snare
    rim             = conf.rim
    loops           = conf.loops
    default         = conf.default
    text1           = conf.text1
    text2           = conf.text2