prepiano
Prev | Orchestra Opcodes and Operators | Next

## prepiano

prepiano — Creates a tone similar to a piano string prepared in a Cageian fashion.

## Description

Audio output is a tone similar to a piano string, prepared with a number of rubbers and rattles. The method uses a physical model developed from solving the partial differential equation.

## Syntax

    ares prepiano ifreq, iNS, iD, iK, \
        iT30,iB, kbcl, kbcr, imass, ihvfreq, iinit, ipos, ivel, isfreq, \
        isspread[, irattles, irubbers]

    al,ar prepiano ifreq, iNS, iD, iK, \
        iT30,iB, kbcl, kbcr, imass, ihvfreq, iinit, ipos, ivel, isfreq, \
        isspread[, irattles, irubbers]

## Initialization

ifreq -- The base frequency of the string.

iNS -- the number of strings involved. In a real piano 1, 2 or 3 strings are found in different frequency regions.

iD -- the amount each string other that the first is detuned from the main frequency, measured in cents.

iK -- dimensionless stiffness parameter.

iT30 -- 30 db decay time in seconds.

ib -- high-frequency loss parameter (keep this small).

imass -- the mass of the piano hammer.

ihvfreq -- the frequency of the natural vibrations of the hammer.

iinit -- the initial position of the hammer.

ipos -- position along the string that the strike occurs.

ivel -- normalized strike velocity.

isfreq -- scanning frequency of the reading place.

isspread -- scanning frequency spread.

irattles -- table number giving locations of any rattle(s).

irubbers -- table number giving locations of any rubbers(s).

The rattles and rubbers tables are collections of four values, preceeded by a count. In the case of a rattle the four are position, mass density ratio of rattle/string, frequency of rattle and vertical length of the rattle. For the rubber the fours are position, mass density ratio of rubber/string, frequency of rubber and the loss parameter.

## Performance

A note is played on a piano string, with the arguments as below.

kbcL -- Boundary condition at left end of string (1 is clamped, 2 pivoting and 3 free).

kbcR -- Boundary condition at right end of string (1 is clamped, 2 pivoting and 3 free).

Note that changing the boundary conditions during playing may lead to glitches and is made available as an experiment.

## Examples

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

Example 730. Example of the prepiano 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 real audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o prepiano.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1
    ;;          fund NS detune stiffness decay loss (bndry) (hammer) scan prep
    aa,ab prepiano 60, 3, 10, p4, 3, 0.002, 2, 2, 1, 5000, -0.01, p5, p6, 0, 0.1, 1, 2
          outs aa*.2, ab*.2

    endin
    </CsInstruments>
    <CsScore>
    f1 0 8 2 1 0.6 10 100 0.001 ;; 1 rattle
    f2 0 8 2 1 0.7 50 500 1000  ;; 1 rubber
    i1 0.0 1 1 0.09 20
    i1 1 .  -1 0.09 40        ;; 1 -> skip initialisation
    i1 2 .  -1 0.09 60
    i1 3 .  -1 0.09 80
    i1 4 1.8  -1 0.09 100
    e
    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: Stefan Bilbao
University of Edinburgh, UK
Author: John ffitch
University of Bath, Codemist Ltd.
Bath, UK

New in Csound version 5.05

Prev | Up | Next
prealloc | Home | print