Process MIDI data?

For general discussion related FlowStone
daslicht
Posts: 14
Joined: Mon Aug 16, 2010 2:11 pm

Process MIDI data?

Post by daslicht »

Hi,
is it possible to craete a Plugin (vst instrument) which i can load on a instruemnt track in studio one which
limits the incoming velocity values eg by 80 to 100? and outputs it to another instrument track, please?
Or is therer maybe something ready like this?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Process MIDI data?

Post by KG_is_back »

Midi can easily be processed with ruby component. Following code will do the job:
3 inputs are required: midi in, integer for min, integer for max and midi output.

Code: Select all

def event i,v,t
note=@ins[0].to_array
if note[0]==144 #if note-on massage 
note[3]=[[@ins[1],note[3]].max,@ins[2]].min

end
note=Midi.new(note[0],note[1],note[2],note[3])
output 0,note,t
end

In order for it to work, you just create module with this ruby component inside and put midi input and output to it. VST plugin must also have one or two mono inputs and outputs in order to be valid VST.
Your DAW should have a way to route midi into the effect and out of it. I'm not familiar with Studio One, but it's possible in FL studio and Cubase as far as I know.
daslicht
Posts: 14
Joined: Mon Aug 16, 2010 2:11 pm

Re: Process MIDI data?

Post by daslicht »

Thank you ,
I set it up as you described, but the forwared notes seam not to have a note off ?
I just get hung notes.?
daslicht
Posts: 14
Joined: Mon Aug 16, 2010 2:11 pm

Re: Process MIDI data?

Post by daslicht »

I added a fader as int source, but now when i move teh fade it will also send notes:) Thats teh source of teh hung note

I keep fiddeling :)
daslicht
Posts: 14
Joined: Mon Aug 16, 2010 2:11 pm

Re: Process MIDI data?

Post by daslicht »

How do I just craete notes when the input came from teh midi in and not when something is coming in the 2 other inputs, please?
oddson
Posts: 36
Joined: Sun Jul 25, 2010 12:13 am

Re: Process MIDI data?

Post by oddson »

daslicht wrote:...I just get hung notes.?

If you limit the minimum value you will get hung notes if your keyboard uses note-on with velocity=0 in place of note-off messages (which many seem to do).
daslicht wrote:How do I just create notes when the input came from the midi in and not when something is coming in the 2 other inputs, please?
Do you mean physical inputs form the external device you're filtering with Flowstone - you'd have to make sure they're coming in on different MIDI channels and make the code sensitive to that.

Before Ruby, Flowstone (and it predecessor SynthMaker) could do this sort of processing with a MIDI splitter and MIDI event primitives and in conjunction with math and logic components without having to code.

While these can be easy to understand when simple they can get pretty messy once you start including complex behaviour.

This module would pass everything except channel 2 note-on messages unaffected and limit velocity on channel 2 note-on messages to 100.
Attachments
capture.png
capture.png (39.38 KiB) Viewed 19846 times
daslicht
Posts: 14
Joined: Mon Aug 16, 2010 2:11 pm

Re: Process MIDI data?

Post by daslicht »

oddson wrote:If you limit the minimum value you will get hung notes if your keyboard uses note-on with velocity=0 in place of note-off messages (which many seem to do).

Yeh looks like my controler do not send NoteOff values
I am using Abpletonb Push + PXT General via MIDI Loop

oddson wrote:eDo you mean physical inputs form the external device you're filtering with Flowstone - you'd have to make sure they're coming in on different MIDI channels and make the code sensitive to that.
?

By inputs i was refering to the script above wihc has 3 inputs: midi, int1, int2

Code: Select all

def event i,v,t
   note=@ins[0].to_array
   if note[0]==144  #if note-on massage 
      note[3]=[[@ins[1],note[3]].max,@ins[2]].min   
      note=Midi.new(note[0],note[1],note[2],note[3])   
      output 0,note,t
   end
end
daslicht
Posts: 14
Joined: Mon Aug 16, 2010 2:11 pm

Re: Process MIDI data?

Post by daslicht »

Ok hung notes are solved at least when playing, but when I move slider 1 the else branch is fired.

so essential I am looking for something like :

Code: Select all

if some value comes from input 1 or 2 (0 is the midi input) do not fire any midi event


idea?
seeL: http://i.imgur.com/2pKcVlR.png


Code: Select all

def event i,v,t
   note=@ins[0].to_array
   min = 50
   max = 100
   watch @ins[1]
      
   if note[0]==144 &&  note[3] > 0  #if note-on massage 
      #note[3]=[[@ins[1],note[3]].max,@ins[2]].min   
      note=Midi.new(144,note[1],note[2],100)   
      output 0,note,t
   else
      note=Midi.new(128,note[1],note[2],100)   
      output 0,note,t
   end
end
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Process MIDI data?

Post by tulamide »

Code: Select all

def event i,v,t

   if i != 1 && i != 2   ### i tells either the name or the index of the input   ###
                  ### that fired the event. Alternatively you could set    ###
                  ### 'if i == 0', but I followed exactly what you wrote   ###
      note = v.to_array if v != nil
      if note[0] == 144
         if note[3] > 0
            note=Midi.new(144,note[1],note[2],100)
         else
            note=Midi.new(128,note[1],note[2],100)
         end
         output 0,note,t
      end
   end
end
"There lies the dog buried" (German saying translated literally)
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Process MIDI data?

Post by tulamide »

oddson wrote:This module would pass everything except channel 2 note-on messages unaffected and limit velocity on channel 2 note-on messages to 100.

Clean and easy-to-follow green solution. Good job!
"There lies the dog buried" (German saying translated literally)
Post Reply