Welcome to %s forums

BrainModular Users Forum

Login Register

script to send out midi notes

I need help on a Patch
Post Reply
woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 09 May 2009, 07:40

Hi All!

I can't find a script that actually generates midi values. I want to just send 24 very low volume very short notes to Mr. Ray every time I do a patch change, so I don't get a bunch of clicks (known bug in the VSTi....)

Here's the script I tried. I thought it should work, but it sends out values constantly, after recieving the first trigger. What am I doing wrong. I only see the 'in loop' message once.....

Code: Select all

//////////////////////////
// send out 24 notes
/////////////////////////
// parameters declaration
var output  : Tparameter;
var trigger : Tparameter;
var start : integer;


// initialisation : create parameters
procedure init;
begin  
 Output := CreateParam('Out',ptMidi);               SetIsInput(Output,false);
 trigger := CreateParam('trig',ptButton);           SetIsOutput(Trigger,false); 


end;

// Global variables
var i            : integer;
var noteOn       : TMidi;
var noteOff      : TMidi;


//////////////////////////////
// main proc
//////////////////////////////

begin
  start := trunc(getValue(Trigger));
  if start = 1 then 
  begin
    writeln('in loop');  
    
    SetLength(outPut,48);      // set the number of output codes
    for i := 0 to 23         // loop for all input codes, for polyphonic data (chords)
    do begin
      noteOn.data1 := i + 12;
      noteOn.data2 := 1;
      noteOn.msg := 128; 
      SetMidiArrayValue(output,i,noteOn); // set output value
    end
    for i := 24 to 47
    do begin  
      noteOff.data1 := i - 12;
      noteOff.data2 := 0;
      noteOff.msg := 128; 
      SetMidiArrayValue(output,i,noteOff); // set output value 
    end;  
  end
  else  
     begin
     end;
end.
thanks for any tips.....

-eric
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

bmoussay
Member
Posts: 130
Contact:

Unread post by bmoussay » 09 May 2009, 09:42

Hi,

Just try:
after "if start=1"
SetValue(Trigger, 0); (a security to reset the value of trigger)

And at the end of the script, after "else begin"
SetLength(output, 0); (this sets the output to nothing if no trigger is received)

Hope it can help.

Regards,

B.

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 11 May 2009, 06:51

great, that did it!!

thanks!
-e
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 14 May 2009, 09:00

okay, that sort of did it. It works sometimes, and not others.

Code: Select all

//////////////////////////
// send out 24 notes
/////////////////////////
// parameters declaration
var output  : Tparameter;
var trigger : Tparameter;
var start : integer;


// initialisation : create parameters
procedure init;
begin  
 Output := CreateParam('Out',ptMidi);               SetIsInput(Output,false);
 trigger := CreateParam('trig',ptButton);           SetIsOutput(Trigger,false); 


end;

// Global variables
var i            : integer;
var noteOn       : TMidi;
var noteOff      : TMidi;
var vol          : TMidi;


//////////////////////////////
// main proc
//////////////////////////////

begin
  start := trunc(getValue(Trigger));
  if start = 1 then 
  
  begin
    writeln('in loop');  
    
    SetLength(outPut,50);      // set the number of output codes
    vol.data1 := 7;
    vol.data2 := 0;
    vol.msg := 176;
    vol.channel := 1;
    SetMidiArrayValue(output,0,vol);
    for i := 1 to 24         // loop for all input codes, for polyphonic data (chords)
    do begin
      noteOn.data1 := i + 12;
      noteOn.data2 := 1;
      noteOn.msg := 144; 
      noteOn.channel := 1;
      SetMidiArrayValue(output,i,noteOn); // set output value
    end
    for i := 25 to 48
    do begin  
      noteOff.data1 := i - 12;
      noteOff.data2 := 0;
      noteOff.msg := 128;
      noteOff.channel := 1;
      SetMidiArrayValue(output,i,noteOff); // set output value 
     end;
     vol.data1 := 7;
     vol.data2 := 127;
     vol.msg := 176;
     vol.channel := 1;
     SetMidiArrayValue(output,49,vol);  
  end
  else  
     begin
        SetLength(output, 0);
     end;
   SetValue(Trigger, 0);
end.
any ideas what's happening? I can get it to work from a trigger in about 1 in 20 times.

thanks,
-eric
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 14 May 2009, 09:51

I found another problem I can't solve. I would like to send noteons, and then wait a few milliseconds before sending noteoffs. But I can't figure out when the midi data actually gets sent! Do I have any control over that? I put a wait in half way through the script, but that just makes it wait to send everything out.....

It's also only working about every 40th time now.

What the????
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 14 May 2009, 10:00

hmmmm. looks like a bug in the display of midi cable data. I discovered 'trace out' in the preferences, and it's actually showing up fine in the console.

Actually, I noticed a similar problem with looking at data streams after a 'has changed'. I was only getting a tiny fraction of the values showing up in the inspector.

So I split the script into 2, and delayed the trigger for the noteOff portion, and it seems to work okay.

-e
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests