RedDiskInSampler:
Filter:
redSampler/Classes (extension) | Red > redSampler

RedDiskInSampler
ExtensionExtension

playing soundfiles from disk

Description

This class buffers a small portion of a soundfile in RAM and then streams the rest from disk. It is built around the DiskIn ugen and makes it quick and easy to preload and manage lots of samples - much more than you could fit in your RAM. It associates each soundfile with a key (usually a number or a symbol) and can simultaneously play n overlaps of each sound.

This class has a small delay before starting the sound as it buffers or 'cues' data right before playing. On the other hand it can deal with an almost unlimited number of samples. So it will not trigger instantaneously but still be pretty quick. How quick depends on the -numFrames and general disk drive activity. The subclass RedDiskInSamplerGiga is recommended if you need your samples to start instantly e.g. when syncing to a beat.

Do not use this class for granular synthesis or for playing heaps of sounds at once. Remember that it streams data from disk. For playing very many soundfiles at once, use the RedSampler class.

NOTE: Soundfiles with sample rate that differ from the server's current samplerate will play back at wrong speed. This because of how DiskIn works.

Class Methods

.new

Create a new sampler on a server.

Arguments:

server

If this is nil it will use Server.default. The server must be booted.

Instance Methods

.prepareForPlay

Attach a soundfile to a key (number or symbol) and create buffers - one for each overlapping voice. This method is also has the alias preload for backward compatibility.

Arguments:

key

A number or a symbol.

path

A string to a soundfile.

startFrame

In samples.

numFrames

Safest to leave this as nil. Then the -numFrames below is used (default for that is 32768).

.play

Play the sample preloaded at key.

Arguments:

key

A number or a symbol.

attack

In seconds.

sustain

In seconds. If this is nil then the total length of the soundfile will be used (-attack-release). So the default: attack 0, sustain nil, release 0 will play the soundfile in its full length without an envelope.

release

In seconds.

amp

Amplitude.

out

Sets outbus and defaults to 0.

group

If nil it will use Server.defaultGroup.

loop

Should be either 0 (default), 1 or 2.

0Loop off. Play once through with finite duration (using attack+sustain+release).
1Loop on. Loop infinite until it receives a .stop (ignoring sustain).
2Loop on. Loop with finite duration (using attack+sustain+release).

.stop

Stops one voice currently playing at this key.

Arguments:

key

A number or a symbol.

release

Release time is in seconds. The voice is stolen when the sound is fully released.

.flush

Stop all currently playing voices for all keys.

.free

Clear all keys, close files, free synths and buffers.

.freeKey

Clear a key, close its file and free its synth and buffer.

.loadedKeys

Report which keys have been preloaded with soundfiles.

.playingKeys

Report which keys that currently have one or more voices playing.

.numFrames

Get or set the size of the preload buffer. The default is 32768.

.overlaps

Get or set number of overlaps or voices allowed to play per key at once. The default is 2. You will need to -prepareForPlay again after setting this.

.length

Report the length in seconds of the soundfile loaded at this key.

.channels

Report the number of channels of the soundfile loaded at this key.

.buffers

Return an array of buffer for this key. The number of buffers depend on how many overlaps you had when preloading.

.voicesLeft

Return number of free voices for this key i.e. the number of non-playing voices.

.isPlaying

Return boolean if more than one voice is playing.

.amp

Set the amplitude for a running synth.

Examples