Csound Csound-dev Csound-tekno Search About

loscil annoyances

Date1999-08-18 08:13
FromPaul Winkler
Subjectloscil annoyances
Is this a bug, or a "feature"?

I'm currently running Unofficial Linux Csound Version  v3.53.0.1b.

I've been using loscil, and I find that it will not work as
I think it should with .aiff files that don't have sustain loop 
points set in the file.
Gen 01 seems to have no trouble loading the file, but here's an
example of an orc that won't work:

;orchestra
        sr      =       44100
        kr      =       2205
        ksmps   =       20
        nchnls  =       1
instr 2
; amp 1, freq = 100, ftable = 12, base freq = 100
a1 loscil  1, 100, 12, 100
out a1                           
endin

; score
f12  0       0     -1 "FX/Worry_Baby/drip_single.aiff"  0 0 0
i2      0       0.45
i2      +       .

This causes csound to report "WARNING: loscil: sustain defers to
non-looping source". No problem-- that's what I want.  But the 
output is silent. If I run the _exact same_ score after adding
sustain and end loop points to the file, it works... though
I've now made the sound loop, which isn't what I wanted. But if
I then modify the orchestra to look like this:

 a1 loscil  ipitch, 100, 12, 100, 0 

...I get the error "INIT ERROR in instr 2: illegal sustain loop
data
a1      loscil  ipitch  100     12      100     0       0
0       -1    0 

This seems unreasonable to me. To my thinking, I've requested
loscil to turn off looping, expecting to get the table played
from beginning to end; but loscil refuses! 

I guess you could argue that
there's no reason to want to turn off looping in loscil (it's a
"looping oscillator", after all.)  But there is: loscil has a
key feature that no other opcode has -- it can read gen01 tables
with deferred table size. This is a big convenience. If you work
with a lot of soundfiles, you don't want to have to look up the
table size every time you edit a soundfile. Why should you?

I think I've figured out what's going on. It seems that loscil
will only play the sample up until the end of the sustain loop,
EVEN IF LOOPING IS TURNED OFF. This means that .aiff samples
with the default non-looping header information will play from
sample 0 to sample 0... that is, not at all.

Furthermore, if the sustain and end loops are set in the
soundfile, setting loscil's loop mode to 0 prevents reading 
the loop points from the soundfile... that is, if you
override the loop mode, you are forced to override the start and
end points as well.
 
Can anyone figure out how to fix this? It seems to me that, in
loop mode 0 (off), the sample should play from beginning to end,
ignoring the loop points entirely.
That would be consistent with the expectations of anyone who's
ever used pretty much any sampler or soundfile editor.

On a related note, while looking for a workaround for the above
problem, I found that I apparently can't use tableng on a
deferred-size ftable. This is rather ironic, since that would
seem to be the case in which it would be most useful to find the
table size automatically!

For example, this code:
 ilast tableng ifn
 a1 loscil  1, 100, ifn, 100, 0 , 1, ilast

...gives this error:
INIT ERROR in instr 2: deferred-size ftable 12.000000 illegal
here
ilast   tableng_i       ifn

There are two ways I could imagine fixing this:
1) Rewrite tableng, et al. to allow them to work with
deferred-size tables; or
2) Add a feature to loscil so that the loop point "-1" is
interpreted as the last point in the table; I could then write
the code above as
 a1 loscil  1, 100, ifn, 100, 0 , 1, -1

Solution 1 would be preferable, I think, because I've never
understood why only one opcode is allowed to work with
deferred-size tables, and it would be nice to have a more
generalized solution. (For that matter, I've never understood
why only the .aiff format is allowed for creating deferred-size
tables with gen 01. Those of us on intel-based platforms would benefit
from eliminating the byte-reverse overhead.)

-- 

----------------    paul winkler    ------------------
slinkP arts:  music, sound, illustration, design, etc.

zarmzarm@hotmail.com   --or-- slinkp AT ulster DOT net
http://www.ulster.net/~abigoo/