-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColliding.sc
executable file
·98 lines (82 loc) · 2.39 KB
/
Colliding.sc
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
/*
Colliding, a simple SuperCollider environment for learning and live coding
(c) Gerard Roma, 2013-2019
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
Colliding{
classvar <>textFont;
classvar <>guiFont;
classvar <>symbolFont;
classvar <instanceId = 0;
classvar <maxTabs = 8;
var <id, >tabId;
var <>gui, <>server, <controller;
var <>buffers, <>sounds;
var <projectPath;
var <mode = 0;
var <sclangPath;
var <config;
*new{|configFile|
^super.new.init(configFile);
}
tabId{
tabId = tabId + 1;
^tabId;
}
init{|configFile|
config = CollidingConfig.new(configFile);
textFont = Font("Verdana", 24);
guiFont = Font("Arial", 12);
symbolFont = Font("Arial", 28);
tabId = 0;
instanceId = instanceId + 1;
id = instanceId;
server = Server.internal;
Server.default = Server.internal;
server.waitForBoot({gui.makeScopeDef});
buffers = Array.fill(8);
sounds = Array.fill(8);
gui = CollidingGUI.new.init(this);
if(config.sclangPath.isEmpty){
sclangPath = this.getSCLangPath;
}{
sclangPath = config.sclangPath;
};
if(config.freesoundKey.isEmpty.not){Freesound.token = config.freesoundKey};
if(config.useNodeProxy) {mode = 1};
}
getSCLangPath{
var path = Platform.resourceDir ++ Platform.pathSeparator;
if (thisProcess.platform.name == \osx){
path = path ++"../MacOS/sclang";
}{
path = path ++ "sclang";
};
^path;
}
post{|str|
gui.tabs[gui.tabView.activeTab.index].post(str);
}
loadBuffer{|idx,path,doneFunc|
sounds[idx] = SoundFile.openRead(path);
if (sounds[idx].notNil){
buffers[idx] = Buffer.read(server, path, bufnum:idx, action:doneFunc);
}{
"Could not read file".postln;
}
}
projectPath_{|path|
gui.win.name = PathName(path).folderName;
projectPath = path;
}
}