Compare commits
25
Commits
640b373b3e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57af955935 | ||
|
|
45a7475f56 | ||
|
|
2910e8d460 | ||
|
|
b570ba885b | ||
|
|
606c011c31 | ||
|
|
8e0f162947 | ||
|
|
53f9515ac9 | ||
|
|
aa94048f53 | ||
|
|
ba29890105 | ||
|
|
f5e6eadcd4 | ||
|
|
3fd823da95 | ||
|
|
799deecc29 | ||
|
|
7cc649d3ee | ||
|
|
68b8c9849b | ||
|
|
c9d1d4b389 | ||
|
|
dc4fd1847d | ||
|
|
b16e68f824 | ||
|
|
ecc15de9bf | ||
|
|
76ab1b533f | ||
|
|
a26de5091c | ||
|
|
2a06474177 | ||
|
|
4970730c06 | ||
|
|
ca7f1ec825 | ||
|
|
ee80ef7d89 | ||
|
|
3f3fdeddf3 |
No files matched your search
+15
-4
@@ -25,11 +25,22 @@ Desktop.ini
|
||||
*.component
|
||||
*.aaxplugin
|
||||
|
||||
# Keep release builds in Git
|
||||
# Keep Windows release builds in Git
|
||||
!Release/
|
||||
!Release/*.vst3/
|
||||
!Release/*.vst3/**
|
||||
!Release/Windows/
|
||||
!Release/Windows/**
|
||||
!Release/Windows/**/*.exe
|
||||
!Release/Windows/**/*.vst3/
|
||||
!Release/Windows/**/*.vst3/**
|
||||
|
||||
# Keep macOS release builds
|
||||
!Release/macOS/
|
||||
!Release/macOS/**
|
||||
!Release/macOS/**/*.app/
|
||||
!Release/macOS/**/*.app/**
|
||||
!Release/macOS/**/*.vst3/
|
||||
!Release/macOS/**/*.vst3/**
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.log
|
||||
*.log.DS_Store
|
||||
@@ -0,0 +1,6 @@
|
||||
[submodule "External/signalsmith-stretch"]
|
||||
path = External/signalsmith-stretch
|
||||
url = https://github.com/Signalsmith-Audio/signalsmith-stretch.git
|
||||
[submodule "External/signalsmith-linear"]
|
||||
path = External/signalsmith-linear
|
||||
url = https://github.com/Signalsmith-Audio/linear.git
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 422 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
@@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON "CrilleBassStrip.ico"
|
||||
@@ -1,38 +0,0 @@
|
||||
# Crille Bass Strip – macOS, Rider och REAPER
|
||||
|
||||
## Krav
|
||||
- macOS 11 eller senare
|
||||
- Xcode Command Line Tools
|
||||
- CMake
|
||||
- Git
|
||||
- Ninja: `brew install ninja`
|
||||
- JetBrains Rider med C++-stöd
|
||||
|
||||
## Bygg i Rider
|
||||
1. Packa upp projektet.
|
||||
2. Öppna mappen `CrilleBassStrip` i Rider, inte en enskild fil.
|
||||
3. Välj CMake-profilen `mac-release`.
|
||||
4. Låt CMake-konfigurationen bli klar. Första gången hämtas JUCE 8.0.6.
|
||||
5. Välj målet `CrilleBassStrip_VST3` och bygg i Release.
|
||||
|
||||
Pluginen kopieras automatiskt till:
|
||||
`~/Library/Audio/Plug-Ins/VST3/Crille Bass Strip.vst3`
|
||||
|
||||
I REAPER: Preferences > Plug-ins > VST > Re-scan.
|
||||
|
||||
## Bygg direkt i Terminal
|
||||
```bash
|
||||
brew install ninja
|
||||
cd CrilleBassStrip
|
||||
cmake --preset mac-release
|
||||
cmake --build --preset mac-release
|
||||
```
|
||||
|
||||
För en Universal Binary för både Apple Silicon och Intel:
|
||||
```bash
|
||||
cmake --preset mac-universal-release
|
||||
cmake --build --preset mac-universal-release
|
||||
```
|
||||
|
||||
## Signalväg
|
||||
Noise Gate -> Compressor -> Distortion -> EQ -> Output
|
||||
+231
-32
@@ -1,32 +1,104 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
project(CrilleBassStrip VERSION 1.0.0 LANGUAGES C CXX)
|
||||
|
||||
project(CrilleBassStrip
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C CXX
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS version")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# JUCE
|
||||
# ============================================================
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
JUCE
|
||||
GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
|
||||
GIT_TAG 8.0.6
|
||||
GIT_SHALLOW TRUE
|
||||
JUCE
|
||||
GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
|
||||
GIT_TAG 8.0.6
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(JUCE)
|
||||
|
||||
if(APPLE)
|
||||
set(VST3_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST3")
|
||||
elseif(WIN32)
|
||||
set(VST3_INSTALL_DIR "C:/Program Files/Common Files/VST3")
|
||||
|
||||
# ============================================================
|
||||
# External libraries
|
||||
# ============================================================
|
||||
|
||||
add_subdirectory(External/signalsmith-stretch)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Common paths
|
||||
# ============================================================
|
||||
|
||||
set(RELEASE_DIR "${CMAKE_SOURCE_DIR}/Release")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Platform-specific configuration
|
||||
# ============================================================
|
||||
|
||||
if(WIN32)
|
||||
|
||||
message(STATUS "Configuring Crille Bass Strip for Windows")
|
||||
|
||||
set(VST3_INSTALL_DIR
|
||||
"C:/Program Files/Common Files/VST3"
|
||||
CACHE PATH
|
||||
"Windows VST3 install directory"
|
||||
)
|
||||
|
||||
set(ASIO_SDK_DIR
|
||||
"C:/SDK/asio"
|
||||
CACHE PATH
|
||||
"Path to the Steinberg ASIO SDK"
|
||||
)
|
||||
|
||||
elseif(APPLE)
|
||||
|
||||
message(STATUS "Configuring Crille Bass Strip for macOS")
|
||||
|
||||
set(VST3_INSTALL_DIR
|
||||
"$ENV{HOME}/Library/Audio/Plug-Ins/VST3"
|
||||
CACHE PATH
|
||||
"macOS VST3 install directory"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Common source files
|
||||
# ============================================================
|
||||
|
||||
set(CRILLE_COMMON_SOURCES
|
||||
Source/PluginProcessor.cpp
|
||||
Source/PluginProcessor.h
|
||||
Source/PluginEditor.cpp
|
||||
Source/PluginEditor.h
|
||||
)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# VST3 plugin
|
||||
# ============================================================
|
||||
|
||||
juce_add_plugin(CrilleBassStrip
|
||||
COMPANY_NAME "Crille Audio"
|
||||
BUNDLE_ID "org.crilleaudio.crillebassstrip"
|
||||
|
||||
PLUGIN_MANUFACTURER_CODE Cril
|
||||
PLUGIN_CODE CbSt
|
||||
FORMATS VST3 Standalone
|
||||
|
||||
FORMATS VST3
|
||||
|
||||
PRODUCT_NAME "Crille Bass Strip"
|
||||
|
||||
COPY_PLUGIN_AFTER_BUILD TRUE
|
||||
VST3_COPY_DIR "${VST3_INSTALL_DIR}"
|
||||
)
|
||||
@@ -34,34 +106,161 @@ juce_add_plugin(CrilleBassStrip
|
||||
juce_generate_juce_header(CrilleBassStrip)
|
||||
|
||||
target_sources(CrilleBassStrip PRIVATE
|
||||
Source/PluginProcessor.cpp
|
||||
Source/PluginProcessor.h
|
||||
Source/PluginEditor.cpp
|
||||
Source/PluginEditor.h
|
||||
${CRILLE_COMMON_SOURCES}
|
||||
)
|
||||
|
||||
target_compile_definitions(CrilleBassStrip PUBLIC
|
||||
JUCE_WEB_BROWSER=0
|
||||
JUCE_USE_CURL=0
|
||||
JUCE_VST3_CAN_REPLACE_VST2=0
|
||||
JUCE_WEB_BROWSER=0
|
||||
JUCE_USE_CURL=0
|
||||
JUCE_VST3_CAN_REPLACE_VST2=0
|
||||
)
|
||||
|
||||
target_include_directories(CrilleBassStrip PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/External/signalsmith-stretch"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/External"
|
||||
)
|
||||
|
||||
target_link_libraries(CrilleBassStrip PRIVATE
|
||||
juce::juce_audio_utils
|
||||
juce::juce_dsp
|
||||
PUBLIC juce::juce_recommended_config_flags
|
||||
juce::juce_recommended_lto_flags
|
||||
juce::juce_recommended_warning_flags
|
||||
juce::juce_audio_utils
|
||||
juce::juce_dsp
|
||||
|
||||
PUBLIC
|
||||
juce::juce_recommended_config_flags
|
||||
juce::juce_recommended_lto_flags
|
||||
juce::juce_recommended_warning_flags
|
||||
)
|
||||
# Copy the finished VST3 to Release/ after build
|
||||
set(RELEASE_DIR "${CMAKE_SOURCE_DIR}/Release")
|
||||
|
||||
add_custom_command(TARGET CrilleBassStrip_VST3 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${RELEASE_DIR}"
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"$<TARGET_FILE_DIR:CrilleBassStrip_VST3>/../.."
|
||||
"${RELEASE_DIR}/Crille Bass Strip.vst3"
|
||||
# ============================================================
|
||||
# Standalone application
|
||||
# ============================================================
|
||||
|
||||
COMMENT "Copying Crille Bass Strip.vst3 to Release"
|
||||
)
|
||||
juce_add_gui_app(CrilleBassStripApp
|
||||
PRODUCT_NAME "Crille Bass Strip"
|
||||
COMPANY_NAME "Crille Audio"
|
||||
BUNDLE_ID "org.crilleaudio.crillebassstrip"
|
||||
|
||||
ICON_BIG "${CMAKE_CURRENT_SOURCE_DIR}/Assets/CrilleBassStrip.png"
|
||||
ICON_SMALL "${CMAKE_CURRENT_SOURCE_DIR}/Assets/CrilleBassStrip.png"
|
||||
)
|
||||
|
||||
juce_generate_juce_header(CrilleBassStripApp)
|
||||
|
||||
target_sources(CrilleBassStripApp PRIVATE
|
||||
Source/StandaloneMain.cpp
|
||||
Source/StandaloneMain.h
|
||||
|
||||
${CRILLE_COMMON_SOURCES}
|
||||
)
|
||||
|
||||
target_compile_definitions(CrilleBassStripApp PRIVATE
|
||||
JUCE_WEB_BROWSER=0
|
||||
JUCE_USE_CURL=0
|
||||
)
|
||||
|
||||
target_include_directories(CrilleBassStripApp PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/External/signalsmith-stretch"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/External"
|
||||
)
|
||||
|
||||
target_link_libraries(CrilleBassStripApp PRIVATE
|
||||
juce::juce_audio_utils
|
||||
juce::juce_dsp
|
||||
|
||||
PUBLIC
|
||||
juce::juce_recommended_config_flags
|
||||
juce::juce_recommended_lto_flags
|
||||
juce::juce_recommended_warning_flags
|
||||
)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Windows-specific configuration
|
||||
# ============================================================
|
||||
|
||||
if(WIN32)
|
||||
|
||||
# ASIO is only used on Windows
|
||||
target_compile_definitions(CrilleBassStripApp PRIVATE
|
||||
JUCE_ASIO=1
|
||||
)
|
||||
|
||||
target_include_directories(CrilleBassStripApp PRIVATE
|
||||
"${ASIO_SDK_DIR}/common"
|
||||
"${ASIO_SDK_DIR}/host"
|
||||
"${ASIO_SDK_DIR}/host/pc"
|
||||
)
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Copy VST3 to Release/Windows
|
||||
# --------------------------------------------------------
|
||||
|
||||
add_custom_command(TARGET CrilleBassStrip_VST3 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
"${RELEASE_DIR}/Windows/VST3"
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"$<TARGET_FILE_DIR:CrilleBassStrip_VST3>/../.."
|
||||
"${RELEASE_DIR}/Windows/VST3/Crille Bass Strip.vst3"
|
||||
|
||||
COMMENT "Copying Windows VST3 to Release"
|
||||
)
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Copy standalone EXE to Release/Windows
|
||||
# --------------------------------------------------------
|
||||
|
||||
add_custom_command(TARGET CrilleBassStripApp POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
"${RELEASE_DIR}/Windows/Standalone"
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"$<TARGET_FILE:CrilleBassStripApp>"
|
||||
"${RELEASE_DIR}/Windows/Standalone/Crille Bass Strip.exe"
|
||||
|
||||
COMMENT "Copying Windows standalone app to Release"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# ============================================================
|
||||
# macOS-specific configuration
|
||||
# ============================================================
|
||||
|
||||
if(APPLE)
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Copy VST3 to Release/macOS
|
||||
# --------------------------------------------------------
|
||||
|
||||
add_custom_command(TARGET CrilleBassStrip_VST3 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
"${RELEASE_DIR}/macOS/VST3"
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"$<TARGET_BUNDLE_DIR:CrilleBassStrip_VST3>"
|
||||
"${RELEASE_DIR}/macOS/VST3/Crille Bass Strip.vst3"
|
||||
|
||||
COMMENT "Copying macOS VST3 to Release"
|
||||
)
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Copy standalone app to Release/macOS
|
||||
# --------------------------------------------------------
|
||||
|
||||
add_custom_command(TARGET CrilleBassStripApp POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
"${RELEASE_DIR}/macOS/Standalone"
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"$<TARGET_BUNDLE_DIR:CrilleBassStripApp>"
|
||||
"${RELEASE_DIR}/macOS/Standalone/Crille Bass Strip.app"
|
||||
|
||||
COMMENT "Copying macOS standalone app to Release"
|
||||
)
|
||||
|
||||
endif()
|
||||
+1
Submodule External/signalsmith-linear added at 7bb1c8f367.
+1
Submodule External/signalsmith-stretch added at 88061fd4ed.
@@ -1,193 +1,526 @@
|
||||
# Crille Bass Strip
|
||||
|
||||
Crille Bass Strip är ett VST3-plugin för bas, utvecklat i C++ med JUCE.
|
||||
Crille Bass Strip är en komplett bassignalprocessor för Windows och macOS, utvecklad i C++ med JUCE.
|
||||
|
||||
Programmet finns både som fristående app och som VST3-plugin för båda plattformarna.
|
||||
|
||||
Crille Bass Strip började som ett sätt att ersätta den långa kedja av separata plugins som tidigare användes i REAPER för att skapa ett färdigt basljud. Målet är att samla hela signalbehandlingen i ett enda enkelt verktyg.
|
||||
|
||||
## Funktioner
|
||||
|
||||
Crille Bass Strip innehåller:
|
||||
|
||||
- DownTune
|
||||
- Inbyggd tuner
|
||||
- Noise Gate
|
||||
- Compressor
|
||||
- Distortion
|
||||
- 4-bands EQ
|
||||
- Input-mätare
|
||||
- Gain Reduction-mätare
|
||||
- Individuell bypass för effekterna
|
||||
- Automatisk sparning av inställningar
|
||||
- Standalone-app för Windows och macOS
|
||||
- VST3-plugin för Windows och macOS
|
||||
- ASIO-stöd på Windows
|
||||
- CoreAudio på macOS
|
||||
|
||||
## Signalkedja
|
||||
|
||||
Noise Gate → Compressor → Distortion → EQ → Output
|
||||
|
||||
## Plattformar
|
||||
|
||||
Pluginet kan byggas på:
|
||||
|
||||
- macOS
|
||||
- Windows
|
||||
|
||||
## Pluginformat
|
||||
|
||||
För närvarande stöds:
|
||||
|
||||
- VST3
|
||||
- Standalone
|
||||
|
||||
JUCE laddas ner automatiskt av CMake vid första bygget.
|
||||
|
||||
---
|
||||
|
||||
# Bygga på macOS
|
||||
|
||||
## 1. Installera Xcode Command Line Tools
|
||||
|
||||
Öppna Terminal och kör:
|
||||
|
||||
```bash
|
||||
xcode-select --install
|
||||
```text
|
||||
Bass Input
|
||||
↓
|
||||
DownTune
|
||||
↓
|
||||
Noise Gate
|
||||
↓
|
||||
Compressor
|
||||
↓
|
||||
Distortion
|
||||
↓
|
||||
Equalizer
|
||||
↓
|
||||
Output
|
||||
```
|
||||
|
||||
Följ instruktionerna för att slutföra installationen.
|
||||
# DownTune
|
||||
|
||||
## 2. Installera Homebrew
|
||||
DownTune-modulen används för att sänka basens tonhöjd en halvton.
|
||||
|
||||
Om Homebrew inte redan finns installerat, kör:
|
||||
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
|
||||
Följ instruktionerna som visas efter installationen. Homebrew kan behöva läggas till i `PATH`.
|
||||
|
||||
Kontrollera sedan installationen:
|
||||
|
||||
```bash
|
||||
brew --version
|
||||
```
|
||||
|
||||
## 3. Installera Git, CMake och Ninja
|
||||
|
||||
```bash
|
||||
brew install git cmake ninja
|
||||
```
|
||||
|
||||
Kontrollera installationerna:
|
||||
|
||||
```bash
|
||||
git --version
|
||||
cmake --version
|
||||
ninja --version
|
||||
```
|
||||
|
||||
## 4. Bygg pluginet
|
||||
|
||||
Gå till projektets katalog och kör:
|
||||
|
||||
```bash
|
||||
cmake --preset mac-release
|
||||
cmake --build --preset mac-release
|
||||
```
|
||||
|
||||
VST3-pluginet installeras automatiskt till:
|
||||
Exempel:
|
||||
|
||||
```text
|
||||
~/Library/Audio/Plug-Ins/VST3/Crille Bass Strip.vst3
|
||||
E → Eb
|
||||
F → E
|
||||
F# → F
|
||||
G → F#
|
||||
```
|
||||
|
||||
---
|
||||
Modulen kan slås av och på direkt i gränssnittet.
|
||||
|
||||
Pitch shifting görs med Signalsmith Stretch.
|
||||
|
||||
Den nuvarande konfigurationen använder:
|
||||
|
||||
```cpp
|
||||
downTune.configure(1, 1024, 256);
|
||||
downTune.setTransposeSemitones(-1.0);
|
||||
```
|
||||
|
||||
Konfigurationen är vald som en kompromiss mellan låg latency och ren pitch shifting.
|
||||
|
||||
Tidigare användes mindre analysblock, vilket gav lägre latency men ett mer metalliskt och onaturligt ljud. Större standardinställningar i Signalsmith gav renare ljud men över 100 ms latency, vilket är för mycket för live-spel.
|
||||
|
||||
Den nuvarande konfigurationen ger i praktiken ungefär:
|
||||
|
||||
```text
|
||||
21 ms
|
||||
```
|
||||
|
||||
intern latency för DownTune-modulen vid den testade konfigurationen.
|
||||
|
||||
Den exakta latencyn kan variera beroende på sample rate och övrig ljudkonfiguration.
|
||||
|
||||
# Tuner
|
||||
|
||||
Crille Bass Strip innehåller en inbyggd tuner för bas.
|
||||
|
||||
Tunern analyserar inkommande signal och visar den närmaste tonen.
|
||||
|
||||
Stämningen visas med tre indikatorer på vardera sidan om mittpunkten:
|
||||
|
||||
```text
|
||||
<<< ● >>>
|
||||
```
|
||||
|
||||
Antalet aktiva indikatorer visar hur långt tonen ligger från korrekt stämning:
|
||||
|
||||
```text
|
||||
3 pilar = långt från rätt ton
|
||||
2 pilar = närmare
|
||||
1 pil = nästan rätt
|
||||
0 pilar = in tune
|
||||
```
|
||||
|
||||
När tonen ligger rätt visas:
|
||||
|
||||
```text
|
||||
IN TUNE
|
||||
```
|
||||
|
||||
Tunern visar inte frekvensvärden i Hz utan fokuserar på tonen och hur mycket instrumentet behöver stämmas upp eller ned.
|
||||
|
||||
När DownTune är aktiverad kan även den förväntade utgångstonen visas.
|
||||
|
||||
Tonanalysen används endast för visning och påverkar inte själva ljudsignalen.
|
||||
|
||||
# Plattformar
|
||||
|
||||
Crille Bass Strip byggs för:
|
||||
|
||||
- Windows 10
|
||||
- Windows 11
|
||||
- macOS
|
||||
|
||||
Samma kodbas används för båda plattformarna.
|
||||
|
||||
Plattformsspecifika delar hanteras av JUCE, CMake och de ljudsystem som respektive operativsystem använder.
|
||||
|
||||
# Format
|
||||
|
||||
Crille Bass Strip finns i två format på både Windows och macOS:
|
||||
|
||||
## Standalone
|
||||
|
||||
En fristående app som kan köras utan DAW.
|
||||
|
||||
### Windows
|
||||
|
||||
```text
|
||||
Crille Bass Strip.exe
|
||||
```
|
||||
|
||||
### macOS
|
||||
|
||||
```text
|
||||
Crille Bass Strip.app
|
||||
```
|
||||
|
||||
Standalone-versionen ger direkt tillgång till datorns ljudenheter och kan användas för att spela bas utan att först starta exempelvis REAPER.
|
||||
|
||||
## VST3
|
||||
|
||||
VST3-versionen kan användas i exempelvis:
|
||||
|
||||
- REAPER
|
||||
- Cubase
|
||||
- Studio One
|
||||
- Ableton Live
|
||||
- andra DAW-program med VST3-stöd
|
||||
|
||||
Plugin-versionen använder DAW-programmets ljudkonfiguration.
|
||||
|
||||
# Ljudsystem
|
||||
|
||||
## Windows
|
||||
|
||||
Standalone-versionen använder ASIO för låg ljudlatency.
|
||||
|
||||
Programmet är inte bundet till ett specifikt ljudkort. Det kan användas med ljudkort som har en fungerande ASIO-driver, exempelvis från tillverkare som:
|
||||
|
||||
- Focusrite
|
||||
- RME
|
||||
- Steinberg
|
||||
- Yamaha
|
||||
- Behringer
|
||||
|
||||
Tillgängliga in- och utgångar väljs i programmets Audio Setup.
|
||||
|
||||
Den totala latency som upplevs vid spelning beror både på DownTune-modulens interna latency och ljudkortets ASIO-buffer.
|
||||
|
||||
## macOS
|
||||
|
||||
På macOS används CoreAudio.
|
||||
|
||||
CoreAudio är inbyggt i macOS och kräver därför ingen separat ASIO SDK eller motsvarande installation.
|
||||
|
||||
Tillgängliga ljudenheter samt in- och utgångar hanteras via programmets Audio Setup och macOS ljudsystem.
|
||||
|
||||
# Utvecklingsmiljö
|
||||
|
||||
Projektet använder:
|
||||
|
||||
- C++20
|
||||
- JUCE 8
|
||||
- CMake
|
||||
- Signalsmith Stretch
|
||||
- Signalsmith Linear
|
||||
- Git
|
||||
|
||||
På Windows används dessutom:
|
||||
|
||||
- Microsoft Visual C++
|
||||
- Windows SDK
|
||||
- Steinberg ASIO SDK
|
||||
|
||||
På macOS används:
|
||||
|
||||
- Apple Clang
|
||||
- Xcode / Xcode Command Line Tools
|
||||
- CoreAudio
|
||||
|
||||
JUCE hämtas automatiskt av CMake när projektet konfigureras.
|
||||
|
||||
Signalsmith-komponenterna ligger som Git-submodules i projektet.
|
||||
|
||||
# Klona projektet
|
||||
|
||||
Eftersom projektet använder Git-submodules rekommenderas:
|
||||
|
||||
```bash
|
||||
git clone --recurse-submodules <repository-url>
|
||||
```
|
||||
|
||||
Om projektet redan har klonats utan submodules:
|
||||
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
Projektet använder bland annat:
|
||||
|
||||
```text
|
||||
External/
|
||||
├── signalsmith-stretch/
|
||||
└── signalsmith-linear/
|
||||
```
|
||||
|
||||
# Bygga på Windows
|
||||
|
||||
Windows-versionen kräver Git, CMake, Ninja samt Microsofts C++-kompilator och Windows SDK.
|
||||
|
||||
De nödvändiga verktygen kan installeras via `winget`.
|
||||
|
||||
## 1. Installera Git
|
||||
|
||||
Öppna PowerShell eller Windows Terminal och kör:
|
||||
Öppna PowerShell eller Windows Terminal:
|
||||
|
||||
```powershell
|
||||
winget install --id Git.Git -e
|
||||
```
|
||||
|
||||
Kontrollera installationen:
|
||||
|
||||
```powershell
|
||||
git --version
|
||||
```
|
||||
|
||||
## 2. Installera CMake
|
||||
|
||||
```powershell
|
||||
winget install --id Kitware.CMake -e
|
||||
```
|
||||
|
||||
## 3. Installera Ninja
|
||||
Kontrollera installationen:
|
||||
|
||||
```powershell
|
||||
winget install --id Ninja-build.Ninja -e
|
||||
cmake --version
|
||||
```
|
||||
|
||||
## 4. Installera Visual Studio 2022 Build Tools
|
||||
|
||||
Installera Visual Studio Build Tools med C++-verktygen:
|
||||
## 3. Installera Visual Studio 2022 Build Tools
|
||||
|
||||
```powershell
|
||||
winget install --id Microsoft.VisualStudio.2022.BuildTools -e --override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
|
||||
```
|
||||
|
||||
Detta installerar bland annat de komponenter som behövs för att kompilera C++-projekt med MSVC. 【1-179a6a】
|
||||
Alternativt kan Visual Studio Build Tools installeras manuellt.
|
||||
|
||||
Alternativt kan Visual Studio Build Tools installeras manuellt. Välj då workloaden:
|
||||
Välj då workloaden:
|
||||
|
||||
```text
|
||||
Desktop development with C++
|
||||
```
|
||||
|
||||
Se till att följande finns installerat:
|
||||
Se till att följande komponenter finns:
|
||||
|
||||
- MSVC C++ Build Tools
|
||||
- Windows SDK
|
||||
- C++ CMake tools
|
||||
- CMake tools för C++
|
||||
|
||||
## 5. Kontrollera installationen
|
||||
## ASIO SDK
|
||||
|
||||
Stäng terminalen och öppna en ny PowerShell eller Windows Terminal.
|
||||
Standalone-versionen på Windows behöver Steinberg ASIO SDK för att byggas.
|
||||
|
||||
Kör:
|
||||
|
||||
```powershell
|
||||
git --version
|
||||
cmake --version
|
||||
ninja --version
|
||||
```
|
||||
|
||||
Alla tre kommandona ska visa installerad version.
|
||||
|
||||
## 6. Bygg pluginet
|
||||
|
||||
Gå till projektets katalog och kör:
|
||||
|
||||
```powershell
|
||||
cmake --preset windows-release
|
||||
cmake --build --preset windows-release
|
||||
```
|
||||
|
||||
Den färdiga VST3-versionen kopieras även till projektets:
|
||||
Projektet förväntar sig som standard att ASIO SDK finns i:
|
||||
|
||||
```text
|
||||
Release/
|
||||
C:\SDK\asio
|
||||
```
|
||||
|
||||
och finns där som:
|
||||
Sökvägen definieras i `CMakeLists.txt`:
|
||||
|
||||
```cmake
|
||||
set(ASIO_SDK_DIR "C:/SDK/asio" CACHE PATH "Path to the Steinberg ASIO SDK")
|
||||
```
|
||||
|
||||
## Bygg projektet
|
||||
|
||||
Gå till projektets katalog.
|
||||
|
||||
Projektet kan byggas med:
|
||||
|
||||
```powershell
|
||||
cmake --build build --config Release
|
||||
```
|
||||
|
||||
Det bygger projektets Release-versioner från den befintliga CMake-konfigurationen.
|
||||
|
||||
För en ny konfiguration kan projektet först konfigureras med:
|
||||
|
||||
```powershell
|
||||
cmake -S . -B build
|
||||
```
|
||||
|
||||
## Bygg Standalone separat
|
||||
|
||||
```powershell
|
||||
cmake --build build --config Release --target CrilleBassStripApp
|
||||
```
|
||||
|
||||
Den färdiga appen kopieras till:
|
||||
|
||||
```text
|
||||
Release/Crille Bass Strip.vst3
|
||||
Release\Windows\Standalone\Crille Bass Strip.exe
|
||||
```
|
||||
|
||||
Standardplatsen för installerade VST3-plugin på Windows är:
|
||||
Applikationsikonen är inbyggd direkt i EXE-filen.
|
||||
|
||||
## Bygg VST3 separat
|
||||
|
||||
```powershell
|
||||
cmake --build build --config Release --target CrilleBassStrip_VST3
|
||||
```
|
||||
|
||||
Den färdiga plugin-versionen kopieras till:
|
||||
|
||||
```text
|
||||
Release\Windows\VST3\Crille Bass Strip.vst3
|
||||
```
|
||||
|
||||
VST3-versionen kan även installeras i Windows standardkatalog för VST3:
|
||||
|
||||
```text
|
||||
C:\Program Files\Common Files\VST3
|
||||
```
|
||||
|
||||
---
|
||||
# Bygga på macOS
|
||||
|
||||
# Utvecklingsmiljö
|
||||
|
||||
Projektet kräver:
|
||||
För att bygga projektet på macOS behövs:
|
||||
|
||||
- Git
|
||||
- CMake
|
||||
- Ninja
|
||||
- C++20-kompatibel kompilator
|
||||
- JUCE 8
|
||||
- Apple Clang
|
||||
- Xcode eller Xcode Command Line Tools
|
||||
|
||||
JUCE behöver inte installeras separat. Rätt version hämtas automatiskt av CMake när projektet konfigureras första gången.
|
||||
Kontrollera verktygen med:
|
||||
|
||||
En IDE är inte nödvändig för att bygga projektet. Rider, Visual Studio eller annan C++-IDE kan användas för utveckling.
|
||||
```bash
|
||||
git --version
|
||||
cmake --version
|
||||
clang++ --version
|
||||
xcodebuild -version
|
||||
```
|
||||
|
||||
## Författare
|
||||
## Hämta senaste versionen
|
||||
|
||||
```bash
|
||||
git pull
|
||||
```
|
||||
|
||||
## Konfigurera Release-bygget
|
||||
|
||||
```bash
|
||||
cmake --preset mac-release
|
||||
```
|
||||
|
||||
## Bygg Release-versionen
|
||||
|
||||
```bash
|
||||
cmake --build --preset mac-release
|
||||
```
|
||||
|
||||
## Bygg Standalone separat
|
||||
|
||||
```bash
|
||||
cmake --build build --config Release --target CrilleBassStripApp
|
||||
```
|
||||
|
||||
Den färdiga appen kopieras till:
|
||||
|
||||
```text
|
||||
Release/macOS/Standalone/Crille Bass Strip.app
|
||||
```
|
||||
|
||||
## Bygg VST3 separat
|
||||
|
||||
```bash
|
||||
cmake --build build --config Release --target CrilleBassStrip_VST3
|
||||
```
|
||||
|
||||
Den färdiga plugin-versionen kopieras till:
|
||||
|
||||
```text
|
||||
Release/macOS/VST3/Crille Bass Strip.vst3
|
||||
```
|
||||
|
||||
# Release-struktur
|
||||
|
||||
Efter att versionerna för båda plattformarna har byggts används följande struktur:
|
||||
|
||||
```text
|
||||
Release/
|
||||
├── Windows/
|
||||
│ ├── Standalone/
|
||||
│ │ └── Crille Bass Strip.exe
|
||||
│ │
|
||||
│ └── VST3/
|
||||
│ └── Crille Bass Strip.vst3
|
||||
│
|
||||
└── macOS/
|
||||
├── Standalone/
|
||||
│ └── Crille Bass Strip.app
|
||||
│
|
||||
└── VST3/
|
||||
└── Crille Bass Strip.vst3
|
||||
```
|
||||
|
||||
# Standalone-versionen
|
||||
|
||||
Standalone-appen innehåller ett eget ljudgränssnitt där användaren kan välja basingång och konfigurera ljudenheten.
|
||||
|
||||
Via `AUDIO SETUP` kan ljudenhet, in- och utgångar samt andra ljudinställningar konfigureras.
|
||||
|
||||
På Windows används ASIO och på macOS används CoreAudio.
|
||||
|
||||
Standalone-versionen är tänkt att kunna användas som ett enkelt alternativ till att starta en komplett DAW bara för att spela bas.
|
||||
|
||||
Arbetsflödet blir exempelvis:
|
||||
|
||||
```text
|
||||
Bass
|
||||
↓
|
||||
Audio Interface
|
||||
↓
|
||||
Crille Bass Strip
|
||||
↓
|
||||
Speakers / Headphones
|
||||
```
|
||||
|
||||
# Sparade inställningar
|
||||
|
||||
Standalone-versionen sparar inställningar mellan körningar.
|
||||
|
||||
Det omfattar bland annat:
|
||||
|
||||
- vald basingång
|
||||
- plugin-parametrar
|
||||
- rattarnas värden
|
||||
- individuella bypass-inställningar
|
||||
- DownTune ON/OFF
|
||||
|
||||
Inställningarna sparas med JUCE `PropertiesFile` i användarens applikationsdata.
|
||||
|
||||
Det innebär att inställningarna finns kvar även om själva programmet ersätts med en ny version.
|
||||
|
||||
# Projektstruktur
|
||||
|
||||
De viktigaste delarna av projektet är:
|
||||
|
||||
```text
|
||||
CrilleBassStrip/
|
||||
│
|
||||
├── Assets/
|
||||
│ ├── CrilleBassStrip.ico
|
||||
│ └── CrilleBassStrip.rc
|
||||
│
|
||||
├── External/
|
||||
│ ├── signalsmith-stretch/
|
||||
│ └── signalsmith-linear/
|
||||
│
|
||||
├── Source/
|
||||
│ ├── PluginProcessor.cpp
|
||||
│ ├── PluginProcessor.h
|
||||
│ ├── PluginEditor.cpp
|
||||
│ ├── PluginEditor.h
|
||||
│ ├── StandaloneMain.cpp
|
||||
│ └── StandaloneMain.h
|
||||
│
|
||||
├── Release/
|
||||
│ ├── Windows/
|
||||
│ │ ├── Standalone/
|
||||
│ │ └── VST3/
|
||||
│ │
|
||||
│ └── macOS/
|
||||
│ ├── Standalone/
|
||||
│ └── VST3/
|
||||
│
|
||||
├── CMakeLists.txt
|
||||
├── CMakePresets.json
|
||||
├── .gitmodules
|
||||
└── README.md
|
||||
```
|
||||
|
||||
# IDE
|
||||
|
||||
En IDE är inte nödvändig för att bygga projektet.
|
||||
|
||||
Utveckling kan exempelvis göras i:
|
||||
|
||||
- JetBrains Rider
|
||||
- Visual Studio
|
||||
- Visual Studio Code
|
||||
- Xcode
|
||||
|
||||
Projektet använder CMake och kan byggas direkt från terminalen på både Windows och macOS.
|
||||
|
||||
Vid utveckling med Rider på Windows används en Visual Studio/MSVC-toolchain för CMake-projektet.
|
||||
|
||||
# Författare
|
||||
|
||||
Christian Ohlsson
|
||||
Binary file not shown.
File renamed without changes.
BIN
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist>
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Crille Bass Strip</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Icon.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.crilleaudio.crillebassstrip</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Crille Bass Strip</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Crille Bass Strip</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
||||
APPL????
|
||||
BIN
Binary file not shown.
Binary file not shown.
Generated
BIN
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist>
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Crille Bass Strip</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.crilleaudio.crillebassstrip</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Crille Bass Strip</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Crille Bass Strip</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
BNDL????
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"Name": "Crille Bass Strip",
|
||||
"Version": "1.0.0",
|
||||
"Factory Info": {
|
||||
"Vendor": "Crille Audio",
|
||||
"URL": "",
|
||||
"E-Mail": "",
|
||||
"Flags": {
|
||||
"Unicode": true,
|
||||
"Classes Discardable": false,
|
||||
"Component Non Discardable": false,
|
||||
},
|
||||
},
|
||||
"Classes": [
|
||||
{
|
||||
"CID": "ABCDEF019182FAEB4372696C43625374",
|
||||
"Category": "Audio Module Class",
|
||||
"Name": "Crille Bass Strip",
|
||||
"Vendor": "Crille Audio",
|
||||
"Version": "1.0.0",
|
||||
"SDKVersion": "VST 3.7.12",
|
||||
"Sub Categories": [
|
||||
"Fx",
|
||||
],
|
||||
"Class Flags": 0,
|
||||
"Cardinality": 2147483647,
|
||||
"Snapshots": [
|
||||
],
|
||||
},
|
||||
{
|
||||
"CID": "ABCDEF011234ABCD4372696C43625374",
|
||||
"Category": "Component Controller Class",
|
||||
"Name": "Crille Bass Strip",
|
||||
"Vendor": "Crille Audio",
|
||||
"Version": "1.0.0",
|
||||
"SDKVersion": "VST 3.7.12",
|
||||
"Sub Categories": [
|
||||
"Fx",
|
||||
],
|
||||
"Class Flags": 0,
|
||||
"Cardinality": 2147483647,
|
||||
"Snapshots": [
|
||||
],
|
||||
},
|
||||
{
|
||||
"CID": "ABCDEF01C0DEF00D4372696C43625374",
|
||||
"Category": "Plugin Compatibility Class",
|
||||
"Name": "Crille Bass Strip",
|
||||
"Vendor": "Crille Audio",
|
||||
"Version": "1.0.0",
|
||||
"SDKVersion": "VST 3.7.12",
|
||||
"Class Flags": 0,
|
||||
"Cardinality": 2147483647,
|
||||
"Snapshots": [
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>files</key>
|
||||
<dict>
|
||||
<key>Resources/moduleinfo.json</key>
|
||||
<data>
|
||||
bFD29tJv6hrtbKMokE84EB4dwr0=
|
||||
</data>
|
||||
</dict>
|
||||
<key>files2</key>
|
||||
<dict>
|
||||
<key>Resources/moduleinfo.json</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
D09kULg/Fy2wnoSoXvTzay4l3BGUVem8xqCtDmO41uk=
|
||||
</data>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>rules</key>
|
||||
<dict>
|
||||
<key>^Resources/</key>
|
||||
<true/>
|
||||
<key>^Resources/.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Resources/Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^version.plist$</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>rules2</key>
|
||||
<dict>
|
||||
<key>.*\.dSYM($|/)</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>11</real>
|
||||
</dict>
|
||||
<key>^(.*/)?\.DS_Store$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>2000</real>
|
||||
</dict>
|
||||
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>^.*</key>
|
||||
<true/>
|
||||
<key>^Info\.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^PkgInfo$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^Resources/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Resources/Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^[^/]+$</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>^embedded\.provisionprofile$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^version\.plist$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
+1071
-103
File diff suppressed because it is too large.
Load diff
+132
-14
@@ -1,12 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "PluginProcessor.h"
|
||||
|
||||
class CrilleBassStripAudioProcessorEditor final : public juce::AudioProcessorEditor,
|
||||
private juce::Timer
|
||||
class CrilleBassStripAudioProcessorEditor final
|
||||
: public juce::AudioProcessorEditor,
|
||||
private juce::Timer
|
||||
{
|
||||
public:
|
||||
explicit CrilleBassStripAudioProcessorEditor(CrilleBassStripAudioProcessor&);
|
||||
explicit CrilleBassStripAudioProcessorEditor(
|
||||
CrilleBassStripAudioProcessor&);
|
||||
|
||||
~CrilleBassStripAudioProcessorEditor() override = default;
|
||||
|
||||
void paint(juce::Graphics&) override;
|
||||
@@ -16,9 +20,14 @@ private:
|
||||
class LevelMeter final : public juce::Component
|
||||
{
|
||||
public:
|
||||
enum class Mode { inputLevel, gainReduction };
|
||||
enum class Mode
|
||||
{
|
||||
inputLevel,
|
||||
gainReduction
|
||||
};
|
||||
|
||||
explicit LevelMeter(Mode meterMode);
|
||||
|
||||
void setLevel(float newLevelDb);
|
||||
void setThreshold(float newThresholdDb);
|
||||
void paint(juce::Graphics&) override;
|
||||
@@ -29,6 +38,34 @@ private:
|
||||
float thresholdDb = -80.0f;
|
||||
};
|
||||
|
||||
class SectionToggleButton final : public juce::ToggleButton
|
||||
{
|
||||
public:
|
||||
SectionToggleButton(
|
||||
const juce::String& sectionName,
|
||||
juce::Colour activeColour);
|
||||
|
||||
void paintButton(
|
||||
juce::Graphics& g,
|
||||
bool shouldDrawButtonAsHighlighted,
|
||||
bool shouldDrawButtonAsDown) override;
|
||||
|
||||
private:
|
||||
juce::Colour sectionColour;
|
||||
};
|
||||
|
||||
class TunerDisplay final : public juce::Component
|
||||
{
|
||||
public:
|
||||
TunerDisplay();
|
||||
|
||||
void setFrequency(float newFrequencyHz);
|
||||
void paint(juce::Graphics& g) override;
|
||||
|
||||
private:
|
||||
float frequencyHz = 0.0f;
|
||||
};
|
||||
|
||||
struct Knob
|
||||
{
|
||||
juce::Slider slider;
|
||||
@@ -36,20 +73,101 @@ private:
|
||||
};
|
||||
|
||||
CrilleBassStripAudioProcessor& processor;
|
||||
std::vector<std::unique_ptr<Knob>> knobs;
|
||||
std::vector<std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment>> attachments;
|
||||
|
||||
LevelMeter gateInputMeter { LevelMeter::Mode::inputLevel };
|
||||
LevelMeter compressorInputMeter { LevelMeter::Mode::inputLevel };
|
||||
LevelMeter compressorReductionMeter { LevelMeter::Mode::gainReduction };
|
||||
std::vector<std::unique_ptr<Knob>> knobs;
|
||||
|
||||
std::vector<std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::SliderAttachment>>
|
||||
attachments;
|
||||
|
||||
juce::ToggleButton downTuneButton;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
downTuneAttachment;
|
||||
|
||||
SectionToggleButton tunerToggleButton {
|
||||
"TUNER",
|
||||
juce::Colour(0xffe5a536)
|
||||
};
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
tunerToggleAttachment;
|
||||
|
||||
TunerDisplay tunerDisplay;
|
||||
|
||||
SectionToggleButton gateToggleButton {
|
||||
"NOISE GATE",
|
||||
juce::Colour(0xffe5a536)
|
||||
};
|
||||
|
||||
SectionToggleButton compressorToggleButton {
|
||||
"COMPRESSOR",
|
||||
juce::Colour(0xffe5a536)
|
||||
};
|
||||
|
||||
SectionToggleButton distortionToggleButton {
|
||||
"DISTORTION",
|
||||
juce::Colour(0xffd26b4f)
|
||||
};
|
||||
|
||||
SectionToggleButton eqToggleButton {
|
||||
"EQUALIZER",
|
||||
juce::Colour(0xffe5a536)
|
||||
};
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
gateToggleAttachment;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
compressorToggleAttachment;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
distortionToggleAttachment;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
eqToggleAttachment;
|
||||
|
||||
LevelMeter gateInputMeter {
|
||||
LevelMeter::Mode::inputLevel
|
||||
};
|
||||
|
||||
LevelMeter compressorInputMeter {
|
||||
LevelMeter::Mode::inputLevel
|
||||
};
|
||||
|
||||
LevelMeter compressorReductionMeter {
|
||||
LevelMeter::Mode::gainReduction
|
||||
};
|
||||
|
||||
float smoothedGateDb = -80.0f;
|
||||
float smoothedCompressorDb = -80.0f;
|
||||
float smoothedReductionDb = 0.0f;
|
||||
|
||||
void addKnob(const juce::String& parameter, const juce::String& caption);
|
||||
void timerCallback() override;
|
||||
static float smoothMeter(float current, float target, float attack, float release);
|
||||
void addKnob(
|
||||
const juce::String& parameter,
|
||||
const juce::String& caption);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CrilleBassStripAudioProcessorEditor)
|
||||
};
|
||||
void timerCallback() override;
|
||||
|
||||
void updateSectionStates();
|
||||
|
||||
void setKnobSectionEnabled(
|
||||
int firstKnob,
|
||||
int numberOfKnobs,
|
||||
bool enabled);
|
||||
|
||||
static float smoothMeter(
|
||||
float current,
|
||||
float target,
|
||||
float attack,
|
||||
float release);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
|
||||
CrilleBassStripAudioProcessorEditor)
|
||||
};
|
||||
+663
-84
@@ -10,8 +10,9 @@ constexpr float meterFloorDb = -80.0f;
|
||||
}
|
||||
|
||||
CrilleBassStripAudioProcessor::CrilleBassStripAudioProcessor()
|
||||
: AudioProcessor(BusesProperties().withInput("Input", juce::AudioChannelSet::stereo(), true)
|
||||
.withOutput("Output", juce::AudioChannelSet::stereo(), true)),
|
||||
: AudioProcessor(BusesProperties()
|
||||
.withInput("Input", juce::AudioChannelSet::mono(), true)
|
||||
.withOutput("Output", juce::AudioChannelSet::stereo(), true)),
|
||||
apvts(*this, nullptr, "PARAMETERS", createParameterLayout())
|
||||
{
|
||||
}
|
||||
@@ -20,153 +21,731 @@ juce::AudioProcessorValueTreeState::ParameterLayout CrilleBassStripAudioProcesso
|
||||
{
|
||||
using P = juce::AudioParameterFloat;
|
||||
juce::AudioProcessorValueTreeState::ParameterLayout p;
|
||||
p.add(std::make_unique<P>(pid("gateThreshold"), "Gate Threshold", juce::NormalisableRange<float>(-80.f, -10.f, 0.1f), -45.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("gateRelease"), "Gate Release", juce::NormalisableRange<float>(20.f, 500.f, 1.f, 0.5f), 150.f, "ms"));
|
||||
p.add(std::make_unique<P>(pid("gateGain"), "Gate Gain", juce::NormalisableRange<float>(-24.f, 12.f, 0.1f), 0.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("compThreshold"), "Comp Threshold", juce::NormalisableRange<float>(-60.f, 0.f, 0.1f), -18.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("compRatio"), "Comp Ratio", juce::NormalisableRange<float>(1.f, 20.f, 0.1f, 0.5f), 4.f, ":1"));
|
||||
p.add(std::make_unique<P>(pid("compGain"), "Comp Gain", juce::NormalisableRange<float>(-12.f, 18.f, 0.1f), 3.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("drive"), "Drive", juce::NormalisableRange<float>(0.f, 24.f, 0.1f), 5.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("mix"), "Distortion Mix", juce::NormalisableRange<float>(0.f, 100.f, 1.f), 25.f, "%"));
|
||||
p.add(std::make_unique<P>(pid("distGain"), "Distortion Gain", juce::NormalisableRange<float>(-18.f, 12.f, 0.1f), 0.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("bass"), "Bass", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 2.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("lowMid"), "Low Mid", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), -2.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("middle"), "Middle", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 0.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("treble"), "Treble", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 1.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("output"), "Output", juce::NormalisableRange<float>(-24.f, 12.f, 0.1f), -1.f, "dB"));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("downTuneOn"),
|
||||
"DownTune",
|
||||
false));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("tunerOn"),
|
||||
"Tuner On",
|
||||
false));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("gateOn"),
|
||||
"Gate On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("compressorOn"),
|
||||
"Compressor On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("distortionOn"),
|
||||
"Distortion On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("eqOn"),
|
||||
"EQ On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("gateThreshold"),
|
||||
"Gate Threshold",
|
||||
juce::NormalisableRange<float>(-80.f, -10.f, 0.1f),
|
||||
-55.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("gateRelease"),
|
||||
"Gate Release",
|
||||
juce::NormalisableRange<float>(20.f, 500.f, 1.f, 0.5f),
|
||||
150.f,
|
||||
"ms"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("gateGain"),
|
||||
"Gate Gain",
|
||||
juce::NormalisableRange<float>(-24.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("compThreshold"),
|
||||
"Comp Threshold",
|
||||
juce::NormalisableRange<float>(-60.f, 0.f, 0.1f),
|
||||
-30.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("compRatio"),
|
||||
"Comp Ratio",
|
||||
juce::NormalisableRange<float>(1.f, 20.f, 0.1f, 0.5f),
|
||||
3.f,
|
||||
":1"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("compGain"),
|
||||
"Comp Gain",
|
||||
juce::NormalisableRange<float>(-12.f, 18.f, 0.1f),
|
||||
2.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("drive"),
|
||||
"Drive",
|
||||
juce::NormalisableRange<float>(0.f, 24.f, 0.1f),
|
||||
5.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("mix"),
|
||||
"Distortion Mix",
|
||||
juce::NormalisableRange<float>(0.f, 100.f, 1.f),
|
||||
25.f,
|
||||
"%"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("distGain"),
|
||||
"Distortion Gain",
|
||||
juce::NormalisableRange<float>(-18.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("bass"),
|
||||
"Bass",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("lowMid"),
|
||||
"Low Mid",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("middle"),
|
||||
"Middle",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("treble"),
|
||||
"Treble",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("output"),
|
||||
"Output",
|
||||
juce::NormalisableRange<float>(-24.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::prepareToPlay(double sr, int block)
|
||||
{
|
||||
currentSampleRate = sr;
|
||||
juce::dsp::ProcessSpec spec { sr, static_cast<juce::uint32>(block), static_cast<juce::uint32>(getTotalNumOutputChannels()) };
|
||||
pitchBuffer.fill(0.0f);
|
||||
pitchWritePosition = 0;
|
||||
pitchSamplesCollected = 0;
|
||||
pitchAnalysisCounter = 0;
|
||||
detectedFrequencyHz.store(0.0f, std::memory_order_relaxed);
|
||||
|
||||
downTune.configure(1, 1024, 256);
|
||||
downTune.setTransposeSemitones(-1.0);
|
||||
|
||||
downTuneBuffer.setSize(1, block, false, false, true);
|
||||
downTuneBuffer.clear();
|
||||
|
||||
setLatencySamples(
|
||||
downTune.inputLatency() +
|
||||
downTune.outputLatency());
|
||||
|
||||
downTuneLatencyMs =
|
||||
1000.0 *
|
||||
(downTune.inputLatency() + downTune.outputLatency()) /
|
||||
sr;
|
||||
|
||||
//debug börjar
|
||||
DBG("DownTune input latency: "
|
||||
<< downTune.inputLatency()
|
||||
<< " samples");
|
||||
|
||||
DBG("DownTune output latency: "
|
||||
<< downTune.outputLatency()
|
||||
<< " samples");
|
||||
|
||||
DBG("DownTune total latency: "
|
||||
<< downTune.inputLatency() + downTune.outputLatency()
|
||||
<< " samples");
|
||||
|
||||
DBG("DownTune latency ms: "
|
||||
<< 1000.0 * (downTune.inputLatency() + downTune.outputLatency()) / sr);
|
||||
// debug slutar
|
||||
|
||||
juce::dsp::ProcessSpec spec {
|
||||
sr,
|
||||
static_cast<juce::uint32>(block),
|
||||
static_cast<juce::uint32>(getTotalNumOutputChannels())
|
||||
};
|
||||
|
||||
compressor.prepare(spec);
|
||||
lowShelf.prepare(spec);
|
||||
lowMid.prepare(spec);
|
||||
mid.prepare(spec);
|
||||
highShelf.prepare(spec);
|
||||
|
||||
compressor.reset();
|
||||
lowShelf.reset();
|
||||
lowMid.reset();
|
||||
mid.reset();
|
||||
highShelf.reset();
|
||||
gateEnvelope.assign(static_cast<size_t>(getTotalNumOutputChannels()), 0.f);
|
||||
|
||||
gateEnvelope.assign(
|
||||
static_cast<size_t>(getTotalNumOutputChannels()),
|
||||
0.f);
|
||||
|
||||
gateInputLevelDb.store(meterFloorDb);
|
||||
compressorInputLevelDb.store(meterFloorDb);
|
||||
compressorGainReductionDb.store(0.0f);
|
||||
|
||||
updateFilters();
|
||||
}
|
||||
|
||||
bool CrilleBassStripAudioProcessor::isBusesLayoutSupported(const BusesLayout& l) const
|
||||
bool CrilleBassStripAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
|
||||
{
|
||||
const auto out = l.getMainOutputChannelSet();
|
||||
return (out == juce::AudioChannelSet::mono() || out == juce::AudioChannelSet::stereo())
|
||||
&& out == l.getMainInputChannelSet();
|
||||
const auto input = layouts.getMainInputChannelSet();
|
||||
const auto output = layouts.getMainOutputChannelSet();
|
||||
|
||||
return input == juce::AudioChannelSet::mono()
|
||||
&& output == juce::AudioChannelSet::stereo();
|
||||
}
|
||||
|
||||
float CrilleBassStripAudioProcessor::getBufferPeak(const juce::AudioBuffer<float>& buffer) noexcept
|
||||
float CrilleBassStripAudioProcessor::getBufferPeak(
|
||||
const juce::AudioBuffer<float>& buffer) noexcept
|
||||
{
|
||||
float peak = 0.0f;
|
||||
|
||||
for (int channel = 0; channel < buffer.getNumChannels(); ++channel)
|
||||
peak = juce::jmax(peak, buffer.getMagnitude(channel, 0, buffer.getNumSamples()));
|
||||
peak = juce::jmax(
|
||||
peak,
|
||||
buffer.getMagnitude(
|
||||
channel,
|
||||
0,
|
||||
buffer.getNumSamples()));
|
||||
|
||||
return peak;
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::updatePitchDetector(
|
||||
const float* input,
|
||||
int numSamples)
|
||||
{
|
||||
for (int i = 0; i < numSamples; ++i)
|
||||
{
|
||||
pitchBuffer[
|
||||
static_cast<std::size_t>(pitchWritePosition)
|
||||
] = input[i];
|
||||
|
||||
pitchWritePosition =
|
||||
(pitchWritePosition + 1) % pitchBufferSize;
|
||||
|
||||
pitchSamplesCollected =
|
||||
juce::jmin(
|
||||
pitchSamplesCollected + 1,
|
||||
pitchBufferSize
|
||||
);
|
||||
}
|
||||
|
||||
pitchAnalysisCounter += numSamples;
|
||||
|
||||
const int analysisInterval =
|
||||
static_cast<int>(currentSampleRate * 0.1);
|
||||
|
||||
if (pitchSamplesCollected == pitchBufferSize
|
||||
&& pitchAnalysisCounter >= analysisInterval)
|
||||
{
|
||||
pitchAnalysisCounter = 0;
|
||||
analysePitch();
|
||||
}
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::analysePitch()
|
||||
{
|
||||
constexpr int downsampleFactor = 4;
|
||||
constexpr int analysisSize =
|
||||
pitchBufferSize / downsampleFactor;
|
||||
|
||||
std::array<float, analysisSize> samples {};
|
||||
|
||||
// pitchWritePosition points to the oldest sample.
|
||||
float mean = 0.0f;
|
||||
|
||||
for (int i = 0; i < analysisSize; ++i)
|
||||
{
|
||||
const int sourcePosition =
|
||||
(pitchWritePosition
|
||||
+ i * downsampleFactor)
|
||||
% pitchBufferSize;
|
||||
|
||||
samples[static_cast<std::size_t>(i)] =
|
||||
pitchBuffer[
|
||||
static_cast<std::size_t>(sourcePosition)
|
||||
];
|
||||
|
||||
mean += samples[static_cast<std::size_t>(i)];
|
||||
}
|
||||
|
||||
mean /= static_cast<float>(analysisSize);
|
||||
|
||||
float energy = 0.0f;
|
||||
|
||||
for (int i = 0; i < analysisSize; ++i)
|
||||
{
|
||||
auto& sample =
|
||||
samples[static_cast<std::size_t>(i)];
|
||||
|
||||
sample -= mean;
|
||||
energy += sample * sample;
|
||||
}
|
||||
|
||||
const float rms =
|
||||
std::sqrt(
|
||||
energy / static_cast<float>(analysisSize)
|
||||
);
|
||||
|
||||
// Ignore silence and very weak signals.
|
||||
if (rms < 0.0005f)
|
||||
{
|
||||
detectedFrequencyHz.store(
|
||||
0.0f,
|
||||
std::memory_order_relaxed
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const float analysisSampleRate =
|
||||
static_cast<float>(currentSampleRate)
|
||||
/ static_cast<float>(downsampleFactor);
|
||||
|
||||
constexpr float minimumFrequencyHz = 30.0f;
|
||||
constexpr float maximumFrequencyHz = 200.0f;
|
||||
|
||||
const int minimumLag =
|
||||
static_cast<int>(
|
||||
analysisSampleRate / maximumFrequencyHz
|
||||
);
|
||||
|
||||
const int maximumLag =
|
||||
juce::jmin(
|
||||
analysisSize - 2,
|
||||
static_cast<int>(
|
||||
analysisSampleRate / minimumFrequencyHz
|
||||
)
|
||||
);
|
||||
|
||||
float bestCorrelation = 0.0f;
|
||||
int bestLag = 0;
|
||||
|
||||
for (int lag = minimumLag;
|
||||
lag <= maximumLag;
|
||||
++lag)
|
||||
{
|
||||
float correlation = 0.0f;
|
||||
float firstEnergy = 0.0f;
|
||||
float secondEnergy = 0.0f;
|
||||
|
||||
const int comparedSamples =
|
||||
analysisSize - lag;
|
||||
|
||||
for (int i = 0;
|
||||
i < comparedSamples;
|
||||
++i)
|
||||
{
|
||||
const float first =
|
||||
samples[static_cast<std::size_t>(i)];
|
||||
|
||||
const float second =
|
||||
samples[
|
||||
static_cast<std::size_t>(i + lag)
|
||||
];
|
||||
|
||||
correlation += first * second;
|
||||
firstEnergy += first * first;
|
||||
secondEnergy += second * second;
|
||||
}
|
||||
|
||||
const float denominator =
|
||||
std::sqrt(firstEnergy * secondEnergy);
|
||||
|
||||
if (denominator > 1.0e-9f)
|
||||
correlation /= denominator;
|
||||
else
|
||||
correlation = 0.0f;
|
||||
|
||||
if (correlation > bestCorrelation)
|
||||
{
|
||||
bestCorrelation = correlation;
|
||||
bestLag = lag;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent unstable note readings.
|
||||
if (bestLag <= 0 || bestCorrelation < 0.25f)
|
||||
{
|
||||
detectedFrequencyHz.store(
|
||||
0.0f,
|
||||
std::memory_order_relaxed
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const float frequency =
|
||||
analysisSampleRate
|
||||
/ static_cast<float>(bestLag);
|
||||
|
||||
const float previousFrequency =
|
||||
detectedFrequencyHz.load(
|
||||
std::memory_order_relaxed
|
||||
);
|
||||
|
||||
const float smoothedFrequency =
|
||||
previousFrequency > 0.0f
|
||||
? previousFrequency * 0.7f
|
||||
+ frequency * 0.3f
|
||||
: frequency;
|
||||
|
||||
detectedFrequencyHz.store(
|
||||
smoothedFrequency,
|
||||
std::memory_order_relaxed
|
||||
);
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::updateFilters()
|
||||
{
|
||||
const auto bass = apvts.getRawParameterValue("bass")->load();
|
||||
const auto lm = apvts.getRawParameterValue("lowMid")->load();
|
||||
const auto m = apvts.getRawParameterValue("middle")->load();
|
||||
const auto tr = apvts.getRawParameterValue("treble")->load();
|
||||
*lowShelf.state = *juce::dsp::IIR::Coefficients<float>::makeLowShelf(currentSampleRate, 80.0, 0.707, dbToGain(bass));
|
||||
*lowMid.state = *juce::dsp::IIR::Coefficients<float>::makePeakFilter(currentSampleRate, 300.0, 0.8, dbToGain(lm));
|
||||
*mid.state = *juce::dsp::IIR::Coefficients<float>::makePeakFilter(currentSampleRate, 900.0, 0.8, dbToGain(m));
|
||||
*highShelf.state = *juce::dsp::IIR::Coefficients<float>::makeHighShelf(currentSampleRate, 3500.0, 0.707, dbToGain(tr));
|
||||
const auto bass =
|
||||
apvts.getRawParameterValue("bass")->load();
|
||||
|
||||
const auto lm =
|
||||
apvts.getRawParameterValue("lowMid")->load();
|
||||
|
||||
const auto m =
|
||||
apvts.getRawParameterValue("middle")->load();
|
||||
|
||||
const auto tr =
|
||||
apvts.getRawParameterValue("treble")->load();
|
||||
|
||||
*lowShelf.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makeLowShelf(
|
||||
currentSampleRate,
|
||||
80.0,
|
||||
0.707,
|
||||
dbToGain(bass));
|
||||
|
||||
*lowMid.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makePeakFilter(
|
||||
currentSampleRate,
|
||||
300.0,
|
||||
0.8,
|
||||
dbToGain(lm));
|
||||
|
||||
*mid.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makePeakFilter(
|
||||
currentSampleRate,
|
||||
900.0,
|
||||
0.8,
|
||||
dbToGain(m));
|
||||
|
||||
*highShelf.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makeHighShelf(
|
||||
currentSampleRate,
|
||||
3500.0,
|
||||
0.707,
|
||||
dbToGain(tr));
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&)
|
||||
void CrilleBassStripAudioProcessor::processBlock(
|
||||
juce::AudioBuffer<float>& buffer,
|
||||
juce::MidiBuffer&)
|
||||
{
|
||||
juce::ScopedNoDenormals noDenormals;
|
||||
for (int c = getTotalNumInputChannels(); c < getTotalNumOutputChannels(); ++c)
|
||||
buffer.clear(c, 0, buffer.getNumSamples());
|
||||
|
||||
const float gateInputPeak = getBufferPeak(buffer);
|
||||
gateInputLevelDb.store(juce::Decibels::gainToDecibels(gateInputPeak, meterFloorDb), std::memory_order_relaxed);
|
||||
const int numSamples = buffer.getNumSamples();
|
||||
|
||||
const float threshold = dbToGain(apvts.getRawParameterValue("gateThreshold")->load());
|
||||
const float releaseMs = apvts.getRawParameterValue("gateRelease")->load();
|
||||
const float releaseCoeff = std::exp(-1.f / (0.001f * releaseMs * static_cast<float>(currentSampleRate)));
|
||||
const float gateGain = dbToGain(apvts.getRawParameterValue("gateGain")->load());
|
||||
const bool gateEnabled =
|
||||
apvts.getRawParameterValue("gateOn")->load() > 0.5f;
|
||||
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
const bool compressorEnabled =
|
||||
apvts.getRawParameterValue("compressorOn")->load() > 0.5f;
|
||||
|
||||
const bool distortionEnabled =
|
||||
apvts.getRawParameterValue("distortionOn")->load() > 0.5f;
|
||||
|
||||
const bool eqEnabled =
|
||||
apvts.getRawParameterValue("eqOn")->load() > 0.5f;
|
||||
|
||||
const bool tunerEnabled =
|
||||
apvts.getRawParameterValue("tunerOn")->load() > 0.5f;
|
||||
|
||||
if (tunerEnabled && buffer.getNumChannels() > 0)
|
||||
{
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
auto& env = gateEnvelope[static_cast<size_t>(c)];
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
updatePitchDetector(
|
||||
buffer.getReadPointer(0),
|
||||
numSamples
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
detectedFrequencyHz.store(
|
||||
0.0f,
|
||||
std::memory_order_relaxed);
|
||||
|
||||
pitchSamplesCollected = 0;
|
||||
pitchAnalysisCounter = 0;
|
||||
}
|
||||
|
||||
// Clear output channels that do not contain input data.
|
||||
for (int c = getTotalNumInputChannels();
|
||||
c < getTotalNumOutputChannels();
|
||||
++c)
|
||||
{
|
||||
buffer.clear(c, 0, numSamples);
|
||||
}
|
||||
|
||||
// Process the mono bass signal through DownTune.
|
||||
if (numSamples <= downTuneBuffer.getNumSamples())
|
||||
{
|
||||
const float* inputChannels[] =
|
||||
{
|
||||
const float target = std::abs(x[i]) >= threshold ? 1.f : 0.f;
|
||||
env = target > env ? target : releaseCoeff * env;
|
||||
x[i] *= env * gateGain;
|
||||
buffer.getReadPointer(0)
|
||||
};
|
||||
|
||||
float* outputChannels[] =
|
||||
{
|
||||
downTuneBuffer.getWritePointer(0)
|
||||
};
|
||||
|
||||
downTune.process(
|
||||
inputChannels,
|
||||
numSamples,
|
||||
outputChannels,
|
||||
numSamples);
|
||||
|
||||
const bool downTuneEnabled =
|
||||
apvts.getRawParameterValue("downTuneOn")->load() > 0.5f;
|
||||
|
||||
if (downTuneEnabled)
|
||||
{
|
||||
buffer.copyFrom(
|
||||
0,
|
||||
0,
|
||||
downTuneBuffer,
|
||||
0,
|
||||
0,
|
||||
numSamples);
|
||||
}
|
||||
}
|
||||
|
||||
const float compressorInputPeak = getBufferPeak(buffer);
|
||||
compressorInputLevelDb.store(juce::Decibels::gainToDecibels(compressorInputPeak, meterFloorDb), std::memory_order_relaxed);
|
||||
// Copy the processed mono bass signal to both stereo output channels.
|
||||
if (buffer.getNumChannels() >= 2)
|
||||
buffer.copyFrom(1, 0, buffer, 0, 0, numSamples);
|
||||
|
||||
compressor.setThreshold(apvts.getRawParameterValue("compThreshold")->load());
|
||||
compressor.setRatio(apvts.getRawParameterValue("compRatio")->load());
|
||||
compressor.setAttack(15.f);
|
||||
compressor.setRelease(100.f);
|
||||
// Measure input level before the noise gate.
|
||||
const float gateInputPeak = getBufferPeak(buffer);
|
||||
|
||||
gateInputLevelDb.store(
|
||||
juce::Decibels::gainToDecibels(
|
||||
gateInputPeak,
|
||||
meterFloorDb),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
// Noise gate
|
||||
if (gateEnabled)
|
||||
{
|
||||
const float threshold =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("gateThreshold")->load());
|
||||
|
||||
const float releaseMs =
|
||||
apvts.getRawParameterValue("gateRelease")->load();
|
||||
|
||||
const float releaseCoeff =
|
||||
std::exp(
|
||||
-1.f /
|
||||
(0.001f * releaseMs *
|
||||
static_cast<float>(currentSampleRate)));
|
||||
|
||||
const float gateGain =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("gateGain")->load());
|
||||
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
{
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
auto& env = gateEnvelope[static_cast<size_t>(c)];
|
||||
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
{
|
||||
const float target =
|
||||
std::abs(x[i]) >= threshold ? 1.f : 0.f;
|
||||
|
||||
env = target > env
|
||||
? target
|
||||
: releaseCoeff * env;
|
||||
|
||||
x[i] *= env * gateGain;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::fill(
|
||||
gateEnvelope.begin(),
|
||||
gateEnvelope.end(),
|
||||
1.0f);
|
||||
}
|
||||
|
||||
// Measure compressor input level.
|
||||
const float compressorInputPeak =
|
||||
getBufferPeak(buffer);
|
||||
|
||||
compressorInputLevelDb.store(
|
||||
juce::Decibels::gainToDecibels(
|
||||
compressorInputPeak,
|
||||
meterFloorDb),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
juce::dsp::AudioBlock<float> block(buffer);
|
||||
juce::dsp::ProcessContextReplacing<float> context(block);
|
||||
compressor.process(context);
|
||||
|
||||
const float compressorOutputPeak = getBufferPeak(buffer);
|
||||
const float gainReduction = compressorInputPeak > 0.0f
|
||||
? juce::jmax(0.0f, juce::Decibels::gainToDecibels(compressorInputPeak / juce::jmax(compressorOutputPeak, 1.0e-9f)))
|
||||
: 0.0f;
|
||||
compressorGainReductionDb.store(juce::jlimit(0.0f, 24.0f, gainReduction), std::memory_order_relaxed);
|
||||
|
||||
buffer.applyGain(dbToGain(apvts.getRawParameterValue("compGain")->load()));
|
||||
|
||||
const float drive = dbToGain(apvts.getRawParameterValue("drive")->load());
|
||||
const float mix = apvts.getRawParameterValue("mix")->load() * 0.01f;
|
||||
const float dg = dbToGain(apvts.getRawParameterValue("distGain")->load());
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
// Compressor
|
||||
if (compressorEnabled)
|
||||
{
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
compressor.setThreshold(
|
||||
apvts.getRawParameterValue("compThreshold")->load());
|
||||
|
||||
compressor.setRatio(
|
||||
apvts.getRawParameterValue("compRatio")->load());
|
||||
|
||||
compressor.setAttack(15.f);
|
||||
compressor.setRelease(100.f);
|
||||
compressor.process(context);
|
||||
|
||||
// Calculate compressor gain reduction.
|
||||
const float compressorOutputPeak =
|
||||
getBufferPeak(buffer);
|
||||
|
||||
const float gainReduction =
|
||||
compressorInputPeak > 0.0f
|
||||
? juce::jmax(
|
||||
0.0f,
|
||||
juce::Decibels::gainToDecibels(
|
||||
compressorInputPeak /
|
||||
juce::jmax(
|
||||
compressorOutputPeak,
|
||||
1.0e-9f)))
|
||||
: 0.0f;
|
||||
|
||||
compressorGainReductionDb.store(
|
||||
juce::jlimit(
|
||||
0.0f,
|
||||
24.0f,
|
||||
gainReduction),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
// Compressor makeup gain.
|
||||
buffer.applyGain(
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("compGain")->load()));
|
||||
}
|
||||
else
|
||||
{
|
||||
compressorGainReductionDb.store(
|
||||
0.0f,
|
||||
std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
// Distortion
|
||||
if (distortionEnabled)
|
||||
{
|
||||
const float drive =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("drive")->load());
|
||||
|
||||
const float mix =
|
||||
apvts.getRawParameterValue("mix")->load() * 0.01f;
|
||||
|
||||
const float dg =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("distGain")->load());
|
||||
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
{
|
||||
const float dry = x[i];
|
||||
const float wet = std::tanh(dry * drive);
|
||||
x[i] = ((1.f - mix) * dry + mix * wet) * dg;
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
{
|
||||
const float dry = x[i];
|
||||
const float wet = std::tanh(dry * drive);
|
||||
|
||||
x[i] =
|
||||
((1.f - mix) * dry + mix * wet) * dg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateFilters();
|
||||
lowShelf.process(context);
|
||||
lowMid.process(context);
|
||||
mid.process(context);
|
||||
highShelf.process(context);
|
||||
buffer.applyGain(dbToGain(apvts.getRawParameterValue("output")->load()));
|
||||
// EQ
|
||||
if (eqEnabled)
|
||||
{
|
||||
updateFilters();
|
||||
|
||||
lowShelf.process(context);
|
||||
lowMid.process(context);
|
||||
mid.process(context);
|
||||
highShelf.process(context);
|
||||
}
|
||||
|
||||
// Final output gain.
|
||||
buffer.applyGain(
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("output")->load()));
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::getStateInformation(juce::MemoryBlock& dest)
|
||||
void CrilleBassStripAudioProcessor::getStateInformation(
|
||||
juce::MemoryBlock& dest)
|
||||
{
|
||||
if (auto xml = apvts.copyState().createXml())
|
||||
copyXmlToBinary(*xml, dest);
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::setStateInformation(const void* data, int size)
|
||||
void CrilleBassStripAudioProcessor::setStateInformation(
|
||||
const void* data,
|
||||
int size)
|
||||
{
|
||||
if (auto xml = getXmlFromBinary(data, size);
|
||||
xml != nullptr && xml->hasTagName(apvts.state.getType()))
|
||||
apvts.replaceState(juce::ValueTree::fromXml(*xml));
|
||||
xml != nullptr
|
||||
&& xml->hasTagName(apvts.state.getType()))
|
||||
{
|
||||
apvts.replaceState(
|
||||
juce::ValueTree::fromXml(*xml));
|
||||
}
|
||||
}
|
||||
|
||||
juce::AudioProcessorEditor* CrilleBassStripAudioProcessor::createEditor()
|
||||
juce::AudioProcessorEditor*
|
||||
CrilleBassStripAudioProcessor::createEditor()
|
||||
{
|
||||
return new CrilleBassStripAudioProcessorEditor(*this);
|
||||
}
|
||||
@@ -174,4 +753,4 @@ juce::AudioProcessorEditor* CrilleBassStripAudioProcessor::createEditor()
|
||||
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
||||
{
|
||||
return new CrilleBassStripAudioProcessor();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
#include <signalsmith-stretch.h>
|
||||
|
||||
class CrilleBassStripAudioProcessor final : public juce::AudioProcessor
|
||||
{
|
||||
@@ -15,7 +18,7 @@ public:
|
||||
|
||||
juce::AudioProcessorEditor* createEditor() override;
|
||||
bool hasEditor() const override { return true; }
|
||||
const juce::String getName() const override { return JucePlugin_Name; }
|
||||
const juce::String getName() const override { return "Crille Bass Strip"; }
|
||||
bool acceptsMidi() const override { return false; }
|
||||
bool producesMidi() const override { return false; }
|
||||
bool isMidiEffect() const override { return false; }
|
||||
@@ -34,13 +37,36 @@ public:
|
||||
float getGateInputLevelDb() const noexcept { return gateInputLevelDb.load(); }
|
||||
float getCompressorInputLevelDb() const noexcept { return compressorInputLevelDb.load(); }
|
||||
float getCompressorGainReductionDb() const noexcept { return compressorGainReductionDb.load(); }
|
||||
double getDownTuneLatencyMs() const noexcept { return downTuneLatencyMs; }
|
||||
float getDetectedFrequencyHz() const noexcept { return detectedFrequencyHz.load(std::memory_order_relaxed);}
|
||||
|
||||
private:
|
||||
using Filter = juce::dsp::IIR::Filter<float>;
|
||||
|
||||
// DownTune
|
||||
signalsmith::stretch::SignalsmithStretch<float> downTune;
|
||||
juce::AudioBuffer<float> downTuneBuffer;
|
||||
// Pitch detection
|
||||
static constexpr int pitchBufferSize = 4096;
|
||||
|
||||
std::array<float, pitchBufferSize> pitchBuffer {};
|
||||
int pitchWritePosition = 0;
|
||||
int pitchSamplesCollected = 0;
|
||||
int pitchAnalysisCounter = 0;
|
||||
|
||||
std::atomic<float> detectedFrequencyHz { 0.0f };
|
||||
|
||||
void updatePitchDetector(
|
||||
const float* input,
|
||||
int numSamples
|
||||
);
|
||||
|
||||
void analysePitch();
|
||||
|
||||
juce::dsp::Compressor<float> compressor;
|
||||
juce::dsp::ProcessorDuplicator<Filter, juce::dsp::IIR::Coefficients<float>> lowShelf, lowMid, mid, highShelf;
|
||||
double currentSampleRate = 44100.0;
|
||||
double downTuneLatencyMs = 0.0;
|
||||
std::vector<float> gateEnvelope;
|
||||
|
||||
std::atomic<float> gateInputLevelDb { -80.0f };
|
||||
@@ -51,4 +77,4 @@ private:
|
||||
static float getBufferPeak(const juce::AudioBuffer<float>& buffer) noexcept;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CrilleBassStripAudioProcessor)
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,300 @@
|
||||
#include "StandaloneMain.h"
|
||||
|
||||
StandaloneAudioEngine::StandaloneAudioEngine()
|
||||
{
|
||||
deviceManager.initialise(2, 2, nullptr, true);
|
||||
|
||||
for (auto* type : deviceManager.getAvailableDeviceTypes())
|
||||
{
|
||||
if (type != nullptr && type->getTypeName().containsIgnoreCase("ASIO"))
|
||||
{
|
||||
deviceManager.setCurrentAudioDeviceType(type->getTypeName(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
deviceManager.addAudioCallback(this);
|
||||
}
|
||||
|
||||
StandaloneAudioEngine::~StandaloneAudioEngine()
|
||||
{
|
||||
deviceManager.removeAudioCallback(this);
|
||||
deviceManager.closeAudioDevice();
|
||||
}
|
||||
|
||||
void StandaloneAudioEngine::setBassInputChannel(int channel) noexcept
|
||||
{
|
||||
bassInputChannel.store(juce::jmax(0, channel), std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
int StandaloneAudioEngine::getBassInputChannel() const noexcept
|
||||
{
|
||||
return bassInputChannel.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void StandaloneAudioEngine::audioDeviceAboutToStart(juce::AudioIODevice* device)
|
||||
{
|
||||
if (device == nullptr)
|
||||
return;
|
||||
|
||||
const auto sampleRate = device->getCurrentSampleRate();
|
||||
const auto blockSize = device->getCurrentBufferSizeSamples();
|
||||
|
||||
processingBuffer.setSize(2, blockSize, false, true, true);
|
||||
processor.setRateAndBufferSizeDetails(sampleRate, blockSize);
|
||||
processor.prepareToPlay(sampleRate, blockSize);
|
||||
}
|
||||
|
||||
void StandaloneAudioEngine::audioDeviceStopped()
|
||||
{
|
||||
processor.releaseResources();
|
||||
}
|
||||
|
||||
void StandaloneAudioEngine::audioDeviceIOCallbackWithContext(
|
||||
const float* const* inputChannelData,
|
||||
int numInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int numOutputChannels,
|
||||
int numSamples,
|
||||
const juce::AudioIODeviceCallbackContext&)
|
||||
{
|
||||
processingBuffer.setSize(2, numSamples, false, false, true);
|
||||
processingBuffer.clear();
|
||||
|
||||
const int selectedInput = bassInputChannel.load(std::memory_order_relaxed);
|
||||
|
||||
if (selectedInput < numInputChannels && inputChannelData[selectedInput] != nullptr)
|
||||
processingBuffer.copyFrom(0, 0, inputChannelData[selectedInput], numSamples);
|
||||
|
||||
midiBuffer.clear();
|
||||
processor.processBlock(processingBuffer, midiBuffer);
|
||||
|
||||
for (int channel = 0; channel < numOutputChannels; ++channel)
|
||||
{
|
||||
if (outputChannelData[channel] == nullptr)
|
||||
continue;
|
||||
|
||||
if (channel < processingBuffer.getNumChannels())
|
||||
juce::FloatVectorOperations::copy(outputChannelData[channel],
|
||||
processingBuffer.getReadPointer(channel),
|
||||
numSamples);
|
||||
else
|
||||
juce::FloatVectorOperations::clear(outputChannelData[channel], numSamples);
|
||||
}
|
||||
}
|
||||
|
||||
StandaloneMainComponent::StandaloneMainComponent()
|
||||
{
|
||||
juce::PropertiesFile::Options options;
|
||||
options.applicationName = "Crille Bass Strip";
|
||||
options.filenameSuffix = ".settings";
|
||||
options.folderName = "Crille Audio";
|
||||
options.storageFormat = juce::PropertiesFile::storeAsXML;
|
||||
settings = std::make_unique<juce::PropertiesFile>(options);
|
||||
|
||||
// Restore every APVTS/plugin parameter before the editor is created,
|
||||
// so all knobs open at their last saved values.
|
||||
loadPluginState();
|
||||
|
||||
inputLabel.setText("BASS INPUT", juce::dontSendNotification);
|
||||
inputLabel.setColour(juce::Label::textColourId, juce::Colour(0xffd9dde3));
|
||||
inputLabel.setFont(juce::Font(12.0f, juce::Font::bold));
|
||||
inputLabel.setJustificationType(juce::Justification::centredRight);
|
||||
addAndMakeVisible(inputLabel);
|
||||
|
||||
inputSelector.setColour(juce::ComboBox::backgroundColourId, juce::Colour(0xff1b1f24));
|
||||
inputSelector.setColour(juce::ComboBox::textColourId, juce::Colour(0xfff0f1f2));
|
||||
inputSelector.setColour(juce::ComboBox::outlineColourId, juce::Colour(0xffe5a536));
|
||||
addAndMakeVisible(inputSelector);
|
||||
|
||||
audioSettingsButton.setColour(juce::TextButton::buttonColourId, juce::Colour(0xff30343a));
|
||||
audioSettingsButton.setColour(juce::TextButton::textColourOffId, juce::Colour(0xfff0f1f2));
|
||||
addAndMakeVisible(audioSettingsButton);
|
||||
|
||||
refreshInputChoices();
|
||||
|
||||
const int savedInput = settings->getIntValue("bassInput", 0);
|
||||
inputSelector.setSelectedId(juce::jlimit(1, juce::jmax(1, inputSelector.getNumItems()), savedInput + 1),
|
||||
juce::dontSendNotification);
|
||||
audioEngine.setBassInputChannel(juce::jmax(0, inputSelector.getSelectedId() - 1));
|
||||
|
||||
inputSelector.onChange = [this]
|
||||
{
|
||||
audioEngine.setBassInputChannel(inputSelector.getSelectedId() - 1);
|
||||
saveSettings();
|
||||
};
|
||||
|
||||
audioSettingsButton.onClick = [this] { showAudioSettings(); };
|
||||
|
||||
editor = std::make_unique<CrilleBassStripAudioProcessorEditor>(audioEngine.getProcessor());
|
||||
addAndMakeVisible(*editor);
|
||||
|
||||
setSize(760, 790);
|
||||
}
|
||||
|
||||
StandaloneMainComponent::~StandaloneMainComponent()
|
||||
{
|
||||
// Save both application settings and every knob value when the app closes.
|
||||
savePluginState();
|
||||
saveSettings();
|
||||
editor.reset();
|
||||
}
|
||||
|
||||
juce::File StandaloneMainComponent::getPluginStateFile() const
|
||||
{
|
||||
// Windows: %APPDATA%\Crille Audio\CrilleBassStrip.state
|
||||
auto folder = juce::File::getSpecialLocation(juce::File::userApplicationDataDirectory)
|
||||
.getChildFile("Crille Audio");
|
||||
folder.createDirectory();
|
||||
return folder.getChildFile("CrilleBassStrip.state");
|
||||
}
|
||||
|
||||
void StandaloneMainComponent::loadPluginState()
|
||||
{
|
||||
const auto stateFile = getPluginStateFile();
|
||||
if (!stateFile.existsAsFile())
|
||||
return;
|
||||
|
||||
juce::MemoryBlock state;
|
||||
if (stateFile.loadFileAsData(state) && state.getSize() > 0)
|
||||
audioEngine.getProcessor().setStateInformation(state.getData(), static_cast<int>(state.getSize()));
|
||||
}
|
||||
|
||||
void StandaloneMainComponent::savePluginState()
|
||||
{
|
||||
juce::MemoryBlock state;
|
||||
audioEngine.getProcessor().getStateInformation(state);
|
||||
|
||||
if (state.getSize() == 0)
|
||||
return;
|
||||
|
||||
const auto stateFile = getPluginStateFile();
|
||||
stateFile.replaceWithData(state.getData(), state.getSize());
|
||||
}
|
||||
|
||||
void StandaloneMainComponent::refreshInputChoices()
|
||||
{
|
||||
const int previousSelection = juce::jmax(1, inputSelector.getSelectedId());
|
||||
inputSelector.clear(juce::dontSendNotification);
|
||||
|
||||
if (auto* device = audioEngine.getDeviceManager().getCurrentAudioDevice())
|
||||
{
|
||||
const auto names = device->getInputChannelNames();
|
||||
for (int i = 0; i < names.size(); ++i)
|
||||
inputSelector.addItem(names[i].isNotEmpty() ? names[i] : "Input " + juce::String(i + 1), i + 1);
|
||||
}
|
||||
|
||||
if (inputSelector.getNumItems() == 0)
|
||||
{
|
||||
inputSelector.addItem("Input 1", 1);
|
||||
inputSelector.addItem("Input 2", 2);
|
||||
}
|
||||
|
||||
inputSelector.setSelectedId(juce::jlimit(1, inputSelector.getNumItems(), previousSelection),
|
||||
juce::dontSendNotification);
|
||||
audioEngine.setBassInputChannel(inputSelector.getSelectedId() - 1);
|
||||
}
|
||||
|
||||
void StandaloneMainComponent::showAudioSettings()
|
||||
{
|
||||
juce::DialogWindow::LaunchOptions options;
|
||||
options.dialogTitle = "Audio Setup";
|
||||
options.dialogBackgroundColour = juce::Colour(0xff1b1f24);
|
||||
options.escapeKeyTriggersCloseButton = true;
|
||||
options.useNativeTitleBar = true;
|
||||
options.resizable = false;
|
||||
|
||||
auto selector = std::make_unique<juce::AudioDeviceSelectorComponent>(
|
||||
audioEngine.getDeviceManager(),
|
||||
2, 2,
|
||||
2, 2,
|
||||
false, false, false, false);
|
||||
|
||||
selector->setSize(500, 420);
|
||||
options.content.setOwned(selector.release());
|
||||
|
||||
auto* dialog = options.launchAsync();
|
||||
if (dialog != nullptr)
|
||||
dialog->enterModalState(true, juce::ModalCallbackFunction::create([safe = juce::Component::SafePointer<StandaloneMainComponent>(this)](int)
|
||||
{
|
||||
if (safe != nullptr)
|
||||
{
|
||||
safe->refreshInputChoices();
|
||||
safe->saveSettings();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void StandaloneMainComponent::saveSettings()
|
||||
{
|
||||
if (settings != nullptr)
|
||||
{
|
||||
settings->setValue("bassInput", juce::jmax(0, inputSelector.getSelectedId() - 1));
|
||||
settings->saveIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
void StandaloneMainComponent::resized()
|
||||
{
|
||||
auto area = getLocalBounds();
|
||||
auto topBar = area.removeFromTop(50);
|
||||
|
||||
inputLabel.setBounds(topBar.removeFromLeft(115).reduced(10, 8));
|
||||
inputSelector.setBounds(topBar.removeFromLeft(220).reduced(5, 8));
|
||||
topBar.removeFromLeft(10);
|
||||
audioSettingsButton.setBounds(topBar.removeFromLeft(130).reduced(5, 8));
|
||||
|
||||
if (editor != nullptr)
|
||||
editor->setBounds(area);
|
||||
}
|
||||
|
||||
class CrilleBassStripApplication final : public juce::JUCEApplication
|
||||
{
|
||||
public:
|
||||
const juce::String getApplicationName() override { return "Crille Bass Strip"; }
|
||||
const juce::String getApplicationVersion() override { return "1.0.0"; }
|
||||
bool moreThanOneInstanceAllowed() override { return false; }
|
||||
|
||||
void initialise(const juce::String&) override
|
||||
{
|
||||
mainWindow = std::make_unique<MainWindow>(getApplicationName());
|
||||
}
|
||||
|
||||
void shutdown() override
|
||||
{
|
||||
mainWindow.reset();
|
||||
}
|
||||
|
||||
void systemRequestedQuit() override
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
void anotherInstanceStarted(const juce::String&) override {}
|
||||
|
||||
private:
|
||||
class MainWindow final : public juce::DocumentWindow
|
||||
{
|
||||
public:
|
||||
explicit MainWindow(const juce::String& name)
|
||||
: DocumentWindow(name,
|
||||
juce::Colour(0xff111317),
|
||||
juce::DocumentWindow::closeButton)
|
||||
{
|
||||
setUsingNativeTitleBar(true);
|
||||
setResizable(false, false);
|
||||
setContentOwned(new StandaloneMainComponent(), true);
|
||||
centreWithSize(getWidth(), getHeight());
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void closeButtonPressed() override
|
||||
{
|
||||
juce::JUCEApplication::getInstance()->systemRequestedQuit();
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<MainWindow> mainWindow;
|
||||
};
|
||||
|
||||
START_JUCE_APPLICATION(CrilleBassStripApplication)
|
||||
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
#include <JuceHeader.h>
|
||||
#include "PluginProcessor.h"
|
||||
#include "PluginEditor.h"
|
||||
|
||||
class StandaloneAudioEngine final : public juce::AudioIODeviceCallback
|
||||
{
|
||||
public:
|
||||
StandaloneAudioEngine();
|
||||
~StandaloneAudioEngine() override;
|
||||
|
||||
juce::AudioDeviceManager& getDeviceManager() noexcept { return deviceManager; }
|
||||
CrilleBassStripAudioProcessor& getProcessor() noexcept { return processor; }
|
||||
|
||||
void setBassInputChannel(int channel) noexcept;
|
||||
int getBassInputChannel() const noexcept;
|
||||
|
||||
void audioDeviceAboutToStart(juce::AudioIODevice* device) override;
|
||||
void audioDeviceStopped() override;
|
||||
void audioDeviceIOCallbackWithContext(const float* const* inputChannelData,
|
||||
int numInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int numOutputChannels,
|
||||
int numSamples,
|
||||
const juce::AudioIODeviceCallbackContext&) override;
|
||||
|
||||
private:
|
||||
juce::AudioDeviceManager deviceManager;
|
||||
CrilleBassStripAudioProcessor processor;
|
||||
juce::AudioBuffer<float> processingBuffer;
|
||||
juce::MidiBuffer midiBuffer;
|
||||
std::atomic<int> bassInputChannel { 0 };
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneAudioEngine)
|
||||
};
|
||||
|
||||
class StandaloneMainComponent final : public juce::Component
|
||||
{
|
||||
public:
|
||||
StandaloneMainComponent();
|
||||
~StandaloneMainComponent() override;
|
||||
|
||||
void resized() override;
|
||||
|
||||
private:
|
||||
void showAudioSettings();
|
||||
void refreshInputChoices();
|
||||
void saveSettings();
|
||||
void loadPluginState();
|
||||
void savePluginState();
|
||||
juce::File getPluginStateFile() const;
|
||||
|
||||
StandaloneAudioEngine audioEngine;
|
||||
std::unique_ptr<CrilleBassStripAudioProcessorEditor> editor;
|
||||
|
||||
juce::Label inputLabel;
|
||||
juce::ComboBox inputSelector;
|
||||
juce::TextButton audioSettingsButton { "AUDIO SETUP" };
|
||||
|
||||
std::unique_ptr<juce::PropertiesFile> settings;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneMainComponent)
|
||||
};
|
||||
Reference in new issue
Block a user