Jump to content

Featured Replies

Posted

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

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.

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy