Package wiat :: Package TM :: Module Inst :: Class Instrument
[hide private]
[frames] | no frames]

Class Instrument

source code

Class used to descibed the geometry of a musical instrument.

Instance Methods [hide private]
 
__init__(self, name, sections, radiation, toneholes=None, fingerings=None)
Instrument class
source code
 
__str__(self) source code
 
add_tonehole(self, tonehole, state=1)
Add a new tonehole to the instrument.
source code
 
get_fingerings(self)
Returns the fingering dictionary of the instrument
source code
 
set_fingering(self, fingering)
Set the fingering of the instrument.
source code
 
set_register_key(self, state=1)
Allow setting the state of the register key
source code
 
get_number_of_sections(self)
Returns the number of sections the instrument is made off
source code
 
calculate_total_length(self)
Return the physical length of the instrument.
source code
 
find_toneholes_in_range(self, xi, xf)
Return a list of the toneholes located in a specific section of the instrument
source code
Method Details [hide private]

__init__(self, name, sections, radiation, toneholes=None, fingerings=None)
(Constructor)

source code 

Instrument class

Example:


>>> import wiat
>>> from wiat.TM import *
>>> I1 = Instrument("Cylinder with one tone hole",
...                [Cylinder(0.014,0.583)], UnflangedOpenEnd(0.014),
...                [ToneHole(0.0117,0.0043,0.474-0.0117/2),
...                 ToneHole(0.0112,0.0043,0.505-0.0112/2)],
...                {'D':[1,1], 'C sharp':[0,1], 'C':[0, 0]})

By default, all toneholes of the instrument are supposed close. Then the fingering can be set with the set_fingering method.

Parameters:
  • name (string) - the name of the instrument
  • sections (list) - a list of Waveguides
  • radiation (an instance of a radiation class (see Radiation.py)) - a radiation condition
  • toneholes (list) - optional list of ToneHole
  • fingerings (dictionary) - an optional fingering dictionary The fingering dictionary should contains lists of open and closed toneholes. The length of the lists should be the same as the number of toneholes.

add_tonehole(self, tonehole, state=1)

source code 

Add a new tonehole to the instrument.

This method is useful in the design stage of an instrument.

Parameters:
  • tonehole (ToneHole) - the new tonehole to be added.
  • state - if the tonehole is to be added in the open (1) or closed (0) state.

set_fingering(self, fingering)

source code 

Set the fingering of the instrument.

The fingering name must be a key of the fingering dictionary.