Skip to content

barmodel

Creates a tone similar to a struck metal bar.

It uses a physical model developed from solving the partial differential equation. There are controls over the boundary conditions as well as the bar characteristics.

Syntax

ares = barmodel(kbcL, kbcR, iK, ib, kscan, iT30, ipos, ivel, iwid)
ares barmodel kbcL, kbcR, iK, ib, kscan, iT30, ipos, ivel, iwid

Initialization

iK -- dimensionless stiffness parameter. If this parameter is negative then the initialisation is skipped and the previous state of the bar is continued.

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

iT30 -- 30 db decay time in seconds.

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

ivel -- normalized strike velocity.

iwid -- spatial width of strike.

Performance

A note is played on a metalic bar, with the arguments as below.

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

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

kscan -- Speed of scanning the output location.

Note that changing the boundary conditions during playing may lead to glitches and is made available as an experiment. The use of a non-zero kscan can give apparent re-introduction of sound due to modulation.

Examples

Here is an example of the barmodel opcode. It uses the file barmodel-modern.csd.

Example of the barmodel opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac           -d     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o barmodel.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; Initialize the global variables.
  sr        =           44100
  kr        =           4410
  ksmps     =           10
  nchnls    =           1

; Instrument #1.
instr 1
  out(barmodel(1, 1, p4, 0.001, 0.23, 5, p5, p6, p7))
endin

</CsInstruments>
<CsScore>

i1 0.0 0.5  3 0.2 500  0.05
i1 0.5 0.5 -3 0.3 1000 0.05
i1 1.0 0.5 -3 0.4 1000 0.1
i1 1.5 4.0 -3 0.5 800  0.05
e
/* barmodel */

</CsScore>
</CsoundSynthesizer>

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

Example of the barmodel opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac           -iadc     -d     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o barmodel.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; Initialize the global variables.
  sr        =           44100
  kr        =           4410
  ksmps     =           10
  nchnls    =           1

; Instrument #1.
instr 1
  aq        barmodel    1, 1, p4, 0.001, 0.23, 5, p5, p6, p7
            out         aq
endin


</CsInstruments>
<CsScore>


i1 0.0 0.5  3 0.2 500  0.05
i1 0.5 0.5 -3 0.3 1000 0.05
i1 1.0 0.5 -3 0.4 1000 0.1
i1 1.5 4.0 -3 0.5 800  0.05
e
/* barmodel */

</CsScore>
</CsoundSynthesizer>

See Also

Models and Emulations

Credits

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

New in Csound version 5.01