1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
/*
==============================================================================
This file is part of the IEM plug-in suite.
Authors: Daniel Rudrich, Franz Zotter
Copyright (c) 2017 - Institute of Electronic Music and Acoustics (IEM)
https://iem.at
The IEM plug-in suite is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The IEM plug-in suite is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this software. If not, see <https://www.gnu.org/licenses/>.
==============================================================================
*/
#pragma once
#include "../../resources/AudioProcessorBase.h"
#include "../JuceLibraryCode/JuceHeader.h"
#include "../../resources/AmbisonicDecoder.h"
#include "../../resources/NewtonApple/NewtonApple_hull3D.h"
#include "../../resources/ReferenceCountedDecoder.h"
#include "../../resources/customComponents/MailBox.h"
#include "../../resources/efficientSHvanilla.h"
#include "tDesign5200.h"
#define CONFIGURATIONHELPER_ENABLE_DECODER_METHODS 1
#define CONFIGURATIONHELPER_ENABLE_LOUDSPEAKERLAYOUT_METHODS 1
#include "../../resources/ConfigurationHelper.h"
#include "../../resources/HammerAitov.h"
#include "../../resources/ambisonicTools.h"
#include "AmbisonicNoiseBurst.h"
#include "NoiseBurst.h"
#define ProcessorClass AllRADecoderAudioProcessor
//==============================================================================
class AllRADecoderAudioProcessor
: public AudioProcessorBase<IOTypes::Ambisonics<7>, IOTypes::AudioChannels<64>>,
public juce::ValueTree::Listener
{
public:
constexpr static int numberOfInputChannels = 64;
constexpr static int numberOfOutputChannels = 64;
static const juce::StringArray weightsStrings;
//==============================================================================
AllRADecoderAudioProcessor();
~AllRADecoderAudioProcessor();
//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
void releaseResources() override;
void processBlock (juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
//==============================================================================
juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;
//==============================================================================
int getNumPrograms() override;
int getCurrentProgram() override;
void setCurrentProgram (int index) override;
const juce::String getProgramName (int index) override;
void changeProgramName (int index, const juce::String& newName) override;
//==============================================================================
void getStateInformation (juce::MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override;
//==============================================================================
void parameterChanged (const juce::String& parameterID, float newValue) override;
void updateBuffers() override; // use this to implement a buffer update method
//==============================================================================
void valueTreePropertyChanged (juce::ValueTree& treeWhosePropertyHasChanged,
const juce::Identifier& property) override;
void valueTreeChildAdded (juce::ValueTree& parentTree,
juce::ValueTree& childWhichHasBeenAdded) override;
void valueTreeChildRemoved (juce::ValueTree& parentTree,
juce::ValueTree& childWhichHasBeenRemoved,
int indexFromWhichChildWasRemoved) override;
void valueTreeChildOrderChanged (juce::ValueTree& parentTreeWhoseChildrenHaveMoved,
int oldIndex,
int newIndex) override;
void valueTreeParentChanged (juce::ValueTree& treeWhoseParentHasChanged) override;
void playNoiseBurst (const int channel);
void playAmbisonicNoiseBurst (const float azimuth, const float elevation);
void addRandomPoint();
void addImaginaryLoudspeakerBelow();
void clearLoudspeakers();
void undo() { undoManager.undo(); }
void redo() { undoManager.redo(); }
void rotate (const float degreesAddedToAzimuth);
void saveConfigurationToFile (juce::File destination);
void loadConfiguration (const juce::File& presetFile);
juce::ValueTree& getLoudspeakersValueTree() { return loudspeakers; }
juce::var lsps;
juce::Atomic<bool> updateLoudspeakerVisualization = false;
juce::Atomic<bool> updateTable = true;
juce::Atomic<bool> updateMessage = true;
juce::Atomic<bool> updateChannelCount = true;
ReferenceCountedDecoder::Ptr getCurrentDecoder() { return decoderConfig; }
std::vector<R3> points;
std::vector<Tri> triangles;
std::vector<juce::Vector3D<float>> normals;
juce::BigInteger imaginaryFlags;
juce::UndoManager undoManager;
juce::Result calculateDecoder();
void setLastDir (juce::File newLastDir);
juce::File getLastDir() { return lastDir; };
juce::Image energyDistribution;
juce::Image rEVector;
MailBox::Message messageToEditor;
//======= Parameters ===========================================================
std::vector<std::unique_ptr<juce::RangedAudioParameter>> createParameterLayout();
//==============================================================================
inline const bool interceptOSCMessage (juce::OSCMessage& message) override;
inline const bool processNotYetConsumedOSCMessage (const juce::OSCMessage& message) override;
private:
//==============================================================================
// list of used audio parameters
std::atomic<float>* inputOrderSetting;
std::atomic<float>* useSN3D;
std::atomic<float>* decoderOrder;
std::atomic<float>* exportDecoder;
std::atomic<float>* exportLayout;
std::atomic<float>* weights;
juce::ValueTree loudspeakers { "Loudspeakers" };
AmbisonicDecoder decoder;
ReferenceCountedDecoder::Ptr decoderConfig { nullptr };
bool isLayoutReady = false;
int highestChannelNumber;
juce::File lastDir;
std::unique_ptr<juce::PropertiesFile> properties;
// ========== METHODS
void prepareLayout();
juce::Result checkLayout();
juce::Result verifyLoudspeakers();
juce::Result calculateTris();
void convertLoudspeakersToArray();
void wrapSphericalCoordinates();
float getKappa (float gIm, float gRe1, float gRe2, int N);
juce::dsp::Matrix<float> getInverse (juce::dsp::Matrix<float> A);
juce::ValueTree createLoudspeakerFromCartesian (juce::Vector3D<float> cartesianCoordinates,
int channel,
bool isImaginary = false,
float gain = 1.0f);
juce::ValueTree createLoudspeakerFromSpherical (juce::Vector3D<float> sphericalCoordinates,
int channel,
bool isImaginary = false,
float gain = 1.0f);
juce::Vector3D<float> cartesianToSpherical (juce::Vector3D<float> cartvect);
juce::Vector3D<float> sphericalToCartesian (juce::Vector3D<float> sphervect);
juce::Vector3D<float> sphericalInRadiansToCartesian (juce::Vector3D<float> sphervect);
NoiseBurst noiseBurst;
AmbisonicNoiseBurst ambisonicNoiseBurst;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AllRADecoderAudioProcessor)
};
|