From eface4534edc15454f6cd70f54788abc38bf4261 Mon Sep 17 00:00:00 2001 From: Christof Ruch Date: Tue, 20 Dec 2022 18:58:06 +0100 Subject: [PATCH] [namespace juce] Modernize the library by removing the old JuceHeader.h, and switching to the new include style. Also, ditch the using namespace juce which leads to a big change but makes refactoring later easier. --- AudioRecorder.cpp | 40 ++++++++++++++-------------- AudioRecorder.h | 35 +++++++++++++------------ Data.cpp | 31 +++++++++++----------- Data.h | 33 +++++++++++------------ DebounceTimer.h | 4 +-- FileHelpers.cpp | 14 +++++----- FileHelpers.h | 14 +++++----- I18NHelper.cpp | 16 ++++++------ I18NHelper.h | 1 - JuceHeader.h | 48 ---------------------------------- Logger.cpp | 28 ++++++++++---------- Logger.h | 28 ++++++++++---------- MidiClocker.cpp | 6 ++--- MidiClocker.h | 8 +++--- MidiHelpers.cpp | 52 ++++++++++++++++++------------------- MidiHelpers.h | 18 ++++++------- MidiNetworkLocation.h | 2 ++ MidiNote.cpp | 4 ++- MidiNote.h | 2 +- MidiRecorder.cpp | 30 ++++++++++----------- MidiRecorder.h | 4 +-- MidiTuning.cpp | 8 +++--- MidiTuning.h | 9 ++++--- PackedDataFormatInfo.cpp | 6 ++--- PackedDataFormatInfo.h | 9 ++++--- RingBuffer.cpp | 14 +++++----- RingBuffer.h | 9 ++++--- RunWithRetry.h | 4 +-- Settings.cpp | 16 ++++++------ Settings.h | 12 ++++----- StreamLogger.cpp | 6 ++--- StreamLogger.h | 4 +-- Sysex.cpp | 56 ++++++++++++++++++++-------------------- Sysex.h | 10 +++---- TypedNamedValue.cpp | 28 ++++++++++---------- TypedNamedValue.h | 33 +++++++++++------------ WaitForEvent.cpp | 4 +-- WaitForEvent.h | 8 +++--- 38 files changed, 309 insertions(+), 345 deletions(-) delete mode 100644 JuceHeader.h diff --git a/AudioRecorder.cpp b/AudioRecorder.cpp index 3e4f0d1..201de38 100644 --- a/AudioRecorder.cpp +++ b/AudioRecorder.cpp @@ -28,10 +28,10 @@ const float kSignalThreshold = 0.001f; // Signals below this value are considered noise (don't trigger recording) -AudioRecorder::AudioRecorder(File directory, std::string const& baseFileName, RecordingType recordingType) : +AudioRecorder::AudioRecorder(juce::File directory, std::string const& baseFileName, RecordingType recordingType) : samplesWritten_(0), directory_(directory), baseFileName_(baseFileName), recordingType_(recordingType), writer_(nullptr), automaticRecordFromSilenceToSilence_(false), silenceDuration_(0) { - thread_ = std::make_unique("RecorderDiskWriter"); + thread_ = std::make_unique("RecorderDiskWriter"); thread_->startThread(); } @@ -47,7 +47,7 @@ AudioRecorder::~AudioRecorder() void AudioRecorder::startRecording(std::string const& filename, bool fromSilenceToSilence, std::function onSilence) { automaticRecordFromSilenceToSilence_ = fromSilenceToSilence; - activeFile_ = File(filename); + activeFile_ = juce::File(filename); onSilence_ = onSilence; if (isRecording()) { // Stop current recorder first @@ -76,9 +76,9 @@ bool AudioRecorder::hasDetectedSignal() const return isRecording() && hasFoundStart_; } -RelativeTime AudioRecorder::getElapsedTime() const +juce::RelativeTime AudioRecorder::getElapsedTime() const { - return RelativeTime(samplesWritten_ / (double) lastSampleRate_); + return juce::RelativeTime(samplesWritten_ / (double) lastSampleRate_); } juce::String AudioRecorder::getFilename() const @@ -101,19 +101,19 @@ void AudioRecorder::updateChannelInfo(int sampleRate, int numChannels) writeThread_.reset(); // Create the audio format writer - std::unique_ptr audioFormat; + std::unique_ptr audioFormat; std::string fileExtension; switch (recordingType_) { case RecordingType::WAV: - audioFormat = std::make_unique(); + audioFormat = std::make_unique(); fileExtension = ".wav"; break; case RecordingType::FLAC: - audioFormat = std::make_unique(); + audioFormat = std::make_unique(); fileExtension = ".flac"; break; case RecordingType::AIFF: - audioFormat = std::make_unique(); + audioFormat = std::make_unique(); fileExtension = ".aiff"; break; } @@ -125,7 +125,7 @@ void AudioRecorder::updateChannelInfo(int sampleRate, int numChannels) if (allowed == bitDepthRequested) bitsOk = true; if (!bitsOk) { jassert(false); - SimpleLogger::instance()->postMessage("Error: trying to create a file with a bit depth that is not supported by the format: " + String(bitDepthRequested)); + SimpleLogger::instance()->postMessage("Error: trying to create a file with a bit depth that is not supported by the format: " + juce::String(bitDepthRequested)); return; } @@ -134,7 +134,7 @@ void AudioRecorder::updateChannelInfo(int sampleRate, int numChannels) if (rate == sampleRate) rateOk = true; if (!rateOk) { jassert(false); - SimpleLogger::instance()->postMessage("Error: trying to create a file with a sample rate that is not supported by the format: " + String(sampleRate)); + SimpleLogger::instance()->postMessage("Error: trying to create a file with a sample rate that is not supported by the format: " + juce::String(sampleRate)); return; } @@ -169,7 +169,7 @@ void AudioRecorder::updateChannelInfo(int sampleRate, int numChannels) }*/ // Set up a new audio file to write to - startTime_ = Time::getCurrentTime(); + startTime_ = juce::Time::getCurrentTime(); if (activeFile_.getFullPathName().isEmpty()) { return; // activeFile_ = directory_.getNonexistentChildFile(String(baseFileName_) + startTime_.formatted("-%Y-%m-%d-%H-%M-%S"), fileExtension, false); @@ -178,10 +178,10 @@ void AudioRecorder::updateChannelInfo(int sampleRate, int numChannels) SimpleLogger::instance()->postMessage("Overwriting file " + activeFile_.getFullPathName()); activeFile_.deleteFile(); } - OutputStream* outStream = new FileOutputStream(activeFile_, 16384); + juce::OutputStream* outStream = new juce::FileOutputStream(activeFile_, 16384); // Create the writer based on the format and file - StringPairArray metaData; + juce::StringPairArray metaData; writer_ = audioFormat->createWriterFor(outStream, sampleRate, (unsigned) numChannels, bitDepthRequested, metaData, 1 /* unused by wav */); if (!writer_) { jassert(false); @@ -191,7 +191,7 @@ void AudioRecorder::updateChannelInfo(int sampleRate, int numChannels) } // Finally, create the new writer associating it with the background thread - writeThread_ = std::make_unique(writer_, *thread_, 16384); + writeThread_ = std::make_unique(writer_, *thread_, 16384); samplesWritten_ = 0; } @@ -203,7 +203,7 @@ void AudioRecorder::saveBlock(const float* const* data, int numSamples) // TODO - need a smarter strategy than that SimpleLogger::instance()->postMessage("Ups, FIFO full and can't write block to disk, lost it!"); } - samplesWritten_ += (uint64) numSamples; + samplesWritten_ += (juce::uint64) numSamples; } } @@ -212,7 +212,7 @@ juce::File AudioRecorder::getDirectory() const return directory_; } -void AudioRecorder::setDirectory(File& directory) +void AudioRecorder::setDirectory(juce::File& directory) { // Stop writing if any writeThread_.reset(); @@ -228,7 +228,7 @@ void AudioRecorder::audioDeviceIOCallbackWithContext (const float* const* inputC float* const* outputChannelData, int numOutputChannels, int numSamples, - const AudioIODeviceCallbackContext& context) + const juce::AudioIODeviceCallbackContext& context) { ignoreUnused(context); #endif @@ -279,7 +279,7 @@ void AudioRecorder::audioDeviceIOCallbackWithContext (const float* const* inputC if (automaticRecordFromSilenceToSilence_ && silenceDuration_ > 0.01 * lastSampleRate_) { // End of story writeThread_.reset(); - MessageManager::callAsync([this]() { onSilence_(); }); + juce::MessageManager::callAsync([this]() { onSilence_(); }); hasFoundStart_ = false; } } @@ -289,7 +289,7 @@ void AudioRecorder::audioDeviceIOCallbackWithContext (const float* const* inputC } } -void AudioRecorder::audioDeviceAboutToStart(AudioIODevice* device) +void AudioRecorder::audioDeviceAboutToStart(juce::AudioIODevice* device) { auto inputChannelMask = device->getActiveInputChannels(); hasFoundStart_ = false; diff --git a/AudioRecorder.h b/AudioRecorder.h index 5aedb6c..a45ad1a 100644 --- a/AudioRecorder.h +++ b/AudioRecorder.h @@ -24,7 +24,8 @@ #pragma once -#include "JuceHeader.h" +#include +#include enum class RecordingType { @@ -34,9 +35,9 @@ enum class RecordingType }; -class AudioRecorder : public AudioIODeviceCallback { +class AudioRecorder : public juce::AudioIODeviceCallback { public: - AudioRecorder(File directory, std::string const& baseFileName, RecordingType recordingType); + AudioRecorder(juce::File directory, std::string const& baseFileName, RecordingType recordingType); virtual ~AudioRecorder() override; void startRecording(std::string const& filename, bool fromSilenceToSilence, std::function onSilence); @@ -44,14 +45,14 @@ class AudioRecorder : public AudioIODeviceCallback { bool isRecording() const; bool hasDetectedSignal() const; - RelativeTime getElapsedTime() const; - String getFilename() const; - File getFile() const; + juce::RelativeTime getElapsedTime() const; + juce::String getFilename() const; + juce::File getFile() const; void updateChannelInfo(int sampleRate, int numChannels); - File getDirectory() const; - void setDirectory(File& directory); + juce::File getDirectory() const; + void setDirectory(juce::File& directory); #if JUCE_VERSION < 0x070000 virtual void audioDeviceIOCallback(const float** inputChannelData, int numInputChannels, float** outputChannelData, int numOutputChannels, int numSamples) override; @@ -61,23 +62,23 @@ class AudioRecorder : public AudioIODeviceCallback { float* const* outputChannelData, int numOutputChannels, int numSamples, - const AudioIODeviceCallbackContext& context) override; + const juce::AudioIODeviceCallbackContext& context) override; #endif - virtual void audioDeviceAboutToStart(AudioIODevice* device) override; + virtual void audioDeviceAboutToStart(juce::AudioIODevice* device) override; virtual void audioDeviceStopped() override; private: void saveBlock(const float* const* data, int numSamples); - Time startTime_; - uint64 samplesWritten_; - File activeFile_; - File directory_; + juce::Time startTime_; + juce::uint64 samplesWritten_; + juce::File activeFile_; + juce::File directory_; std::string baseFileName_; RecordingType recordingType_; - AudioFormatWriter* writer_; - std::unique_ptr thread_; - std::unique_ptr writeThread_; + juce::AudioFormatWriter* writer_; + std::unique_ptr thread_; + std::unique_ptr writeThread_; int lastSampleRate_; int lastNumChannels_; diff --git a/Data.cpp b/Data.cpp index 92e5988..81ded15 100644 --- a/Data.cpp +++ b/Data.cpp @@ -34,51 +34,51 @@ Data& Data::instance() return instance_; } -const juce::var Data::getProperty(const Identifier& name) +const juce::var Data::getProperty(const juce::Identifier& name) { return instance().get().getProperty(name); } -const juce::var Data::getEphemeralProperty(const Identifier& name) +const juce::var Data::getEphemeralProperty(const juce::Identifier& name) { return instance().getEphemeral().getProperty(name); } -const juce::var Data::getRuntimeProperty(const Identifier& name) +const juce::var Data::getRuntimeProperty(const juce::Identifier& name) { return instance().getRuntime().getProperty(name); } -juce::Value Data::getPropertyAsValue(const Identifier& name) +juce::Value Data::getPropertyAsValue(const juce::Identifier& name) { return instance().get().getPropertyAsValue(name, nullptr); } -juce::Value Data::getEphemeralPropertyAsValue(const Identifier& name) +juce::Value Data::getEphemeralPropertyAsValue(const juce::Identifier& name) { return instance().getEphemeral().getPropertyAsValue(name, nullptr); } -juce::Value Data::getRuntimePropertyAsValue(const Identifier& name) +juce::Value Data::getRuntimePropertyAsValue(const juce::Identifier& name) { return instance().getRuntime().getPropertyAsValue(name, nullptr); } -void Data::ensurePropertyExists(const Identifier &name, var defaultValue) +void Data::ensurePropertyExists(const juce::Identifier& name, juce::var defaultValue) { if (!instance_.get().hasProperty(name)) { instance_.get().setProperty(name, defaultValue, nullptr); } } -void Data::ensureEphemeralPropertyExists(const Identifier &name, var defaultValue) +void Data::ensureEphemeralPropertyExists(const juce::Identifier& name, juce::var defaultValue) { if (!instance_.getEphemeral().hasProperty(name)) { instance_.getEphemeral().setProperty(name, defaultValue, nullptr); } } -void Data::ensureRuntimePropertyExists(const Identifier &name, var defaultValue) +void Data::ensureRuntimePropertyExists(const juce::Identifier& name, juce::var defaultValue) { if (!instance_.getRuntime().hasProperty(name)) { instance_.getRuntime().setProperty(name, defaultValue, nullptr); @@ -87,14 +87,15 @@ void Data::ensureRuntimePropertyExists(const Identifier &name, var defaultValue) void Data::reset() { - instance_.tree_ = std::make_unique(Identifier("Setup")); - instance_.ephemeralTree_ = std::make_unique(Identifier("Ephemeral")); + instance_.tree_ = std::make_unique(juce::Identifier("Setup")); + instance_.ephemeralTree_ = std::make_unique(juce::Identifier("Ephemeral")); } Data::Data() - : tree_{std::make_unique(Identifier("Setup"))} - , ephemeralTree_{std::make_unique(Identifier("Ephemeral"))} - , runtimeTree_{std::make_unique(Identifier("EphemeralSurvivingReset"))} + : + tree_ { std::make_unique(juce::Identifier("Setup")) }, ephemeralTree_ { std::make_unique(juce::Identifier("Ephemeral")) }, runtimeTree_ { + std::make_unique(juce::Identifier("EphemeralSurvivingReset")) + } {} juce::ValueTree& Data::get() @@ -117,7 +118,7 @@ void Data::initializeFromSettings() auto xmlDoc = Settings::instance().get("ClientSettings", ""); auto topLevel = juce::parseXML(xmlDoc); if (topLevel) { - *tree_ = ValueTree::fromXml(*topLevel); + *tree_ = juce::ValueTree::fromXml(*topLevel); } } diff --git a/Data.h b/Data.h index b61b04e..8864b69 100644 --- a/Data.h +++ b/Data.h @@ -24,26 +24,27 @@ #pragma once -#include "JuceHeader.h" +#include +#include class Data { public: static Data& instance(); - static const var getProperty(const Identifier& name); // Convenience function for instance().get().getProperty() - static const var getEphemeralProperty(const Identifier& name); - static const var getRuntimeProperty(const Identifier& name); - static Value getPropertyAsValue(const Identifier& name); // Convenience function for instance().get().getPropertyAsValue() - static Value getEphemeralPropertyAsValue(const Identifier& name); - static Value getRuntimePropertyAsValue(const Identifier& name); - static void ensurePropertyExists(const Identifier &name, var defaultValue); - static void ensureEphemeralPropertyExists(const Identifier &name, var defaultValue); - static void ensureRuntimePropertyExists(const Identifier &name, var defaultValue); + static const juce::var getProperty(const juce::Identifier& name); // Convenience function for instance().get().getProperty() + static const juce::var getEphemeralProperty(const juce::Identifier& name); + static const juce::var getRuntimeProperty(const juce::Identifier& name); + static juce::Value getPropertyAsValue(const juce::Identifier& name); // Convenience function for instance().get().getPropertyAsValue() + static juce::Value getEphemeralPropertyAsValue(const juce::Identifier& name); + static juce::Value getRuntimePropertyAsValue(const juce::Identifier& name); + static void ensurePropertyExists(const juce::Identifier& name, juce::var defaultValue); + static void ensureEphemeralPropertyExists(const juce::Identifier& name, juce::var defaultValue); + static void ensureRuntimePropertyExists(const juce::Identifier& name, juce::var defaultValue); static void reset(); - ValueTree& get(); - ValueTree& getEphemeral(); - ValueTree& getRuntime(); + juce::ValueTree& get(); + juce::ValueTree& getEphemeral(); + juce::ValueTree& getRuntime(); void initializeFromSettings(); void saveToSettings(); @@ -53,7 +54,7 @@ class Data { static Data instance_; - std::unique_ptr tree_; - std::unique_ptr ephemeralTree_; - std::unique_ptr runtimeTree_; + std::unique_ptr tree_; + std::unique_ptr ephemeralTree_; + std::unique_ptr runtimeTree_; }; diff --git a/DebounceTimer.h b/DebounceTimer.h index 92937aa..487ac01 100644 --- a/DebounceTimer.h +++ b/DebounceTimer.h @@ -24,9 +24,9 @@ #pragma once -#include "JuceHeader.h" +#include -class DebounceTimer : public Timer { +class DebounceTimer : public juce::Timer { public: void callDebounced(std::function action, int milliseconds); diff --git a/FileHelpers.cpp b/FileHelpers.cpp index e0a874b..052bf12 100644 --- a/FileHelpers.cpp +++ b/FileHelpers.cpp @@ -24,33 +24,33 @@ #include "FileHelpers.h" -juce::File getOrCreateSubdirectory(File dir, String const &name) +juce::File getOrCreateSubdirectory(juce::File dir, juce::String const &name) { - File subdir = dir.getChildFile(name); + juce::File subdir = dir.getChildFile(name); if (!subdir.exists()) { subdir.createDirectory(); } return subdir; } -int FileDateComparatorOldestFirst::compareElements(File const &first, File const &second) +int FileDateComparatorOldestFirst::compareElements(juce::File const &first, juce::File const &second) { if (first.getLastModificationTime() < second.getLastModificationTime()) return -1; if (first.getLastModificationTime() > second.getLastModificationTime()) return 1; return 0; } -int FileDateComparatorNewestFirst::compareElements(File const &first, File const &second) +int FileDateComparatorNewestFirst::compareElements(juce::File const &first, juce::File const &second) { if (first.getLastModificationTime() < second.getLastModificationTime()) return 1; if (first.getLastModificationTime() > second.getLastModificationTime()) return -1; return 0; } -TemporaryDirectory::TemporaryDirectory() +TemporaryDirectory::TemporaryDirectory(juce::String prefix, juce::String suffix) { - File tempDir = File::getSpecialLocation(File::tempDirectory); - dir_ = tempDir.getNonexistentChildFile("knobkraft", "tmp"); + juce::File tempDir = juce::File::getSpecialLocation(juce::File::tempDirectory); + dir_ = tempDir.getNonexistentChildFile(prefix, suffix); dir_.createDirectory(); } diff --git a/FileHelpers.h b/FileHelpers.h index 4e0f0a3..25c625a 100644 --- a/FileHelpers.h +++ b/FileHelpers.h @@ -24,30 +24,30 @@ #pragma once -#include "JuceHeader.h" +#include //! Do get the file for the subdirectory, if it doesn't exist create a directory and return it -File getOrCreateSubdirectory(File dir, String const &name); +juce::File getOrCreateSubdirectory(juce::File dir, juce::String const &name); // We might want to sort files by date class FileDateComparatorOldestFirst { public: - static int compareElements(File const &first, File const &second); + static int compareElements(juce::File const &first, juce::File const &second); }; class FileDateComparatorNewestFirst { public: - static int compareElements(File const &first, File const &second); + static int compareElements(juce::File const &first, juce::File const &second); }; class TemporaryDirectory { public: - TemporaryDirectory(); + TemporaryDirectory(juce::String prefix, juce::String suffix); virtual ~TemporaryDirectory(); - File asFile(); + juce::File asFile(); std::string name(); private: - File dir_; + juce::File dir_; }; diff --git a/I18NHelper.cpp b/I18NHelper.cpp index b703665..bcb5171 100644 --- a/I18NHelper.cpp +++ b/I18NHelper.cpp @@ -24,7 +24,7 @@ #include "I18NHelper.h" -#include "JuceHeader.h" +#include #include "Logger.h" @@ -36,7 +36,7 @@ #ifdef GETTEXT_AVAILABLE -File gLocalePath; +juce::File gLocalePath; juce::String U8(const char* translatedString) { @@ -51,12 +51,12 @@ juce::String U8(const char* translatedString) void globalSetupLocale() { - File executablePath = File::getSpecialLocation(File::SpecialLocationType::currentExecutableFile).getParentDirectory(); + juce::File executablePath = juce::File::getSpecialLocation(juce::File::SpecialLocationType::currentExecutableFile).getParentDirectory(); gLocalePath = executablePath.getChildFile("share"); // Normal case - the share directory with the gmo files is a subdirectory of the executable directory if (!gLocalePath.exists()) { // Special case - if we are building with a multi-config generator and are running a development version, the share path could be one directory up! - File alternativeLocalePath = executablePath.getParentDirectory().getChildFile("share"); + juce::File alternativeLocalePath = executablePath.getParentDirectory().getChildFile("share"); if (!alternativeLocalePath.exists()) { SimpleLogger::instance()->postMessage("Translation files not found at " + gLocalePath.getFullPathName() + ", turning off translations!"); return; @@ -64,7 +64,7 @@ void globalSetupLocale() gLocalePath = alternativeLocalePath; } auto result = bindtextdomain(USE_GETTEXT_TEXT_DOMAIN, gLocalePath.getFullPathName().getCharPointer()); - SimpleLogger::instance()->postMessage("Bindtext domain gave us " + String(result)); + SimpleLogger::instance()->postMessage("Bindtext domain gave us " + juce::String(result)); #if defined(WIN32) || defined(__APPLE__) std::string displayLocale = juce::SystemStats::getDisplayLanguage().toStdString(); #else @@ -92,18 +92,18 @@ void switchDisplayLanguage(const char* languageID) #else auto returnValue = ::setlocale(LC_MESSAGES, languageID); if (returnValue == nullptr) { - SimpleLogger::instance()->postMessage("User locale " + String(languageID) + " requested but error returned"); + SimpleLogger::instance()->postMessage("User locale " + juce::String(languageID) + " requested but error returned"); } localeToSet = languageID; #endif // Make sure there is a directory of that ID if (!gLocalePath.getChildFile(localeToSet).exists()) { - SimpleLogger::instance()->postMessage("User locale " + String(localeToSet) + " requested but no matching directory at " + gLocalePath.getFullPathName()); + SimpleLogger::instance()->postMessage("User locale " + juce::String(localeToSet) + " requested but no matching directory at " + gLocalePath.getFullPathName()); } textdomain(USE_GETTEXT_TEXT_DOMAIN); - SimpleLogger::instance()->postMessage("Setting user language to " + String(languageID) + " reported to " + String(localeToSet)); + SimpleLogger::instance()->postMessage("Setting user language to " + juce::String(languageID) + " reported to " + juce::String(localeToSet)); } #endif diff --git a/I18NHelper.h b/I18NHelper.h index ae73d6c..38e6e40 100644 --- a/I18NHelper.h +++ b/I18NHelper.h @@ -25,7 +25,6 @@ #pragma once #ifdef GETTEXT_AVAILABLE -#include "JuceHeader.h" #include #include diff --git a/JuceHeader.h b/JuceHeader.h deleted file mode 100644 index b2f5c7f..0000000 --- a/JuceHeader.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2019-2021 Christof Ruch - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "juce_core/juce_core.h" -//#include "juce_analytics/juce_analytics.h" -#include "juce_audio_basics/juce_audio_basics.h" -#include "juce_audio_devices/juce_audio_devices.h" -#include "juce_audio_formats/juce_audio_formats.h" -//#include "juce_audio_plugin_client/juce_audio_plugin_client.h" -#include "juce_audio_processors/juce_audio_processors.h" -#include "juce_audio_utils/juce_audio_utils.h" -//#include "juce_blocks_basics/juce_blocks_basics.h" -//#include "juce_box2d/juce_box2d.h" -#include "juce_core/juce_core.h" -#include "juce_cryptography/juce_cryptography.h" -#include "juce_data_structures/juce_data_structures.h" -#include "juce_dsp/juce_dsp.h" -#include "juce_events/juce_events.h" -#include "juce_graphics/juce_graphics.h" -#include "juce_gui_basics/juce_gui_basics.h" -#include "juce_gui_extra/juce_gui_extra.h" -#include "juce_opengl/juce_opengl.h" -//#include "juce_osc/juce_osc.h" -//#include "juce_product_unlocking/juce_product_unlocking.h" -//#include "juce_video/juce_video.h" - -using namespace juce; diff --git a/Logger.cpp b/Logger.cpp index 0f99c8b..f2cf55b 100644 --- a/Logger.cpp +++ b/Logger.cpp @@ -24,15 +24,17 @@ #include "Logger.h" +#include + class BootstrapLogger : public SimpleLogger { public: - virtual void postMessage(const String& message) override; - virtual void postMessageOncePerRun(const String& message) override; + virtual void postMessage(const juce::String& message) override; + virtual void postMessageOncePerRun(const juce::String& message) override; - std::vector getLogMessagesDuringBoot(); + std::vector getLogMessagesDuringBoot(); private: - std::vector logMessagesDuringBoot_; + std::vector logMessagesDuringBoot_; }; SimpleLogger::SimpleLogger() @@ -45,7 +47,7 @@ SimpleLogger::SimpleLogger() } // Don't do this immediately, but rather when the message queue runs! - MessageManager::callAsync([this, bootstrap]() { + juce::MessageManager::callAsync([this, bootstrap]() { for (auto const& text : bootstrap->getLogMessagesDuringBoot()) { postMessage(text); } @@ -81,15 +83,15 @@ void SimpleLogger::shutdown() hasBeenShutdown_ = true; // To prevent logging during destruction } -void SimpleLogger::markBenchmarkPoint(const String& message) +void SimpleLogger::markBenchmarkPoint(const juce::String& message) { - Time now = Time::getCurrentTime(); + juce::Time now = juce::Time::getCurrentTime(); std::stringstream result; result << "Benchmark at " << now.toISO8601(true) << ": " << message; postMessage(result.str()); } -void SimpleLogger::writeToFile(const String& message) +void SimpleLogger::writeToFile(const juce::String& message) { fileLogger_->writeToLog(message); } @@ -97,23 +99,23 @@ void SimpleLogger::writeToFile(const String& message) SimpleLogger* SimpleLogger::instance_ = new BootstrapLogger(); bool SimpleLogger::hasBeenShutdown_ = false; -void SimpleLogger::logMessage(const String& message) +void SimpleLogger::logMessage(const juce::String& message) { postMessage(message); } -void BootstrapLogger::postMessage(const String& message) +void BootstrapLogger::postMessage(const juce::String& message) { logMessagesDuringBoot_.push_back(message); } -void BootstrapLogger::postMessageOncePerRun(const String& message) +void BootstrapLogger::postMessageOncePerRun(const juce::String& message) { - jassertfalse; + //jassertfalse; logMessagesDuringBoot_.push_back(message); } -std::vector BootstrapLogger::getLogMessagesDuringBoot() +std::vector BootstrapLogger::getLogMessagesDuringBoot() { return logMessagesDuringBoot_; } diff --git a/Logger.h b/Logger.h index a91eb9e..c5ba7c6 100644 --- a/Logger.h +++ b/Logger.h @@ -24,27 +24,27 @@ #pragma once -#include "JuceHeader.h" +#include -class SimpleLogger : private Logger { +class SimpleLogger : private juce::Logger { public: - SimpleLogger(); - virtual ~SimpleLogger() override; + SimpleLogger(); + virtual ~SimpleLogger() override; - static SimpleLogger *instance(); - static void shutdown(); + static SimpleLogger *instance(); + static void shutdown(); - virtual void postMessage(const String& message) = 0; - virtual void postMessageOncePerRun(const String& message) = 0; - virtual void markBenchmarkPoint(const String &message); + virtual void postMessage(const juce::String &message) = 0; + virtual void postMessageOncePerRun(const juce::String &message) = 0; + virtual void markBenchmarkPoint(const juce::String &message); - void writeToFile(const String &message); + void writeToFile(const juce::String &message); protected: - void logMessage(const String& message) override; + void logMessage(const juce::String &message) override; private: - static SimpleLogger *instance_; - std::unique_ptr fileLogger_; - static bool hasBeenShutdown_; + static SimpleLogger *instance_; + std::unique_ptr fileLogger_; + static bool hasBeenShutdown_; }; diff --git a/MidiClocker.cpp b/MidiClocker.cpp index 37ca481..ebc745a 100644 --- a/MidiClocker.cpp +++ b/MidiClocker.cpp @@ -32,7 +32,7 @@ MidiClocker::MidiClocker() double MidiClocker::getCurrentBPM() { - ScopedLock lock(lock_); + juce::ScopedLock lock(lock_); // Do we have at least one clock source? if (clockTimes_.size() == 0) { @@ -56,9 +56,9 @@ double MidiClocker::getCurrentBPM() return 60.0 / averageSecondsPerBPM / 24; // MIDI Clock sends at 24 pulses per quarter note (ppqn) } -void MidiClocker::processClockMessage(String const &midiSource, MidiMessage const &message) +void MidiClocker::processClockMessage(juce::String const &midiSource, juce::MidiMessage const &message) { - ScopedLock lock(lock_); + juce::ScopedLock lock(lock_); if (clockTimes_.find(midiSource) == clockTimes_.end()) { // First clock signal on this source! diff --git a/MidiClocker.h b/MidiClocker.h index b55432d..31ecb2b 100644 --- a/MidiClocker.h +++ b/MidiClocker.h @@ -24,7 +24,7 @@ #pragma once -#include "JuceHeader.h" +#include #include @@ -36,11 +36,11 @@ class MidiClocker { double getCurrentBPM(); - void processClockMessage(String const &midiSource, MidiMessage const &message); + void processClockMessage(juce::String const &midiSource, juce::MidiMessage const &message); size_t numInputsWithClock() const; - std::vector inputsWithClock() const; + std::vector inputsWithClock() const; private: juce::CriticalSection lock_; - std::map> clockTimes_; + std::map> clockTimes_; }; diff --git a/MidiHelpers.cpp b/MidiHelpers.cpp index cca9946..95ccad7 100644 --- a/MidiHelpers.cpp +++ b/MidiHelpers.cpp @@ -24,15 +24,15 @@ #include "MidiHelpers.h" -juce::MidiMessage MidiHelpers::sysexMessage(std::vector const &sysEx) +juce::MidiMessage MidiHelpers::sysexMessage(std::vector const &sysEx) { - return MidiMessage::createSysExMessage(sysEx.data(), (int) sysEx.size()); + return juce::MidiMessage::createSysExMessage(sysEx.data(), (int) sysEx.size()); } -juce::MidiBuffer MidiHelpers::bufferFromMessages(std::vector const &messages) +juce::MidiBuffer MidiHelpers::bufferFromMessages(std::vector const &messages) { // We assume the same timestamp for all messages in this little helper - MidiBuffer buffer; + juce::MidiBuffer buffer; int num = 0; for (auto message : messages) { jassert(message.getRawDataSize() <= 65535); @@ -41,40 +41,40 @@ juce::MidiBuffer MidiHelpers::bufferFromMessages(std::vector const return buffer; } -std::vector MidiHelpers::generateRPN(int midiChannel, int parameterNumber, int value, bool isNRPN, bool use14BitValue, bool MSBbeforeLSB) +std::vector MidiHelpers::generateRPN(int midiChannel, int parameterNumber, int value, bool isNRPN, bool use14BitValue, bool MSBbeforeLSB) { jassert(midiChannel > 0 && midiChannel <= 16); jassert(parameterNumber >= 0 && parameterNumber < 16384); jassert(value >= 0 && value < (use14BitValue ? 16384 : 128)); - uint8 parameterLSB = uint8(parameterNumber & 0x7f); - uint8 parameterMSB = uint8(parameterNumber >> 7); + juce::uint8 parameterLSB = juce::uint8(parameterNumber & 0x7f); + juce::uint8 parameterMSB = juce::uint8(parameterNumber >> 7); - uint8 valueLSB = use14BitValue ? uint8(value & 0x7f) : 0x00; - uint8 valueMSB = use14BitValue ? uint8(value >> 7) : uint8(value); + juce::uint8 valueLSB = use14BitValue ? juce::uint8(value & 0x7f) : 0x00; + juce::uint8 valueMSB = use14BitValue ? juce::uint8(value >> 7) : juce::uint8(value); - uint8 channelByte = uint8(0xb0 + midiChannel - 1); + juce::uint8 channelByte = juce::uint8(0xb0 + midiChannel - 1); - std::vector buffer; + std::vector buffer; if (MSBbeforeLSB) { - buffer.push_back(MidiMessage(channelByte, isNRPN ? 0x63 : 0x65, parameterMSB)); - buffer.push_back(MidiMessage(channelByte, isNRPN ? 0x62 : 0x64, parameterLSB)); - buffer.push_back(MidiMessage(channelByte, 0x06, valueMSB)); - if (use14BitValue) buffer.push_back(MidiMessage(channelByte, 0x26, valueLSB)); + buffer.push_back(juce::MidiMessage(channelByte, isNRPN ? 0x63 : 0x65, parameterMSB)); + buffer.push_back(juce::MidiMessage(channelByte, isNRPN ? 0x62 : 0x64, parameterLSB)); + buffer.push_back(juce::MidiMessage(channelByte, 0x06, valueMSB)); + if (use14BitValue) buffer.push_back(juce::MidiMessage(channelByte, 0x26, valueLSB)); } else { - buffer.push_back(MidiMessage(channelByte, isNRPN ? 0x62 : 0x64, parameterLSB)); - buffer.push_back(MidiMessage(channelByte, isNRPN ? 0x63 : 0x65, parameterMSB)); + buffer.push_back(juce::MidiMessage(channelByte, isNRPN ? 0x62 : 0x64, parameterLSB)); + buffer.push_back(juce::MidiMessage(channelByte, isNRPN ? 0x63 : 0x65, parameterMSB)); // sending the value LSB is optional, but must come before sending the value MSB: - if (use14BitValue) buffer.push_back(MidiMessage(channelByte, 0x26, valueLSB)); - buffer.push_back(MidiMessage(channelByte, 0x06, valueMSB)); + if (use14BitValue) buffer.push_back(juce::MidiMessage(channelByte, 0x26, valueLSB)); + buffer.push_back(juce::MidiMessage(channelByte, 0x06, valueMSB)); } return buffer; } -bool MidiHelpers::equalSysexMessageContent(MidiMessage const &message1, MidiMessage const &message2, int digitsToCompare /* = -1 */) +bool MidiHelpers::equalSysexMessageContent(juce::MidiMessage const &message1, juce::MidiMessage const &message2, int digitsToCompare /* = -1 */) { if (!(message1.isSysEx() & message2.isSysEx())) return false; if (digitsToCompare == -1) { @@ -93,7 +93,7 @@ bool MidiHelpers::equalSysexMessageContent(MidiMessage const &message1, MidiMess return true; } -bool MidiHelpers::isSysexMessageMatching(MidiMessage const &message, std::vector> const &indexAndContentCondition) +bool MidiHelpers::isSysexMessageMatching(juce::MidiMessage const &message, std::vector> const &indexAndContentCondition) { if (!message.isSysEx()) { return false; @@ -113,21 +113,21 @@ bool MidiHelpers::isSysexMessageMatching(MidiMessage const &message, std::vector return true; } -juce::uint8 MidiHelpers::checksum7bit(std::vector const &data) +juce::uint8 MidiHelpers::checksum7bit(std::vector const &data) { int sum = 0; - std::for_each(data.begin(), data.end(), [&](uint8 byte) { sum += byte; }); + std::for_each(data.begin(), data.end(), [&](juce::uint8 byte) { sum += byte; }); return sum & 0x7f; } -bool MidiHelpers::isEmptySysex(MidiMessage const &m) +bool MidiHelpers::isEmptySysex(juce::MidiMessage const &m) { return m.isSysEx() && m.getSysExDataSize() == 0; } -juce::MidiBuffer MidiHelpers::removeEmptySysexMessages(MidiBuffer const &midiBuffer) +juce::MidiBuffer MidiHelpers::removeEmptySysexMessages(juce::MidiBuffer const &midiBuffer) { - MidiBuffer filtered; + juce::MidiBuffer filtered; for (auto message : midiBuffer) { auto m = message.getMessage(); // Suppress empty sysex messages, they seem to confuse vintage hardware (e.g. the Kawai K3 in particular) diff --git a/MidiHelpers.h b/MidiHelpers.h index f2aed46..338f8e8 100644 --- a/MidiHelpers.h +++ b/MidiHelpers.h @@ -24,18 +24,18 @@ #pragma once -#include "JuceHeader.h" +#include class MidiHelpers { public: - static MidiMessage sysexMessage(std::vector const &data); - static MidiBuffer bufferFromMessages(std::vector const &messages); - static std::vector generateRPN(int midiChannel, int parameterNumber, int value, bool isNRPN, bool use14BitValue, bool MSBbeforeLSB); - static uint8 checksum7bit(std::vector const &data); + static juce::MidiMessage sysexMessage(std::vector const &data); + static juce::MidiBuffer bufferFromMessages(std::vector const &messages); + static std::vector generateRPN(int midiChannel, int parameterNumber, int value, bool isNRPN, bool use14BitValue, bool MSBbeforeLSB); + static juce::uint8 checksum7bit(std::vector const &data); - static bool isEmptySysex(MidiMessage const &m); - static MidiBuffer removeEmptySysexMessages(MidiBuffer const &midiBuffer); + static bool isEmptySysex(juce::MidiMessage const &m); + static juce::MidiBuffer removeEmptySysexMessages(juce::MidiBuffer const &midiBuffer); - static bool equalSysexMessageContent(MidiMessage const &message1, MidiMessage const &message2, int digitsToCompare = -1); - static bool isSysexMessageMatching(MidiMessage const &message, std::vector> const &indexAndContentCondition); + static bool equalSysexMessageContent(juce::MidiMessage const &message1, juce::MidiMessage const &message2, int digitsToCompare = -1); + static bool isSysexMessageMatching(juce::MidiMessage const &message, std::vector> const &indexAndContentCondition); }; diff --git a/MidiNetworkLocation.h b/MidiNetworkLocation.h index a341c22..f454729 100644 --- a/MidiNetworkLocation.h +++ b/MidiNetworkLocation.h @@ -24,6 +24,8 @@ #pragma once +#include + #include #include "MidiChannel.h" diff --git a/MidiNote.cpp b/MidiNote.cpp index f73e335..31487eb 100644 --- a/MidiNote.cpp +++ b/MidiNote.cpp @@ -24,6 +24,8 @@ #include "MidiNote.h" +#include + #include MidiNote::MidiNote(double frequency, double frequencyA4 /* = 440.0 */) : frequency_(frequency), frequencyA4_(frequencyA4) @@ -78,7 +80,7 @@ std::string MidiNote::name() const { // Ok, JUCE can do this for us if (midiNote_ > 0) { - return MidiMessage::getMidiNoteName(midiNote_, true, true, 4).toStdString(); + return juce::MidiMessage::getMidiNoteName(midiNote_, true, true, 4).toStdString(); } else { return "-"; diff --git a/MidiNote.h b/MidiNote.h index b1c0d1a..410407e 100644 --- a/MidiNote.h +++ b/MidiNote.h @@ -24,7 +24,7 @@ #pragma once -#include "JuceHeader.h" +#include class MidiNote { public: diff --git a/MidiRecorder.cpp b/MidiRecorder.cpp index b4bb1f1..7b1a63a 100644 --- a/MidiRecorder.cpp +++ b/MidiRecorder.cpp @@ -27,29 +27,29 @@ #include "Settings.h" #include "StreamLogger.h" -MidiRecorder::MidiRecorder(AudioDeviceManager &deviceManager) : isRecording_(false), deviceManager_(deviceManager) +MidiRecorder::MidiRecorder(juce::AudioDeviceManager &deviceManager) : isRecording_(false), deviceManager_(deviceManager) { // Just enable *all* Midi devices. Not sure if that's smart in the long run, but hey... - auto devices = MidiInput::getAvailableDevices(); + auto devices = juce::MidiInput::getAvailableDevices(); for (int i = 0; i < devices.size(); i++) { enableMidiInput(devices[i]); } clocker_ = std::make_shared(); } -void MidiRecorder::saveToFile(String filename) +void MidiRecorder::saveToFile(juce::String filename) { - Time now = Time::getCurrentTime(); - File directory = Settings::instance().getSessionStorageDir(); - File midFile = directory.getNonexistentChildFile(String(filename) + now.formatted("-%Y-%m-%d-%H-%M-%S"), ".mid", false); - MidiFile midiFile; + juce::Time now = juce::Time::getCurrentTime(); + juce::File directory = Settings::instance().getSessionStorageDir(); + juce::File midFile = directory.getNonexistentChildFile(juce::String(filename) + now.formatted("-%Y-%m-%d-%H-%M-%S"), ".mid", false); + juce::MidiFile midiFile; for (auto track : recorded_) { if (track.second.getNumEvents() > 0) { track.second.updateMatchedPairs(); midiFile.addTrack(track.second); } } - FileOutputStream outputStream(midFile, 16384); + juce::FileOutputStream outputStream(midFile, 16384); //midiFile.setSmpteTimeFormat(25, 400); // Tenths of milliseconds at 25 fps midiFile.setTicksPerQuarterNote(96); midiFile.writeTo(outputStream); @@ -71,15 +71,15 @@ MidiRecorder::~MidiRecorder() void MidiRecorder::startRecording() { - recordingStartTime_ = Time::getMillisecondCounterHiRes() / 1000.0; + recordingStartTime_ = juce::Time::getMillisecondCounterHiRes() / 1000.0; isRecording_ = true; } -void MidiRecorder::handleIncomingMidiMessage(MidiInput* source, const MidiMessage& message) +void MidiRecorder::handleIncomingMidiMessage(juce::MidiInput* source, const juce::MidiMessage& message) { if (!message.isActiveSense() && !message.isMidiClock()) { StreamLogger::instance() << message.getTimeStamp() << " " << message.getDescription() << std::endl; - MidiMessage relativeTimestampMessage = message; + juce::MidiMessage relativeTimestampMessage = message; double deltaSeconds = message.getTimeStamp() - recordingStartTime_; double deltaTicksPerBeat = deltaSeconds * 120 * 96 / 60; // 96 Ticks per quarter note at 120 bpm relativeTimestampMessage.setTimeStamp(deltaTicksPerBeat); @@ -92,13 +92,13 @@ void MidiRecorder::handleIncomingMidiMessage(MidiInput* source, const MidiMessag } } -void MidiRecorder::handlePartialSysexMessage(MidiInput* source, const uint8* messageData, int numBytesSoFar, double timestamp) +void MidiRecorder::handlePartialSysexMessage(juce::MidiInput* source, const juce::uint8* messageData, int numBytesSoFar, double timestamp) { // What to do with this one? ignoreUnused(source, messageData, numBytesSoFar, timestamp); } -void MidiRecorder::enableMidiInput(MidiDeviceInfo device) +void MidiRecorder::enableMidiInput(juce::MidiDeviceInfo device) { // Only enable and register once if (!deviceManager_.isMidiInputDeviceEnabled(device.identifier)) { @@ -109,11 +109,11 @@ void MidiRecorder::enableMidiInput(MidiDeviceInfo device) callbacks_[device.identifier] = this; } if (recorded_.find(device.identifier) == recorded_.end()) { - recorded_[device.identifier] = MidiMessageSequence(); + recorded_[device.identifier] = juce::MidiMessageSequence(); } } -void MidiRecorder::disableMidiInput(MidiDeviceInfo input) +void MidiRecorder::disableMidiInput(juce::MidiDeviceInfo input) { if (deviceManager_.isMidiInputDeviceEnabled(input.identifier)) { deviceManager_.setMidiInputDeviceEnabled(input.identifier, false); diff --git a/MidiRecorder.h b/MidiRecorder.h index 82a0a18..2d16ba3 100644 --- a/MidiRecorder.h +++ b/MidiRecorder.h @@ -24,7 +24,7 @@ #pragma once -#include "JuceHeader.h" +#include #include "MidiClocker.h" @@ -50,7 +50,7 @@ class MidiRecorder : private juce::MidiInputCallback { bool isRecording_; double recordingStartTime_; - std::map callbacks_; + std::map callbacks_; juce::AudioDeviceManager &deviceManager_; std::shared_ptr clocker_; // To determine the BPM from the Midi Clock signals diff --git a/MidiTuning.cpp b/MidiTuning.cpp index 5fd75a1..74ce07e 100644 --- a/MidiTuning.cpp +++ b/MidiTuning.cpp @@ -26,14 +26,14 @@ #include "MidiHelpers.h" -MidiMessage MidiTuning::createTuningDumpRequest(uint8 deviceID, MidiProgramNumber tuningBankNumber) +juce::MidiMessage MidiTuning::createTuningDumpRequest(juce::uint8 deviceID, MidiProgramNumber tuningBankNumber) { // See e.g. http://www.microtonal-synthesis.com/MIDItuning.html jassert(tuningBankNumber.toZeroBased() >= 0 && tuningBankNumber.toZeroBased() < 128); - return MidiHelpers::sysexMessage({ 0x7E, deviceID, 0x08 /* MIDI Tuning Standard */, 0x00 /* Micro tuning request */, (uint8) tuningBankNumber.toZeroBased() }); + return MidiHelpers::sysexMessage({ 0x7E, deviceID, 0x08 /* MIDI Tuning Standard */, 0x00 /* Micro tuning request */, (juce::uint8) tuningBankNumber.toZeroBased() }); } -bool MidiTuning::isTuningDump(MidiMessage const &message) +bool MidiTuning::isTuningDump(juce::MidiMessage const &message) { if (message.isSysEx()) { if (message.getSysExDataSize() > 3) { @@ -47,7 +47,7 @@ bool MidiTuning::isTuningDump(MidiMessage const &message) return false; } -bool MidiTuning::fromMidiMessage(MidiMessage const &message, MidiTuning &tuningResult) +bool MidiTuning::fromMidiMessage(juce::MidiMessage const &message, MidiTuning &tuningResult) { if (isTuningDump(message)) { auto data = message.getSysExData(); diff --git a/MidiTuning.h b/MidiTuning.h index c3f031b..83b0057 100644 --- a/MidiTuning.h +++ b/MidiTuning.h @@ -24,7 +24,7 @@ #pragma once -#include "JuceHeader.h" +#include #include "MidiNote.h" #include "MidiProgramNumber.h" @@ -33,9 +33,9 @@ class MidiTuning { public: using TTuning = std::vector>; - static MidiMessage createTuningDumpRequest(uint8 deviceID, MidiProgramNumber tuningBankNumber); - static bool isTuningDump(MidiMessage const &message); - static bool fromMidiMessage(MidiMessage const &message, MidiTuning &tuningResult); + static juce::MidiMessage createTuningDumpRequest(juce::uint8 deviceID, MidiProgramNumber tuningBankNumber); + static bool isTuningDump(juce::MidiMessage const &message); + static bool fromMidiMessage(juce::MidiMessage const &message, MidiTuning &tuningResult); MidiTuning(MidiProgramNumber program, std::string const &name, TTuning const &tuning); MidiTuning(); @@ -47,3 +47,4 @@ class MidiTuning { std::string name_; // Limited to 16 ASCII chars by the standard TTuning tuning_; }; + diff --git a/PackedDataFormatInfo.cpp b/PackedDataFormatInfo.cpp index 0804bae..85ac0e5 100644 --- a/PackedDataFormatInfo.cpp +++ b/PackedDataFormatInfo.cpp @@ -23,14 +23,14 @@ */ #include "PackedDataFormatInfo.h" -std::vector PackedDataFormatInfo::applyMapping(std::vector const &kToneFormatDefinition, std::vector const &source, size_t sizeDestination) +std::vector PackedDataFormatInfo::applyMapping(std::vector const &kToneFormatDefinition, std::vector const &source, size_t sizeDestination) { // Build up the APR tone record, which will be our preferred internal format and the one to store stuff in the database // If I trust the documentation correctly, this is also a message the MKS-50 will recognize without the user pressing a front panel button - std::vector aprBlock(sizeDestination, 0); + std::vector aprBlock(sizeDestination, 0); for (auto info : kToneFormatDefinition) { // Read the value from the input block - uint8 value = (source[(size_t) info.byteIndex] >> info.lsbIndex) & ((1 << info.bitCount) - 1); + uint8_t value = (source[(size_t) info.byteIndex] >> info.lsbIndex) & ((1 << info.bitCount) - 1); // Map it! if (info.converter_) { value = info.converter_(value); diff --git a/PackedDataFormatInfo.h b/PackedDataFormatInfo.h index b9e6ab2..df0d972 100644 --- a/PackedDataFormatInfo.h +++ b/PackedDataFormatInfo.h @@ -23,7 +23,8 @@ */ #pragma once -#include "JuceHeader.h" +#include +#include // This is the definition of the tone data format, which is really bit packed with individual bits spread all over the place. RAM was expensive... class PackedDataFormatInfo { @@ -32,7 +33,7 @@ class PackedDataFormatInfo { byteIndex(byteInd), lsbIndex(lsbInd), bitCount(bitCnt), targetParameter(target), targetBitIndex(targetBitInd) { } - PackedDataFormatInfo(int byteInd, int lsbInd, int bitCnt, int target, std::function converter) : + PackedDataFormatInfo(int byteInd, int lsbInd, int bitCnt, int target, std::function converter) : PackedDataFormatInfo(byteInd, lsbInd, bitCnt, target) { converter_ = converter; } @@ -42,7 +43,7 @@ class PackedDataFormatInfo { int bitCount; int targetParameter; int targetBitIndex; - std::function converter_; + std::function converter_; - static std::vector applyMapping(std::vector const &kToneFormatDefinition, std::vector const &source, size_t sizeDestination); + static std::vector applyMapping(std::vector const &kToneFormatDefinition, std::vector const &source, size_t sizeDestination); }; diff --git a/RingBuffer.cpp b/RingBuffer.cpp index 72ad848..aa96c03 100644 --- a/RingBuffer.cpp +++ b/RingBuffer.cpp @@ -24,7 +24,7 @@ #include "RingBuffer.h" -RingBuffer::RingBuffer(int numChannelsToAllocate, int numSamplesToAllocate) : AbstractFifo(numSamplesToAllocate) +RingBuffer::RingBuffer(int numChannelsToAllocate, int numSamplesToAllocate) : juce::AbstractFifo(numSamplesToAllocate) { ringBuffer_.setSize(numChannelsToAllocate, numSamplesToAllocate); ringBuffer_.clear(); @@ -55,23 +55,23 @@ void RingBuffer::read(float** channelPointers, int numChannels, int numSamples) prepareToRead(numSamples, startIndex1, blockSize1, startIndex2, blockSize2); if (blockSize1 > 0) { for (int c = 0; c < std::min(numChannels, ringBuffer_.getNumChannels()); ++c) { - FloatVectorOperations::copy(channelPointers[c], ringBuffer_.getReadPointer(c, startIndex1), blockSize1); + juce::FloatVectorOperations::copy(channelPointers[c], ringBuffer_.getReadPointer(c, startIndex1), blockSize1); } } if (blockSize2 > 0) { for (int c = 0; c < std::min(numChannels, ringBuffer_.getNumChannels()); ++c) { - FloatVectorOperations::copy(channelPointers[c] + blockSize1, ringBuffer_.getReadPointer(c, blockSize2), blockSize2); + juce::FloatVectorOperations::copy(channelPointers[c] + blockSize1, ringBuffer_.getReadPointer(c, blockSize2), blockSize2); } } finishedRead(blockSize1 + blockSize2); } -void RingBuffer::addBuffer(std::shared_ptr> bufferToAdd) +void RingBuffer::addBuffer(std::shared_ptr> bufferToAdd) { write(bufferToAdd->getArrayOfReadPointers(), bufferToAdd->getNumChannels(), bufferToAdd->getNumSamples()); } -void RingBuffer::readPastData(std::shared_ptr> outBuffer, int samplesOffset) +void RingBuffer::readPastData(std::shared_ptr> outBuffer, int samplesOffset) { outBuffer->clear(); @@ -99,13 +99,13 @@ void RingBuffer::readPastData(std::shared_ptr> outBuffer, int if (blockSize1 > 0) { int dataToReadFromBlock1 = std::min(dataToReallyRead, blockSize1); for (int c = 0; c < std::min(outBuffer->getNumChannels(), ringBuffer_.getNumChannels()); ++c) { - FloatVectorOperations::copy(outBuffer->getWritePointer(c), ringBuffer_.getReadPointer(c, startIndex1), dataToReadFromBlock1); + juce::FloatVectorOperations::copy(outBuffer->getWritePointer(c), ringBuffer_.getReadPointer(c, startIndex1), dataToReadFromBlock1); } } if (blockSize2 > 0 && dataToReallyRead > blockSize1) { int dataToReadFromBlock2 = std::min(dataToReallyRead - blockSize1, blockSize2); for (int c = 0; c < std::min(outBuffer->getNumChannels(), ringBuffer_.getNumChannels()); ++c) { - FloatVectorOperations::copy(outBuffer->getWritePointer(c), ringBuffer_.getReadPointer(c, startIndex2), dataToReadFromBlock2); + juce::FloatVectorOperations::copy(outBuffer->getWritePointer(c), ringBuffer_.getReadPointer(c, startIndex2), dataToReadFromBlock2); } } } diff --git a/RingBuffer.h b/RingBuffer.h index 0c33192..5e49277 100644 --- a/RingBuffer.h +++ b/RingBuffer.h @@ -24,18 +24,19 @@ #pragma once -#include "JuceHeader.h" +#include +#include // Use the JUCE AbstractFifo class to build the most minimalistic RingBuffer for sample data -class RingBuffer : public AbstractFifo { +class RingBuffer : public juce::AbstractFifo { public: RingBuffer(int numChannelsToAllocate, int numSamplesToAllocate); void write(const float* const* channelPointers, int numChannels, int numSamples); void read(float** channelPointers, int numChannels, int numSamples); - void addBuffer(std::shared_ptr> bufferToAdd); - void readPastData(std::shared_ptr> outBuffer, int samplesOffset); + void addBuffer(std::shared_ptr> bufferToAdd); + void readPastData(std::shared_ptr> outBuffer, int samplesOffset); void discard(int numSamples); diff --git a/RunWithRetry.h b/RunWithRetry.h index b5ec92c..aa89b5c 100644 --- a/RunWithRetry.h +++ b/RunWithRetry.h @@ -24,9 +24,9 @@ #pragma once -#include "JuceHeader.h" +#include -class RunWithRetry : public Timer { +class RunWithRetry : public juce::Timer { public: static void start(std::function action, std::function retryRequired, int numRetries, int retryIntervalMS, std::string const &message); diff --git a/Settings.cpp b/Settings.cpp index 8688816..b138ccd 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -42,7 +42,7 @@ void Settings::shutdown() instance_.reset(); } -void Settings::setSettingsID(String const &id) +void Settings::setSettingsID(juce::String const &id) { settingsID_ = id; } @@ -54,13 +54,13 @@ std::string Settings::get(std::string const &key, std::string const &defaultValu int Settings::get(std::string const &key, int defaultValue) { - auto int_as_text = properties_.getUserSettings()->getValue(key, String(defaultValue)).toStdString(); + auto int_as_text = properties_.getUserSettings()->getValue(key, juce::String(defaultValue)).toStdString(); return atoi(int_as_text.c_str()); } void Settings::set(std::string const &key, std::string const &value) { - properties_.getUserSettings()->setValue(key, String(value)); + properties_.getUserSettings()->setValue(key, juce::String(value)); properties_.getUserSettings()->setNeedsToBeSaved(true); } @@ -69,9 +69,9 @@ bool Settings::keyIsSet(std::string const &key) return properties_.getUserSettings()->containsKey(key); } -File Settings::getSessionStorageDir() const +juce::File Settings::getSessionStorageDir() const { - auto dir = File(File::getSpecialLocation(File::userDocumentsDirectory).getFullPathName() + "/JammerNetzSession"); + auto dir = juce::File(juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getFullPathName() + "/JammerNetzSession"); if (!dir.exists()) { dir.createDirectory(); } @@ -79,20 +79,20 @@ File Settings::getSessionStorageDir() const if (dir.existsAsFile()) { jassert(false); StreamLogger::instance() << "Can't record to " << dir.getFullPathName() << " as it is a file and not a directory!" << std::endl; - return File::getSpecialLocation(File::userDocumentsDirectory).getFullPathName(); + return juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getFullPathName(); } } return dir; } -File const & Settings::getPropertiesFile() noexcept +juce::File const &Settings::getPropertiesFile() noexcept { return properties_.getUserSettings()->getFile(); } Settings::Settings() { - PropertiesFile::Options options; + juce::PropertiesFile::Options options; options.folderName = settingsID_; options.applicationName = settingsID_; options.filenameSuffix = ".settings"; diff --git a/Settings.h b/Settings.h index c4564b2..ab7e86d 100644 --- a/Settings.h +++ b/Settings.h @@ -23,11 +23,11 @@ */ #pragma once -#include "JuceHeader.h" +#include class Settings { public: - static void setSettingsID(String const &id); // Call this before any call to instance + static void setSettingsID(juce::String const &id); // Call this before any call to instance static Settings &instance(); static void shutdown(); void saveAndClose(); @@ -38,8 +38,8 @@ class Settings { void set(std::string const &key, std::string const &value); bool keyIsSet(std::string const &key); - File getSessionStorageDir() const; - File const & getPropertiesFile() noexcept; + juce::File getSessionStorageDir() const; + juce::File const &getPropertiesFile() noexcept; // Singleton! Settings(Settings const &) = delete; @@ -50,6 +50,6 @@ class Settings { private: static std::unique_ptr instance_; - static String settingsID_; - ApplicationProperties properties_; + static juce::String settingsID_; + juce::ApplicationProperties properties_; }; diff --git a/StreamLogger.cpp b/StreamLogger.cpp index c87b8a6..e5c9f32 100644 --- a/StreamLogger.cpp +++ b/StreamLogger.cpp @@ -33,7 +33,7 @@ void StreamLogger::flushBuffer(bool force /* = false */) std::string toEmit = buffer.str(); // If the whole string ends on a newline, just write it. Else, we must split it and call writeToLog twice if (force || (toEmit.size() > 0 && toEmit.at(toEmit.length() - 1) == '\n')) { - Logger::getCurrentLogger()->writeToLog(toEmit); + juce::Logger::getCurrentLogger()->writeToLog(toEmit); buffer.str(std::string()); } else if (toEmit.find(endl) != std::string::npos) { @@ -41,7 +41,7 @@ void StreamLogger::flushBuffer(bool force /* = false */) size_t start = 0; size_t end; while ((end = toEmit.find(endl, start)) != std::string::npos) { - Logger::getCurrentLogger()->writeToLog(toEmit.substr(start, end - start)); + juce::Logger::getCurrentLogger()->writeToLog(toEmit.substr(start, end - start)); start = end + endl.length(); } buffer.str(std::string()); @@ -94,7 +94,7 @@ StreamLogger &StreamLogger::operator<<(StandardEndLine manipulator) return *this; } -StreamLogger &StreamLogger::operator<<(uint64 value) +StreamLogger &StreamLogger::operator<<(uint64_t value) { buffer << value; flushBuffer(); diff --git a/StreamLogger.h b/StreamLogger.h index beb31a8..77cff09 100644 --- a/StreamLogger.h +++ b/StreamLogger.h @@ -23,7 +23,7 @@ */ #pragma once -#include "JuceHeader.h" +#include class StreamLogger { public: @@ -40,7 +40,7 @@ class StreamLogger { StreamLogger &operator<<(juce::String const &string); StreamLogger &operator<<(StandardEndLine manipulator); StreamLogger &operator<<(int value); - StreamLogger &operator<<(uint64 value); + StreamLogger &operator<<(uint64_t value); StreamLogger &operator<<(double value); void flushBuffer(bool force = false); diff --git a/Sysex.cpp b/Sysex.cpp index 02ff6b4..f71912e 100644 --- a/Sysex.cpp +++ b/Sysex.cpp @@ -26,21 +26,21 @@ #include "Logger.h" -std::vector Sysex::loadSysex(std::string const &filename) +std::vector Sysex::loadSysex(std::string const &filename) { - std::vector messages; + std::vector messages; - File sysexFile = File::createFileWithoutCheckingPath(filename); + juce::File sysexFile = juce::File::createFileWithoutCheckingPath(filename); if (sysexFile.existsAsFile()) { // This could be a ZIP file? if (sysexFile.getFileExtension().toLowerCase() == ".zip") { - ZipFile zip(sysexFile); + juce::ZipFile zip(sysexFile); for (int i = 0; i < zip.getNumEntries(); i++) { auto entry = zip.getEntry(i); - File zipEntry = File::createFileWithoutCheckingPath(entry->filename); + juce::File zipEntry = juce::File::createFileWithoutCheckingPath(entry->filename); if (zipEntry.getFileExtension().toLowerCase() == ".mid" || zipEntry.getFileExtension().toLowerCase() == ".syx") { // That's an interesting entry - SimpleLogger::instance()->postMessage(String("Opening ") + String(entry->filename)); + SimpleLogger::instance()->postMessage(juce::String("Opening ") + juce::String(entry->filename)); auto zipStream = zip.createStreamForEntry(i); if (zipStream) { auto newMessages = loadSysex(*zipStream); @@ -52,16 +52,16 @@ std::vector Sysex::loadSysex(std::string const &filename) } else if (sysexFile.getFileExtension().toLowerCase() == ".txt") { // Let's assume this is one of the funny files which contains the sysex hex dump as text - I found some with MKS80 patches that looked like that! - FileInputStream inputStream(sysexFile); + juce::FileInputStream inputStream(sysexFile); auto content = inputStream.readEntireStreamAsString(); - MemoryBlock memory; + juce::MemoryBlock memory; memory.loadFromHexString(content); - MemoryInputStream sysexStream(memory, false); + juce::MemoryInputStream sysexStream(memory, false); return loadSysex(sysexStream); } else { // Single file - FileInputStream inputStream(sysexFile); + juce::FileInputStream inputStream(sysexFile); return loadSysex(inputStream); } } @@ -69,17 +69,17 @@ std::vector Sysex::loadSysex(std::string const &filename) return messages; } -std::vector Sysex::loadSysex(InputStream &inputStream) +std::vector Sysex::loadSysex(juce::InputStream &inputStream) { - std::vector messages; + std::vector messages; // It could be SMF (Standard Midi File). Then there is a bit more structure we need to parse - MidiFile smfFile; + juce::MidiFile smfFile; if (smfFile.readFrom(inputStream, false)) { // Loop over all tracks for (int track = 0; track < smfFile.getNumTracks(); track++) { auto t = smfFile.getTrack(track); - MidiMessageSequence::MidiEventHolder *const *currentMsg; + juce::MidiMessageSequence::MidiEventHolder *const *currentMsg; for (currentMsg = t->begin(); currentMsg != t->end(); currentMsg++) { // If this is a sysex message, keep it if ((*currentMsg)->message.isSysEx()) { @@ -91,38 +91,38 @@ std::vector Sysex::loadSysex(InputStream &inputStream) else { // More likely, this is a pure sysex file where we read the raw messages from a binary stream inputStream.setPosition(0); - std::vector data((size_t) inputStream.getTotalLength()); + std::vector data((size_t) inputStream.getTotalLength()); inputStream.read(&data[0], (int) inputStream.getTotalLength()); // 4 GB Limit return vectorToMessages(data); } return messages; } -std::vector Sysex::vectorToMessages(std::vector const &midiData) +std::vector Sysex::vectorToMessages(std::vector const &midiData) { - std::vector messages; + std::vector messages; // Now produce the Sysex messages from the file size_t inPointer = 0; - uint8 lastStatusByte = 0xf0; // Sysex message + juce::uint8 lastStatusByte = 0xf0; // Sysex message while (inPointer < midiData.size()) { int bytesUsed = 0; // TODO - this crashes in case the data is not well formed sysex (example: Depeche Mode TI sound set, there is a message which ends on 0xff 0xff). - messages.push_back(MidiMessage(&midiData[inPointer], (int) (midiData.size() - inPointer), bytesUsed, lastStatusByte, 0.0, false)); + messages.push_back(juce::MidiMessage(&midiData[inPointer], (int) (midiData.size() - inPointer), bytesUsed, lastStatusByte, 0.0, false)); inPointer += (size_t) bytesUsed; } return messages; } -std::vector Sysex::memoryBlockToMessages(MemoryBlock const &midiData) +std::vector Sysex::memoryBlockToMessages(juce::MemoryBlock const &midiData) { - std::vector messages; + std::vector messages; size_t inPointer = 0; - uint8 lastStatusByte = 0xf0; // Sysex message + juce::uint8 lastStatusByte = 0xf0; // Sysex message while (inPointer < midiData.getSize()) { int bytesUsed = 0; // TODO - this crashes in case the data is not well formed sysex (example: Depeche Mode TI sound set, there is a message which ends on 0xff 0xff). - messages.push_back(MidiMessage(&midiData[inPointer], (int) (midiData.getSize() - inPointer), bytesUsed, lastStatusByte, 0.0, false)); + messages.push_back(juce::MidiMessage(&midiData[inPointer], (int) (midiData.getSize() - inPointer), bytesUsed, lastStatusByte, 0.0, false)); inPointer += (size_t) bytesUsed; } return messages; @@ -130,14 +130,14 @@ std::vector Sysex::memoryBlockToMessages(MemoryBlock const &m void Sysex::saveSysex(std::string const &filename, std::vector const &messages) { - File sysExFile(filename); + juce::File sysExFile(filename); if (sysExFile.existsAsFile()) { sysExFile.deleteFile(); } - File sysexFile = File::createFileWithoutCheckingPath(filename); + juce::File sysexFile = juce::File::createFileWithoutCheckingPath(filename); - FileOutputStream outputStream(sysexFile); + juce::FileOutputStream outputStream(sysexFile); if (sysexFile.existsAsFile()) { for (auto message : messages) { outputStream.write(message.getRawData(), (size_t) message.getRawDataSize()); @@ -147,9 +147,9 @@ void Sysex::saveSysex(std::string const &filename, std::vector const &messages) { - File dir(directory); + juce::File dir(directory); if (dir.isDirectory()) { - File newFile = dir.getNonexistentChildFile(desiredFileName, ".syx", false); + juce::File newFile = dir.getNonexistentChildFile(desiredFileName, ".syx", false); saveSysex(newFile.getFullPathName().toStdString(), messages); return newFile.getFullPathName().toStdString(); } diff --git a/Sysex.h b/Sysex.h index fd203a2..f100eb8 100644 --- a/Sysex.h +++ b/Sysex.h @@ -24,14 +24,14 @@ #pragma once -#include "JuceHeader.h" +#include class Sysex { public: - static std::vector loadSysex(std::string const &filename); - static std::vector loadSysex(InputStream &inputStream); - static std::vector vectorToMessages(std::vector const &midiData); - static std::vector memoryBlockToMessages(MemoryBlock const &midiData); + static std::vector loadSysex(std::string const &filename); + static std::vector loadSysex(juce::InputStream &inputStream); + static std::vector vectorToMessages(std::vector const &midiData); + static std::vector memoryBlockToMessages(juce::MemoryBlock const &midiData); static void saveSysex(std::string const &filename, std::vector const &messages); static std::string saveSysexIntoNewFile(std::string const &directory, std::string const &desiredFileName, std::vector const &messages); }; diff --git a/TypedNamedValue.cpp b/TypedNamedValue.cpp index 15ec3f0..d65095c 100644 --- a/TypedNamedValue.cpp +++ b/TypedNamedValue.cpp @@ -24,48 +24,48 @@ #include "TypedNamedValue.h" -TypedNamedValue::TypedNamedValue(String const &name, String const §ionName, bool defaultValue) : name_(name), sectionName_(sectionName), valueType_(ValueType::Bool) +TypedNamedValue::TypedNamedValue(juce::String const &name, juce::String const §ionName, bool defaultValue) : name_(name), sectionName_(sectionName), valueType_(ValueType::Bool) { - value_ = Value(defaultValue); + value_ = juce::Value(defaultValue); minValue_ = 0; maxValue_ = 1; enabled_ = true; } -TypedNamedValue::TypedNamedValue(String const &name, String const §ionName, String const &defaultValue, int maxLength) : name_(name), sectionName_(sectionName), valueType_(ValueType::String) +TypedNamedValue::TypedNamedValue(juce::String const &name, juce::String const §ionName, juce::String const &defaultValue, int maxLength) : name_(name), sectionName_(sectionName), valueType_(ValueType::String) { - value_ = Value(defaultValue); + value_ = juce::Value(defaultValue); minValue_ = 0; maxValue_ = maxLength; enabled_ = true; } -TypedNamedValue::TypedNamedValue(String const &name, String const §ionName, int defaultValue, int minValue, int maxValue) : name_(name), sectionName_(sectionName), valueType_(ValueType::Integer) +TypedNamedValue::TypedNamedValue(juce::String const &name, juce::String const §ionName, int defaultValue, int minValue, int maxValue) : name_(name), sectionName_(sectionName), valueType_(ValueType::Integer) { - value_ = Value(defaultValue); + value_ = juce::Value(defaultValue); minValue_ = minValue; maxValue_ = maxValue; enabled_ = true; } -TypedNamedValue::TypedNamedValue(String const &name, String const §ionName, int defaultValue, std::map const &lookup) : +TypedNamedValue::TypedNamedValue(juce::String const &name, juce::String const §ionName, int defaultValue, std::map const &lookup) : name_(name), sectionName_(sectionName), valueType_(ValueType::Lookup) { setLookup(lookup); - value_ = Value(defaultValue); + value_ = juce::Value(defaultValue); enabled_ = true; } -TypedNamedValue::TypedNamedValue(String const &name, String const §ionName, File const &defaultValue, bool isDirectory) : +TypedNamedValue::TypedNamedValue(juce::String const &name, juce::String const §ionName, juce::File const &defaultValue, bool isDirectory) : name_(name), sectionName_(sectionName), valueType_(isDirectory ? ValueType::Pathname : ValueType::Filename) { - value_ = Value(defaultValue.getFullPathName()); + value_ = juce::Value(defaultValue.getFullPathName()); enabled_ = true; } -TypedNamedValue::TypedNamedValue(String const &name, String const §ionName, Colour defaultValue) : name_(name), sectionName_(sectionName), valueType_(ValueType::Color) +TypedNamedValue::TypedNamedValue(juce::String const &name, juce::String const §ionName, juce::Colour defaultValue) : name_(name), sectionName_(sectionName), valueType_(ValueType::Color) { - value_ = Value(defaultValue.toString()); + value_ = juce::Value(defaultValue.toString()); enabled_ = true; } @@ -172,11 +172,11 @@ juce::Value &TypedNamedValueSet::valueByName(std::string const &name) throw std::runtime_error("Illegal argument - key does not exist"); } -void TypedNamedValueSet::addToValueTree(ValueTree &tree) +void TypedNamedValueSet::addToValueTree(juce::ValueTree &tree) { for (auto param : *this) { tree.setProperty(param->name(), param->value().getValue(), nullptr); - auto v = tree.getPropertyAsValue(Identifier(param->name()), nullptr, false); + auto v = tree.getPropertyAsValue(juce::Identifier(param->name()), nullptr, false); param->value().referTo(v); } } diff --git a/TypedNamedValue.h b/TypedNamedValue.h index 01ac33d..de0edca 100644 --- a/TypedNamedValue.h +++ b/TypedNamedValue.h @@ -24,7 +24,8 @@ #pragma once -#include "JuceHeader.h" +#include +#include enum class ValueType { @@ -40,25 +41,25 @@ enum class ValueType class TypedNamedValue { public: //! Construct a Bool type - TypedNamedValue(String const &name, String const §ionName, bool defaultValue); - //! Construct a String type (edit field) - TypedNamedValue(String const &name, String const §ionName, String const &defaultValue, int maxLength); + TypedNamedValue(juce::String const &name, juce::String const §ionName, bool defaultValue); + //! Construct a juce::String type (edit field) + TypedNamedValue(juce::String const &name, juce::String const §ionName, juce::String const &defaultValue, int maxLength); //! Construct an Integer type - TypedNamedValue(String const &name, String const §ionName, int defaultValue, int minValue, int maxValue); + TypedNamedValue(juce::String const &name, juce::String const §ionName, int defaultValue, int minValue, int maxValue); //! Construct a lookup value type - TypedNamedValue(String const &name, String const §ionName, int defaultValue, std::map const &lookup); + TypedNamedValue(juce::String const &name, juce::String const §ionName, int defaultValue, std::map const &lookup); //! Construct a Filepath value type - TypedNamedValue(String const &name, String const §ionName, File const &defaultValue, bool isDirectory); + TypedNamedValue(juce::String const &name, juce::String const §ionName, juce::File const &defaultValue, bool isDirectory); //! Construct a color value type - TypedNamedValue(String const &name, String const §ionName, Colour defaultValue); + TypedNamedValue(juce::String const &name, juce::String const §ionName, juce::Colour defaultValue); virtual ~TypedNamedValue() = default; void setEnabled(bool enabled); - Value &value(); - String name() const; - String sectionName() const; + juce::Value &value(); + juce::String name() const; + juce::String sectionName() const; ValueType valueType() const; int minValue() const; int maxValue() const; @@ -71,9 +72,9 @@ class TypedNamedValue { void setLookup(std::map const &newLookup); protected: - String name_; - String sectionName_; - Value value_; + juce::String name_; + juce::String sectionName_; + juce::Value value_; ValueType valueType_; int minValue_; int maxValue_; @@ -85,6 +86,6 @@ class TypedNamedValueSet : public std::vector> public: std::shared_ptr typedNamedValueByName(std::string const &name); // TODO - suboptimal linear search bool hasValue(std::string const &name); - Value &valueByName(std::string const &name); // TODO - suboptimal linear search - void addToValueTree(ValueTree &tree); + juce::Value &valueByName(std::string const &name); // TODO - suboptimal linear search + void addToValueTree(juce::ValueTree &tree); }; diff --git a/WaitForEvent.cpp b/WaitForEvent.cpp index eec0533..7ef4917 100644 --- a/WaitForEvent.cpp +++ b/WaitForEvent.cpp @@ -24,11 +24,11 @@ #include "WaitForEvent.h" -WaitForEvent::WaitForEvent(std::function hasHappened, Thread *threadToBeNotified) : Thread("WaitForEvent"), hasHappened_(hasHappened), notify_(threadToBeNotified) +WaitForEvent::WaitForEvent(std::function hasHappened, juce::Thread *threadToBeNotified) : juce::Thread("WaitForEvent"), hasHappened_(hasHappened), notify_(threadToBeNotified) { } -WaitForEvent::WaitForEvent(std::function hasHappened) : Thread("WaitForEvent"), hasHappened_(hasHappened), notify_(nullptr) +WaitForEvent::WaitForEvent(std::function hasHappened) : juce::Thread("WaitForEvent"), hasHappened_(hasHappened), notify_(nullptr) { } diff --git a/WaitForEvent.h b/WaitForEvent.h index 7efd2ae..dfb5bd2 100644 --- a/WaitForEvent.h +++ b/WaitForEvent.h @@ -24,16 +24,16 @@ #pragma once -#include "JuceHeader.h" +#include -class WaitForEvent : public Thread { +class WaitForEvent : public juce::Thread { public: WaitForEvent(std::function hasHappened); - WaitForEvent(std::function hasHappened, Thread *threadToBeNotified); + WaitForEvent(std::function hasHappened, juce::Thread *threadToBeNotified); virtual void run() override; private: std::function hasHappened_; - Thread *notify_; + juce::Thread *notify_; };