Skip to content

Commit

Permalink
Merge pull request #5 from audacitorch/aa/template
Browse files Browse the repository at this point in the history
ara with libtorch
  • Loading branch information
aldo-aguilar committed May 17, 2023
2 parents 4f2aa17 + 76c002d commit 3d90d43
Show file tree
Hide file tree
Showing 5 changed files with 435 additions and 72 deletions.
63 changes: 29 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.21)
set(PROJECT_NAME "tensor-juce-ARA")
project(${PROJECT_NAME} VERSION 0.0.1)
add_subdirectory(JUCE)

project(AUDIO_PLUGIN_EXAMPLE_CMAKE_64 VERSION 333.0.1)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
# windows library location
message("Building for Windows...")
# libtorch settings
find_package(Torch REQUIRED PATHS "C:\\libtorch" NO_DEFAULT_PATH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
# ara settings
juce_set_ara_sdk_path("C:\\SDKs\\ARA_SDK")

find_package(Torch REQUIRED PATHS "C:\\libtorch" NO_DEFAULT_PATH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
# mac and linux library location
message("Building for UNIX...")
# libtorch settings
find_package(Torch REQUIRED PATHS "/usr/local/lib/libtorch" NO_DEFAULT_PATH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
# ara settings
juce_set_ara_sdk_path("/usr/local/lib/ARA_SDK")

add_subdirectory(JUCE)
else()
message(FATAL_ERROR "Unsupported platform.")

juce_set_ara_sdk_path("C:\\SDKs\\ARA_SDK")
endif()

add_subdirectory(tracktion_engine/modules)

# juce_add_plugin(AudioPluginExampleCMAKE64
# # VERSION ... # Set this if the plugin version is different to the project version
# # ICON_BIG ... # ICON_* arguments specify a path to an image file to use as an icon for the Standalone
# # ICON_SMALL ...
# # COMPANY_NAME ... # Specify the name of the plugin's author
# # IS_SYNTH TRUE/FALSE # Is this a synth or an effect?
# # NEEDS_MIDI_INPUT TRUE/FALSE # Does the plugin need midi input?
# # NEEDS_MIDI_OUTPUT TRUE/FALSE # Does the plugin need midi output?
# # IS_MIDI_EFFECT TRUE/FALSE # Is this plugin a MIDI effect?
# IS_ARA_EFFECT TRUE
# # EDITOR_WANTS_KEYBOARD_FOCUS TRUE/FALSE # Does the editor need keyboard focus?
# # COPY_PLUGIN_AFTER_BUILD TRUE/FALSE # Should the plugin be installed to a default location after building?
# PLUGIN_MANUFACTURER_CODE Team # A four-character manufacturer id with at least one upper-case character
# PLUGIN_CODE Dem0 # A unique four-character plugin id with exactly one upper-case character
# # GarageBand 10.3 requires the first letter to be upper-case, and the remaining letters to be lower-case
# FORMATS AU VST3 Standalone # The formats to build. Other valid formats are: AAX Unity VST AU AUv3
# PRODUCT_NAME "AudioPluginExampleCMAKE64") # The name of the final executable, which can differ from the target name
add_subdirectory(tracktion_engine/modules)

juce_add_plugin(AudioPluginExampleCMAKE64
# VERSION ... # Set this if the plugin version is different to the project version
# ICON_BIG ... # ICON_* arguments specify a path to an image file to use as an icon for the Standalone
# ICON_SMALL ...
COMPANY_NAME "" # Specify the name of the plugin's author
COMPANY_NAME "TEAMuP" # Specify the name of the plugin's author
# IS_SYNTH FALSE # Is this a synth or an effect?
# NEEDS_MIDI_INPUT FALSE # Does the plugin need midi input?
# NEEDS_MIDI_OUTPUT FALSE # Does the plugin need midi output?
Expand All @@ -46,7 +46,7 @@ juce_add_plugin(AudioPluginExampleCMAKE64
# However this ID has been assigned before that behaviour was discovered, and remains as-is for backwards
# compatibility - GarageBand 10.3 does not support ARA anyways.
FORMATS AU VST3 Standalone # The formats to build. Other valid formats are: AAX Unity VST AU AUv3
PRODUCT_NAME ARA_sandbox # The name of the final executable, which can differ from the target name
PRODUCT_NAME tensor-juce # The name of the final executable, which can differ from the target name
# VST3_CATEGORIES "Tools"
# AU_SANDBOX_SAFE TRUE
# APP_SANDBOX_ENABLED TRUE
Expand All @@ -65,10 +65,9 @@ juce_generate_juce_header(AudioPluginExampleCMAKE64)

target_sources(AudioPluginExampleCMAKE64
PRIVATE
# Source/ARAPluginDemo.h
Source/Main.cpp)
# PluginEditor.cpp
# PluginProcessor.cpp)
Source/Main.cpp
Source/DeepModel.h
)

# `target_compile_definitions` adds some preprocessor definitions to our target. In a Projucer
# project, these might be passed in the 'Preprocessor Definitions' field. JUCE modules also make use
Expand All @@ -79,14 +78,10 @@ target_sources(AudioPluginExampleCMAKE64

target_compile_definitions(AudioPluginExampleCMAKE64
PUBLIC
# JUCE_PLUGINHOST_ARA=1
# JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them.
JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_plugin` call
JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_plugin` call
JUCE_VST3_CAN_REPLACE_VST2=0)

# juce_add_binary_data(AudioPluginData SOURCES ...)

target_link_libraries(AudioPluginExampleCMAKE64
PRIVATE
# AudioPluginData
Expand Down
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ A repository for a custom ARA plugin with juce, tracktion, and libtorch working
- Libtorch is in C:\libtorch. Change your path in CMakeLists.txt accordingly
- It's important to maintain the order of the `include` statements in `Main.cpp` (torch before juce)

### Downloading libtorch for MacOS
We're currently having trouble making ARA work for x86 Mac builds, so make sure you build
For ARM MacOS builds, you can download an ARM build here: https://github.com/mlverse/libtorch-mac-m1/releases/tag/LibTorch-for-R.
This should be a drop-in replacement for a regular libtorch build.

To ensure you're building on arm, make sure that you build the application from an ARM shell, `arch -arm64 zsh`.

### CMake
#### Windows
Here are the commands used in VSCode (Cmake Tools extension) and Windows 10.
Note that if you're using Reaper x64, you need to build the 64bit version of the plugin.
- Configure
Expand All @@ -31,5 +39,44 @@ Note that if you're using Reaper x64, you need to build the 64bit version of the
```php
"C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/xribene/Projects/audacitorch/plugin_sandbox/build --config Debug --target ALL_BUILD -j 14 --
```
#### Mac
On Mac M1 computers here are the commands you can usse for configuration and building. This project will only run on M1 Macs currently due to building issues for ARA on x86. This is building from inside of a build folder in the project.
- Configure
```
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 ../
```

-Build
```
make -jNUM_PROCESSORS
```


## Debugging
### Mac
1. download visual studio code for mac https://code.visualstudio.com/
2. install Microsoft's C/C++ extension
3. open the "Run and Debug" tab in vsc, and press "create a launch.json file" using the LLDB
4. create a configuration for attaching to a process, here's an example launch.json you could use

```
{
"version": "0.2.0",
"configurations": [
{
"name": "lldb reaper",
"type": "cppdbg",
"request": "launch",
"program": "/Applications/REAPER.app/Contents/MacOS/REAPER",
"args": [],
"cwd": "${fileDirname}",
"MIMode": "lldb",
"miDebuggerArgs": "--symbol-file=build/AudioPluginExampleCMAKE64_artefacts/Debug/VST3/ARA_sandbox.vst3/Contents/MacOS/ARA_sandbox"
}
]
}
```
***make sure to include the `miDebuggerArgs` argument***

5. build the plugin using this flag `-DCMAKE_BUILD_TYPE=Debug`
6. run the debugger and add break poitns
Loading

0 comments on commit 3d90d43

Please sign in to comment.