From e6f2f11b656e2ca30d6cc021ae684c76df387f64 Mon Sep 17 00:00:00 2001 From: Max Pollack Date: Mon, 6 Jul 2020 21:11:58 -0400 Subject: [PATCH] Initial commit --- .github/FUNDING.yml | 12 ++ .github/workflows/juce_plugin_ci.yml | 301 +++++++++++++++++++++++++++ .gitmodules | 3 + CMakeLists.txt | 104 +++++++++ JUCE | 1 + PluginEditor.cpp | 33 +++ PluginEditor.h | 22 ++ PluginProcessor.cpp | 186 +++++++++++++++++ PluginProcessor.h | 47 +++++ README.md | 5 + 10 files changed, 714 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/juce_plugin_ci.yml create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 JUCE create mode 100644 PluginEditor.cpp create mode 100644 PluginEditor.h create mode 100644 PluginProcessor.cpp create mode 100644 PluginProcessor.h create mode 100644 README.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..686481e --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: maxwellpollack +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/juce_plugin_ci.yml b/.github/workflows/juce_plugin_ci.yml new file mode 100644 index 0000000..b1e2ea5 --- /dev/null +++ b/.github/workflows/juce_plugin_ci.yml @@ -0,0 +1,301 @@ +# Continuous Integration for AU/VST3/Standalone audio plugins made with JUCE + CMake for Windows/Linux/macOS +# Adapted from github.com/cristianadam/HelloWorld + +name: CMake Build Matrix + +on: [push, pull_request] + +env: + CMAKE_VERSION: 3.16.2 + NINJA_VERSION: 1.9.0 + BUILD_TYPE: Release + CCACHE_VERSION: 3.7.7 + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - { + name: "Windows Latest MSVC", + os: windows-latest, + cc: "cl", cxx: "cl", + environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + } + - { + name: "Ubuntu Latest GCC", + os: ubuntu-latest, + cc: "gcc", cxx: "g++" + } + - { + name: "macOS Latest Clang", + os: macos-latest, + cc: "clang", cxx: "clang++" + } + + steps: + + - uses: actions/checkout@v2 + with: + submodules: true + + - if: ${{ runner.os == 'Linux' }} + name: Install JUCE dependencies (Linux only) + id: juce_dependencies + run: | + sudo apt-get install -y g++ libgtk-3-dev libfreetype6-dev libx11-dev libxinerama-dev libxrandr-dev libxcursor-dev mesa-common-dev libasound2-dev freeglut3-dev libxcomposite-dev libcurl4-openssl-dev + sudo add-apt-repository -y ppa:webkit-team && sudo apt-get update + sudo apt-get install libwebkit2gtk-4.0-37 libwebkit2gtk-4.0-dev + + - name: Download Ninja and CMake + id: cmake_and_ninja + shell: cmake -P {0} + run: | + set(cmake_version $ENV{CMAKE_VERSION}) + set(ninja_version $ENV{NINJA_VERSION}) + message(STATUS "Using host CMake version: ${CMAKE_VERSION}") + if ("${{ runner.os }}" STREQUAL "Windows") + set(ninja_suffix "win.zip") + set(cmake_suffix "win64-x64.zip") + set(cmake_dir "cmake-${cmake_version}-win64-x64/bin") + elseif ("${{ runner.os }}" STREQUAL "Linux") + set(ninja_suffix "linux.zip") + set(cmake_suffix "Linux-x86_64.tar.gz") + set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin") + elseif ("${{ runner.os }}" STREQUAL "macOS") + set(ninja_suffix "mac.zip") + set(cmake_suffix "Darwin-x86_64.tar.gz") + set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin") + endif() + set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") + file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) + set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") + file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) + # Save the path for other steps + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) + message("::set-output name=cmake_dir::${cmake_dir}") + if (NOT "${{ runner.os }}" STREQUAL "Windows") + execute_process( + COMMAND chmod +x ninja + COMMAND chmod +x ${cmake_dir}/cmake + ) + endif() + + - name: Download ccache + id: ccache + shell: cmake -P {0} + run: | + set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz") + file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz) + + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + + - name: ccache cache files + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ matrix.config.name }}-ccache- + + - name: Configure + shell: cmake -P {0} + run: | + set(ENV{CC} ${{ matrix.config.cc }}) + set(ENV{CXX} ${{ matrix.config.cxx }}) + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + execute_process( + COMMAND "${{ matrix.config.environment_script }}" && set + OUTPUT_FILE environment_script_output.txt + ) + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") + execute_process( + COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake + -S . + -B build + -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} + -G Ninja + -D CMAKE_MAKE_PROGRAM=ninja + -D CMAKE_C_COMPILER_LAUNCHER=ccache + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + - name: Build + shell: cmake -P {0} + run: | + set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir) + set(ENV{CCACHE_BASEDIR} "${ccache_basedir}") + set(ENV{CCACHE_DIR} "${ccache_basedir}/.ccache") + set(ENV{CCACHE_COMPRESS} "true") + set(ENV{CCACHE_COMPRESSLEVEL} "6") + set(ENV{CCACHE_MAXSIZE} "400M") + if ("${{ matrix.config.cxx }}" STREQUAL "cl") + set(ENV{CCACHE_MAXSIZE} "600M") + endif() + execute_process(COMMAND ccache -p) + execute_process(COMMAND ccache -z) + execute_process( + COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + execute_process(COMMAND ccache -s) + + - name: Run tests + shell: cmake -P {0} + run: | + include(ProcessorCount) + ProcessorCount(N) + set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") + execute_process( + COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/ctest -j ${N} + WORKING_DIRECTORY build + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Running tests failed!") + endif() + + - if: ${{ runner.os=='Windows'}} + name: Pack (Windows) + run: | + mkdir ${{ github.event.repository.name }}-${{ runner.os }} + cd build\*_artefacts\Release + del *.* + move * ..\..\..\${{ github.event.repository.name }}-${{ runner.os }} + cd ..\..\.. + cmake -E tar cvf ${{ github.event.repository.name }}-${{ runner.os }}.zip --format=zip -- ${{ github.event.repository.name }}-${{ runner.os }} + + - if: ${{ runner.os!='Windows'}} + name: Pack (Unix) + run: | + mkdir ${{ github.event.repository.name }}-${{ runner.os }} + cd build/*_artefacts/Release + rm *.* + mv * ../../../${{ github.event.repository.name }}-${{ runner.os }} + cd ../../.. + cmake -E tar cvf ${{ github.event.repository.name }}-${{ runner.os }}.zip --format=zip -- ${{ github.event.repository.name }}-${{ runner.os }} + + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: ${{ github.event.repository.name }}-${{ runner.os }} + path: ${{ github.event.repository.name }}-${{ runner.os }}.zip + + release: + if: contains(github.ref, 'tags/v') + runs-on: ubuntu-latest + needs: build + + steps: + - name: Create Release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Store Release url + run: | + echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url + - uses: actions/upload-artifact@v1 + with: + path: ./upload_url + name: upload_url + + publish: + if: contains(github.ref, 'tags/v') + name: Publish ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - { + name: "Windows Latest MSVC", artifact: "Windows", + os: ubuntu-latest + } + - { + name: "Ubuntu Latest GCC", artifact: "Linux", + os: ubuntu-latest + } + - { + name: "macOS Latest Clang", artifact: "macOS", + os: ubuntu-latest + } + needs: release + + steps: + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: ${{ github.event.repository.name }}-${{ matrix.config.artifact }} + path: ./ + + - name: Download URL + uses: actions/download-artifact@v1 + with: + name: upload_url + path: ./ + + - id: set_upload_url + run: | + upload_url=`cat ./upload_url` + echo ::set-output name=upload_url::$upload_url + + - name: Upload to Release + id: upload_to_release + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.set_upload_url.outputs.upload_url }} + asset_path: ./${{ github.event.repository.name }}-${{ matrix.config.artifact }}.zip + asset_name: ${{ github.event.repository.name }}-${{ matrix.config.artifact }}.zip + asset_content_type: application/zip diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a5fdfff --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "JUCE"] + path = JUCE + url = https://github.com/juce-framework/JUCE.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..808ebbe --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,104 @@ +# Example Audio Plugin CMakeLists.txt + +# To get started on a new plugin, copy this entire folder (containing this file and C++ sources) to +# a convenient location, and then start making modifications. + +# The first line of any CMake project should be a call to `cmake_minimum_required`, which checks +# that the installed CMake will be able to understand the following CMakeLists, and ensures that +# CMake's behaviour is compatible with the named version. This is a standard CMake command, so more +# information can be found in the CMake docs. + +cmake_minimum_required(VERSION 3.15) + +# The top-level CMakeLists.txt file for a project must contain a literal, direct call to the +# `project()` command. `project()` sets up some helpful variables that describe source/binary +# directories, and the current project version. This is a standard CMake command. + +project(AUDIO_PLUGIN_EXAMPLE VERSION 0.0.1) + +# If you've installed JUCE somehow (via a package manager, or directly using the CMake install +# target), you'll need to tell this project that it depends on the installed copy of JUCE. If you've +# included JUCE directly in your source tree (perhaps as a submodule), you'll need to tell CMake to +# include that subdirectory as part of the build. + +# find_package(JUCE CONFIG REQUIRED) # If you've installed JUCE to your system +# or +add_subdirectory(JUCE) # If you've put JUCE in a subdirectory called JUCE + +# If you are building a VST2 or AAX plugin, CMake needs to be told where to find these SDKs on your +# system. This setup should be done before calling `juce_add_plugin`. + +# juce_set_vst2_sdk_path(...) +# juce_set_aax_sdk_path(...) + +# `juce_add_plugin` adds a static library target with the name passed as the first argument +# (AudioPluginExample here). This target is a normal CMake target, but has a lot of extra properties set +# up by default. As well as this shared code static library, this function adds targets for each of +# the formats specified by the FORMATS arguments. This function accepts many optional arguments. +# Check the readme at `docs/CMake API.md` in the JUCE repo for the full list. + +juce_add_plugin(AudioPluginExample + # VERSION ... # Set this if the plugin version is different to the project version + # ICON_BIG ... # ICON_* arguments specify a path to an image file to use as an icon for the Standalone + # ICON_SMALL ... + # COMPANY_NAME ... # Specify the name of the plugin's author + # IS_SYNTH TRUE/FALSE # Is this a synth or an effect? + # NEEDS_MIDI_INPUT TRUE/FALSE # Does the plugin need midi input? + # NEEDS_MIDI_OUTPUT TRUE/FALSE # Does the plugin need midi output? + # IS_MIDI_EFFECT TRUE/FALSE # Is this plugin a MIDI effect? + # EDITOR_WANTS_KEYBOARD_FOCUS TRUE/FALSE # Does the editor need keyboard focus? + # COPY_PLUGIN_AFTER_BUILD TRUE/FALSE # Should the plugin be installed to a default location after building? + PLUGIN_MANUFACTURER_CODE Juce # A four-character manufacturer id with at least one upper-case character + PLUGIN_CODE Dem0 # A unique four-character plugin id with at least one upper-case character + FORMATS AU VST3 Standalone # The formats to build. Other valid formats are: AAX Unity VST AU AUv3 + PRODUCT_NAME "Audio Plugin Example") # The name of the final executable, which can differ from the target name + +# `juce_generate_juce_header` will create a JuceHeader.h for a given target, which will be generated +# into your build tree. This should be included with `#include `. The include path for +# this header will be automatically added to the target. The main function of the JuceHeader is to +# include all your JUCE module headers; if you're happy to include module headers directly, you +# probably don't need to call this. + +# juce_generate_juce_header(AudioPluginExample) + +# `target_sources` adds source files to a target. We pass the target that needs the sources as the +# first argument, then a visibility parameter for the sources (PRIVATE is normally best practice, +# although it doesn't really affect executable targets). Finally, we supply a list of source files +# that will be built into the target. This is a standard CMake command. + +target_sources(AudioPluginExample PRIVATE + PluginEditor.cpp + PluginProcessor.cpp) + +# `target_compile_definitions` adds some preprocessor definitions to our target. In a Projucer +# project, these might be passed in the 'Preprocessor Definitions' field. JUCE modules also make use +# of compile definitions to switch certain features on/off, so if there's a particular feature you +# need that's not on by default, check the module header for the correct flag to set here. These +# definitions will be visible both to your code, and also the JUCE module code, so for new +# definitions, pick unique names that are unlikely to collide! This is a standard CMake command. + +target_compile_definitions(AudioPluginExample + PUBLIC + # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. + JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_plugin` call + JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_plugin` call + JUCE_VST3_CAN_REPLACE_VST2=0) + +# If your target needs extra binary assets, you can add them here. The first argument is the name of +# a new static library target that will include all the binary resources. There is an optional +# `NAMESPACE` argument that can specify the namespace of the generated binary data class. Finally, +# the SOURCES argument should be followed by a list of source files that should be built into the +# static library. These source files can be of any kind (wav data, images, fonts, icons etc.). +# Conversion to binary-data will happen when your target is built. + +# juce_add_binary_data(AudioPluginData SOURCES ...) + +# `target_link_libraries` links libraries and JUCE modules to other libraries or executables. Here, +# we're linking our executable target to the `juce::juce_audio_utils` module. Inter-module +# dependencies are resolved automatically, so `juce_core`, `juce_events` and so on will also be +# linked automatically. If we'd generated a binary data target above, we would need to link to it +# here too. This is a standard CMake command. + +target_link_libraries(AudioPluginExample PRIVATE + # AudioPluginData # If we'd created a binary data target, we'd link to it here + juce::juce_audio_utils) diff --git a/JUCE b/JUCE new file mode 160000 index 0000000..55df089 --- /dev/null +++ b/JUCE @@ -0,0 +1 @@ +Subproject commit 55df0897d104c9a20a1363c748389d821a7cea1f diff --git a/PluginEditor.cpp b/PluginEditor.cpp new file mode 100644 index 0000000..50f8eb4 --- /dev/null +++ b/PluginEditor.cpp @@ -0,0 +1,33 @@ +#include "PluginProcessor.h" +#include "PluginEditor.h" + +//============================================================================== +AudioPluginAudioProcessorEditor::AudioPluginAudioProcessorEditor (AudioPluginAudioProcessor& p) + : AudioProcessorEditor (&p), processorRef (p) +{ + juce::ignoreUnused (processorRef); + // Make sure that before the constructor has finished, you've set the + // editor's size to whatever you need it to be. + setSize (400, 300); +} + +AudioPluginAudioProcessorEditor::~AudioPluginAudioProcessorEditor() +{ +} + +//============================================================================== +void AudioPluginAudioProcessorEditor::paint (juce::Graphics& g) +{ + // (Our component is opaque, so we must completely fill the background with a solid colour) + g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId)); + + g.setColour (juce::Colours::white); + g.setFont (15.0f); + g.drawFittedText ("Hello World!", getLocalBounds(), juce::Justification::centred, 1); +} + +void AudioPluginAudioProcessorEditor::resized() +{ + // This is generally where you'll want to lay out the positions of any + // subcomponents in your editor.. +} diff --git a/PluginEditor.h b/PluginEditor.h new file mode 100644 index 0000000..ef96e04 --- /dev/null +++ b/PluginEditor.h @@ -0,0 +1,22 @@ +#pragma once + +#include "PluginProcessor.h" + +//============================================================================== +class AudioPluginAudioProcessorEditor : public juce::AudioProcessorEditor +{ +public: + explicit AudioPluginAudioProcessorEditor (AudioPluginAudioProcessor&); + ~AudioPluginAudioProcessorEditor() override; + + //============================================================================== + void paint (juce::Graphics&) override; + void resized() override; + +private: + // This reference is provided as a quick way for your editor to + // access the processor object that created it. + AudioPluginAudioProcessor& processorRef; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginAudioProcessorEditor) +}; diff --git a/PluginProcessor.cpp b/PluginProcessor.cpp new file mode 100644 index 0000000..3139462 --- /dev/null +++ b/PluginProcessor.cpp @@ -0,0 +1,186 @@ +#include "PluginProcessor.h" +#include "PluginEditor.h" + +//============================================================================== +AudioPluginAudioProcessor::AudioPluginAudioProcessor() + : AudioProcessor (BusesProperties() + #if ! JucePlugin_IsMidiEffect + #if ! JucePlugin_IsSynth + .withInput ("Input", juce::AudioChannelSet::stereo(), true) + #endif + .withOutput ("Output", juce::AudioChannelSet::stereo(), true) + #endif + ) +{ +} + +AudioPluginAudioProcessor::~AudioPluginAudioProcessor() +{ +} + +//============================================================================== +const juce::String AudioPluginAudioProcessor::getName() const +{ + return JucePlugin_Name; +} + +bool AudioPluginAudioProcessor::acceptsMidi() const +{ + #if JucePlugin_WantsMidiInput + return true; + #else + return false; + #endif +} + +bool AudioPluginAudioProcessor::producesMidi() const +{ + #if JucePlugin_ProducesMidiOutput + return true; + #else + return false; + #endif +} + +bool AudioPluginAudioProcessor::isMidiEffect() const +{ + #if JucePlugin_IsMidiEffect + return true; + #else + return false; + #endif +} + +double AudioPluginAudioProcessor::getTailLengthSeconds() const +{ + return 0.0; +} + +int AudioPluginAudioProcessor::getNumPrograms() +{ + return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, + // so this should be at least 1, even if you're not really implementing programs. +} + +int AudioPluginAudioProcessor::getCurrentProgram() +{ + return 0; +} + +void AudioPluginAudioProcessor::setCurrentProgram (int index) +{ + juce::ignoreUnused (index); +} + +const juce::String AudioPluginAudioProcessor::getProgramName (int index) +{ + juce::ignoreUnused (index); + return {}; +} + +void AudioPluginAudioProcessor::changeProgramName (int index, const juce::String& newName) +{ + juce::ignoreUnused (index, newName); +} + +//============================================================================== +void AudioPluginAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) +{ + // Use this method as the place to do any pre-playback + // initialisation that you need.. + juce::ignoreUnused (sampleRate, samplesPerBlock); +} + +void AudioPluginAudioProcessor::releaseResources() +{ + // When playback stops, you can use this as an opportunity to free up any + // spare memory, etc. +} + +bool AudioPluginAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const +{ + #if JucePlugin_IsMidiEffect + juce::ignoreUnused (layouts); + return true; + #else + // This is the place where you check if the layout is supported. + // In this template code we only support mono or stereo. + if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono() + && layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo()) + return false; + + // This checks if the input layout matches the output layout + #if ! JucePlugin_IsSynth + if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) + return false; + #endif + + return true; + #endif +} + +void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer& buffer, + juce::MidiBuffer& midiMessages) +{ + juce::ignoreUnused (midiMessages); + + juce::ScopedNoDenormals noDenormals; + auto totalNumInputChannels = getTotalNumInputChannels(); + auto totalNumOutputChannels = getTotalNumOutputChannels(); + + // In case we have more outputs than inputs, this code clears any output + // channels that didn't contain input data, (because these aren't + // guaranteed to be empty - they may contain garbage). + // This is here to avoid people getting screaming feedback + // when they first compile a plugin, but obviously you don't need to keep + // this code if your algorithm always overwrites all the output channels. + for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) + buffer.clear (i, 0, buffer.getNumSamples()); + + // This is the place where you'd normally do the guts of your plugin's + // audio processing... + // Make sure to reset the state if your inner loop is processing + // the samples and the outer loop is handling the channels. + // Alternatively, you can process the samples with the channels + // interleaved by keeping the same state. + for (int channel = 0; channel < totalNumInputChannels; ++channel) + { + auto* channelData = buffer.getWritePointer (channel); + juce::ignoreUnused (channelData); + // ..do something to the data... + } +} + +//============================================================================== +bool AudioPluginAudioProcessor::hasEditor() const +{ + return true; // (change this to false if you choose to not supply an editor) +} + +juce::AudioProcessorEditor* AudioPluginAudioProcessor::createEditor() +{ + return new AudioPluginAudioProcessorEditor (*this); +} + +//============================================================================== +void AudioPluginAudioProcessor::getStateInformation (juce::MemoryBlock& destData) +{ + // You should use this method to store your parameters in the memory block. + // You could do that either as raw data, or use the XML or ValueTree classes + // as intermediaries to make it easy to save and load complex data. + juce::ignoreUnused (destData); +} + +void AudioPluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes) +{ + // You should use this method to restore your parameters from this memory block, + // whose contents will have been created by the getStateInformation() call. + juce::ignoreUnused (data, sizeInBytes); +} + +//============================================================================== +// This creates new instances of the plugin.. +juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() +{ + return new AudioPluginAudioProcessor(); +} diff --git a/PluginProcessor.h b/PluginProcessor.h new file mode 100644 index 0000000..d686ef3 --- /dev/null +++ b/PluginProcessor.h @@ -0,0 +1,47 @@ +#pragma once + +#include + +//============================================================================== +class AudioPluginAudioProcessor : public juce::AudioProcessor +{ +public: + //============================================================================== + AudioPluginAudioProcessor(); + ~AudioPluginAudioProcessor() override; + + //============================================================================== + void prepareToPlay (double sampleRate, int samplesPerBlock) override; + void releaseResources() override; + + bool isBusesLayoutSupported (const BusesLayout& layouts) const override; + + void processBlock (juce::AudioBuffer&, juce::MidiBuffer&) override; + + //============================================================================== + juce::AudioProcessorEditor* createEditor() override; + bool hasEditor() const override; + + //============================================================================== + const juce::String getName() const override; + + bool acceptsMidi() const override; + bool producesMidi() const override; + bool isMidiEffect() const override; + double getTailLengthSeconds() const override; + + //============================================================================== + int getNumPrograms() override; + int getCurrentProgram() override; + void setCurrentProgram (int index) override; + const juce::String getProgramName (int index) override; + void changeProgramName (int index, const juce::String& newName) override; + + //============================================================================== + void getStateInformation (juce::MemoryBlock& destData) override; + void setStateInformation (const void* data, int sizeInBytes) override; + +private: + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginAudioProcessor) +}; diff --git a/README.md b/README.md new file mode 100644 index 0000000..b64b97f --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +To trigger a new Release build, tag your latest commit with a version number and push: +```shell +git tag v1.0.0 +git push origin master --tags +```