| Hi, Andres,
I've added some doc suggestions inline below. These include:
1) References to WAV as well as AIFF, and samples with or without loop data.
2) Specification of 1 for ibas and kcps, as well as variations on kcps
(based on 1 as original frequency).
3) Revised example to get closer to actual practice (such as not knowing
length of sample, and format). It actually reflects now the *simplest*
possible looping situation.
Let me know if anything I've added is unclear.
I think this revision is a significant improvement.
Art Hunkins
----- Original Message -----
From: "Andres Cabrera"
To: "Art Hunkins"
Sent: Wednesday, May 31, 2006 8:16 AM
Subject: Re: [Csnd] Help Needed: loscil
Thanks Art,
I've added your suggestions for ftlen and nsamp. I've also added some
information to loscil. Please have a look and let me know if more is
needed.
Cheers,
Andrés
loscil
loscil — Read sampled sound from a table.
Description
Read sampled sound (mono or stereo) from a table, with optional sustain
and release looping.
Syntax
ares [,ar2] loscil xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] [, iend1] [,
imod2] [, ibeg2] [, iend2]
Initialization
ifn -- function table number, typically denoting an AIFF or WAV sampled
sound
segment with or without prescribed looping points. The source file may be
mono or
stereo.
ibas (optional) -- base frequency in Hz of the recorded sound. This
optionally overrides the frequency given in the AIFF or WAV file, but is
required if the file did not contain one. The default value is 261.626
Hz, i.e. middle C. (New in Csound 4.03). If you do not know this value,
enter 1.
imod1, imod2 (optional, default=-1) -- play modes for the sustain and
release loops. A value of 1 denotes normal looping, 2 denotes forward &
backward looping, 0 denotes no looping (i.e., it plays through the sample
once). The default value (-1) will
defer to the mode and the looping points, if any, given in the source file.
ibeg1, iend1, ibeg2, iend2 (optional, dependent on mod1, mod2) -- begin
and end points of the sustain and release loops. These are measured in
sample frames from the beginning of the file, so will look the same
whether the sound segment is monaural or stereo. If no loop points are
specified, and a looping mode (imod1, imod2) is given, the file will be
looped for the whole length.
Performance
ar1, ar2 -- the output at audio-rate. There is just ar1 for mono output.
However, there is both ar1 and ar2 for stereo output.
xamp -- the amplitude of the output signal.
kcps -- the frequency of the output signal in cycles per second. This value
for base frequency is represented as 1 by the user if you don't know the
frequency. Multiples of this "base frequency" are also allowed: e.g., 2 =
one octave higher, .5 = one octave lower.
loscil samples the ftable audio at a-rate determined by kcps, then
multiplies the result by xamp. The sampling increment for kcps is
dependent on the table's base-note frequency ibas, and is automatically
adjusted if the orchestra sr value differs from that at which the source
was recorded. In this unit, ftable is always sampled with
interpolation.
If sampling reaches the sustain loop endpoint and looping is in effect,
the point of sampling will be modified and loscil will continue reading
from within that loop segment. Once the instrument has received a
turnoff signal (from the score or from a MIDI noteoff event), the next
sustain endpoint encountered will be ignored and sampling will continue
towards the release loop end-point, or towards the last sample
(henceforth to zeros).
loscil is the basic unit for building a sampling synthesizer. Given a
sufficient set of recorded piano tones, for example, this unit can
resample them to simulate the missing tones. Locating the sound source
nearest a desired pitch can be done via table lookup. Once a sampling
instrument has begun, its turnoff point may be unpredictable and require
an external release envelope; this is often done by gating the sampled
audio with linenr, which will extend the duration of a turned-off
instrument by a specific period while it implements a decay.
If you want to loop the whole file, specify a looping mode with imod1 and do
not enter any values for ibeg and iend.
Note
This is mono loscil:
a1 loscil 10000, 1, 1
...an
> so will look the same
> whether the sound segment is monaural or stereo. If no loop points are
> specified, and a looping mode (imod1, imod2) is given, the file will be
> looped for the whole length.
>
>
>
> Performance
> ar1, ar2 -- the output at audio-rate. There is just ar1 for mono output.
> However, there is both ar1 and ar2 for stereo output.
>
> xamp -- the amplitude of the output signal.
>
> kcps -- the frequency of the output signal in cycles per second.
>
> loscil samples the ftable audio at a-rate determined by kcps, then
> multiplies the result by xamp. The sampling increment for kcps is
> dependent on the table's base-note frequency ibas, and is automatically
> adjusted if the orchestra sr value differs from that at which the source
> was recorded. In this unit, ftable is always sampled with
> interpolation.
>
> If sampling reaches the sustain loop endpoint and looping is in effect,
> the point of sampling will be modified and loscil will continue reading
> from within that loop segment. Once the instrument has received a
> turnoff signal (from the score or from a MIDI noteoff event), the next
> sustain endpoint encountered will be ignored and sampling will continue
> towards the release loop end-point, or towards the last sample
> (henceforth to zeros).
>
> loscil is the basic unit for building a sampling synthesizer. Given a
> sufficient set of recorded piano tones, for example, this unit can
> resample them to simulate the missing tones. Locating the sound source
> nearest a desired pitch can be done via table lookup. Once a sampling
> instrument has begun, its turnoff point may be unpredictable and require
> an external release envelope; this is often done by gating the sampled
> audio with linenr, which will extend the duration of a turned-off
> instrument by a specific period while it implements a decay.
>
> If you want to loop the whole file, specify a looping mode with imod1 do
> not enter any values for ibeg and iend.
>
> [Note]
> Note
> This is mono loscil:
>
> a1 loscil 10000, 1, 1
>
> ...and this is stereo loscil:
>
> a1, a2 loscil 10000, 1, 1
>
> Examples
> Here is an example of the loscil opcode. It uses the files loscil.orc,
> loscil.sco, and beats.aiff.
>
> Example 210. Example of the loscil opcode.
>
> /* loscil.orc */
> ; Initialize the global variables.
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
>
> ; Instrument #1.
> instr 1
> kamp = 30000
> ; If you don't know the frequency of your audio file,
> ; set both the kcps and ibas parameters equal to 1.
> kcps = 1
> ifn = 1
> ibas = 1
>
> a1 loscil kamp, kcps, ifn, ibas
> out a1
> endin
> /* loscil.orc */
>
>
> /* loscil.sco */
> ; Table #1: an audio file.
; Its table size is deferred,
; and format taken from the soundfile header.
> f 1 0 0 1 "beats.aiff" 0 0 0
>
> ; Play Instrument #1 for 6 seconds.
> ; This will loop the audio file several times.
> i 1 0 6
> e
> /* loscil.sco */
>
>
> See Also
> loscil3
>
>
>
> Credits
> Note about the mono/stereo difference was contributed by Rasmus Ekman.
>
> Example written by Kevin Conder.
>
>
>
> |