You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.9 KiB
51 lines
2.9 KiB
(defun create-scd-project ()
|
|
"Create a new project directory with a samples subdirectory and a main.scd file containing SuperCollider code."
|
|
(interactive)
|
|
(let* ((project-path (read-directory-name "Project path: " default-directory))
|
|
(project-name (read-string "Project name: "))
|
|
(full-path (expand-file-name project-name project-path))
|
|
(samples-path (expand-file-name "samples" full-path))
|
|
(main-file (expand-file-name "main.scd" full-path))
|
|
(supercollider-code (format
|
|
"(
|
|
s.options.memSize_(2.pow(20));
|
|
s.waitForBoot({
|
|
~makeBuffers = { |path, event, mono = false|
|
|
var dir = PathName.new(path);
|
|
var contents = dir.entries;
|
|
if (contents.select({ |n| n.isFile }).size > 0)
|
|
{
|
|
var files, bufArray;
|
|
files = contents.select({ |n| n.isFile });
|
|
files = files.select({ |n|
|
|
[\"aif\", \"aiff\", \"wav\"].includesEqual(n.extension)
|
|
});
|
|
if (event[dir.folderName.asSymbol] != nil)
|
|
{ \"duplicate subfolder name ignored\".warn; }
|
|
{
|
|
bufArray = files.collect({ |n|
|
|
if(mono)
|
|
{ Buffer.readChannel(s, n.fullPath, channels:[0]) }
|
|
{ Buffer.read(s, n.fullPath) };
|
|
});
|
|
event[dir.folderName.asSymbol] = bufArray;
|
|
};
|
|
};
|
|
if (contents.select({ |n| n.isFolder }).size > 0)
|
|
{
|
|
var folders = contents.select({ |n| n.isFolder });
|
|
folders.do({ |n| ~makeBuffers.(n.fullPath, event, mono) });
|
|
};
|
|
event;
|
|
};
|
|
~samples = ~makeBuffers.(\"%s\", ());
|
|
});
|
|
)"
|
|
samples-path)))
|
|
(make-directory full-path t)
|
|
(make-directory samples-path t)
|
|
(with-temp-file main-file
|
|
(insert supercollider-code))
|
|
(find-file main-file)
|
|
(save-buffer)))
|