Skip to content

Commit

Permalink
Merge pull request #4 from 3DTune-In/release/1.1.4
Browse files Browse the repository at this point in the history
Release/1.1.4
  • Loading branch information
ragnaringi authored Mar 22, 2022
2 parents 828cb51 + 5d556b7 commit ce0ba4e
Show file tree
Hide file tree
Showing 24 changed files with 287 additions and 1,215 deletions.
2 changes: 1 addition & 1 deletion 3dti_Anechoic/3dti_Anechoic.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pluginVSTCategory="kPlugCategSpacializer" pluginAUMainType="'aupn'"
pluginFormats="buildAU,buildVST3" pluginManufacturer="3D Tune-In"
aaxIdentifier="eu.3d-tune-in.anechoic" bundleIdentifier="eu.3d-tune-in.anechoic"
version="1.1.3" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
version="1.1.4" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
pluginManufacturerCode="Tdti" pluginCode="Tspa" displaySplashScreen="1">
<MAINGROUP id="J6xy11" name="3DTI Anechoic Spatialisation">
<GROUP id="{59D5466E-D9A3-AE3E-55D8-0744C13FA3E0}" name="Libs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pluginAAXCategory="512" pluginVSTCategory="kPlugCategEffect"
pluginAUMainType="'aufx'" pluginFormats="buildAU,buildVST3" pluginManufacturer="3D Tune-In"
aaxIdentifier="eu.3d-tune-in.hasplugin" bundleIdentifier="eu.3d-tune-in.hasplugin"
version="1.1.3" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
version="1.1.4" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
pluginManufacturerCode="Dtun" pluginCode="Hasm" displaySplashScreen="1">
<MAINGROUP id="J6xy11" name="3DTI Hearing Aid Simulator">
<GROUP id="{59D5466E-D9A3-AE3E-55D8-0744C13FA3E0}" name="Libs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pluginAAXCategory="512" pluginVSTCategory="kPlugCategEffect"
pluginAUMainType="'aufx'" pluginFormats="buildAU,buildVST3" pluginManufacturer="3D Tune-In"
aaxIdentifier="eu.3d-tune-in.hlsplugin" bundleIdentifier="eu.3d-tune-in.hlsplugin"
version="1.1.3" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
version="1.1.4" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
pluginManufacturerCode="Dtun" pluginCode="Hlsm" displaySplashScreen="1">
<MAINGROUP id="J6xy11" name="3DTI Hearing Loss Simulator">
<GROUP id="{59D5466E-D9A3-AE3E-55D8-0744C13FA3E0}" name="Libs">
Expand Down
2 changes: 1 addition & 1 deletion 3dti_Reverb/3dti_Reverb.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pluginVSTCategory="kPlugCategSpacializer" pluginAUMainType="'aufx'"
pluginFormats="buildAU,buildVST3" pluginManufacturer="3D Tune-In"
aaxIdentifier="eu.3d-tune-in.reverbplugin" bundleIdentifier="eu.3d-tune-in.reverbplugin"
version="1.1.3" companyWebsite="http://3d-tune-in.eu" pluginCode="Trev"
version="1.1.4" companyWebsite="http://3d-tune-in.eu" pluginCode="Trev"
pluginManufacturerCode="Tdti" jucerFormatVersion="1" displaySplashScreen="1"
compilerFlagSchemes="NoDebug">
<MAINGROUP id="J6xy11" name="3DTI 3D Reverb">
Expand Down
2 changes: 1 addition & 1 deletion 3dti_Spatialisation.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pluginAAXCategory="512" pluginVSTCategory="kPlugCategSpacializer"
pluginFormats="buildAU,buildVST3" pluginManufacturer="3D Tune-In"
aaxIdentifier="eu.3d-tune-in.toolkitplugin" bundleIdentifier="eu.3d-tune-in.toolkitplugin"
version="1.1.3" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
version="1.1.4" companyWebsite="http://3d-tune-in.eu" jucerFormatVersion="1"
pluginManufacturerCode="Dtun" pluginCode="Plug" pluginAUMainType="'aufx'"
displaySplashScreen="1" compilerFlagSchemes="NoDebug">
<MAINGROUP id="J6xy11" name="3DTI Spatialisation">
Expand Down
116 changes: 55 additions & 61 deletions Source/Binaural/AnechoicControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \class AnechoicControls
*
* \brief Declaration of AnechoicControls interface.
* \date June 2019
* \date February 2022
*
* \authors Reactify Music LLP: R. Hrafnkelsson ||
* Coordinated by , A. Reyes-Lecuona (University of Malaga) and L.Picinali (Imperial College London) ||
Expand All @@ -11,7 +11,7 @@
* \b Project: 3DTI (3D-games for TUNing and lEarnINg about hearing aids) ||
* \b Website: http://3d-tune-in.eu/
*
* \b Copyright: University of Malaga and Imperial College London - 2021
* \b Copyright: University of Malaga and Imperial College London - 2022
*
* \b Licence: This copy of the 3D Tune-In Toolkit Plugin is licensed to you under the terms described in the LICENSE.md file included in this distribution.
*
Expand All @@ -21,18 +21,17 @@
#include "Utils.h"
#include "AnechoicControls.h"

AnechoicControls::AnechoicControls (AnechoicProcessor& processor)
: mCore (processor),
distanceAttenuationLabel("Distance Label", "dB attenuation per double distance")
AnechoicControls::AnechoicControls (AnechoicProcessor& processor,
AudioProcessorValueTreeState& params)
: mCore (processor)
, mParameters (params)
, buttonAttachment (params, "HRTF", hrtfMenu)
, distanceAttenuationLabel("Distance Label", "dB attenuation per double distance")
{
setOpaque (true);

for ( int i = 0; i < BundledHRTFs.size(); i++ ) {
hrtfMenu.addItem( BundledHRTFs[i], i+1 ); // IDs must be non-zero
}
hrtfMenu.onChange = [this] { hrtfMenuChanged(); };
hrtfMenu.setSelectedItemIndex(0, dontSendNotification);
addAndMakeVisible( hrtfMenu );
hrtfMenu.addItemList (BundledHRTFs, 1);
addAndMakeVisible (hrtfMenu);

headCircumferenceToggle.setButtonText( "Custom Head Circumference" );
headCircumferenceToggle.onClick = [this] { updateHeadCircumference(); };
Expand Down Expand Up @@ -80,10 +79,14 @@ AnechoicControls::AnechoicControls (AnechoicProcessor& processor)
addAndMakeVisible( distanceAttenuationSlider );

updateGui();
updateHrtfLabelText();

mCore.didReloadHRTF = [this] {
updateHrtfLabelText();
};
mCore.addChangeListener (this);
}

AnechoicControls::~AnechoicControls()
{
mCore.removeChangeListener (this);
}

void AnechoicControls::updateGui() {
Expand All @@ -107,6 +110,15 @@ void AnechoicControls::updateGui() {
qualityToggle.setToggleState( mCore.spatializationMode, dontSendNotification);
}

void AnechoicControls::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); // clear the background
g.setColour (Colours::white);
g.setFont (18.0f);
g.drawText ("Anechoic Path", getLocalBounds().withTrimmedBottom( getLocalBounds().getHeight() - 32 ),
Justification::centred, true);
}

void AnechoicControls::resized() {
auto area = getLocalBounds();
bypassToggle.setBounds( 10, 4, 80, 24 );
Expand All @@ -121,6 +133,20 @@ void AnechoicControls::resized() {
distanceAttenuationSlider.setBounds( 6, distanceAttenuationToggle.getBottom() + 4, area.getWidth()-20, 24);
}

void AnechoicControls::sliderValueChanged (Slider* slider)
{
if ( slider == &headCircumferenceSlider ) {
updateHeadCircumference();
} else {
mCore.sourceDistanceAttenuation = (float)slider->getValue();
}
}

void AnechoicControls::changeListenerCallback (ChangeBroadcaster *source)
{
updateHrtfLabelText();
}

void AnechoicControls::updateBypass() {
bool enabled = bypassToggle.getToggleState();
if ( enabled ) {
Expand All @@ -131,46 +157,6 @@ void AnechoicControls::updateBypass() {
setAlpha( enabled + 0.4f );
}

void AnechoicControls::hrtfMenuChanged() {
auto text = hrtfMenu.getText();
// Note(Ragnar): Windows FileChooser will only accept
// one filetype at a time so we provide separate options
if ( text == "Load 3DTI" ) {
loadCustomHrtf("*.3dti-hrtf");
} else if ( text == "Load SOFA" ) {
loadCustomHrtf("*.sofa");
} else {
mCore.loadHRTF(hrtfMenu.getSelectedItemIndex());
}
}

void AnechoicControls::loadCustomHrtf(String fileTypes) {
fc.reset (new FileChooser ("Choose a file to open...",
HRTFDirectory(),
fileTypes,
true));

fc->showDialog (FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles, nullptr);

auto results = fc->getURLResults();
if (results.isEmpty())
{
updateHrtfLabelText();
return;
}

auto result = results.getFirst();

String chosen;
chosen << (result.isLocalFile() ? result.getLocalFile().getFullPathName()
: result.toString (false));

hrtfMenu.setText ("Loading...");

if (! mCore.loadHRTF(File(chosen.removeCharacters("\n"))))
updateHrtfLabelText();
}

void AnechoicControls::updateHeadCircumference() {
bool enabled = headCircumferenceToggle.getToggleState();
mCore.enableCustomizedITD = enabled;
Expand All @@ -181,14 +167,22 @@ void AnechoicControls::updateHeadCircumference() {
headCircumferenceSlider.setEnabled(enabled);
}

void AnechoicControls::updateHrtfLabelText() {
auto hrtfIndex = mCore.getHrtfIndex();
if (hrtfIndex >= 0 && hrtfIndex < BundledHRTFs.size()-2) {
hrtfMenu.setSelectedItemIndex(hrtfIndex, dontSendNotification);
} else {
void AnechoicControls::updateHrtfLabelText()
{
auto* parameter = mParameters.getParameter ("HRTF");

auto hrtfValue = parameter->getValue();
int hrtfIndex = std::floor (parameter->convertFrom0to1 (hrtfValue));

if (hrtfIndex >= BundledHRTFs.size() - 2)
{
// Show filename if custom file is selected
auto hrtf = mCore.getHrtfPath().getFileNameWithoutExtension().upToLastOccurrenceOf("_", false, false);;
hrtfMenu.setText(hrtf, dontSendNotification);
auto hrtf = mCore.getHrtfPath().getFileNameWithoutExtension().upToLastOccurrenceOf ("_", false, false);
hrtfMenu.setText (hrtf, dontSendNotification);
}
else
{
hrtfMenu.setSelectedItemIndex (hrtfIndex, dontSendNotification);
}
}

Expand Down
37 changes: 15 additions & 22 deletions Source/Binaural/AnechoicControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \class AnechoicControls
*
* \brief Declaration of AnechoicControls interface.
* \date June 2019
* \date February 2022
*
* \authors Reactify Music LLP: R. Hrafnkelsson ||
* Coordinated by , A. Reyes-Lecuona (University of Malaga) and L.Picinali (Imperial College London) ||
Expand All @@ -11,7 +11,7 @@
* \b Project: 3DTI (3D-games for TUNing and lEarnINg about hearing aids) ||
* \b Website: http://3d-tune-in.eu/
*
* \b Copyright: University of Malaga and Imperial College London - 2021
* \b Copyright: University of Malaga and Imperial College London - 2022
*
* \b Licence: This copy of the 3D Tune-In Toolkit Plugin is licensed to you under the terms described in the LICENSE.md file included in this distribution.
*
Expand All @@ -26,39 +26,30 @@
//==============================================================================
/*
*/
class AnechoicControls : public Component, public Slider::Listener
class AnechoicControls : public Component,
public ChangeListener,
public Slider::Listener
{
public:
AnechoicControls (AnechoicProcessor& processor);
//============================================================================
AnechoicControls (AnechoicProcessor& processor, AudioProcessorValueTreeState& params);

~AnechoicControls() {}
~AnechoicControls();

void updateGui();

void paint (Graphics& g) override {
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); // clear the background
g.setColour(Colours::white);
g.setFont(18.0f);
g.drawText("Anechoic Path", getLocalBounds().withTrimmedBottom( getLocalBounds().getHeight() - 32 ),
Justification::centred, true);
}
void paint (Graphics& g) override;

void resized() override;

void sliderValueChanged(Slider* slider) override {
if ( slider == &headCircumferenceSlider ) {
updateHeadCircumference();
} else {
mCore.sourceDistanceAttenuation = (float)slider->getValue();
}
}
void sliderValueChanged(Slider* slider) override;

void changeListenerCallback (ChangeBroadcaster* source) override;

ToggleButton bypassToggle;

private:

void hrtfMenuChanged();
void loadCustomHrtf(String fileTypes);
//============================================================================
void updateBypass();
void updateHeadCircumference();
void updateHrtfLabelText();
Expand All @@ -68,8 +59,10 @@ class AnechoicControls : public Component, public Slider::Listener
void updateDistanceAttenuation();

AnechoicProcessor& mCore;
AudioProcessorValueTreeState& mParameters;

ComboBox hrtfMenu;
AudioProcessorValueTreeState::ComboBoxAttachment buttonAttachment;
ToggleButton headCircumferenceToggle;
Slider headCircumferenceSlider;
std::unique_ptr<FileChooser> fc;
Expand Down
2 changes: 1 addition & 1 deletion Source/Binaural/AnechoicPluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AnechoicPluginProcessorEditor::AnechoicPluginProcessorEditor (AnechoicPluginProc
: AudioProcessorEditor (&p)
, processor (p)
, sourceControls (p.getCore())
, anechoicControls (p.getCore())
, anechoicControls (p.getCore(), p.treeState)
, reverbControls (p)
, spatializerWidget (p.getCore())
{
Expand Down
16 changes: 4 additions & 12 deletions Source/Binaural/AnechoicPluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \class AnechoicPluginProcessor
*
* \brief Declaration of AnechoicPluginProcessor interface.
* \date November 2021
* \date February 2022
*
* \authors Reactify Music LLP: R. Hrafnkelsson ||
* Coordinated by , A. Reyes-Lecuona (University of Malaga) and L.Picinali (Imperial College London) ||
Expand Down Expand Up @@ -101,7 +101,7 @@ AnechoicPluginProcessor::AnechoicPluginProcessor()
treeState.addParameterListener ("Enable Reverb", this);

treeState.createAndAddParameter (std::make_unique<Parameter> ("HRTF", "HRTF", "", NormalisableRange<float>(0, BundledHRTFs.size()-1), 0, [](float value) { return String (value, 0); }, nullptr));
treeState.addParameterListener ("HRTF", this);
treeState.addParameterListener ("HRTF", &mSpatializer);

treeState.state = ValueTree("3DTI Anechoic Spatialisation Parameters");

Expand All @@ -111,10 +111,7 @@ AnechoicPluginProcessor::AnechoicPluginProcessor()
#endif
}

AnechoicPluginProcessor::~AnechoicPluginProcessor()
{
stopTimer();
}
AnechoicPluginProcessor::~AnechoicPluginProcessor() {}

//==============================================================================
const String AnechoicPluginProcessor::getName() const
Expand Down Expand Up @@ -205,8 +202,6 @@ void AnechoicPluginProcessor::prepareToPlay (double sampleRate, int samplesPerBl
mCore.SetAudioState ({(int)sampleRate, blockSizeInternal});

mSpatializer.setup (sampleRate/*,blockSizeInternal*/);

startTimer (30);
}

void AnechoicPluginProcessor::releaseResources() {
Expand Down Expand Up @@ -351,8 +346,7 @@ void AnechoicPluginProcessor::updateHostParameters()
{"Near Field", getCore().enableNearDistanceEffect},
{"Far Field", getCore().enableFarDistanceEffect},
{"Custom Head", getCore().enableCustomizedITD},
{"Head Circumference", getCore().headCircumference},
{"HRFT", getCore().getHrtfIndex() },
{"Head Circumference", getCore().headCircumference}
};

for (auto const & parameter : parameters)
Expand Down Expand Up @@ -421,8 +415,6 @@ void AnechoicPluginProcessor::parameterChanged (const String& parameterID, float
sources.front()->DisableReverbProcess();
}
}
} else if ( parameterID == "HRTF" ) {
getCore().loadHRTF((int)newValue);
}

if (sources.size() > 0)
Expand Down
Loading

0 comments on commit ce0ba4e

Please sign in to comment.