VSTPlugin with NRT Pattern

Dear List,

i’m trying to use VSTPlugin in an NRT context rendering the score from a Pattern (so a different approach than exemplified in the vst helpfile).

Im adding the following messages to the score, but the second doesn’t seem to work:

essentially this:

p=pattern.asScore(10))

p.add([0.0, VSTPlugin.searchMsg("/path/to/-VSTDirectory")])
p.add([0.0, VSTPluginController(Synth(\synth1).openMsg("Plugin.vst"))])

p.recordNRT(....

returns the following in post window:

searching in '/path/to/-VSTDirectory/'...
found 1 plugin
nextOSCPacket 0
FAILURE IN SERVER /u_cmd Node 0 not found //somethings fails to pass here
nextOSCPacket 0.001
....
nextOSCPacket 10

Would anyone have an idea on how to add these messages so as to make it with the NRT pattern system?

Many thanks,

jan

The problem is how you create the Synth. This is actually explained in section 3 of the NRT example. The following should work:

// use temporary Server!
~server = Server(\nrt);

~p=pattern.asScore(10);

~synth =  Synth.basicNew(\synth1, ~server);
~vst = VSTPluginController(~synth);

~p.add([0.0, VSTPlugin.searchMsg("/path/to/-VSTDirectory")]);
~p.add([0.0, ~synth.newMsg]);
~p.add([0.0, ~vst.openMsg("Plugin.vst")]);

~p.recordNRT(....);

~server.remove;

Thank you very much. This did solve it!

1 Like

I’m having some trouble with this. Any ideas?

I am trying to make a VST plugin ripper that plays all midi notes and records them using a pattern. I’ve tried to follow the tutorial in the help file but this just results in a silent .wav file. Any ideas?

VSTRipper {
    var <vst, vstSynth;
    var server;
    var <score;

    *new{|numChannels=2, sampleRate=96000|
        ^super.new.init(numChannels, sampleRate)
    }

    init{|numChannels, sampleRate|
        server = Server(\vstrippernrt,
            options: ServerOptions.new.sampleRate_(sampleRate)
            .numOutputBusChannels_(numChannels)
        );

        SynthDef.new(\my_vstinstrument, { arg out;
            Out.ar(out, VSTPlugin.ar(nil, 2, id: \vsti));
        }).store;

        vstSynth = Synth.basicNew(\my_vstinstrument, server);
        vst = VSTPluginController.new(synth:vstSynth, id: \vsti);
    }

    render{|path, pluginName="Pianoteq 8", programMsg, noteDuration=8, legato=1, amp=0.75, action|
        var totalDur = noteDuration * 128 * 2;
        var patScore;
        var notes = (0..127).collect{|midinote| [midinote, Rest()]}.flatten;

        score = Score.new;

        // Search for plugins
        score.add([0.0, VSTPlugin.searchMsg(verbose: false)]);

        // Create synth
        score.add([0.0, vstSynth.newMsg]);

        // Open VSTi
        score.add([0.0, vst.openMsg(pluginName, editor: true)]);

        // Choose program
        programMsg.notNil.if({
            score.add([0.0, vst.programMsg(programMsg)]);
        });

        patScore = Pbind(
            \type, \vst_midi,
            \vst, vst,
            \midicmd, \noteOn,
            \chan, 0,
            // Render all notes
            \midinote, Pseq(notes, 1),
            \dur, noteDuration,
            \amp, amp,
            \legato, legato,
        ).asScore(totalDur,0, (vst: vst));

        patScore = patScore.score[1..patScore.score.size-2];

        score.score = score.score.addAll(patScore); // we have to remove the first and last bundle (/g_new + /c_set)!

        score.sort;

        score.recordNRT(
            outputFilePath: path.standardizePath,
            sampleRate: server.options.sampleRate,
            action: action ? {"Done rendering".postln},
            headerFormat: "WAV"
        );

        // Clean up
        server.remove;

    }

}

Ah, it does work, you just can’t hear the first few notes because they don’t exist in a Piano, doh.

3 Likes