TomTolleson Posted October 4 Share Posted October 4 Hello, I have a synthdef for a sampler that plays from a buffer based on the list of all files in a folder. It's working fine in SuperCollider: ( SynthDef(\play, { var sig, buf, e; e = PathName.new("/directory_path/*").files.scramble.copyFromStart(20); buf = \buf.ir(0); sig = PlayBuf.ar(1!2, buf, BufRateScale.ir(buf) * \rate.ir(1), doneAction: 2); sig = sig * \amp.ir(0.5); Out.ar(\out.ir(0), sig); }).add; ) Synth(\play, [buf: b, rate: 0.midiratio]); I'm not sure how to build this in OM's sc:synthdef as the examples seem to be focused on oscillator-based sound sources. My first attempt at an OpusModus sc:synthdef sampler (based on the above example) is: (sc:defsynth sampler ((freq 200) (dur 2.0)) (let* (e = PathName.new("/directory_path/*").files.scramble.copyFromStart(20)) (buf = \buf.ir(0)) (sig = PlayBuf.ar(1!2, buf, BufRateScale.ir(buf) * \rate.ir(1), doneAction: 2)) (sig = sig * \amp.ir(0.5)) (sc:out.ar 0 out))) Which evaluates with a bug. I'm sure there are syntax problems but I'm also wondering if there are conceptual switches I could make to understand synthbuilding in OM rather than supercollider. Thanks! THT Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted October 4 Share Posted October 4 Here's an example of sampler design: (sc:defsynth stf-sampler1 ((buffer 0) (rate 1) (start 0) (amp 0.5) (out 0)) (let ( (sig (sc:play-buf.ar 2 buffer (* rate (sc:buf-rate-scale.ir buffer)) :start-pos (* start (sc:buf-frames.ir buffer)) :act :free))) (sc:out.ar out (* amp sig)))) (defparameter sample1 (sc:buffer-read "/Users/stephaneboussuge/Samples/tibetan-singing-bowl.wav" :bufnum 0)) ;(sc:synth :stf-sampler1) ;(sc:synth :stf-sampler1 :rate 0.5) ;(sc:synth :stf-sampler1 :rate 2) (sc:stop) Hope it helps. Best S. TomTolleson 1 Quote Link to comment Share on other sites More sharing options...
TomTolleson Posted October 4 Author Share Posted October 4 Big help! Thank you! THT Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.