ftsamplebank
Prev | Orchestra Opcodes and Operators | Next

## ftsamplebank

ftsamplebank — Reads a directory for sound files.

## Description

Plugin opcode in ftsamplebank.

Reads a directory for sound files and loads them to a series of GEN01 function tables.

## Syntax

    iNumberOfFile ftsamplebank SDirectory, iFirstTableNumber, iSkipTime, iFormat, iChannel,

    kNumberOfFile ftsamplebank SDirectory, kFirstTableNumber, kTrigger, kSkipTime, kFormat, kChannel,

## Initialization

SDirectory -- a string that identifies the directory to browse for files

FirstTableNumber -- this sets the number of the first table into which a soundfile will be loaded

Trigger -- updates the tables when kTrigger is 1, only applicable to k-rate version.

SkipTime -- begin reading at skiptime seconds into the file.

Format -- specifies the audio data-file format:

1 - 8-bit signed character 4 - 16-bit short integers
2 - 8-bit A-law bytes 5 - 32-bit long integers
3 - 8-bit U-law bytes 6 - 32-bit floats

Channel -- channel number to read in. 0 denotes read all channels.

If format = 0 the sample format is taken from the soundfile header, or by default from the CSound -o command-line flag.

## Performance

iNumberOfFile -- the number of tables that have been created

kNumberOfFile -- the number of tables that have been created

| Note
Loading a lot of sound files into function tables at k-rate may cause some audio dropouts.

## Example

This example shows ftsamplebank browsing for samples in a fixed location. It loads all samples it finds into GEN01 function tables and then playsa them back in a sequence, one every second. It uses the file ftsamplebank.csd.

Example 398. Example of the ftsamplebank opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac     ;;RT audio out
    ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o diskin.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>
    0dbfs = 1

    ;load all samples in a given directory into function tables and play them using instrument 1000
    instr 1
       iFirstTableNumber = 60;
       iFileCount init 1
       iNumberOfFiles ftsamplebank "../examples/", iFirstTableNumber, 0, 4, 1

       until iFileCount>=iNumberOfFiles do
    	event_i "i", 1000, iFileCount, 1, iFirstTableNumber+iFileCount
    	iFileCount = iFileCount+1
       enduntil

    endin

    instr 1000
       iTable = p4
       aOut loscil3 1, 1, iTable, 1, 0;
       outs aOut, aOut
    endin

    </CsInstruments>
    <CsScore>
    i1 0 20
    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: Rory Walsh
2015

Prev | Up | Next
ftprint | Home | ftsave