Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 42 additions & 9 deletions .github/workflows/project-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ jobs:
run: make build

- name: Show Build Output
run: ls -lR ${{github.workspace}}/build
run: ls -lR ${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-bin
path: |
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/NeuralDX7PatchGenerator
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/VST3/
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/lib/
!**/*.a

build-macos:
runs-on: macos-latest
if: false

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -96,7 +98,7 @@ jobs:
run: make build

- name: Show Build Output
run: ls -lR ${{github.workspace}}/build
run: ls -lR ${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts

- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand All @@ -105,6 +107,8 @@ jobs:
path: |
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/NeuralDX7PatchGenerator.app
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/NeuralDX7PatchGenerator.component
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/AU/
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/VST3/

build-windows:
runs-on: windows-latest
Expand Down Expand Up @@ -149,14 +153,15 @@ jobs:

- name: Show
shell: cmd
run: dir /s ${{github.workspace}}\build
run: dir /s ${{github.workspace}}\build\NeuralDX7PatchGenerator_artefacts

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: windows-bin
path: |
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/NeuralDX7PatchGenerator.exe
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/VST3/
${{github.workspace}}/build/NeuralDX7PatchGenerator_artefacts/${{env.BUILD_TYPE}}/*.dll

release:
Expand Down Expand Up @@ -185,24 +190,52 @@ jobs:

- name: Create release packages
run: |
# Create Windows ZIP
# Create Windows Standalone ZIP
if [ -d "./artifacts/windows-bin" ]; then
cd artifacts/windows-bin
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-windows.zip .
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-windows-standalone.zip NeuralDX7PatchGenerator.exe *.dll
cd ../..
fi

# Create Linux ZIP
# Create Windows VST ZIP
if [ -d "./artifacts/windows-bin" ]; then
cd artifacts/windows-bin
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-windows-vst.zip VST3/
cd ../..
fi

# Create Linux Standalone ZIP
if [ -d "./artifacts/linux-bin" ]; then
cd artifacts/linux-bin
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-linux-standalone.zip NeuralDX7PatchGenerator lib/
cd ../..
fi

# Create Linux VST ZIP
if [ -d "./artifacts/linux-bin" ]; then
cd artifacts/linux-bin
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-linux.zip .
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-linux-vst.zip VST3/
cd ../..
fi

# Create macOS Standalone ZIP
if [ -d "./artifacts/macos-bin" ]; then
cd artifacts/macos-bin
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-macos-standalone.zip NeuralDX7PatchGenerator.app
cd ../..
fi

# Create macOS VST ZIP
if [ -d "./artifacts/macos-bin" ]; then
cd artifacts/macos-bin
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-macos-vst.zip VST3/
cd ../..
fi

# Create macOS ZIP
# Create macOS AU ZIP
if [ -d "./artifacts/macos-bin" ]; then
cd artifacts/macos-bin
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-macos.zip .
zip -r ../../NeuralDX7PatchGenerator-${{ steps.extract_tag.outputs.tag }}-macos-au.zip AU/
cd ../..
fi

Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ juce_add_plugin(NeuralDX7PatchGenerator
COPY_PLUGIN_AFTER_BUILD TRUE
PLUGIN_MANUFACTURER_CODE NinA
PLUGIN_CODE NeuD
FORMATS Standalone AU
FORMATS Standalone VST3 AU
VST3_CATEGORIES "Generator Tools"
VST3_AUTO_MANIFEST FALSE
LV2_CATEGORIES "GeneratorPlugin"
LV2URI "urn:nintoracaudio:neuraldx7patchgenerator"
PRODUCT_NAME "NeuralDX7PatchGenerator")

# Override standalone binary location to be in ${CMAKE_BUILD_TYPE}/ instead of ${CMAKE_BUILD_TYPE}/Standalone/
Expand Down Expand Up @@ -95,6 +99,7 @@ target_sources(NeuralDX7PatchGenerator
Source/DX7BulkPacker.cpp
Source/NeuralModelWrapper.cpp
Source/EmbeddedModelLoader.cpp
Source/ThreadedInferenceEngine.cpp
${CMAKE_CURRENT_BINARY_DIR}/model_data.h)

# Link libraries
Expand Down Expand Up @@ -197,7 +202,8 @@ endif()
# Disable JUCE networking features to avoid curl dependency
target_compile_definitions(NeuralDX7PatchGenerator PRIVATE
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0)
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0)

# Include directories
target_include_directories(NeuralDX7PatchGenerator PRIVATE Source ${CMAKE_CURRENT_BINARY_DIR} ${GTK3_INCLUDE_DIRS} ${WEBKIT2GTK_INCLUDE_DIRS})
Expand Down
35 changes: 13 additions & 22 deletions Source/NeuralModelWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,28 @@ std::vector<DX7Voice> NeuralModelWrapper::generateVoices(const std::vector<float
return {};
}

if (latentVector.size() != LATENT_DIM) {
if (latentVector.size() % LATENT_DIM != 0) {
return {};
}

try {
// Create tensor from latent vector
torch::Tensor z = torch::tensor(latentVector).unsqueeze(0).repeat({N_VOICES, 1});
// Create tensor from latent vector - assume latentVector is already batched correctly
torch::Tensor z = torch::tensor(latentVector).view({-1, LATENT_DIM});

// Generate parameters using the model
std::vector<torch::jit::IValue> inputs;
inputs.push_back(z);

torch::Tensor logits = model.forward(inputs).toTensor();

// Infer number of voices from the output tensor size
int numVoices = logits.size(0);

// Convert logits to parameters and then to voices
std::vector<DX7Voice> voices;
voices.reserve(N_VOICES);
voices.reserve(numVoices);

for (int i = 0; i < N_VOICES; ++i) {
for (int i = 0; i < numVoices; ++i) {
torch::Tensor voiceLogits = logits[i];
auto parameters = DX7Voice::logitsToParameters(voiceLogits);
voices.push_back(DX7Voice::fromParameters(parameters));
Expand Down Expand Up @@ -146,26 +149,14 @@ std::vector<DX7Voice> NeuralModelWrapper::generateMultipleRandomVoices()
std::mt19937 gen(rd());
std::normal_distribution<float> dis(0.0f, 1.0f);

// Create tensor with different random latent vectors for each voice
torch::Tensor z = torch::randn({N_VOICES, LATENT_DIM});

// Generate parameters using the model
std::vector<torch::jit::IValue> inputs;
inputs.push_back(z);

torch::Tensor logits = model.forward(inputs).toTensor();

// Convert logits to parameters and then to voices
std::vector<DX7Voice> voices;
voices.reserve(N_VOICES);
// Create batched latent vectors for multiple voices
std::vector<float> batchedLatent(N_VOICES * LATENT_DIM);

for (int i = 0; i < N_VOICES; ++i) {
torch::Tensor voiceLogits = logits[i];
auto parameters = DX7Voice::logitsToParameters(voiceLogits);
voices.push_back(DX7Voice::fromParameters(parameters));
for (int i = 0; i < N_VOICES * LATENT_DIM; ++i) {
batchedLatent[i] = dis(gen);
}

return voices;
return generateVoices(batchedLatent);
}
catch (const std::exception& e) {
std::cerr << "Error generating multiple random voices: " << e.what() << "\n";
Expand Down
Loading