Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ak5k committed Dec 18, 2023
1 parent 05f2484 commit 28e0f78
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,15 @@ elseif(APPLE AND NOT IOS)
set(CPACK_GENERATOR "productbuild")
set(CPACK_PACKAGING_INSTALL_PREFIX "/Applications")
set(APP_DEST "${PRODUCT_NAME}/" )
# set(NDILIB_DEST "../Library/Application Support/${PRODUCT_NAME}" )
set(NDILIB_DEST "../Library/Application Support/${PRODUCT_NAME}/" )
# set(NDILIB_DEST "../Library/Application Support/${PRODUCT_NAME}/" )
set(NDILIB_DEST "../usr/local/lib" )
set(VST3_DEST "../Library/Audio/Plug-Ins/VST3" )
set(AU_DEST "../Library/Audio/Plug-Ins/Components" )
set(AAX_DEST "../Library/Application Support/Avid/Audio/Plug-Ins")

# set_target_properties(${PROJECT_NAME}_Standalone PROPERTIES INSTALL_RPATH ${PROJECT_SOURCE_DIR}/external/ndi5-sdk/lib)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_INSTALL_NAME_DIR "/Library/Application Support/${PRODUCT_NAME}/")
set(CMAKE_INSTALL_NAME_DIR "/usr/local/lib")
set_target_properties(${PROJECT_NAME}_Standalone PROPERTIES BUNDLE TRUE)

install(TARGETS ${PROJECT_NAME}_Standalone RUNTIME DESTINATION . BUNDLE DESTINATION . COMPONENT Standalone)
Expand Down
50 changes: 27 additions & 23 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
#include "PluginProcessor.h"
#include "PluginEditor.h"

std::mutex NdiAudioProcessor::init_mutex {};
std::mutex NdiAudioProcessor::init_mutex{};

//==============================================================================
NdiAudioProcessor::NdiAudioProcessor()
// : AudioProcessor()
: AudioProcessor(
BusesProperties()
.withInput("Input", juce::AudioChannelSet::stereo(), true)
.withOutput("Output", juce::AudioChannelSet::stereo(), true))
, apvts {*this, nullptr, juce::Identifier("APVTS"), createParameterLayout()}
.withOutput("Output", juce::AudioChannelSet::stereo(), true)),
apvts{*this, nullptr, juce::Identifier("APVTS"), createParameterLayout()}
{
std::scoped_lock init_lock(init_mutex);

std::string ndi_runtime_path {};
std::string ndi_runtime_path{};
auto ndi_runtime_path_included =
#ifdef __linux__
File::getSpecialLocation(File::userApplicationDataDirectory)
#else
File::getSpecialLocation(File::commonApplicationDataDirectory)
#endif
#ifdef __APPLE__
.getChildFile("Application Support")
#endif
.getChildFile(JucePlugin_Name)
.getChildFile(NDILIB_LIBRARY_NAME)
.getFullPathName();

#ifdef __APPLE__
ndi_runtime_path_included =
File::File("/usr/local/lib")
.getChildFile(NDILIB_LIBRARY_NAME)
.getFullPathName();
#endif

#ifdef __linux__
// linux and macos
goto linux_load;
linux_load:
#define dynamic_load 1
hNDILib = nullptr;
const char* p_ndi_runtime_v5 = getenv(NDILIB_REDIST_FOLDER);
const char *p_ndi_runtime_v5 = getenv(NDILIB_REDIST_FOLDER);
if (p_ndi_runtime_v5)
{
ndi_runtime_path = p_ndi_runtime_v5;
Expand All @@ -58,10 +62,10 @@ NdiAudioProcessor::NdiAudioProcessor()
hNDILib = dlopen(ndi_runtime_path.c_str(), RTLD_LOCAL | RTLD_LAZY);

// The main NDI entry point for dynamic loading if we got the librari
const NDIlib_v5* (*NDIlib_v5_load)(void) = nullptr;
const NDIlib_v5 *(*NDIlib_v5_load)(void) = nullptr;
if (hNDILib)
{
*((void**)&NDIlib_v5_load) = dlsym(hNDILib, "NDIlib_v5_load");
*((void **)&NDIlib_v5_load) = dlsym(hNDILib, "NDIlib_v5_load");
}
if (!NDIlib_v5_load)
{
Expand All @@ -82,7 +86,7 @@ NdiAudioProcessor::NdiAudioProcessor()
// Windows 32 and 64
#define dynamic_load 1

char* p_ndi_runtime_v5 = nullptr;
char *p_ndi_runtime_v5 = nullptr;
size_t sz = 0;
auto err = _dupenv_s(&p_ndi_runtime_v5, &sz, NDILIB_REDIST_FOLDER);
if (!err && p_ndi_runtime_v5 != nullptr)
Expand All @@ -109,10 +113,10 @@ NdiAudioProcessor::NdiAudioProcessor()
}
hNDILib = LoadLibraryA(ndi_runtime_path.c_str());

const NDIlib_v5* (*NDIlib_v5_load)(void) = nullptr;
const NDIlib_v5 *(*NDIlib_v5_load)(void) = nullptr;
if (hNDILib)
{
*((FARPROC*)&NDIlib_v5_load) =
*((FARPROC *)&NDIlib_v5_load) =
GetProcAddress(hNDILib, "NDIlib_v5_load");
}

Expand Down Expand Up @@ -276,7 +280,7 @@ const juce::String NdiAudioProcessor::getProgramName(int index)
}

void NdiAudioProcessor::changeProgramName(int index,
const juce::String& newName)
const juce::String &newName)
{
(void)index;
(void)newName;
Expand Down Expand Up @@ -350,7 +354,7 @@ void NdiAudioProcessor::releaseResources()
}

#ifndef JucePlugin_PreferredChannelConfigurations
bool NdiAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
bool NdiAudioProcessor::isBusesLayoutSupported(const BusesLayout &layouts) const
{
(void)layouts;
// This checks if the input layout matches the output layout
Expand All @@ -360,8 +364,8 @@ bool NdiAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
#endif

template <typename T>
void NdiAudioProcessor::processBlock2(juce::AudioBuffer<T>& buffer,
juce::MidiBuffer& midiMessages)
void NdiAudioProcessor::processBlock2(juce::AudioBuffer<T> &buffer,
juce::MidiBuffer &midiMessages)
{
(void)midiMessages;

Expand Down Expand Up @@ -432,7 +436,7 @@ void NdiAudioProcessor::processBlock2(juce::AudioBuffer<T>& buffer,
recv_channels.size() <= totalNumOutputChannels)
{
select_channels_ok = true;
for (auto&& i : recv_channels)
for (auto &&i : recv_channels)
{
if (i > num_source_channels)
select_channels_ok = false;
Expand Down Expand Up @@ -478,13 +482,13 @@ bool NdiAudioProcessor::hasEditor() const
return true; // (change this to false if you choose to not supply an editor)
}

juce::AudioProcessorEditor* NdiAudioProcessor::createEditor()
juce::AudioProcessorEditor *NdiAudioProcessor::createEditor()
{
return new NdiAudioProcessorEditor(*this);
}

//================================================================= =
void NdiAudioProcessor::getStateInformation(juce::MemoryBlock& destData)
void NdiAudioProcessor::getStateInformation(juce::MemoryBlock &destData)
{
// block. You should use this method to store your parameters in
// the memory block. You could do that either as raw data, or use the X
Expand All @@ -499,7 +503,7 @@ void NdiAudioProcessor::getStateInformation(juce::MemoryBlock& destData)
copyXmlToBinary(*xml, destData);
}

void NdiAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
void NdiAudioProcessor::setStateInformation(const void *data, int sizeInBytes)
{
// memory You should use this method to restore your paramete
// rs from this memory block, whose contents will have been created by the
Expand All @@ -522,7 +526,7 @@ void NdiAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
return;
}

void NdiAudioProcessor::parameterChanged(const String& parameterID,
void NdiAudioProcessor::parameterChanged(const String &parameterID,
float newValue)
{
if (!p_NDILib)
Expand Down Expand Up @@ -596,7 +600,7 @@ void NdiAudioProcessor::parameterChanged(const String& parameterID,

//==============================================================================
// This creates new instances of the plugin..
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
juce::AudioProcessor *JUCE_CALLTYPE createPluginFilter()
{
return new NdiAudioProcessor();
}

0 comments on commit 28e0f78

Please sign in to comment.