├── .gitignore ├── .clang-format ├── .gitmodules ├── src ├── EditableComponent.h ├── PluginEditor.h ├── PluginEditor.cpp ├── PluginProcessor.h ├── CMakeLists.txt └── PluginProcessor.cpp ├── .clang-tidy ├── CHANGELOG.md ├── CMakeLists.txt ├── juce_cmake_vscode_example.code-workspace ├── assets └── juce-logo.svg └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .cache -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/JUCE"] 2 | path = lib/JUCE 3 | url = https://github.com/juce-framework/JUCE.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /src/EditableComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class EditableComponent : public Component{ 5 | 6 | EditableComponent():Component(){ 7 | 8 | addAndMakeVisible(border); 9 | } 10 | 11 | #if JUCE_DEBUG 12 | ResizableBorderComponent border; 13 | #endif 14 | }; -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: "clang-diagnostic-*,\ 2 | clang-analyzer-*,\ 3 | cppcoreguidelines-*,\ 4 | google-*,\ 5 | modernize-*,\ 6 | misc-*,\ 7 | readability-*,\ 8 | performance-*,\ 9 | portability-*,\ 10 | -modernize-use-trailing-return-type\ 11 | " 12 | HeaderFilterRegex: '**/Source/*\.(hpp|h)' 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2024-12-04 4 | 5 | - Added an additional debug configuration for Visual Studio (by @kinoshita-lab [#5](https://github.com/tomoyanonymous/juce_cmake_vscode_example/pull/5)) 6 | - Changed the default version of JUCE to 8.0.4 (by @kinoshita-lab [#6](https://github.com/tomoyanonymous/juce_cmake_vscode_example/pull/6)) 7 | - Updated an instruction, especially for windows users. 8 | 9 | ## 2023-01-09 10 | 11 | Changed the default version of JUCE to 7.0.3. -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | PROJECT(JUCE_CMAKE_EXAMPLE 4 | LANGUAGES CXX 5 | VERSION 0.0.2 6 | ) 7 | 8 | # for clang-tidy(this enable to find system header files). 9 | if(CMAKE_EXPORT_COMPILE_COMMANDS) 10 | set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) 11 | endif() 12 | 13 | # Enable JUCE. Do not use find_package to prevent from mix up with one globally installed. 14 | add_subdirectory(lib/JUCE) 15 | 16 | add_subdirectory(src) -------------------------------------------------------------------------------- /src/PluginEditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file contains the basic framework code for a JUCE plugin editor. 5 | 6 | ============================================================================== 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include "PluginProcessor.h" 14 | 15 | 16 | //============================================================================== 17 | /** 18 | */ 19 | class TestpluginAudioProcessorEditor : public juce::AudioProcessorEditor { 20 | public: 21 | TestpluginAudioProcessorEditor(TestpluginAudioProcessor &); 22 | ~TestpluginAudioProcessorEditor() override; 23 | 24 | //============================================================================== 25 | void paint(juce::Graphics &) override; 26 | void resized() override; 27 | 28 | private: 29 | // This reference is provided as a quick way for your editor to 30 | // access the processor object that created it. 31 | TestpluginAudioProcessor &audioProcessor; 32 | std::unique_ptr svgimg; 33 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TestpluginAudioProcessorEditor) 34 | }; 35 | -------------------------------------------------------------------------------- /juce_cmake_vscode_example.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "extensions": { 8 | "recommendations": [ 9 | "ms-vscode.cmake-tools", 10 | "twxs.cmake", 11 | "ms-vscode.cpptools", 12 | "llvm-vs-code-extensions.vscode-clangd", 13 | "vadimcn.vscode-lldb" 14 | ] 15 | }, 16 | "settings": { 17 | "C_Cpp.intelliSenseEngine": "disabled", 18 | "C_Cpp.default.cppStandard": "c++17", 19 | "cmake.buildDirectory": "${workspaceFolder}/build", 20 | "git.ignoreLimitWarning": true, 21 | "clangd.arguments": [ 22 | "-clang-tidy", 23 | "-background-index", 24 | "-compile-commands-dir=${workspaceFolder}/build", 25 | "-header-insertion=never", 26 | "--query-driver=\"/usr/bin/clang++\"" 27 | ], 28 | "cmake.ctestArgs": [ 29 | "--verbose" 30 | ], 31 | "cmake.configureArgs": [ 32 | // if you want to build AAX, set PATH for SDK here. 33 | // "-DAAX_SDK_PATH=" 34 | ], 35 | "cmake.preferredGenerators": [ 36 | "Ninja", 37 | "Unix Makefiles" 38 | ] 39 | }, 40 | "launch": { 41 | "configurations": [ 42 | { 43 | "name": "Debug via lldb", 44 | "request": "launch", 45 | "type": "lldb", 46 | "program": "${command:cmake.launchTargetPath}", 47 | "args": [], 48 | "cwd": "${workspaceFolder}" 49 | }, 50 | { 51 | "name": "Debug via cppvsdbg", 52 | "request": "launch", 53 | "type": "cppvsdbg", 54 | "program": "${command:cmake.launchTargetPath}", 55 | "args": [], 56 | "cwd": "${workspaceFolder}" 57 | } 58 | ] 59 | } 60 | } -------------------------------------------------------------------------------- /src/PluginEditor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file contains the basic framework code for a JUCE plugin editor. 5 | 6 | ============================================================================== 7 | */ 8 | 9 | #include "PluginEditor.h" 10 | 11 | #include "PluginProcessor.h" 12 | 13 | //============================================================================== 14 | TestpluginAudioProcessorEditor::TestpluginAudioProcessorEditor( 15 | TestpluginAudioProcessor &p) 16 | : AudioProcessorEditor(&p), audioProcessor(p) { 17 | // Make sure that before the constructor has finished, you've set the 18 | // editor's size to whatever you need it to be. 19 | setSize(400, 300); 20 | // load Image from BinaryData 21 | svgimg = juce::Drawable::createFromImageData(BinaryData::jucelogo_svg, 22 | BinaryData::jucelogo_svgSize); 23 | } 24 | 25 | TestpluginAudioProcessorEditor::~TestpluginAudioProcessorEditor() {} 26 | 27 | //============================================================================== 28 | void TestpluginAudioProcessorEditor::paint(juce::Graphics &g) { 29 | // (Our component is opaque, so we must completely fill the background with a 30 | // solid colour) 31 | g.fillAll( 32 | getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId)); 33 | svgimg->drawWithin(g, getLocalBounds().toFloat(), 34 | juce::Justification::centred, 1); 35 | 36 | g.setColour(juce::Colours::black); 37 | g.setFont(30.0f); 38 | g.drawFittedText("Hello World!", getLocalBounds(), 39 | juce::Justification::centred, 1); 40 | } 41 | 42 | void TestpluginAudioProcessorEditor::resized() { 43 | // This is generally where you'll want to lay out the positions of any 44 | // subcomponents in your editor.. 45 | } 46 | -------------------------------------------------------------------------------- /assets/juce-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/PluginProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file contains the basic framework code for a JUCE plugin processor. 5 | 6 | ============================================================================== 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | //============================================================================== 14 | /** 15 | */ 16 | class TestpluginAudioProcessor : public juce::AudioProcessor { 17 | public: 18 | //============================================================================== 19 | TestpluginAudioProcessor(); 20 | ~TestpluginAudioProcessor() override; 21 | 22 | //============================================================================== 23 | void prepareToPlay(double sampleRate, int samplesPerBlock) override; 24 | void releaseResources() override; 25 | 26 | #ifndef JucePlugin_PreferredChannelConfigurations 27 | bool isBusesLayoutSupported(const BusesLayout &layouts) const override; 28 | #endif 29 | 30 | void processBlock(juce::AudioBuffer &, juce::MidiBuffer &) override; 31 | 32 | //============================================================================== 33 | juce::AudioProcessorEditor *createEditor() override; 34 | bool hasEditor() const override; 35 | 36 | //============================================================================== 37 | const juce::String getName() const override; 38 | 39 | bool acceptsMidi() const override; 40 | bool producesMidi() const override; 41 | bool isMidiEffect() const override; 42 | double getTailLengthSeconds() const override; 43 | 44 | //============================================================================== 45 | int getNumPrograms() override; 46 | int getCurrentProgram() override; 47 | void setCurrentProgram(int index) override; 48 | const juce::String getProgramName(int index) override; 49 | void changeProgramName(int index, const juce::String &newName) override; 50 | 51 | //============================================================================== 52 | void getStateInformation(juce::MemoryBlock &destData) override; 53 | void setStateInformation(const void *data, int sizeInBytes) override; 54 | 55 | private: 56 | //============================================================================== 57 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TestpluginAudioProcessor) 58 | }; 59 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(DEFINED ENV{AAX_SDK_PATH}) 2 | set(AAX_SDK_PATH $ENV{AAX_SDK_PATH}) 3 | endif() 4 | if(DEFINED AAX_SDK_PATH) 5 | set(AAX_BUILD_FLAG AAX) 6 | file(TO_CMAKE_PATH "${AAX_SDK_PATH}" AAX_SDK_CMAKE_PATH) 7 | message(STATUS "AAX Build is enabled. AAX SDK = " ${AAX_SDK_CMAKE_PATH}) 8 | juce_set_aax_sdk_path(${AAX_SDK_CMAKE_PATH}) 9 | else() 10 | message(STATUS "AAX Build is disabled. To enable, set AAX_SDK_PATH to your environment variable or specify -DAAX_SDK_PATH to CMake configure option.") 11 | endif() 12 | 13 | juce_add_plugin(ExamplePlugin 14 | # VERSION ... # Set this if the plugin version is different to the project version 15 | # ICON_BIG "" # ICON_* arguments specify a path to an image file to use as an icon for the Standalone 16 | # ICON_SMALL "${CMAKE_SOURCE_DIR}/Assets/icon16.png " 17 | COMPANY_NAME "TomoyaMatsuura" # Specify the name of the plugin's author 18 | COMPANY_COPYRIGHT "Tomoya Matsuura" 19 | COMPANY_WEBSITE "https://matsuuratomoya.com/" 20 | COMPANY_EMAIL "me@matsuuratomoya.com" 21 | IS_SYNTH FALSE # Is this a synth or an effect? 22 | # NEEDS_MIDI_INPUT TRUE/FALSE # Does the plugin need midi input? 23 | # NEEDS_MIDI_OUTPUT TRUE/FALSE # Does the plugin need midi output? 24 | # IS_MIDI_EFFECT TRUE/FALSE # Is this plugin a MIDI effect? 25 | # EDITOR_WANTS_KEYBOARD_FOCUS TRUE/FALSE # Does the editor need keyboard focus? 26 | # COPY_PLUGIN_AFTER_BUILD TRUE/FALSE # Should the plugin be installed to a default location after building? 27 | PLUGIN_MANUFACTURER_CODE CCCC # A four-character manufacturer id with at least one upper-case character 28 | PLUGIN_CODE XXXX # A unique four-character plugin id with at least one upper-case character 29 | FORMATS 30 | # The formats to build. Other valid formats are: AAX Unity VST AU AUv3 31 | Standalone 32 | AU 33 | # AUv3 34 | VST3 35 | # Unity 36 | ${AAX_BUILD_FLAG} 37 | VST3_CATEGORIES "Fx" 38 | AU_MAIN_TYPE "kAudioUnitType_Effect" 39 | # AU_SANDBOX_SAFE TRUE 40 | # AAX_CATEGORY "" 41 | # HARDENED_RUNTIME_ENABLED # macOS app settings 42 | # HARDENED_RUNTIME_OPTIONS 43 | # APP_SANDBOX_ENABLED 44 | # APP_SANDBOX_INHERIT 45 | # DESCRIPTION "" #when i set this option, the name of AAX plugin became this description(bug?) 46 | MICROPHONE_PERMISSION_ENABLED TRUE 47 | MICROPHONE_PERMISSION_TEXT "This applicaion requires a permission to use an audio input device of your computer. By Default, Built-In microphone will be used." 48 | 49 | PRODUCT_NAME "ExamplePlugin") # The name of the final 50 | 51 | target_compile_features(ExamplePlugin PUBLIC cxx_std_17) 52 | 53 | 54 | target_compile_definitions(ExamplePlugin 55 | PUBLIC 56 | # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. 57 | JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_plugin` call 58 | JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_plugin` call 59 | JUCE_VST3_CAN_REPLACE_VST2=0 60 | # JUCE_DISPLAY_SPLASH_SCREEN=0 #if your plugin is distributed with GPL license or paid 61 | ) 62 | 63 | juce_add_binary_data(JuceLogoBinary 64 | SOURCES 65 | ${CMAKE_SOURCE_DIR}/assets/juce-logo.svg 66 | ) 67 | 68 | target_sources(ExamplePlugin PRIVATE 69 | PluginEditor.cpp 70 | PluginProcessor.cpp 71 | ) 72 | 73 | target_link_libraries(ExamplePlugin PUBLIC 74 | JuceLogoBinary 75 | juce::juce_audio_basics 76 | juce::juce_audio_devices 77 | juce::juce_audio_formats 78 | juce::juce_audio_plugin_client 79 | juce::juce_audio_processors 80 | juce::juce_audio_utils 81 | juce::juce_core 82 | juce::juce_cryptography 83 | juce::juce_data_structures 84 | juce::juce_dsp 85 | juce::juce_events 86 | juce::juce_graphics 87 | juce::juce_gui_basics 88 | juce::juce_gui_extra 89 | juce::juce_opengl 90 | juce::juce_product_unlocking 91 | ) 92 | 93 | juce_generate_juce_header(ExamplePlugin) 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BoilerPlate Repository for developing audio plugins with JUCE & CMake & Visual Studio Code 2 | 3 | ## Requirements 4 | 5 | - JUCE >= 6.0.0 (supports CMake after v6. Default is v8.0.4 now) 6 | - CMake >= 3.15 7 | - Visual Studio Code 8 | 9 | ### Recommended Extentions for vscode 10 | 11 | - [cpptools](https://github.com/microsoft/vscode-cpptools) (basic language supports for C++ development) 12 | - CMake (CMake language supports) 13 | - [CMake Tools](https://github.com/microsoft/vscode-cmake-tools) (Advanced Integration for using CMake in VScode with GUI) 14 | - [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) (better debugger than built-in gdb) 15 | - [clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) (Advanced intellisense support and formatter powered by llvm) 16 | 17 | ## Getting Started 18 | 19 | ### macOS 20 | 21 | - Install Xcode from AppStore. 22 | - Open "/Applications/Terminal.app". 23 | - Type `xcode-select --install` in the terminal and hit Enter. Follow the instruction on the terminal. 24 | - open `~/.zshrc` and add `export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"` in the last line of the file and save. 25 | 26 | Install [homebrew](https://brew.sh/). Run `brew install cmake llvm ninja` on the terminal. 27 | 28 | Install [Visual Studio Code](https://code.visualstudio.com/). (You can also get by `brew install --cask visual-studio-code`) 29 | 30 | ### Windows 31 | 32 | Install Visual Studio, Visual Studio Code and Winget from Windows App Store. 33 | 34 | Run `winget install --scope machine git cmake Ninja-build.Ninja LLVM.LLVM`. 35 | 36 | ### Common 37 | 38 | Clone this repository. 39 | 40 | ```sh 41 | git clone https://github.com/tomoyanonymous/juce_cmake_vscode_example --recursive 42 | ``` 43 | 44 | Or, you can create your own repository from the "Use this template" button. If you forked to your repository, replace the URL to yours. 45 | 46 | Open `juce_cmake_vscode_example.code-workspace` with Visual Studio Code. 47 | 48 | If the recommended extensions above are not fully installed, a notification will come up to install them. 49 | 50 | #### Build 51 | 52 | If CMake Tools is correctly installed, you will be asked which CMake Kits(compiler) you want to use. 53 | 54 | In macOS, choose `Clang x.x.x` which point to `/usr/bin/clang++` (clang provided by xcode. of course you can choose other compilers if you have). 55 | 56 | In Windows, choose something like `Clang 18.1.8 x86_64_pc-windows-msvc`. Do not choose kits which start with `Visual Studio~` because they are not compatible with `clangd`. 57 | 58 | Open CMake Menu on your left sidebar (it will show up if CMake Tools is installed). 59 | 60 | Click "Build All Projects" on the "Project Outline". 61 | 62 | #### Auto completion and Language server 63 | 64 | If you use `#include ` in your code, the language server can not search JUCE library codes unless you build the project once. (`JuceHeader.h` is generated on `build/ExamplePlugin_artifacts/JuceLibraryCode`) 65 | 66 | Note that `JuceHeader.h` is required just for the compatibility with the project generated by Projucer. So if you are going to start a project from scratch, you can just include header files relative to `lib/JUCE/modules` as you needed, like `#include `. 67 | 68 | #### Debugging 69 | 70 | If successfully built, right click `JUCE_CMAKE_EXAMPLE/src/ExamplePlugin_Standalone` and select "set as Debug/Launch Target". 71 | 72 | Open Debug Menu in left Sidebar. And click Run button on the left in a menu of CMake Debug(workspace). Standalone version of your plugin will be launched. 73 | 74 | (Note that you can also debug from "Debug" button in right-click menu of CMake Tools but you cannot use CodeLLDB debugger in this case.) 75 | 76 | 77 | #### (Optional) Setting JUCE version. 78 | 79 | The version of JUCE is v8.0.4 by default currently. Juce is located as a git submodule in `lib` directory, so you can switch the version by checking out in the directory like this. 80 | 81 | ```sh 82 | cd lib/JUCE 83 | git tag # show the tagged releases. 84 | git checkout 8.0.3 85 | # If you need, you can commit the change of JUCE version in the main directory. 86 | cd .. 87 | git commit -m "Changed the version of JUCE." 88 | ``` 89 | 90 | ## Resources 91 | 92 | [JUCE CMake API Documents](https://github.com/juce-framework/JUCE/blob/master/docs/CMake%20API.md) 93 | 94 | [sudara/pamplejuce](https://github.com/sudara/pamplejuce/) another great template repository for developing JUCE with CMake + Catch2 + GitHub Actions + C++20 95 | 96 | ## License 97 | 98 | (c) Tomoya Matsuura https://matsuuratomoya.com 99 | 100 | --- 101 | 102 | All of source codes included in this repository are published under MIT License. 103 | 104 | 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: 105 | 106 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 107 | 108 | 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. 109 | 110 | --- 111 | 112 | Creative Commons License
All of documents included in this repositry are published under Creative Commons Attribution 4.0 International License. 113 | -------------------------------------------------------------------------------- /src/PluginProcessor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file contains the basic framework code for a JUCE plugin processor. 5 | 6 | ============================================================================== 7 | */ 8 | 9 | #include "PluginProcessor.h" 10 | 11 | #include "PluginEditor.h" 12 | 13 | 14 | //============================================================================== 15 | TestpluginAudioProcessor::TestpluginAudioProcessor() 16 | #ifndef JucePlugin_PreferredChannelConfigurations 17 | : AudioProcessor( 18 | BusesProperties() 19 | #if !JucePlugin_IsMidiEffect 20 | #if !JucePlugin_IsSynth 21 | .withInput("Input", juce::AudioChannelSet::stereo(), true) 22 | #endif 23 | .withOutput("Output", juce::AudioChannelSet::stereo(), true) 24 | #endif 25 | ) 26 | #endif 27 | { 28 | } 29 | 30 | TestpluginAudioProcessor::~TestpluginAudioProcessor() {} 31 | 32 | //============================================================================== 33 | const juce::String TestpluginAudioProcessor::getName() const { 34 | return JucePlugin_Name; 35 | } 36 | 37 | bool TestpluginAudioProcessor::acceptsMidi() const { 38 | #if JucePlugin_WantsMidiInput 39 | return true; 40 | #else 41 | return false; 42 | #endif 43 | } 44 | 45 | bool TestpluginAudioProcessor::producesMidi() const { 46 | #if JucePlugin_ProducesMidiOutput 47 | return true; 48 | #else 49 | return false; 50 | #endif 51 | } 52 | 53 | bool TestpluginAudioProcessor::isMidiEffect() const { 54 | #if JucePlugin_IsMidiEffect 55 | return true; 56 | #else 57 | return false; 58 | #endif 59 | } 60 | 61 | double TestpluginAudioProcessor::getTailLengthSeconds() const { return 0.0; } 62 | 63 | int TestpluginAudioProcessor::getNumPrograms() { 64 | return 1; // NB: some hosts don't cope very well if you tell them there are 0 65 | // programs, so this should be at least 1, even if you're not 66 | // really implementing programs. 67 | } 68 | 69 | int TestpluginAudioProcessor::getCurrentProgram() { return 0; } 70 | 71 | void TestpluginAudioProcessor::setCurrentProgram(int index) {} 72 | 73 | const juce::String TestpluginAudioProcessor::getProgramName(int index) { 74 | return {}; 75 | } 76 | 77 | void TestpluginAudioProcessor::changeProgramName(int index, 78 | const juce::String &newName) {} 79 | 80 | //============================================================================== 81 | void TestpluginAudioProcessor::prepareToPlay(double sampleRate, 82 | int samplesPerBlock) { 83 | // Use this method as the place to do any pre-playback 84 | // initialisation that you need.. 85 | } 86 | 87 | void TestpluginAudioProcessor::releaseResources() { 88 | // When playback stops, you can use this as an opportunity to free up any 89 | // spare memory, etc. 90 | } 91 | 92 | #ifndef JucePlugin_PreferredChannelConfigurations 93 | bool TestpluginAudioProcessor::isBusesLayoutSupported( 94 | const BusesLayout &layouts) const { 95 | #if JucePlugin_IsMidiEffect 96 | juce::ignoreUnused(layouts); 97 | return true; 98 | #else 99 | // This is the place where you check if the layout is supported. 100 | // In this template code we only support mono or stereo. 101 | if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono() && 102 | layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo()) 103 | return false; 104 | 105 | // This checks if the input layout matches the output layout 106 | #if !JucePlugin_IsSynth 107 | if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) 108 | return false; 109 | #endif 110 | 111 | return true; 112 | #endif 113 | } 114 | #endif 115 | 116 | void TestpluginAudioProcessor::processBlock(juce::AudioBuffer &buffer, 117 | juce::MidiBuffer &midiMessages) { 118 | juce::ScopedNoDenormals noDenormals; 119 | auto totalNumInputChannels = getTotalNumInputChannels(); 120 | auto totalNumOutputChannels = getTotalNumOutputChannels(); 121 | 122 | // In case we have more outputs than inputs, this code clears any output 123 | // channels that didn't contain input data, (because these aren't 124 | // guaranteed to be empty - they may contain garbage). 125 | // This is here to avoid people getting screaming feedback 126 | // when they first compile a plugin, but obviously you don't need to keep 127 | // this code if your algorithm always overwrites all the output channels. 128 | for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) 129 | buffer.clear(i, 0, buffer.getNumSamples()); 130 | 131 | // This is the place where you'd normally do the guts of your plugin's 132 | // audio processing... 133 | // Make sure to reset the state if your inner loop is processing 134 | // the samples and the outer loop is handling the channels. 135 | // Alternatively, you can process the samples with the channels 136 | // interleaved by keeping the same state. 137 | for (int channel = 0; channel < totalNumInputChannels; ++channel) { 138 | auto *channelData = buffer.getWritePointer(channel); 139 | 140 | // ..do something to the data... 141 | } 142 | } 143 | 144 | //============================================================================== 145 | bool TestpluginAudioProcessor::hasEditor() const { 146 | return true; // (change this to false if you choose to not supply an editor) 147 | } 148 | 149 | juce::AudioProcessorEditor *TestpluginAudioProcessor::createEditor() { 150 | return new TestpluginAudioProcessorEditor(*this); 151 | } 152 | 153 | //============================================================================== 154 | void TestpluginAudioProcessor::getStateInformation( 155 | juce::MemoryBlock &destData) { 156 | // You should use this method to store your parameters in the memory block. 157 | // You could do that either as raw data, or use the XML or ValueTree classes 158 | // as intermediaries to make it easy to save and load complex data. 159 | } 160 | 161 | void TestpluginAudioProcessor::setStateInformation(const void *data, 162 | int sizeInBytes) { 163 | // You should use this method to restore your parameters from this memory 164 | // block, whose contents will have been created by the getStateInformation() 165 | // call. 166 | } 167 | 168 | //============================================================================== 169 | // This creates new instances of the plugin.. 170 | juce::AudioProcessor *JUCE_CALLTYPE createPluginFilter() { 171 | return new TestpluginAudioProcessor(); 172 | } 173 | --------------------------------------------------------------------------------