Thursday, March 22, 2018




In this page you can see some code samples which demonstrate how easy it is to use OTL-Acoustics Lib and PEMARD-Framework in your own project.

Sample Calculation with OTL-Acoustics Lib and PEMARD-Framework

Performing calculations with OTL-Acoustics Lib and PEMARD-Framework can be as simple as the following code snippet. In the following code we add some objects in a 3D geometry, add the required calculations, perform a calculation and bind the SPL and Excess Attenuation results to some grids

            var geometry = new Geometry();        
// We add the noise sources to the geometry
            foreach (var source in sourcesBindingSource.List)                 geometry.AddObject((Source)source);             // We add the receivers to the geometry             foreach (var receiver in receiverBindingSource.List)                 geometry.AddObject((Receiver)receiver);             // We add the walls to the geometry             foreach (var wall in neutralObstacleBindingSource.List)                 geometry.AddObject((Wall)wall);             // We add the calculations to the geometry. These calculations are ready calculations included inside Acoustics-Lib             geometry.Calculations.Add(new HPSDiffractionCalculation());             geometry.Calculations.Add(new ReflectionCalculation());             geometry.Calculations.Add(new FresnelCalculation());             // This is a custom calculation implemented in this project for demonstration purposes             geometry.Calculations.Add(new CustomCalculation());             // We initialize the calculation options for this geometry             geometry.CalculationOptions = (CalculationOptions)calculationOptionsBindingSource.List[0];             // we initialize the meteorological conditions for this geometry             geometry.Meteo = (Meteo)meteoBindingSource.List[0];             // We calculate this geometry             geometry.Calculate(CalculationMethod.Precise);             // We bind the results to grids             dgvLpAfter.DataSource = (receiverBindingSource.Current as Receiver).PreciseResults.LpAfter.Points;             dgvEA.DataSource = (receiverBindingSource.Current as Receiver).PreciseResults.GEA.Points;

Sample Path Detection with OTL-Acoustics Lib and PEMARD-Framework

In this sample we can see a simple path detection for a 3D geometry. The steps are the same as above but instead of calculating the acoustical parameters of the geometry, we just get the paths.

           var geometry = new Geometry();
            // We add the noise sources to the geometry
            foreach (var source in sourcesBindingSource.List)
            // We add the receivers to the geometry
            foreach (var receiver in receiverBindingSource.List)
            // We add the walls to the geometry
            foreach (var wall in neutralObstacleBindingSource.List)
            // We initialize the calculation options for this geometry
            geometry.CalculationOptions = (CalculationOptions)calculationOptionsBindingSource.List[0];           
            // We bind the results to grids
            dgvPaths.DataSource = geometry.GetAllPaths();