[frames] | no frames]

Module Inst

source code

Inst.py - This file contains the class defining an Instrument and the functions CalculateImpedance and CalculateMaxima.

The CalculateImpedance returns the impedance of an instrument for each requested frequency.

The CalculateMaxima seach for the exact location of the maxima of the instrument and return a list of (frequency,magnitude) tuples.

 Classes
Instrument
Class used to descibed the geometry of a musical instrument.
 Functions

 create_identity_matrix_array(n) Returns an array of 2X2 identity matrices for uses in the transmission matrix calculation method. source code

 multiply_matrix_arrays(TM1, TM2) Multiplication of two arrays of 2X2 matrices. source code

 CalculateImpedance(instrument, freqs, T=25.0) Calculate the input impedance of the instrument. source code

 CalculateMaxima(Z, inst, freqs, T, number_of_maxima=None) Calculate the exact location of the impedance maxima of an Instrument. source code
 Function Details

multiply_matrix_arrays(TM1, TM2)

source code

Multiplication of two arrays of 2X2 matrices.

Example:

```
```
```>>> TM1 = create_identity_matrix_array(10)
>>> TM2 = multiply_matrix_arrays(TM1,TM1)
>>> TM1 == TM2
array([[[ True,  True,  True,  True,  True,  True,  True,  True,  True,
True],
[ True,  True,  True,  True,  True,  True,  True,  True,  True,
True]],
<BLANKLINE>
[[ True,  True,  True,  True,  True,  True,  True,  True,  True,
True],
[ True,  True,  True,  True,  True,  True,  True,  True,  True,
True]]], dtype=bool)
>>>```

CalculateImpedance(instrument, freqs, T=25.0)

source code

Calculate the input impedance of the instrument.

This function performs the transfer matrix multiplication.

The frequency vector f must be sufficiently fine for the impedance to be well represented, otherwise, the CalculateMaxima functions won't be able to find the maxima. A good vector is:

`>>> freqs = numpy.arange(50,5000,5,dtype=float)`
Parameters:
• `instrument` - an Instrument instance
• `freqs` - frequency vector
• `T` - the temperature

CalculateMaxima(Z, inst, freqs, T, number_of_maxima=None)

source code

Calculate the exact location of the impedance maxima of an Instrument.

It uses an impedance vector Z, previously calculated with the CalculateImpedance function, to determine the approximate location of the maxima and then, uses an optimization algorithm to find their exact location.

Parameters:
• `Z` - impedance vector
• `inst` - Instrument instance
• `freqs` - frequency vector
• `T` - temperature
• `number_of_maxima` - optional argument to limit the number of maxima that are returned
Returns:
a list of tuples containing frequency and magnitude of each impedance maxima.

 Generated by Epydoc 3.0.1 on Wed Jun 18 14:33:28 2008 http://epydoc.sourceforge.net