Commit 45b4d4b7 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Fixing bugs

parent 1e848813
/*
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VAHRIRMultiDataset3D.cpp
*
* Zweck: Distanzabhngige HRIR interpoliert aus verschiedenen
* HRIR-Datenstzen mit festen Distanzen
*
* Autor(en): Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*/
// $Id: VAHRIRMultiDataset3D.cpp 2871 2012-08-08 21:52:37Z fwefers $
#include "VAHRIRMultiDataset3D.h"
#include <VAException.h>
......@@ -37,61 +14,61 @@
#include <sstream>
#include <DAFF.h>
CVAHRIRMultiDataset3D::CVAHRIRMultiDataset3D(const std::string& sFilename,
const std::string& sName,
double dDesiredSamplerate)
: m_sFilename(sFilename),
m_sName(sName)
CVAHRIRMultiDataset3D::CVAHRIRMultiDataset3D( const std::string& sFilename, const std::string& sName, double dDesiredSamplerate )
: m_sFilename( sFilename ),
m_sName( sName )
{
/* Fehler so ...
VA_EXCEPT1( std::string("Could not load HRIR dataset from file \"") +
sFilename + std::string("\".") );
*/
sFilename + std::string("\".") );
*/
if (!doesFileExist(sFilename))
ITA_EXCEPT1(FILE_NOT_FOUND, std::string("File \"") + sFilename + std::string("\" not found"));
if( !doesFileExist( sFilename ) )
ITA_EXCEPT1( FILE_NOT_FOUND, std::string( "File \"" ) + sFilename + std::string( "\" not found" ) );
std::ifstream ifs(sFilename);
if (!ifs.good()) ITA_EXCEPT1(IO_ERROR, "Cannot read file");
std::ifstream ifs( sFilename );
if( !ifs.good() ) ITA_EXCEPT1( IO_ERROR, "Cannot read file" );
std::string line;
// Datei Zeile fr Zeile einlesen
while (getline(ifs, line)) {
line = stripSpaces(line);
while( getline( ifs, line ) )
{
line = stripSpaces( line );
// Kommentare (#) und leere Zeilen berspringen
if (line.empty()) continue;
if (line[0] == '#') continue;
if( line.empty() ) continue;
if( line[ 0 ] == '#' ) continue;
// TODO: Format berprfen
// DEBUG: std::cout << line;
std::stringstream ss(line);
std::stringstream ss( line );
Record r;
ss >> r.fDistance;
ss >> r.sFilename;
v.push_back(r);
v.push_back( r );
}
// Nach Distanz sortieren
std::sort(v.begin(), v.end(), RecordCmp());
std::sort( v.begin(), v.end(), RecordCmp() );
// HRIR-Datenbanken laden
std::string sBasePath = getDirectoryFromPath(sFilename);
for (std::vector<Record>::iterator it=v.begin(); it!=v.end(); ++it) {
std::string sBasePath = getDirectoryFromPath( sFilename );
for( std::vector<Record>::iterator it = v.begin(); it != v.end(); ++it )
{
Record& r = *it;
VA_DEBUG_PRINTF("Loading HRIR dataset \"%s\" for distance %0.3fm\n", r.sFilename.c_str(), r.fDistance);
r.pData = new CVAHRIRDatasetDAFF2D(combinePath(sBasePath, r.sFilename), "", dDesiredSamplerate);
VA_DEBUG_PRINTF( "Loading HRIR dataset \"%s\" for distance %0.3fm\n", r.sFilename.c_str(), r.fDistance );
r.pData = new CVAHRIRDatasetDAFF2D( combinePath( sBasePath, r.sFilename ), "", dDesiredSamplerate );
// Sicherstellen das die HRIR-Datenstze indiziert sind und
// die gleichen Raster haben
if (!r.pData->GetProperties()->bSpaceDiscrete)
VA_EXCEPT2(INVALID_PARAMETER, "Multi HRIR datasets can only be assembled from space discrete HRIR datasets");
if( !r.pData->GetProperties()->bSpaceDiscrete )
VA_EXCEPT2( INVALID_PARAMETER, "Multi HRIR datasets can only be assembled from space discrete HRIR datasets" );
/* TODO:
if (it!=v.begin()) {
Record& s = v.front();
if (r.pData->GetProperties()->
Record& s = v.front();
if (r.pData->GetProperties()->
}
*/
}
......@@ -111,53 +88,54 @@ CVAHRIRMultiDataset3D::CVAHRIRMultiDataset3D(const std::string& sFilename,
m_oProps.bDistanceDependent = m_b3D;
}
CVAHRIRMultiDataset3D::~CVAHRIRMultiDataset3D() {
CVAHRIRMultiDataset3D::~CVAHRIRMultiDataset3D()
{
}
std::string CVAHRIRMultiDataset3D::GetFilename() const {
std::string CVAHRIRMultiDataset3D::GetFilename() const
{
return m_sFilename;
}
std::string CVAHRIRMultiDataset3D::GetName() const {
std::string CVAHRIRMultiDataset3D::GetName() const
{
return m_sName;
}
std::string CVAHRIRMultiDataset3D::GetDesc() const {
char buf[1024];
std::string CVAHRIRMultiDataset3D::GetDesc() const
{
char buf[ 1024 ];
/*
sprintf(buf, "Multi order %d, %s, full sphere, continuous, %d taps",
m_iSHOrder,
(m_b3D ? "3D" : "2D"),
m_oProps.iFilterLength);
*/
m_iSHOrder,
(m_b3D ? "3D" : "2D"),
m_oProps.iFilterLength);
*/
return buf;
}
const CVAHRIRDatasetProperties* CVAHRIRMultiDataset3D::GetProperties() const {
const CVAHRIRDatasetProperties* CVAHRIRMultiDataset3D::GetProperties() const
{
return &m_oProps;
}
void CVAHRIRMultiDataset3D::GetNearestNeighbour(float fAzimuthDeg, float fElevationDeg,
int* piIndex, bool* pbOutOfBounds) {
void CVAHRIRMultiDataset3D::GetNearestNeighbour( float fAzimuthDeg, float fElevationDeg, int* piIndex, bool* pbOutOfBounds )
{
VA_EXCEPT2( NOT_IMPLEMENTED, "Not implemented" );
}
void CVAHRIRMultiDataset3D::GetHRIRByIndex(ITASampleFrame* psfDest,
const int iIndex,
const float fDistanceMeters) {
void CVAHRIRMultiDataset3D::GetHRIRByIndex( ITASampleFrame* psfDest, const int iIndex, const float fDistanceMeters )
{
}
void CVAHRIRMultiDataset3D::GetHRIR(ITASampleFrame* psfDest,
const float fAzimuthDeg,
const float fElevationDeg,
const float fDistanceMeters,
int* piIndex,
bool* pbOutOfBounds) {
void CVAHRIRMultiDataset3D::GetHRIR( ITASampleFrame* psfDest, const float fAzimuthDeg, const float fElevationDeg, const float fDistanceMeters, int* piIndex, bool* pbOutOfBounds )
{
// TODO;
if (*piIndex) piIndex = 0;
if (*pbOutOfBounds) pbOutOfBounds = false;
if( *piIndex )
piIndex = 0;
if( pbOutOfBounds != nullptr )
*pbOutOfBounds = false;
}
......@@ -3,7 +3,8 @@
#include <VAException.h>
#include "../../Utils/VAUtils.h"
double CVAAudioDriverConfig::DEFAULT_SAMPLERATE = 44100.0;
const int CVAAudioDriverConfig::AUTO = -1;
const double CVAAudioDriverConfig::DEFAULT_SAMPLERATE = 44100.0;
CVAAudioDriverConfig::CVAAudioDriverConfig()
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment