Last active
December 10, 2015 01:58
-
-
Save tgck/4363860 to your computer and use it in GitHub Desktop.
loadSoundFiles2Buffer in SuperCollider(3.5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// loadSoundFiles2Buffer.rtf | |
// ディレクトリ指定で取得したファイルをバッファにロードするサンプル | |
// 2012.12.23 tgck | |
// | |
s = Server.default; s.boot; | |
f = "find ~/Desktop/ -name '*aiff' | head".unixCmdGetStdOut; | |
f = f.split($\n); | |
f.do ({ arg item, i; b = [Buffer.read(s, f.at(i))];}); | |
// confirm file list | |
f.do ({ arg item, i; item.postln;}); | |
// define our Player | |
b = Buffer.alloc(s, 10*44100, 1); // bufnumが参照できないとSynthDefが転けるのでおまじないとして | |
( | |
SynthDef("player", | |
{ arg out = 0, bufnum = 0, rate = 1, trigger = 1, startPos = 0.05, loop = 1; | |
Out.ar( out, | |
Pan2.ar(PlayBuf.ar( 1, | |
bufnum, | |
BufRateScale.kr(bufnum) * rate, | |
trigger, | |
BufFrames.kr(b.bufnum) * startPos, | |
loop), | |
0.0)) | |
}).send(s); | |
) | |
// Test our Buffer | |
a = Synth("player"); | |
a.set("bufnum", b.bufnum.rand); | |
// done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment