Sample:
Filter:
Classes (extension) | Libraries > crucial > Buffers | Libraries > crucial > SoundFiles

Sample : AbstractSample : BufferProxy : Object
ExtensionExtension

a soundfile small enough to be loaded in memory
Source: Sample.sc

Description

This class can be used as an argument to a Patch. It will take care of all the troubles of loading, allocating, measuring, and even beat synchronizing of a small sound file. It will not clear the copyright.

It will not play by itself, its just like a Buffer.

But within the Instr function you can use many useful methods on your Sample object such as .bufDurKr

Notice that the path to the sample is relative to the sounds/ directory, not to SuperCollider's own directory. You can set the Sample.soundsDir to the directory of your choice (eg, ~/Library/Sounds/ or ~/Sounds/ ). Copy a11wlk01.wav to your own sounds directory so you can still play examples.

Class Methods

Sample.new(soundFilePath, tempo, startFrame: 0, endFrame: -1)

Arguments:

soundFilePath
tempo

If the sample is a rhythmic loop then this specifies what the tempo of that loop is. This can then be used for beat sync or beat splicing calculations. If the sample is an even 4 or 8 beats then it will do a fairly good job of guessing the tempo.

startFrame
endFrame

Sample.newClear(numFrames: 44100, numChannels: 1, sampleRate: 44100.0)

Arguments:

numFrames
numChannels
sampleRate

Sample.roster: METHOD NOT FOUND!

Arguments:

perItems
globals

Inherited class methods

Instance Methods

.soundFile

.soundFile = value

.beats

.beats = bt

number of beats in the sample if its a rhythmic loop. this co-depends on the tempo setting.

Arguments:

bt

.tempo

.tempo = tm

tempo of the musical content of the sample if its a rhythmic loop. this co-depends on the beats setting.

Arguments:

tm

.beatsize

number of samples per beat based on beat or tempo setting.

.end

signal.size - 1 the last indexable position in the signal

.storeArgs

.printOn(stream)

Arguments:

stream

.load(thing, tempo, argStartFrame: 0, argEndFrame: -1)

Arguments:

thing
tempo
argStartFrame
argEndFrame

.prLoad(thing, t)

Arguments:

thing
t

.reloadBuffer

.bpm

.bpm = bpm

Arguments:

bpm

.calculate

.guessBeats(min: 80, max: 140)

Arguments:

min
max

.initForSynthDef(synthDef, argi)

Arguments:

synthDef
argi

.pchRatioKr

.getTempoBus

.beatsizeIr

.sampleTempoIr

.prepareToBundle(group, bundle)

Arguments:

group
bundle

.guiClass

.play

.asSignal(channel)

Arguments:

channel

.addToDefName(stream)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/crucial-library/Instr/instrSupport.sc

Arguments:

stream

.spec

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/crucial-library/Instr/instrSupport.sc

.rand: METHOD NOT FOUND!

Inherited instance methods

Examples

You can swap the samples while playing. Click on the name of the sample (in black font) and browse for a stereo sample. Then start play, and you can browse for more and change it while playing.

The def name was : help-SampleO8NEut

You can build up a library of Instr functions and exploit them with Patch.

Patch object:

You can save it to disk and reload it the settings will be restored.

methods usable inside an Instr function.

These methods will work inside an Instr but not when used in a normal SynthDef.

bufnumIr at the start of the synth, this will get the dynamic bufferID of your Sample object. this Instr will reuse SynthDefs where possible. Multiple synths may use the same basic sample synthDef for many voices with no need to compile new SynthDefs and send to the server.

sampleRate a float of the current sample's sample rate, embedded into the SynthDef as a constant. the def will be resuable for all samples of that sample rate, and will be slightly more efficient. sampleRateKr a kr rate signal that will change if you load a different sample into the buffer,even while playing. sampleRateIr a ir rate signal that will NOT change if you load a different sample into the buffer. use when you know the sample will not change, or if you know that all samples are the same sampleRate anyway.

bufRateScaleKr the nominal pitchRatio value needed to play at the original pitch bufRateScaleIr the nominal pitchRatio value needed to play at the original pitch. will NOT change if you load a different sample into the buffer.

bufFramesKr a kr rate signal with the number of frames of the current sample bufFramesIr an ir rate signal with the number of frames of the sample

bufSamplesKr a kr rate signal with the number of samples of the current sample bufSamplesIr an ir rate signal with the number of samples of the current sample

duration duration in seconds of current sample, embedded into SynthDef as a constant. bufDurKr duration in seconds bufDurIr duration in seconds

numChannels integer, number of channels of the current sample. this will be embedded into the SynthDef as a constant. the SynthDef will still be reusable for all samples of the same numChannels. bufChannelsKr number of channels of the current sample. you cannot use this to modulate a PlayBuf. bufChannelsIr number of channels of the sample. you cannot use this to modulate a PlayBuf.

Beat Synching

Note that the patch will not play starting on the even bar division unless it is started with p.play(atTime: 1)