ResonatorNetwork
allows one to assemble a system of inter-connected resonators in the form of strings, bars, membranes and plates. Once a network has been specified, its modal data can be calculated, which in turn may be used to simulate the resonator network in real time. Note that the calculation of all modal data is an offline procedure and is done behind the scenes in the Python programming language with the help of the NumPy and SciPy packages. This calculation stage may take a significant amount of time, dependending on the complexity of the resonator network.
WARNING: This class has only been tested to work on OSX. Although it may work prefectly well on other platforms provided that a suitable version of Python 2.7.x and the packages NumPy and SciPy have been installed, no guarantees are given. The default full path to the Python executable is set as "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python". This is tailored to the OSX platform and hence, would need to be adapted in case one would like to use a Python executable living at another location or if you are on a different platform. Note that if a full path to a python executable is not properly specified, ResonatorNetwork
will be unable to calculate any modal data and hence, an error will be thrown.
Create a system of inter-connected objects according to the specification of the arguments.
Arguments:
resonators |
An Array containing instances of Resonator1D and Resonator2D that form the basic building blocks of the resonator network. |
connPointMatrix |
An Array2D containing m rows and n columns, where m needs to be equal to the number of items in resonators and n is equal to the total number of object inter-connections. Each column of connPointMatrix should only contain two nonzero entrees, where the first entree denotes the relative point (0 - 1) of inter-connection as seen from the first object and the second entree denotes the relative point of inter-connection as seen from the second object involved in the inter-connection. Note that a value of 0 is not considered to denote a connection point. If one requires to connect one of the objects at relative position 0, one can simply enter a very small, but nonzero value instead (e.g. 0.001). |
massMatrix |
An Array2D containing m rows and n columns, where m needs to be equal to the number of items in resonators and n is equal to the total number of object inter-connections. As such the shape of massMatrix is equal to the shape of resonators . Each column of massMatrix should only contain two nonzero entrees, where the first entree denotes the mass of the first object and the second entree denotes the mass of the second object involved in the inter-connection. Note that the quantity which matters only in the end is the mass ratio of the two objects and hence the interpretation of the individual entree values is arbitrary. |
excPointMatrix |
An Array2D containing m rows and n columns, where m needs to be equal to the number of items in resonators and n is equal to the number of distinct excitations to be executed. Note that it is possible to excite multiple objects making up the complete system at the same time by having more than one nonzero entrees in a column. |
readoutPointMatrix |
An Array2D containing m rows and n columns, where m needs to be equal to the number of items in resonators and n is equal to the number of distinct readouts to be executed. Note that is possible to pick up the sum of the vibrational response of multiple objects making up the complete system by having more than one nonzero entrees in a column. |
Returns:
An instance of ResonatorNetwork
with the given objects, mass matrix, matrices describing the positions of object inter-connection and matrices for the excitation and readout points of the resulting system as instance variables.
Class variable which points to a valid executable version of Python 2.7.x. Set this to a different path if necessary (see below).
Arguments:
value |
A String denoting the location of a Python executable. It is essential to point this to a valid executable path, otherwise the instance method calc_modes will fail to compute any modal data. The default path is set to the location of the default currently used Python version by the OSX operating system, which for version 10.11.5 is equal to "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python". |
Returns:
A String which points to the path denoting the current location of Python.
Calculate the modal data associated with the system of inter-connected objects.
NOTE: The purpose of the arguments is to be able to obtain more efficient simulations by providing the user some control over deciding which modes should be included in the simulation and which modes can be discarded. If one is unsure about what to set these arguments to, it is adviced to just leave them at their default values.
Arguments:
minFreq |
Modes which fall below minFreq will be discarded. |
maxFreq |
Modes which are higher than maxFreq will be discarded. |
minT60 |
Modes with a duration below minT60 will be discarded. |
gain |
An optional multiplicative factor to be applied to the numerator coefficients of the second order biquad sections. This may be used to boost the response of the filter by a specified amount of dB's. if one is unsure about how to use this parameter, it is adviced to leave it as it is. If it turns out the response of the resonator is very low in amplitude, one can always increase the gain of the second order section ugens during the simulation (this will have exactly the same effect, although will be slightly less efficient). |
pathname |
A String denoting a valid path (must include the file name and json extension) where the json representation of the calculated modal data will be saved. |
incl |
A four parameter String indicating which representations of the modal data should be saved to disk in json format. Every parameter can take on one of two values: "y" or "n" , signifying "yes" or "no" respectively. The first slot corresponds to the transfer function matrix (i.e. a dictionary of second order filter section coefficients), the second slot corresponds to the eigenvalues in rectangular coordinates, the third slot corresponds to the eigenvalues in polar coordinates, and the fourth and final slot corresponds to the eigenvectors. |
async |
A Boolean denoting whether the calculation of the modal data should be done synchronously or asynchronously. |
Discussion:
The calculation of the modal data roughly involves the following six steps:
- The system described by an instance of
ResonatorNetwork
will be parsed into a json representation written to disk temporarily. - A Python script will read in this json file and it into a finite difference representation of all individual resonators making up our resonator network.
- The separate finite difference representations of the individual resonator objects will be collected into a single, state transition block matrix taking into account all resonator object inter-connections.
- The state transition block matrix will be diagonalised in order to obtain all eigenvalues and eigenvectors associated with our resonator network.
- Depending on the include flags specified by the user, different representations of the modal data will be calculated and saved to a json file.
- This json data will be read back into SuperCollider. After parsing, the result will be stored in the
modalData
instance variable.
Load the modal data associated with a previously calculated system of inter-connected objects.
Arguments:
pathname |
A String indicating the location of a json file which contains the modal data associated with the system of inter-connected resonator objects represented by this instance of ResonatorNetwork . |
An instance of Dictionary which will hold all modal data associated with the current system of inter-connected resonator objects. This instance variable will only be defined after the instance methods calcModalData
or loadModalData
have been called successfully on the current instance of ResonatorNetwork
.
Some examples of how to design and simulate systems of inter-connected objects will follow with the intent to give a hands on demonstration of how ResonatorNetwork
can be of practical use.
The previous examples all made use of SC's native SOS UGen for the simulation part. Another option is to use the SOSBank UGen . The next example compares both methods.