lorismorph
Prev | Orchestra Opcodes and Operators | Next

## lorismorph

lorismorph — Morphs two stored sets of bandwidth-enhanced partials and stores a new set of partials representing the morphed sound. The morph is performed by linearly interpolating the parameter envelopes (frequency, amplitude, and bandwidth, or noisiness) of the bandwidth-enhanced partials according to control-rate frequency, amplitude, and bandwidth morphing functions.

## Syntax

    lorismorph isrcidx, itgtidx, istoreidx, kfreqmorphenv, kampmorphenv, kbwmorphenv

## Description

lorismorph morphs two stored sets of bandwidth-enhanced partials and stores a new set of partials representing the morphed sound. The morph is performed by linearly interpolating the parameter envelopes (frequency, amplitude, and bandwidth, or noisiness) of the bandwidth-enhanced partials according to control-rate frequency, amplitude, and bandwidth morphing functions.

## Initialization

istoreidx, ireadidx, isrcidx, itgtidx are labels that identify a stored set of bandwidth-enhanced partials. lorisread imports partials from a SDIF file and stores them with the integer label istoreidx. lorismorph morphs sets of partials labeled isrcidx and itgtidx, and stores the resulting partials with the integer label istoreidx. lorisplay renders the partials stored with the label ireadidx. The labels are used only at initialization time, and may be reused without any cost or benefit in efficiency, and without introducing any interaction between instruments or instances.

## Performance

lorismorph generates a set of bandwidth-enhanced partials by morphing two stored sets of partials, the source and target partials, which may have been imported using lorisread, or generated by another unit generator, including another instance of lorismorph. The morph is performed by interpolating the parameters of corresponding (labeled) partials in the two source sounds. The sound morph is described by three control-rate morphing envelopes. kfreqmorphenv describes the interpolation of partial frequency values in the two source sounds. When kfreqmorphenv is 0, partial frequencies are obtained from the partials stored at isrcidx. When kfreqmorphenv is 1, partial frequencies are obtained from the partials at itgtidx. When kfreqmorphenv is between 0 and 1, the partial frequencies are interpolated between corresponding source and target partials. Interpolation of partial amplitudes and bandwidth (noisiness) coefficients are similarly described by kampmorphenv and kbwmorphenv.

## Examples

Here is an example of the lorismorph opcode. It uses the file lorismorph.csd.

Example 503. Example of the lorismorph opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

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

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1
    ; clarinet.sdif and meow.sdif can be found in /manual/examples

    ; Morph the partials in meow.sdif into the partials in clarinet.sdif over the duration of
    ; the sustained portion of the two tones (from .2 to 2.0 seconds in the meow, and from
    ; .5 to 2.1 seconds in the clarinet). The onset and decay portions in the morphed sound are
    ; specified by parameters p4 and p5, respectively. The morphing time is the time between the
    ; onset and the decay. The meow partials are shfited in pitch to match the pitch of the clarinet
    ; tone (D above middle C).

    instr 1

    ionset	= p4
    idecay	= p5
    itmorph = p3 - (ionset + idecay)
    ipshift	= cpspch(8.02)/cpspch(8.08)

    ktme	linseg	0, ionset, .2, itmorph, 2.0, idecay, 2.1    ; meow time function, morph from .2 to 2.0 seconds
    ktcl	linseg	0, ionset, .5, itmorph, 2.1, idecay, 2.3    ; clarinet time function, morph from .5 to 2.1 seconds
    kmurph	linseg	0, ionset, 0, itmorph, 1, idecay, 1
    	lorisread  ktme, "meow.sdif", 1, ipshift, 2, 1, .001
    	lorisread  ktcl, "clarinet.sdif", 2, 1, 1, 1, .001
    	lorismorph 1, 2, 3, kmurph, kmurph, kmurph
    asig	lorisplay  3, 1, 1, 1
    	outs	   asig, asig
    endin

    ; Morph the partials in clarinet.sdif into the partials in meow.sdif. The start and end times
    ; for the morph are specified by parameters p4 and p5, respectively. The morph occurs over the
    ; second of four pitches in each of the sounds, from .75 to 1.2 seconds in the flutter-tongued
    ; clarinet tone, and from 1.7 to 2.2 seconds in the cat's meow. Different morphing functions are
    ; used for the frequency and amplitude envelopes, so that the partial amplitudes make a faster
    ; transition from clarinet to cat than the frequencies. (The bandwidth envelopes use the same
    ; morphing function as the amplitudes.)

    instr 2

    ionset	 = p4
    imorph	 = p5 - p4
    irelease = p3 - p5

    ktclar	linseg	0, ionset, .75, imorph, 1.2, irelease, 2.4
    ktmeow	linseg	0, ionset, 1.7, imorph, 2.2, irelease, 3.4

    kmfreq	linseg	0, ionset, 0, .75*imorph, .25, .25*imorph, 1, irelease, 1
    kmamp	linseg	0, ionset, 0, .75*imorph, .9, .25*imorph, 1, irelease, 1

    	lorisread  ktclar, "clarinet.sdif", 1, 1, 1, 1, .001
    	lorisread  ktmeow, "meow.sdif", 2, 1, 1, 1, .001
    	lorismorph 1, 2, 3, kmfreq, kmamp, kmamp
    asig	lorisplay  3, 1, 1, 1
    	outs	   asig, asig
    endin

    </CsInstruments>
    <CsScore>
    ;     strt   dur   onset   decay
    i 1    0      3     .25     .15
    i 1    +      1     .10     .10
    i 1    +      6    1.      1.

    ;    strt   dur  morph_start   morph_end
     i 2    9    4     .75           2.75

    e
    </CsScore>
    </CsoundSynthesizer>

## Credits

This implementation of the Loris unit generators was written by Kelly Fitz (loris@cerlsoundgroup.org). It is patterned after a prototype implementation of the lorisplay unit generator written by Corbin Champion, and based on the method of Bandwidth-Enhanced Additive Synthesis and on the sound morphing algorithms implemented in the Loris library for sound modeling and manipulation. The opcodes were further adapted as a plugin for Csound 5 by Michael gogins.

Prev | Up | Next
lorisread | Home | lorisplay