ar1[,ar2] loscil xamp, kcps, ifn[, ibas][,imod1,ibeg1,iend1] \ [, imod2,ibeg2,iend2] ar1[,ar2] doscil xamp, ifn
ibas (optional) - base frequency in cps of the recorded sound. This optionally overrides the frequency given in the AIFF file, but is required if the file did not contain one. The default value is 0 (no override).
imod1, imod2 (optional) - play modes for the sustain and release loops. A value of 1 denotes normal looping, 2 denotes forward & backward looping, 0 denotes no looping. The default value (-1) will defer to the mode and the looping points 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 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.
doscil is a direct form of loscil, with no frequency control and no looping. It simply reads the table from beginning to end, then stops. This is useful for sampled effects such as percussion sounds, where the pitch needs no alteration and loop points are not provided.
inum notnum icps cpsmidi iamp ampmidi 3000, 1 ifno table inum, 2 ;notnum to choose an audio sample ibas table inum, 3 kamp linenr iamp, 0, .05, .01 ;at noteoff, extend by 50 ms. asig loscil kamp, icps, ifno, cpsoct(ibas/12. + 3)