<commit_before>/*
 ==============================================================================

 PluginProcessor.cpp
 Author:  <NAME>

 ==============================================================================
 */

#include "PluginProcessor.h"
#include "PluginEditor.h"
#include "LookAndFeel.h"

//==============================================================================
SoundboardAudioProcessor::SoundboardAudioProcessor() : masterGain(1.0f), duckPercentage(0.33f), duckEnabled(false), fadeOutSeconds(6)
{
    defaultLookAndFeel = new LookAndFeel_Ultraschall();
    awesomeLookAndFeel = new LookAndFeel_Ultraschall_Awesome();

    Logger::setCurrentLogger(logger = FileLogger::createDefaultAppLogger(ProjectInfo::projectName, String(ProjectInfo::projectName) + ".txt", String(ProjectInfo::projectName) + " " + String(ProjectInfo::versionString)));

    // Internal OSC Parameter
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/ui/theme"), true);
    
    oscManager.addOscParameter(new OscBooleanParameter("/ultraschall/soundboard/setup/osc/receive/enabled"), true);
    oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/setup/osc/receive/host"), true);
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/osc/receive/port"), true);
    
    oscManager.addOscParameter(new OscBooleanParameter("/ultraschall/soundboard/setup/osc/remote/enabled"), true);
    oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/setup/osc/remote/host"), true);
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/osc/remote/port"), true);
    
    oscManager.addOscParameter(new OscBooleanParameter("/ultraschall/soundboard/setup/osc/repeater/enabled"), true);
    oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/setup/osc/repeater/host"), true);
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/osc/repeater/port"), true);
    
    // OSC Parameter
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/fadeout"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/gain"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/duck/percentage"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/duck/enabled"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/stopall"));

    for (int index = 0; index < MaximumSamplePlayers; index++) {
        String indexString = String(index + 1);
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/play"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/pause"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/stop"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/trigger"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/ftrigger"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/loop"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/fadeout"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/fadein"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/fade"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/gain"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/done"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/progress"));
        oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/player/" + indexString + "/title"));
        oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/player/" + indexString + "/time"));
        oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/player/" + indexString + "/remaining"));
    }

    // OSC Setup done not listen to all events here
    oscManager.addOscParameterListener(this, ".+");

    playersLocked = true;
    formatManager.registerBasicFormats();
    thumbnailCache = new AudioThumbnailCache(MaximumSamplePlayers);

    PropertiesFile::Options options;
    options.applicationName = JucePlugin_Name;
    options.filenameSuffix = "properties";
    options.folderName = "UltraschallSoundboard";
    options.osxLibrarySubFolder = "Application Support";
    propertiesFile = new PropertiesFile(options);
    fallbackProperties = new PropertySet();
    fallbackProperties->setValue(CurrentProgramIndexIdentifier.toString(), var(255));

    fallbackProperties->setValue(OscReceiveEnabledIdentifier.toString(), var(false));
    fallbackProperties->setValue(OscReceivePortNumberIdentifier.toString(), var(8050));

    fallbackProperties->setValue(OscRemoteEnabledIdentifier.toString(), var(false));
    fallbackProperties->setValue(OscRemoteHostnameIdentifier.toString(), "127.0.0.1");
    fallbackProperties->setValue(OscRemotePortNumberIdentifier.toString(), var(9050));

    fallbackProperties->setValue(OscRepeaterEnabledIdentifier.toString(), var(false));
    fallbackProperties->setValue(OscRepeaterHostnameIdentifier.toString(), "127.0.0.1");
    fallbackProperties->setValue(OscRepeaterPortNumberIdentifier.toString(), var(8000));

    fallbackProperties->setValue(WindowWidthIdentifier.toString(), var(380));
    fallbackProperties->setValue(WindowHeightIdentifier.toString(), var(320));

    fallbackProperties->setValue(FadeIdentifier.toString(), var(6));
    fallbackProperties->setValue(DuckingIdentifier.toString(), var(0.33));

    fallbackProperties->setValue(ThemeIdentifier.toString(), var(static_cast<int>(ThemeTomorrowNightEighties)));

    propertiesFile->setFallbackPropertySet(fallbackProperties);

    SwitchTheme(static_cast<Themes>(propertiesFile->getIntValue(ThemeIdentifier)));
    
    fadeOutRange.start = 1.0;
    fadeOutRange.end = 30.0;
    fadeOutRange.interval = 1.0;
    fadeOutRange.skew = 0.5;

    // delay osc server start
    startTimer(TimerOscServerDelay, 1000 * 1);
    startTimer(TimerMidiEvents, 20);
}

SoundboardAudioProcessor::~SoundboardAudioProcessor()
{
    oscManager.removeOscParameter(".+");
    stopTimer(TimerOscServerDelay);<commit_msg>store ducking and fade time<commit_after>/*
 ==============================================================================

 PluginProcessor.cpp
 Author:  <NAME>

 ==============================================================================
 */

#include "PluginProcessor.h"
#include "PluginEditor.h"
#include "LookAndFeel.h"

//==============================================================================
SoundboardAudioProcessor::SoundboardAudioProcessor() : masterGain(1.0f), duckPercentage(0.33f), duckEnabled(false), fadeOutSeconds(6)
{
    defaultLookAndFeel = new LookAndFeel_Ultraschall();
    awesomeLookAndFeel = new LookAndFeel_Ultraschall_Awesome();

    Logger::setCurrentLogger(logger = FileLogger::createDefaultAppLogger(ProjectInfo::projectName, String(ProjectInfo::projectName) + ".txt", String(ProjectInfo::projectName) + " " + String(ProjectInfo::versionString)));

    // Internal OSC Parameter
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/ui/theme"), true);
    
    oscManager.addOscParameter(new OscBooleanParameter("/ultraschall/soundboard/setup/osc/receive/enabled"), true);
    oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/setup/osc/receive/host"), true);
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/osc/receive/port"), true);
    
    oscManager.addOscParameter(new OscBooleanParameter("/ultraschall/soundboard/setup/osc/remote/enabled"), true);
    oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/setup/osc/remote/host"), true);
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/osc/remote/port"), true);
    
    oscManager.addOscParameter(new OscBooleanParameter("/ultraschall/soundboard/setup/osc/repeater/enabled"), true);
    oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/setup/osc/repeater/host"), true);
    oscManager.addOscParameter(new OscIntegerParameter("/ultraschall/soundboard/setup/osc/repeater/port"), true);
    
    // OSC Parameter
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/fadeout"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/gain"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/duck/percentage"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/duck/enabled"));
    oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/stopall"));

    for (int index = 0; index < MaximumSamplePlayers; index++) {
        String indexString = String(index + 1);
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/play"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/pause"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/stop"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/trigger"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/ftrigger"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/loop"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/fadeout"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/fadein"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/fade"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/gain"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/done"));
        oscManager.addOscParameter(new OscFloatParameter("/ultraschall/soundboard/player/" + indexString + "/progress"));
        oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/player/" + indexString + "/title"));
        oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/player/" + indexString + "/time"));
        oscManager.addOscParameter(new OscStringParameter("/ultraschall/soundboard/player/" + indexString + "/remaining"));
    }

    // OSC Setup done not listen to all events here
    oscManager.addOscParameterListener(this, ".+");

    playersLocked = true;
    formatManager.registerBasicFormats();
    thumbnailCache = new AudioThumbnailCache(MaximumSamplePlayers);

    PropertiesFile::Options options;
    options.applicationName = JucePlugin_Name;
    options.filenameSuffix = "properties";
    options.folderName = "UltraschallSoundboard";
    options.osxLibrarySubFolder = "Application Support";
    propertiesFile = new PropertiesFile(options);
    fallbackProperties = new PropertySet();
    fallbackProperties->setValue(CurrentProgramIndexIdentifier.toString(), var(255));

    fallbackProperties->setValue(OscReceiveEnabledIdentifier.toString(), var(false));
    fallbackProperties->setValue(OscReceivePortNumberIdentifier.toString(), var(8050));

    fallbackProperties->setValue(OscRemoteEnabledIdentifier.toString(), var(false));
    fallbackProperties->setValue(OscRemoteHostnameIdentifier.toString(), "127.0.0.1");
    fallbackProperties->setValue(OscRemotePortNumberIdentifier.toString(), var(9050));

    fallbackProperties->setValue(OscRepeaterEnabledIdentifier.toString(), var(false));
    fallbackProperties->setValue(OscRepeaterHostnameIdentifier.toString(), "127.0.0.1");
    fallbackProperties->setValue(OscRepeaterPortNumberIdentifier.toString(), var(8000));

    fallbackProperties->setValue(WindowWidthIdentifier.toString(), var(380));
    fallbackProperties->setValue(WindowHeightIdentifier.toString(), var(320));

    fallbackProperties->setValue(FadeIdentifier.toString(), var(6));
    fallbackProperties->setValue(DuckingIdentifier.toString(), var(0.33f));

    fallbackProperties->setValue(ThemeIdentifier.toString(), var(static_cast<int>(ThemeTomorrowNightEighties)));

    propertiesFile->setFallbackPropertySet(fallbackProperties);

    oscManager.setOscParameterValue("/ultraschall/soundboard/duck/percentage",
            propertiesFile->getValue(DuckingIdentifier));
    oscManager.setOscParameterValue("/ultraschall/soundboard/fadeout",
            propertiesFile->getValue(FadeIdentifier));

    SwitchTheme(static_cast<Themes>(propertiesFile->getIntValue(ThemeIdentifier)));

    fadeOutRange.start = 1.0;
    fadeOutRange.end = 30.0;
    fadeOutRange.interval = 1.0;
    fadeOutRange.skew = 0.5;

    // delay osc server start
    startTimer(TimerOscServerDelay, 1000 * 1);
    startTimer(TimerMidiEvents, 20);
}

SoundboardAudioProcessor::~SoundboardAudioProcessor()
{
    oscManager.removeOscParameter(".+");
    stopTimer(TimerOscServerDelay);
{'fraction_non_alphanumeric': 0.15826868701515262, 'fraction_numerical': 0.008845066337997535, 'mean_word_length': 5.970186963112683, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5980436', 'n_tokens_mistral': 3950, 'n_tokens_neox': 3817, 'n_words': 459}