Commit 88863707 authored by Armin Erraji's avatar Armin Erraji
Browse files

In FilterEngineTest exports the spectrum after its calculation to a .wav file.

parent 7edae76d
......@@ -278,7 +278,7 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
oThirdOctMagnitudes.SetIdentity();
//Include sound energy decrease due to the length of the path
fScalarMagnitude *= 1.0f / pow(fPathLength,2);
fScalarMagnitude /= pow(fPathLength,2);
//Subtract air attenuation according to ISO9613-1
ITABase::CThirdOctaveFactorMagnitudeSpectrum oThirdOctAbsorption;
......
......@@ -19,6 +19,7 @@
#include <ITAPropagationModels/FilterEngine.h>
#include <ITAGeo/Base.h>
#include <ITAFFTUtils.h>
#include <ITAISO9613.h>
......@@ -60,6 +61,9 @@ int main(int, char**)
pW->v3VertextStart.SetValues(.0f, 1.0f, -1.0f);
pW->v3VertextEnd.SetValues(.0f, 1.0f, 1.0f);
CPropagationPath oPathDirect;
oPathDirect.push_back(pSender);
oPathDirect.push_back(pReceiver);
CPropagationPath oPathReflection;
oPathReflection.push_back(pSender);
......@@ -72,24 +76,31 @@ int main(int, char**)
oPathDiffraction.push_back(pReceiver);
CPropagationPathList oPathList;
oPathList.push_back(oPathReflection);
oPathList.push_back(oPathDiffraction);
//oPathList.push_back(oPathDirect);
//oPathList.push_back(oPathReflection);
//oPathList.push_back(oPathDiffraction);
oPathList.Load("PropagationPathListExample.json");
CFilterEngine oFilter;
oFilter.ApplyAcousticModels(oPathList);
//Set filter length according to the maximum path length
const float fSpeedOfSound = 344.0f; //Approximation of speed of sound at ~20C
const float fSampleRate = 44.1e3;
const float fSampleRate = 44.1e3f;
const int iFilterLength = (int)(oPathList.GetMaxLength()/ fSpeedOfSound * fSampleRate ) + 1024;
const int iFilterLength = (int)(oPathList.GetMaxLength()/ fSpeedOfSound * fSampleRate );
ITABase::CHDFTSpectra oSpectra(fSampleRate, pReceiver->iNumChannels, iFilterLength);
oFilter.Generate(oPathList, oSpectra);
ITAFFTUtils::Export(oSpectra[0], "ImageSource_Example.wav");
}
{
"class" : "PropagationPathList",
"identifier" : "",
"propagation paths" : [
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-20.783312,
37.346016,
1.997554,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-12.63172,
2.235323,
2.06889,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-11.717958,
5.645531,
1.926507,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
6.069502,
-0.279125,
2.173873,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-10.896731,
8.71039,
1.860683,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
6.069501,
6.369852,
2.020027,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-12.199164,
3.849638,
2.191604,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-0.003496,
-11.121946,
2.078037,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
1.881607,
12.842746,
1.9384,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-2.057416,
12.842748,
1.811582,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-14.910498,
-6.269193,
2.011958,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-13.993473,
-19.646799,
2.128615,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
3.068241,
12.842749,
1.850501,
1
]
},
{
"class" : "PropagationAnchor",
"anchor type" : "SpecularReflection",
"interaction point" : [
-1.506748,
-11.121946,
2.189389,
1
]
},
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"num_channels" : 1,
"class" : "PropagationAnchor",
"anchor type" : "Receiver",
"interaction point" : [
-3,
-3.3,
2.3,
1
]
}
]
},
{
"class" : "PropagationPath",
"identifier" : "",
"propagation anchors" : [
{
"name" : "",
"orientation" : [
0,
0,
0,
1
],
"class" : "PropagationAnchor",
"anchor type" : "Source",
"interaction point" : [
5.1,
2.2,
1.7,
1
]
},