  Collisions are an innate part of the function of many musical instruments.
Due to the nonlinear nature of contact forces, special care has to be taken in
the construction of numerical schemes for simulation and sound synthesis.
Finite difference schemes and other time-stepping algorithms used for musical
instrument modelling purposes are normally arrived at by discretising a
Newtonian description of the system. However because impact forces are
non-analytic functions of the phase space variables, algorithm stability can
rarely be established this way. This paper presents a systematic approach to
deriving energy conserving schemes for frictionless impact modelling. The
proposed numerical formulations follow from discretising Hamilton's equations
of motion, generally leading to an implicit system of nonlinear equations that
can be solved with Newton's method. The approach is first outlined for point
mass collisions and then extended to distributed settings, such as vibrating
strings and beams colliding with rigid obstacles. Stability and other relevant
properties of the proposed approach are discussed and further demonstrated with
simulation examples. The methodology is exemplified through a case study on
tanpura string vibration, with the results confirming the main findings of
previous studies on the role of the bridge in sound generation with this type
of string instrument.
