Re: [Csnd] ftsamplebank

Sorry to be following along a little late. I was also playing with ftsamplebank and have encountered the same error. A few things I’d like to toss out and ask:

  1. If there could be an alternate example for ftsamplebank that compensates for the speed of some systems, so that the first sample loads before playback, that would be great. Yes, I know I should suggest one myself.

  2. The example has "iFileCount init 1”
    which should be corrected to init to 0 as pointed out here.

  3. I proved to myself that ftsamplebank does in fact load the files by adding direct calls to loscil3 after i1 like this:

i1000 20 1 60

i1000 21 1 61

i1000 22 1 62

i1000 23 1 63

etc.

  1. ftsamplebank only works with .wav files?

Best,
Grant.

Date: Mon, 3 Jun 2024 18:17:37 -0400
From: ST Music <stunes6556@GMAIL.COM>
Subject: Re: ftsamplebank

Hi Marcelo, although I didn’t get the error every time, I did get it
sporadically. However, it never played all 3 samples.

The issue appears to be you are not allowing adequate time for the first
sample to load before attempting playback. This becomes even more important
when using larger sample directories. In this case, even a .1 second delay
resolves the issue (see score below).

If you don’t want to initialize the samples outside of an instr, you can
always use a seperate instr to load them.

It is also necessary to init iFileCount at 0, not 1, or else the first file
played will be 60 + 1.

//////////

; Select audio/midi flags here according to platform

-odac -d ;;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

sr = 48000
ksmps = 32
nchnls=2
0dbfs = 1

;load all samples in a given directory into function tables and play them
using instrument 1000

giFirstTableNumber = 60;

giNumberOfFiles ftsamplebank “/sdcard/download/wav”, giFirstTableNumber, 0,
4, 0

instr 1
iFileCount init 0

print giNumberOfFiles

until iFileCount>=giNumberOfFiles do

event_i “i”, 1000, iFileCount * 4, 5, giFirstTableNumber+iFileCount

print iFileCount

iFileCount += 1

od

endin

instr 1000

iTable = p4

print iTable

aOut,aOut loscil3 1, 1, iTable, 1, 0;

outs aOut, aOut

endin

i1 .1 15

//////////

I also changed the event start times just to make it more obvious all 3
samples are played.

Best,
Scott

Hi.
I am studying ftsamplebank opcode. I am running the example from the
Reference Manual with experimenting with my own sounds (just 3 small WAV
files). Most of the time, I get just two of them (tables 61 and 62). Table
60 is considered invalid. Why?
The WAV files are ok for *diskin2 *opcode, but one of them never plays
back with the ftsamplebank example.
I pasted the Console message and the code below. Sounds are attached to
this email message.
What am I doing wrong here?
Thank you.
Best wishes,
Marcelo

Invalid ftable no. 60.000000ftable 60:

deferred alloc for
/Users/marcelocarneiro/Dropbox/MacMini_Back/Csound/porcos_teste_player/mictorio_1_trecho1.wav

audio sr = 48000, stereo, reading both channels

opening WAV infile
/Users/marcelocarneiro/Dropbox/MacMini_Back/Csound/porcos_teste_player/mictorio_1_trecho1.wav

defer length 241115

ftable 61:

deferred alloc for
/Users/marcelocarneiro/Dropbox/MacMini_Back/Csound/porcos_teste_player/mictorio_1_trecho2.wav

audio sr = 48000, stereo, reading both channels

opening WAV infile
/Users/marcelocarneiro/Dropbox/MacMini_Back/Csound/porcos_teste_player/mictorio_1_trecho2.wav

defer length 105902

ftable 62:

deferred alloc for
/Users/marcelocarneiro/Dropbox/MacMini_Back/Csound/porcos_teste_player/porcos_mamando_01_gaintrecho.wav

audio sr = 48000, stereo, reading both channels

opening WAV infile
/Users/marcelocarneiro/Dropbox/MacMini_Back/Csound/porcos_teste_player/porcos_mamando_01_gaintrecho.wav

defer length 236524

; 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

sr = 48000

nchnls=2

0dbfs = 1

;load all samples in a given directory into function tables and play them
using instrument 1000

instr 1

iFirstTableNumber = 60;

iNumberOfFiles ftsamplebank
“/Users/marcelocarneiro/Dropbox/MacMini_Back/Csound/porcos_teste_player”,
iFirstTableNumber, 0, 4, 0

iFileCount init 1

print iNumberOfFiles

until iFileCount>=iNumberOfFiles do

event_i “i”, 1000, iFileCount, 5, iFirstTableNumber+iFileCount

iFileCount = iFileCount+1

enduntil

endin

instr 1000

iTable = p4

aOut,aOut loscil3 1, 1, iTable, 1, 0;

outs aOut, aOut

endin

i1 0 15


Marcelo Carneiro
Prof. of Composition
Instituto Villa-Lobos- Rio de Janeiro State Federal University, UNIRIO
https://marcelocarneiro.bandcamp.com
<https://marcelocarneiro.bandcamp.com/?from=search&search_item_id=3188694390&search_item_type=b&search_match_part=%3F&search_page_id=2693239491&search_page_no=1&search_rank=1&search_sig=984807e6cea0e7a97f8c48d2444d604d>
http://marceloarcos2.wixsite.com/marcelocarneiro
Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features
can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

  1. If there could be an alternate example for ftsamplebank that compensates for the speed of some systems, so that the first sample loads before playback, that would be great. Yes, I know I should suggest one myself.

You can just load the samples before you need them. There is no issue with that.

  1. ftsamplebank only works with .wav files?

From looking at the source it would appear that it can load a variety of different file types.

https://github.com/csound/csound/blob/927e131477d848a623aca2befa53af5aa7280839/Opcodes/ftsamplebank.cpp#L138-L141

The manual example should probably be updated.

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here