Giter Club home page Giter Club logo

samplebank.sc's Introduction

SampleBank.sc

A simple sample bank for managing buffers in SuperCollider.

Usage

// Set up SampleBank by pointing it to your sample bank directory
SampleBank.loadAll(thisProcess.platform.userHomeDir ++ "/Samples/");

// Buffers are created automatically at server boot
s.boot;

// Print on post window the list of sample banks
SampleBank.displayList;
/*
bd [3]
808 [10]
909 [9]
mark [13]
...
*/

// For example, you can use buffers directly like this
SampleBank.buffers[\bd][0].play
// also with the .get method:
SampleBank.get(\bd, 1)

// The index parameter wraps around if trying to play a non-existant buffer in
// bank.  For example, "bd" has 3 samples only, so trying to read sample 4 will
// give you sample 0:
SampleBank.get(\bd, 3) == SampleBank.get(\bd, 0)
SampleBank.get(\bd, 4) == SampleBank.get(\bd, 1)
// ...

// SampleBank adds a new Event type called \sample, which will try to add a \buf
// key automatically based on some other keys.
//
// Suppose you have this Synthdef for playing mono samples
(
SynthDef(\vplaym, { |out=0, buf=0, rate=1, amp=0.5, pan=0, atk=0.01, rel=1, pos=0|
	var sig, env;
	sig = Pan2.ar(PlayBuf.ar(1, buf, BufRateScale.ir(buf) * rate, 1, BufDur.kr(buf) * pos * s.sampleRate, doneAction: 2), pan);
	env = EnvGen.ar(Env.linen(0.0, rel, 0.0, 1));
	sig = sig * env;
	sig = sig * amp;
	Out.ar(out, sig)
}).add;
)

// You can now provide \bank and \index, and the \buf argument will be fetched
// automatically:
(
x = Pbind(\instrument, \vplaym,
	\type, \sample,
	\bank, Pseq([\klang, \Sutra, \mark], inf),
	\index, Pshuf((0..15), inf),
	\dur, 0.125).play;
)
x.stop;

// Also, there's the \sample key, which will be a string containing both bank name and
// index separated by a colon (`:`):
(
x = Pbind(\instrument, \vplaym,
	\type, \sample,
	\sample, Pseq(["klang:3", "Sutra:1", "Sutra"], inf),
	\dur, 0.125).play
)

// Finally, you can free buffers. This will also stop loading buffers on server boot.
SampleBank.free

Install

Open a new document on your SC IDE and type:

Quarks.install("https://github.com/munshkr/SampleBank.sc");

When quark is installed, recompile your class library. Go to Language menu, Recompile class library, or hit Ctrl+Shift+L.

To do

  • Allow user to refresh and create buffers when new samples or banks have been added at runtime.
  • When refreshing, delete buffers if file is not found anymore.
  • Allow user to load specific banks only

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/munshkr/SampleBank.sc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

LICENSE

See LICENSE

samplebank.sc's People

Contributors

munshkr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

lvm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.