-
Notifications
You must be signed in to change notification settings - Fork 1
/
Module.sc
42 lines (34 loc) · 992 Bytes
/
Module.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
Module { var <modulePath, <name, <arguments, <modules, <soundProcess;
var <envir;
*new { arg modulePath, name, arguments, modules;
modulePath = modulePath.standardizePath;
^super.newCopyArgs(modulePath, name, arguments, modules).init.run;
}
init {
envir = ();
}
run { var path;
arguments = arguments.add(\module);
arguments = arguments.add(this);
arguments = arguments.add(\modules);
arguments = arguments.add(modules);
path = PathName(modulePath +/+ name);
if(File.exists(path.fullPath), {
soundProcess = this.runFile(path, "run");
},{("Module"+name+"not installed.").error});
}
stop { var path;
path = modulePath +/+ name;
path = PathName(path);
this.runFile(path, "stop");
}
runFile { arg folder, file; var path;
path = (folder.fullPath+/+file.asString++".scd");
if (File.exists(path), {
^path.load.performKeyValuePairs(\value, arguments);
});
}
free {
this.stop;
}
}