Acoustic Research Tool (ART) v0.10
Windows programmers can use the DLL. C++ programmers can include the ART.h file.
If you are working on windows and not using C++, you can use a DLL. The DLL can be downloaded from the sourceforge site. If you prefer to compile the DLL by yourself, use the MakeARTDLL.bat make file script. Check the Delphi examples on source forge to find out how to use the DLL.
When working in C++, simply include the ART.h file into your project. Don't forget to add all files of the ART package as dependencies. So far only compiling on Microsoft Visual C++ 6.0 has been tested, other compilers could work. We are still working on making the code portable to other compilers and platforms. Check out the source forge page if you want to get the source code.
It is important to grasp the difference between a model, a prototype and an element.
Models provide functions to prepare the calculation of their own acoustic properties. The data properties of a model are its physical features, like length, width or temperature. Other properties concern implementation details, like for which simulation domain and which wavetypes the model provides calculation functions. A model has to implement the ARTmodelInterface.
Prototypes (or "prototype models") are models, that are instantiated during the initialization of the ART root object. Each of these prototype models contains meaningful default values. Prototypes serve as templates to create other models of the same class during runtime. Theses clones are attached to elements (see below), which you can insert into circuits and use for calculation.
Elements are wrappers of models and can be used for simulation. Their properties, like input impedance or radiation impedance, are dependent on their place in a circuit. Elements contain their own model object (which is a clone of a prototype model).
Circuits are arrangements of acoustic elements. When simulating a musical instrument, you will have to build a circuit to represent that instrument closely. A circuit must contain one or more elements. So far elements can only be arranged in in a one dimensional way, branches (with the notable excepetion of tone holes) are not (yet) possible.
When calculation the impedance of a cylindrical tube, you would first create an element. When creating an element of type cylinder, the cylinder prototype is automatically cloned and the clone is attached to the element as its model. Then you would adapt the properties of the element's model, place the element into a circuit within the same simulator and evaluate the circuits impedance. When computing the impedance, the element will use the functions provided by its model.
First the user must create the ART root object. This object will contain all simulators and provides us with all prototypes. Then the user has to create a simulator for a certain wave type and a certain simulation domain. So far only frequency domain and multimodal waves are supported, so we will create a simulator for that and save a pointer to it:
Elements are created from prototypes and placed into a simulator by the function ARTCreateElement. The prototypes need to provide functions for simulation in the simulator's domain and wavetype. We will create a cylinder and call it "Cyl", a cone called "Con" and a Bessel horn named "Bes", all in the simulator created before.
To change the measurements and other parameters of the elements use the function ARTSetParameter. We well change the measurements of the cylinder to a 100 cm long tube with a radius of 1 cm. The cone will be 50 cm long, and have the same radius as the cylinder at the beginning and 1.5 times that radius at the end. The Bessel horn will be 20 cm long, have the same radius as the cone ending and bend to a radius of 12.5 cm at the end. The parameter flare, controlling the shape of the Bessel horn is set to 0.4.
The order in which the elements are added is important. The first element will be the element nearest to the mouth of the player. Use the functions ARTAppendReferenceBefore and ARTAppendReferenceAfter if you want to insert elements at a certain place. We will first create an instrument and then add our customised elements one by one.
Before calculating the impedance the frequency range and the number of modes have to be defined. The impedance is evaluated for discrete points within the range. The distance between these points is determined by the frequency step. We will set the range of the simulator to be from 50 Hz to 1800 Hz, with a frequency step of 5 Hz. We set the number of modes to 1.
To calculate a circuit's impedance we simply use the function ARTInputImpedance. The impedance curve returned won't change if the arrangement is changed after the function is called. A new call ensures the impedance curve is up-to-date. The function returns a pointer to an object of class ARTdataContainer, which holds the data.
We will have the impedance of our instrument calculated and print it as numbers to the screen.
When you are done you must destroy all elements and simulators you create and also the ART root object:
When errors are encountered, the interface either throws an exception as an object of the class ARTerror (when not using the DLL) or returns a bad value through a function (when using the DLL).
When not using the DLL, include critical operations in try/catch blocks, like this:
Of course it does not harm to include all operations in try/catch blocks. At this stage of the project that can be useful for debugging. Note that most error messages so far are indeed rather for debugging and not meant for end-users.
When the impedance is evaluated, first all parameters it depends on are evaluated. If those parameters depend themselves on other parameters, they are evalauted before. All parameters are in a dependency tree, which the programme automatically follows to its principle elements, those that do not depend on any other parameter. In our example the dependency tree looks as follows:
So when the impedance is queried, all other properties are evaluated first. Therefore the user never has to worry about evaluating other properties before calling ARTInputImpedance.
Properties keep track of their validity. As soon as a dependency of a property is changed, the property is marked for recalculation the next time it is needed.
The user can specify a callback function, which will be called at regular intervals during the calculation process to communicate information about the progress. This function can also be used to abort the calculation. Before the calculation starts, the interface determines the cost of the computation in computation steps, that is parser or functionoid calls respectively. Since not all of these operations are of the same complexity the first thousand computation steps can be twice as fast as the following thousand.@see ARTSetProgressFunction
Check the documentation of the ART interface for a detailed description of its functions.