Load VST or AU virtual instruments

I have a couple of MIDI apps which use available devices on the Mac to record and play MIDI.

I have a number of virtual software instruments, AU and VST plugins which load into DAWs like Logic Pro or Digital Performer. Is there a way to access these plugins from Xojo? I have MBS plugins but haven’t found routines to do this.

Thanks.

The AVAudioUnitSamplerMBS class has loadInstrumentAtFile and loadInstrumentAtURL methods. Maybe these help?

Thanks, Christian. I’ll check this out.

Christian,
Thanks to your help in pointing out the direction to take, I’ve been able to load virtual instruments. These are AVComponents that are type “Music Device”, plug-ins that are software synths which can be triggered by MIDI events as well as code. Apple’s terminology is a little confusing because the component used to load them is AVAudioUnitSampler. The component contains the file path and the instrument is loaded by the Constructor.

Anyway, using the Audio Components Xojo example, I was able to load the instruments. This code loads and lists each instrument and plays a middle C (if there’s a default sound).

I’m posting this to save others the work of figuring this out. You’ll need a ListBox (“List”) in a window to get this working.

Thanks

Var m As New AVAudioUnitComponentManagerMBS
Var a() As AVAudioUnitComponentMBS = m.allComponents
Var Engine As AVAudioEngineMBS

For Each c As AVAudioUnitComponentMBS In a
  Var d As AVAudioComponentDescriptionMBS = c.audioComponentDescription
  If c.LocalizedTypeName = "Music Device" Then 
    List.AddRow c.Name, c.ManufacturerName, c.LocalizedTypeName, c.VersionString, d.componentType+" "+d.componentSubType
    app.DoEvents ' just to update the listbox
    Var MD As AVAudioUnitSamplerMBS
    Try
      MD = New AVAudioUnitSamplerMBS(d) ' this loads the virtual instrument
    End
    Engine = New AVAudioEngineMBS
    Engine.attachNode MD
    Engine.connect(MD, Engine.mainMixerNode, Nil)
    Var error As NSErrorMBS
    If Not Engine.startAndReturnError(error) Then
      MessageBox("Error starting audio engine")
    End
    
    MD.sendMIDIEvent(&h90, 64, 100) ' play middle C
    SleepMBS(.5)
    MD.sendMIDIEvent(&h90, 64, 0)
    SleepMBS(.5)
  End
Next
4 Likes