-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a basic ADM renderer to handle Object, DirectSpeaker and HOA st…
…reams
- Loading branch information
1 parent
06c4800
commit 8306cdc
Showing
17 changed files
with
3,642 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/*############################################################################*/ | ||
/*# #*/ | ||
/*# A renderer for ADM streams. #*/ | ||
/*# CAdmRenderer - ADM Renderer #*/ | ||
/*# Copyright © 2020 Peter Stitt #*/ | ||
/*# #*/ | ||
/*# Filename: AdmRenderer.h #*/ | ||
/*# Version: 0.1 #*/ | ||
/*# Date: 23/06/2020 #*/ | ||
/*# Author(s): Peter Stitt #*/ | ||
/*# Licence: LGPL + proprietary #*/ | ||
/*# #*/ | ||
/*############################################################################*/ | ||
|
||
#pragma once | ||
|
||
#include "AdmLayouts.h" | ||
#include "AdmUtils.h" | ||
#include "kiss_fftr.h" | ||
|
||
namespace admrender { | ||
|
||
/** | ||
This class applied decorrelation to the output speaker layouts. | ||
It allows allows for compensation delay to be applied to the direct signal | ||
*/ | ||
|
||
class CAdmDecorrelate | ||
{ | ||
public: | ||
/* | ||
layout is the target loudspeaker layout | ||
nSamples is the maximum block size expected | ||
*/ | ||
CAdmDecorrelate(); | ||
~CAdmDecorrelate(); | ||
|
||
/** | ||
Re-create the object for the given configuration. Previous data is | ||
lost. Returns true if successful. | ||
*/ | ||
bool Configure(Layout layout, unsigned int nBlockSize); | ||
/** | ||
Not implemented. | ||
*/ | ||
void Reset(); | ||
/** | ||
Filter otate B-Format stream. | ||
*/ | ||
void Process(std::vector<std::vector<float>> &ppInDirect, std::vector<std::vector<float>> &ppInDiffuse, unsigned int nSamples); | ||
|
||
private: | ||
// The time-domain decorrelation filters | ||
std::vector<std::vector<float>> decorrelationFilters; | ||
// Output layout | ||
Layout m_layout; | ||
// The number of channels in the output array | ||
unsigned int m_nCh; | ||
|
||
// According to Rec. ITU-R BS.2127-0 sec. 7.4 the decorrelation filter length is 512 samples | ||
const unsigned int m_nDecorrelationFilterSamples = 512; | ||
|
||
kiss_fftr_cfg m_pFFT_decor_cfg; | ||
kiss_fftr_cfg m_pIFFT_decor_cfg; | ||
|
||
float* m_pfScratchBufferA; | ||
float** m_pfOverlap; | ||
unsigned m_nFFTSize; | ||
unsigned m_nBlockSize; | ||
unsigned m_nTaps; | ||
unsigned m_nOverlapLength; | ||
unsigned m_nFFTBins; | ||
float m_fFFTScaler; | ||
|
||
kiss_fft_cpx** m_ppcpDecorFilters; | ||
kiss_fft_cpx* m_pcpScratch; | ||
|
||
// Buffers to hold the delayed direct signals | ||
float** m_ppfDirectDelay; | ||
unsigned int m_nDelayLineLength; | ||
int m_nDelay = (m_nDecorrelationFilterSamples - 1) / 2; | ||
int m_nReadPos = 0; | ||
int m_nWritePos = 0; | ||
|
||
/** | ||
Read and write data to delay lines | ||
*/ | ||
void WriteToDelayLine(float* pDelayLine, float* pIn, int nWritePos, int nSamples); | ||
void ReadFromDelayLine(float* pDelayLine, float* pOut, int nReadPos, int nSamples); | ||
|
||
/** | ||
Calculate decorrelation filters using the method described in Rec. ITU-R BS.2127-0 sec. 7.4 | ||
The filters depend on the layout set at construction | ||
*/ | ||
std::vector<std::vector<float>> CalculateDecorrelationFilterBank(); | ||
|
||
/** | ||
Calculate the time-domain decorrelation filter for the a particular channel index seed | ||
*/ | ||
std::vector<float> CalculateDecorrelationFilter(unsigned int seedIndex); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*############################################################################*/ | ||
/*# #*/ | ||
/*# Calculate the gain vector to spatialise a DirectSpeaker channel. #*/ | ||
/*# CAdmDirectSpeakersGainCalc #*/ | ||
/*# Copyright © 2020 Peter Stitt #*/ | ||
/*# #*/ | ||
/*# Filename: AdmDirectSpeakersGainCalc.h #*/ | ||
/*# Version: 0.1 #*/ | ||
/*# Date: 23/06/2020 #*/ | ||
/*# Author(s): Peter Stitt #*/ | ||
/*# Licence: LGPL + proprietary #*/ | ||
/*# #*/ | ||
/*############################################################################*/ | ||
|
||
#pragma once | ||
|
||
#include "AdmMetadata.h" | ||
#include "AdmLayouts.h" | ||
#include "AdmUtils.h" | ||
#include "AdmMappingRules.h" | ||
#include "AdmPointSourcePannerGainCalc.h" | ||
|
||
namespace admrender { | ||
|
||
/** | ||
A class to calculate the gains to be applied to a set of loudspeakers for DirectSpeaker processing | ||
*/ | ||
class CAdmDirectSpeakersGainCalc | ||
{ | ||
public: | ||
CAdmDirectSpeakersGainCalc(Layout layoutWithLFE); | ||
~CAdmDirectSpeakersGainCalc(); | ||
|
||
/** | ||
Calculate the gain vector corresponding to the metadata input | ||
*/ | ||
std::vector<double> calculateGains(DirectSpeakerMetadata metadata); | ||
|
||
private: | ||
unsigned int m_nCh = 0; | ||
Layout m_layout; | ||
CAdmPointSourcePannerGainCalc m_pointSourcePannerGainCalc; | ||
|
||
bool isLFE(DirectSpeakerMetadata metadata); | ||
|
||
/** | ||
Find the closest speaker in the layout within the tolerance bounds | ||
set | ||
*/ | ||
int findClosestWithinBounds(DirectSpeakerPolarPosition direction, double tol); | ||
|
||
/** | ||
Determine if a given mapping rule applies for input layout, speaker label and output layout. | ||
See Rec. ITU-R BS.2127-0 sec 8.4 | ||
*/ | ||
bool MappingRuleApplies(const MappingRule& rule, const std::string& input_layout, const std::string& speakerLabel, admrender::Layout& output_layout); | ||
}; | ||
} |
Oops, something went wrong.