spotify / pedalboard

🎛 🔊 A Python library for audio.
https://spotify.github.io/pedalboard
GNU General Public License v3.0
4.96k stars 249 forks source link

Unable to Change Instruments in BBC Symphony Orchestra VST via Midi messages #311

Open WanJohan opened 2 months ago

WanJohan commented 2 months ago

Hello everyone,

I'm currently working with the BBC Symphony Orchestra VST plugin and trying to switch between different instruments using Python and the Pedalboard library. Despite my efforts, I seem to be stuck using what I assume is the default preset of the plugin, as I'm unable to switch to any other instruments.

Issue Description: I've been attempting to use MIDI program_change messages to switch instruments within the plugin. Here's a brief overview of my approach:

I load the plugin using Pedalboard’s load_plugin function. I create a MIDI file with MidiFile and MidiTrack from the Mido library, inserting program_change messages followed by note_on and note_off messages to produce sound. I then generate audio using the Pedalboard plugin call, which processes the MIDI messages and should theoretically alter the instrument based on the program_change message. Sample Code:

from pedalboard import load_plugin
from mido import MidiFile, MidiTrack, Message

# Load the VST plugin
instrument = load_plugin("/path/to/BBC Symphony Orchestra.vst3")

# Create MIDI messages
midi = MidiFile()
track = MidiTrack()
midi.tracks.append(track)
track.append(Message('program_change', program=5, time=0))  # Attempt to change instrument
track.append(Message('note_on', note=60, velocity=72, time=10))
track.append(Message('note_off', note=60, velocity=64, time=1000))

# Process MIDI and generate audio
audio = instrument(midi, sample_rate=44100, num_channels=2)

Problem: Despite changing the program parameter in the program_change message, the audio output seems to reflect only the default instrument preset. I've tried various program numbers but to no avail.

Questions: Are there specific program numbers associated with different instruments in the BBC Symphony Orchestra VST that I might be missing? Does this plugin possibly require a different method to change instruments that isn’t just through standard MIDI program_change messages?

Thank you in advance for your help and advice!