Skip to content

Commit a5c8c11

Browse files
committed
Merge branch 'release/1.1.4' of https://github.com/3DTune-In/3dti_AudioToolkit_VST_Plugins into release/1.1.4
2 parents 574b881 + 8634f7c commit a5c8c11

5 files changed

Lines changed: 28 additions & 93 deletions

File tree

Source/Binaural/AnechoicProcessor.cpp

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,25 @@ AnechoicProcessor::AnechoicProcessor (Binaural::CCore& core)
5353

5454
AnechoicProcessor::~AnechoicProcessor()
5555
{
56-
stopTimer();
5756
}
5857

5958
void AnechoicProcessor::setup (double sampleRate)
6059
{
60+
auto position = getSourcePosition();
61+
62+
if (! mSources.empty())
63+
{
64+
mSources.clear();
65+
mTransforms.clear();
66+
}
67+
68+
addSoundSource (position);
69+
6170
auto blockSize = mCore.GetAudioState().bufferSize;
6271

6372
// Declaration and initialization of stereo buffer
6473
mOutputBuffer.left .resize (blockSize);
6574
mOutputBuffer.right.resize (blockSize);
66-
// Load HRTF
6775

6876
auto loadedHrtf = getHrtfPath();
6977

@@ -74,9 +82,7 @@ void AnechoicProcessor::setup (double sampleRate)
7482
int index = hrtfPathToBundledIndex (loadedHrtf);
7583

7684
if (index >= 0)
77-
{
7885
loadHRTF (getBundledHRTF (index, sampleRate));
79-
}
8086
}
8187

8288
mSampleRate = sampleRate;
@@ -87,36 +93,17 @@ void AnechoicProcessor::setup (double sampleRate)
8793
loadHRTF (getBundledHRTF (0, sampleRate));
8894

8995
mSampleRate = sampleRate;
90-
91-
JUCE_ASSERT_MESSAGE_MANAGER_EXISTS;
92-
startTimerHz (2);
93-
94-
timerCallback();
95-
}
96-
97-
void AnechoicProcessor::timerCallback()
98-
{
99-
if (mHRTFsToLoad.size() > 0)
100-
{
101-
if (isLoading.load())
102-
return;
103-
104-
auto path = mHRTFsToLoad[0];
105-
reset (path);
106-
107-
mHRTFsToLoad.removeAllInstancesOf (path);
108-
}
10996
}
11097

111-
void AnechoicProcessor::reset (const File& hrtf)
98+
bool AnechoicProcessor::loadHRTF (const File& hrtf)
11299
{
113100
isLoading.store (true);
114101

115102
if (! hrtf.existsAsFile())
116103
{
117104
DBG ("HRTF file doesn't exist");
118105
isLoading.store (false);
119-
return;
106+
return false;
120107
}
121108

122109
__loadHRTF(hrtf);
@@ -129,7 +116,7 @@ void AnechoicProcessor::reset (const File& hrtf)
129116
{
130117
DBG ("HRTF ILD file doesn't exist");
131118
isLoading.store (false);
132-
return;
119+
return false;
133120
}
134121

135122
__loadHRTF_ILD (hrtfILD);
@@ -139,19 +126,22 @@ void AnechoicProcessor::reset (const File& hrtf)
139126
if (! nearFieldConf.existsAsFile() ) {
140127
DBG ("Near field ILD file doesn't exist");
141128
isLoading.store (false);
142-
return;
129+
return false;
143130
}
144131

145132

146133
DBG("Loading ILD (near field): " + nearFieldConf.getFullPathName());
147134
if ( !ILD::CreateFrom3dti_ILDNearFieldEffectTable( nearFieldConf.getFullPathName().toStdString(), mListener )) {
148135
DBG ("Unable to load ILD Near Field Effect simulation file. Near (ILD) will not work");
136+
return false;
149137
}
150138

151139
// Re-enable processing
152140
isLoading.store (false);
153141

154142
sendChangeMessage();
143+
144+
return true;
155145
}
156146

157147
void AnechoicProcessor::processBlock (AudioBuffer<float>& monoIn, AudioBuffer<float>& stereoOut)
@@ -215,7 +205,7 @@ void AnechoicProcessor::parameterChanged (const String& parameterID, float newVa
215205
{
216206
String fileTypes = index == BundledHRTFs.size() ? "*.sofa" : "*.3dti-hrtf";
217207

218-
loadCustomHrtf (fileTypes, [this] (File hrtf) {
208+
loadCustomHRTF (fileTypes, [this] (File hrtf) {
219209
loadHRTF (hrtf);
220210
});
221211
}
@@ -265,14 +255,6 @@ void AnechoicProcessor::updateParameters()
265255
mCore.SetMagnitudes(magnitudes);
266256
}
267257

268-
bool AnechoicProcessor::loadHRTF (const File& file)
269-
{
270-
if (file == hrtfPath)
271-
return false;
272-
273-
return mHRTFsToLoad.addIfNotAlreadyThere (file);
274-
}
275-
276258
bool AnechoicProcessor::__loadHRTF (const File& file)
277259
{
278260
DBG("Loading HRTF: " << file.getFullPathName());
@@ -333,7 +315,7 @@ void AnechoicProcessor::addSoundSource (const Common::CVector3& position) {
333315
mTransforms.back().SetPosition (Common::CVector3 (1,0,0));
334316
}
335317

336-
void AnechoicProcessor::loadCustomHrtf (String fileTypes, std::function<void(File)> callback)
318+
void AnechoicProcessor::loadCustomHRTF (String fileTypes, std::function<void(File)> callback)
337319
{
338320
fc.reset (new FileChooser ("Choose a file to open...",
339321
HRTFDirectory(),

Source/Binaural/AnechoicProcessor.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ using CMonoBufferPair = Common::CEarPair<CMonoBuffer<float>>;
3030
void copySourceSettings(CSingleSourceRef oldSource, CSingleSourceRef newSource);
3131

3232
class AnechoicProcessor : public ChangeBroadcaster,
33-
public AudioProcessorValueTreeState::Listener,
34-
private Timer
33+
public AudioProcessorValueTreeState::Listener
3534
{
3635
public:
3736
//============================================================================
@@ -80,22 +79,20 @@ class AnechoicProcessor : public ChangeBroadcaster,
8079

8180
inline Common::CVector3 getSourcePosition (int index = 0)
8281
{
83-
if (index > mSources.size() - 1)
84-
return Common::CVector3();
82+
if (index > (int)mSources.size() - 1)
83+
return Common::CVector3 (0, 1, 0);
8584

8685
return mTransforms[index].GetPosition();
8786
}
8887

8988
inline Common::CVector3 getSourcePosition (CSingleSourceRef source)
9089
{
9190
if (mSources.empty())
92-
return Common::CVector3();
91+
return Common::CVector3 (0, 1, 0);
9392

9493
return getSourcePosition (0);
9594
}
9695

97-
void timerCallback() override;
98-
9996
//==========================================================================
10097
AudioParameterBool enableCustomizedITD;
10198
AudioParameterInt headCircumference;
@@ -114,12 +111,10 @@ class AnechoicProcessor : public ChangeBroadcaster,
114111
private:
115112
//============================================================================
116113
void updateParameters();
117-
118-
void reset(const File& hrtf);
119114
bool __loadHRTF (const File& file);
120115
bool __loadHRTF_ILD (const File& file);
121-
bool loadResourceFile(const File& file);
122-
void loadCustomHrtf (String fileTypes, std::function<void(File)> chosen);
116+
bool loadResourceFile (const File& file);
117+
void loadCustomHRTF (String fileTypes, std::function<void(File)> chosen);
123118

124119
//============================================================================
125120
double mSampleRate;
@@ -129,8 +124,6 @@ class AnechoicProcessor : public ChangeBroadcaster,
129124
std::vector<CSingleSourceRef> mSources;
130125
std::vector<Common::CTransform> mTransforms;
131126

132-
Array<File, CriticalSection> mHRTFsToLoad;
133-
134127
File hrtfPath;
135128
std::unique_ptr<FileChooser> fc;
136129
};

Source/Binaural/ReverbProcessor.cpp

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
//==============================================================================
2727
ReverbProcessor::ReverbProcessor (Binaural::CCore& core)
28-
: Thread ("ReverbProcessor")
29-
, reverbEnabled ("Reverb Enabled", "Reverb Enabled", true)
28+
: reverbEnabled ("Reverb Enabled", "Reverb Enabled", true)
3029
, reverbLevel ("Reverb Level", "Reverb Level", NormalisableRange<float> (-30.f, 6.f, 0.1f), -3.f)
3130
, reverbOrder ("Reverb Order", "Reverb Order", 0, 2, 1)
3231
, reverbBRIR ("Reverb BRIR", "Reverb BRIR", 0, BundledBRIRs.size() + 1, 0)
@@ -42,8 +41,6 @@ ReverbProcessor::ReverbProcessor (Binaural::CCore& core)
4241
ReverbProcessor::~ReverbProcessor()
4342
{
4443
reverbBRIR.removeListener (this);
45-
46-
stopThread (500);
4744
}
4845

4946
//==============================================================================
@@ -139,40 +136,12 @@ void ReverbProcessor::process (AudioBuffer<float>& quadIn, AudioBuffer<float>& s
139136
mPower = stereoOut.getRMSLevel (0, 0, numSamples);
140137
}
141138

142-
//==============================================================================
143-
bool ReverbProcessor::loadBRIR (const File& file)
144-
{
145-
if (file == mBRIRPath)
146-
return false;
147-
148-
mBRIRsToLoad.clearQuick();
149-
mBRIRsToLoad.add (file);
150-
151-
startThread();
152-
153-
return true;
154-
}
155-
156139
//==============================================================================
157140
StringArray ReverbProcessor::getBRIROptions()
158141
{
159142
return {"Small", "Medium", "Large", "Library", "Trapezoid", "Load File ..."};
160143
}
161144

162-
//==============================================================================
163-
void ReverbProcessor::run()
164-
{
165-
if (mBRIRsToLoad.size() > 0 && ! isLoading.load())
166-
{
167-
doLoadBRIR (mBRIRsToLoad.removeAndReturn (0));
168-
169-
if (mBRIRsToLoad.isEmpty())
170-
signalThreadShouldExit();
171-
}
172-
173-
sleep (100);
174-
}
175-
176145
//==============================================================================
177146
void ReverbProcessor::handleAsyncUpdate()
178147
{
@@ -223,7 +192,7 @@ void ReverbProcessor::parameterGestureChanged (int parameterIndex, bool gestureI
223192
}
224193

225194
//==============================================================================
226-
bool ReverbProcessor::doLoadBRIR (const File& file)
195+
bool ReverbProcessor::loadBRIR (const File& file)
227196
{
228197
isLoading.store (true);
229198

Source/Binaural/ReverbProcessor.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
//==============================================================================
2727
class ReverbProcessor : public ChangeBroadcaster,
28-
private Thread,
2928
private AsyncUpdater,
3029
private AudioProcessorParameter::Listener
3130
{
@@ -77,9 +76,6 @@ class ReverbProcessor : public ChangeBroadcaster,
7776

7877
private:
7978
//==========================================================================
80-
/** Thread */
81-
void run() override;
82-
8379
/** AsyncUpdater */
8480
void handleAsyncUpdate() override;
8581

@@ -88,8 +84,6 @@ class ReverbProcessor : public ChangeBroadcaster,
8884
void parameterGestureChanged (int parameterIndex, bool gestureIsStarting) override;
8985

9086
//==========================================================================
91-
bool doLoadBRIR (const File& file);
92-
9387
void resetBRIRIndex();
9488

9589
void updateParameters();
@@ -103,7 +97,6 @@ class ReverbProcessor : public ChangeBroadcaster,
10397
std::shared_ptr<Binaural::CEnvironment> mEnvironment;
10498

10599
File mBRIRPath;
106-
Array<File, CriticalSection> mBRIRsToLoad;
107100
std::unique_ptr<FileChooser> fc;
108101

109102
float mPower;

Source/Binaural/SpatialisePluginProcessor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ Toolkit3dtiPluginAudioProcessor::Toolkit3dtiPluginAudioProcessor()
5656
inFifo (2, 512),
5757
outFifo(2, 512)
5858
{
59-
auto position = Common::CVector3 (0, 1, 0);
60-
61-
mSpatialiser.addSoundSource (position);
59+
auto position = mSpatialiser.getSourcePosition();
6260

6361
using Parameter = AudioProcessorValueTreeState::Parameter;
6462
treeState.createAndAddParameter (std::make_unique<Parameter> ("Azimuth", "Azimuth", "", NormalisableRange<float> (-180.f, 180.f), position.GetAzimuthDegrees(), [](float value) { return String (value, 1); }, nullptr));

0 commit comments

Comments
 (0)