Skip to content
View in the app

A better way to browse. Learn more.

Opusmodus

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

sc:Synthdef for sampler

Featured Replies

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.

  • Author

Big help! Thank you!

 

THT

 

Create an account or sign in to comment


Copyright © 2014-2026 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.