Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level Detective Processor - Audio Processing & Visualiser #322

Merged
merged 18 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
path: modules/BYOD-add-ons
token: ${{ secrets.OUR_GITHUB_PAT }}

- name: Checkout Jai
uses: actions/checkout@v2
if: github.actor == 'jatinchowdhury18'
with:
ref: main
repository: Chowdhury-DSP/jai-minimal
token: ${{ secrets.OUR_GITHUB_PAT }}
path: modules/jai

- name: Configure
shell: bash
env:
Expand All @@ -63,7 +72,7 @@ jobs:

- name: Build
shell: bash
run: cmake --build build --config Release --parallel
run: cmake --build build --config Release --parallel 3

- name: Unit Tests
if: runner.os == 'Linux'
Expand Down
1 change: 1 addition & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ target_link_libraries(juce_plugin_modules
chowdsp::chowdsp_serialization
chowdsp::chowdsp_units
chowdsp::chowdsp_wdf
chowdsp::chowdsp_visualizers
RTNeural
ea_variant
PUBLIC
Expand Down
18 changes: 18 additions & 0 deletions modules/cmake/FindJaiCompiler.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if(NOT (IOS OR LINUX))
if(WIN32)
set(JAI_COMPILER_EXE "jai.exe")
elseif(APPLE)
set(JAI_COMPILER_EXE "jai-macos")
else()
set(JAI_COMPILER_EXE "jai-linux")
endif()

find_program(JAI_COMPILER
NAMES ${JAI_COMPILER_EXE}
HINTS ${CMAKE_SOURCE_DIR}/modules/jai/bin ${CMAKE_SOURCE_DIR}/../../Research/jai/bin
)
message(STATUS "Jai compiler: ${JAI_COMPILER}")
else()
message(STATUS "Skipping Jai checks on this platform")
set(JAI_COMPILER "JAI_COMPILER-NOTFOUND")
endif()
12 changes: 8 additions & 4 deletions scripts/aax_builds.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# expand bash aliases
shopt -s expand_aliases
source ~/.bashrc

# exit on failure
set -e

Expand Down Expand Up @@ -52,8 +56,8 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
else # Windows
echo "Building for WINDOWS"

AAX_PATH=C:/SDKs/AAX_SDK/
ilok_pass=$(cat /d/ilok_pass)
AAX_PATH=C:/Users/Jatin/SDKs/AAX_SDK_clang/
ilok_pass=$(cat ~/ilok_pass)
aax_target_dir="/c/Program Files/Common Files/Avid/Audio/Plug-Ins"
TARGET_DIR="Win64"
fi
Expand All @@ -75,7 +79,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
cmake --build build-aax --config $build_config -j12 --target "${TARGET_NAME}_AAX" | xcpretty

else # Windows
cmake -Bbuild-aax -G"Visual Studio 16 2019" -A x64 -DBYOD_BUILD_ADD_ON_MODULES=ON
cmake -Bbuild-aax -G"Visual Studio 17 2022" -T ClangCL -A x64 -DBYOD_BUILD_ADD_ON_MODULES=ON
cmake --build build-aax --config $build_config --parallel $(nproc) --target "${TARGET_NAME}_AAX"
fi

Expand All @@ -101,7 +105,7 @@ else # Windows
--account chowdsp \
--password "$ilok_pass" \
--wcguid $wcguid \
--keyfile /c/Users/jatin/Downloads/jatin_aax_cert.p12 \
--keyfile ~/jatin_aax_cert.p12 \
--keypassword "$ilok_pass" \
--in $aax_location \
--out $aax_location
Expand Down
15 changes: 14 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if(NOT (IOS OR BUILD_RELEASE))
add_subdirectory(headless)
endif()

# main source files
target_sources(BYOD PRIVATE
BYOD.cpp

Expand Down Expand Up @@ -132,6 +133,7 @@ target_sources(BYOD PRIVATE
processors/other/Compressor.cpp
processors/other/Delay.cpp
processors/other/EnvelopeFilter.cpp
processors/other/LevelDetective.cpp
processors/other/Gate.cpp
processors/other/Octaver.cpp
processors/other/ShimmerReverb.cpp
Expand All @@ -140,6 +142,7 @@ target_sources(BYOD PRIVATE
processors/other/cry_baby/CryBabyNDK.cpp
processors/other/spring_reverb/SpringReverb.cpp
processors/other/spring_reverb/SpringReverbProcessor.cpp
processors/other/krusher/Krusher.cpp

processors/utility/CleanGain.cpp
processors/utility/FreqBandSplitter.cpp
Expand All @@ -155,8 +158,15 @@ target_sources(BYOD PRIVATE
processors/netlist_helpers/NetlistViewer.cpp
)

target_precompile_headers(BYOD PRIVATE pch.h)
# Jai files
include(${CMAKE_SOURCE_DIR}/modules/cmake/FindJaiCompiler.cmake)
if (NOT(${JAI_COMPILER} STREQUAL "JAI_COMPILER-NOTFOUND"))
message(STATUS "Configuring Jai compilation!")
add_subdirectory(jai)
target_compile_definitions(BYOD PRIVATE BYOD_BUILDING_JAI_MODULES=1)
endif()

# AVX/SSE files for accelerated neural nets
make_lib_simd_runtime(rnn_accelerated processors/drive/neural_utils/RNNAccelerated.cpp)
foreach(target IN ITEMS rnn_accelerated_sse_or_arm rnn_accelerated_avx)
target_link_libraries(${target} PRIVATE config_flags juce::juce_recommended_lto_flags warning_flags)
Expand All @@ -177,7 +187,10 @@ target_compile_definitions(rnn_accelerated_sse_or_arm PRIVATE RTNEURAL_DEFAULT_A
target_compile_definitions(rnn_accelerated_avx PRIVATE RTNEURAL_DEFAULT_ALIGNMENT=32)
target_link_libraries(BYOD PRIVATE rnn_accelerated)

# special flags for MSVC
if (MSVC)
target_compile_options(BYOD PRIVATE /bigobj)
endif ()

# pre-compiled header
target_precompile_headers(BYOD PRIVATE pch.h)
4 changes: 4 additions & 0 deletions src/jai/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.build/
*.lib
*.a
*_jai_lib.h
42 changes: 42 additions & 0 deletions src/jai/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
if(WIN32)
set(JAI_LIBRARY_FILE "byod_jai_lib.lib")
else()
set(JAI_LIBRARY_FILE "byod_jai_lib.a")
endif()

add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAI_LIBRARY_FILE}
COMMAND ${JAI_COMPILER} build.jai
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS build.jai krusher/bit_reduction.jai krusher/lofi_downsampler.jai
)
add_custom_target(jai_library_build DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${JAI_LIBRARY_FILE})

add_library(byod_jai_lib STATIC IMPORTED GLOBAL)
add_dependencies(byod_jai_lib jai_library_build)

set_target_properties(byod_jai_lib
PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/${JAI_LIBRARY_FILE}
)

target_link_libraries(BYOD PRIVATE byod_jai_lib)
target_sources(BYOD PRIVATE SharedJaiContext.cpp stb_sprintf.cpp)
target_compile_definitions(BYOD PRIVATE STB_SPRINTF_IMPLEMENTATION=1)

if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
string(JOIN " " STB_CXX_FLAGS
"-Wno-language-extension-token"
"-Wno-zero-as-null-pointer-constant"
"-Wno-cast-align"
"-Wno-implicit-fallthrough"
"-Wno-conditional-uninitialized"
"-Wno-duplicate-decl-specifier"
"-Wno-unreachable-code"
)
set_source_files_properties(stb_sprintf.cpp
TARGET_DIRECTORY BYOD
PROPERTIES COMPILE_FLAGS "${STB_CXX_FLAGS}"
)
endif()

#TODO: remove stb_sprintf once Jai.Basic no longer depends on it!
12 changes: 12 additions & 0 deletions src/jai/SharedJaiContext.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "SharedJaiContext.h"
#include "byod_jai_lib.h"

JaiContextWrapper::JaiContextWrapper()
{
internal = __jai_runtime_init (0, nullptr);
}

JaiContextWrapper::~JaiContextWrapper()
{
__jai_runtime_fini (internal);
}
17 changes: 17 additions & 0 deletions src/jai/SharedJaiContext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <juce_core/juce_core.h>

struct jai_Context;
struct JaiContextWrapper
{
JaiContextWrapper();
~JaiContextWrapper();

operator jai_Context*() { return internal; }; // NOLINT

private:
jai_Context* internal = nullptr;
};

using SharedJaiContext = juce::SharedResourcePointer<JaiContextWrapper>;
44 changes: 44 additions & 0 deletions src/jai/build.jai
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#import "Basic";
#import "Compiler";
#import "generate_c_header";

#run build();

SRC_FILES :: string.[
"krusher/lofi_downsampler.jai",
"krusher/bit_reduction.jai"
];

build :: () {
header_info : Header_Info;
header_info.jai_type_prefix = "jai_";

w := compiler_create_workspace();

target_options := get_build_options(w);
target_options.output_executable_name = "byod_jai_lib";
target_options.output_type = .STATIC_LIBRARY; // specifies output to be a static library
target_options.backend = .LLVM;
target_options.text_output_flags = 1;
set_optimization(*target_options, .OPTIMIZED);

set_build_options(target_options, w);

compiler_begin_intercept(w);
for file, _ : SRC_FILES {
add_build_file(tprint("%/%", #filepath, file), w);
}
while true {
message := compiler_wait_for_message();
handle_message(*header_info, message);
if message.kind == {
case .COMPLETE;
break;
}
}
compiler_end_intercept(w);

generate_header(*header_info, "byod_jai_lib.h");

set_build_options_dc(.{do_output=false}); // No executable for this workspace.
}
Loading