Changing velocities
-
Vincent
take a look on the midi transformer module.
Olivier Sens
www.brainmodular.com
www.brainmodular.com
Hi Vincent, most of what the ndc midi plugs do can be easily done with Usine modules, and probably with less use of CPU.
Re your initial problem with changing velocities: It's maybe a little confusing that the velocity scaling input is called "gain" with a "db" caption. The min/max values are also typical of an audio fader, not velocity.
Re your initial problem with changing velocities: It's maybe a little confusing that the velocity scaling input is called "gain" with a "db" caption. The min/max values are also typical of an audio fader, not velocity.
Bjørn S
Hello again Vincent,
it was late when I wrote the last message and I didn't really check how the gain parameter affected the velocity; it isn't really "velocity scaling".
Not surprisingly it behaves more like an audio fader, while velocity scaling - at least to me - works in a way similar to compressors and expanders: input * ratio = output.
To Olivier: Another request for functionality...
Would it be possible to add a new Midi Filter module that where the opposite of the existing; ie removing the selected message type and let all other messages through? It would make it much simpler to create various types of midi manipulating patches. Filter the message type you want to do something with through the existing module and route another line through the new module. I know it's quite possible to this without a new module, but if you send a lot of different messages and want to make sure all them are passed, it becomes a bit clumsy. (I have a feeling that you'll have more work updating the manual than coding such a module...)
it was late when I wrote the last message and I didn't really check how the gain parameter affected the velocity; it isn't really "velocity scaling".
Not surprisingly it behaves more like an audio fader, while velocity scaling - at least to me - works in a way similar to compressors and expanders: input * ratio = output.
To Olivier: Another request for functionality...
Would it be possible to add a new Midi Filter module that where the opposite of the existing; ie removing the selected message type and let all other messages through? It would make it much simpler to create various types of midi manipulating patches. Filter the message type you want to do something with through the existing module and route another line through the new module. I know it's quite possible to this without a new module, but if you send a lot of different messages and want to make sure all them are passed, it becomes a bit clumsy. (I have a feeling that you'll have more work updating the manual than coding such a module...)
Bjørn S
-
Vincent
Hello wiring men.
My suggestion would be to give up with the old midi filter and to do a new one with two Outputs range :
- on the top, only the filtered signal and it's values (like now);
- on the bottom, the midi out that sends all except the filtered signal (like Bj?rn's suggestion).
Finally, as sophisticated sub-patches connections need a lot of CPU, I decided to develp by myself some midi patches or plugins that I cannot find on the Web.
Can someone suggest me some free C++ API and some tutos?
Waiting for me to be good enough, here is a script for transposition (half-steps and octaves) and velocity compressor/expander:
Check it before trust it!
I totally agree with Bj?rn!bsork wrote:Would it be possible to add a new Midi Filter module that where the opposite of the existing; ie removing the selected message type and let all other messages through?
My suggestion would be to give up with the old midi filter and to do a new one with two Outputs range :
- on the top, only the filtered signal and it's values (like now);
- on the bottom, the midi out that sends all except the filtered signal (like Bj?rn's suggestion).
Finally, as sophisticated sub-patches connections need a lot of CPU, I decided to develp by myself some midi patches or plugins that I cannot find on the Web.
Can someone suggest me some free C++ API and some tutos?
Waiting for me to be good enough, here is a script for transposition (half-steps and octaves) and velocity compressor/expander:
Code: Select all
// Vincent MICHEL
// 20-02-2007
// Note transposition and velocity compressor/expander
// parameters declaration
//var LLimit : TParameter; // those parameters for further developments
//var RLimit : TParameter; // will be used to filter note range between two limits (ie: split keyboard)
var Input : Tparameter;
var Oct : TParameter;
var Trans : TParameter;
var Vel : TParameter;
var Output : Tparameter;
// initialisation : create parameters
procedure init;
begin
// LLimit := CreateParam('Left Limit',ptDataFader); // those inlets for further developments
// RLimit := CreateParam('Right Limit',ptDataFader);
Input := CreateParam('In',ptMidi);
Trans := CreateParam('Transpo',ptDataFader);
Oct := CreateParam('Octave',ptDataFader);
Vel := CreateParam('Velo',ptDataFader);
Output := CreateParam('Out',ptMidi);
SetIsOutPut(Input,false);
// further developments///////////
// SetIsOutPut(LLimit,false);
// SetFormat(LLimit,'%.0f'); SetMin(LLimit,0); SetMax(LLimit,127); SetValue(LLimit,36);
// SetIsOutPut(RLimit,false);
// SetFormat(RLimit,'%.0f'); SetMin(RLimit,0); SetMax(RLimit,127); SetValue(RLimit,72);
//////////////////////////////////
SetIsOutPut(Oct,false);
SetFormat(Oct,'%.0f'); SetMin(Oct,-4); SetMax(Oct,4); SetDefaultValue(Oct,0);
SetIsOutPut(Trans,false);
SetFormat(Trans,'%.0f'); SetSymbol(Trans,' ?T'); SetMin(Trans,-11); SetMax(Trans,11); SetDefaultValue(Trans,0);
SetIsOutPut(Vel,false);
SetFormat(Vel,'%.0f'); SetSymbol(Vel,'%'); SetMin(Vel,0); SetMax(Vel,400); SetDefaultValue(Vel,100);
SetIsInput(Output,false);
end;
// Global variables
var i : integer;
var nbOfMidi : integer;
var ReceivedMidi : TMidi;
var TranspoVal : single;
var VeloVal : variant;
// main proc
begin
nbOfMidi := GetLength(input); // get the number of incoming midi codes
if nbOfMidi = 0
then begin
SetLength(outPut,0); // nothing received, set out length to 0
end
else begin
SetLength(outPut,nbOfMidi); // set the number of output codes
TranspoVal := getValue(Trans)+(getValue(Oct) * 12); // calculate the total transpo value
VeloVal := getValue(Vel) / 100; // calculate the velocity factor
for i := 0 to nbOfMidi-1 // loop for all input codes of polyphonic data
do begin
GetMidiArrayValue(Input,i,ReceivedMidi); // get each midi data
if (TranspoVal - VeloVal) <> -1 // only if transpo or velo <> 0
then begin
ReceivedMidi.data1 := trunc(ReceivedMidi.data1) + trunc(TranspoVal); // transposes notes
ReceivedMidi.data2 := trunc(ReceivedMidi.data2 * VeloVal); // sets compressed/expanded velo
end
SetMidiArrayValue(Output,i,ReceivedMidi); // set output value
end;
end
end.Good idea with two different outputs, Vincent.
But why do you have that strange IF-test - surely the transposition value and the velocity scaling dosn't have anything to do with each other(?). You could also save a (tiny) bit of CPU by doing the truncation of the transposistion outside of the loop.
But why do you have that strange IF-test - surely the transposition value and the velocity scaling dosn't have anything to do with each other(?). You could also save a (tiny) bit of CPU by doing the truncation of the transposistion outside of the loop.
Bjørn S
-
Vincent
Hi Bj?rn!
You like scripting, don't you?
Why two different outputs?
One for new velo and one for new note #?
Could it be often useful?
If not so often, just add a midi filter, no?
Velo and note # have nothing to do together, that's true.
The IF condition mixes them just to control if there is a modification in one of them. If both NO, skips the loop.
I could have do one loop for velo and one other for note #, but too slow (and generates weird things as soon as you play quickly or big chords) !
Tiny bits of CPU are nothing to spare but stupid to waste!
I have to check this. My script "as changed" since I sent the one you have.
Thanks for your precious advices, Bj?rn!
You like scripting, don't you?
Why two different outputs?
One for new velo and one for new note #?
Could it be often useful?
If not so often, just add a midi filter, no?
Velo and note # have nothing to do together, that's true.
The IF condition mixes them just to control if there is a modification in one of them. If both NO, skips the loop.
I could have do one loop for velo and one other for note #, but too slow (and generates weird things as soon as you play quickly or big chords) !
Absolutely right, Master!You could also save a (tiny) bit of CPU by doing the truncation of the transposition outside of the loop.
Tiny bits of CPU are nothing to spare but stupid to waste!
I have to check this. My script "as changed" since I sent the one you have.
Thanks for your precious advices, Bj?rn!
Sorry for the confusion, Vincent, but I meant that it was a good idea with two outputs on a new/improved midi filter module; one for the filtered messages, and the other for all other messages (except sysex, I suppose).
---
I don't see why you would need two loops in your script. You could of course test whether there are any transposition or velocity scaling happening and, if not, just send the input array to the output array. Come to think of it, maybe you could use the same parameter for both input and output and just leave the data unaltered? I haven't tried this myself, so maybe there are some traps hidden doing it that way...
Just a wild guess, but..: One possible source of weird things happening in your script, might be that you're setting the array length before you're assigning any values to it. I've had best results with midi outputs when the length is first zeroed and the new length is set after assigning new values.
---
And yes, I like scripting - it satifies the geek in me, I think. In addition to give new musical possibilities, of course. I have some more or less finished patches that I'd like to put in Add-ons, but I'm waiting for the new version of Usine to be released.
---
I don't see why you would need two loops in your script. You could of course test whether there are any transposition or velocity scaling happening and, if not, just send the input array to the output array. Come to think of it, maybe you could use the same parameter for both input and output and just leave the data unaltered? I haven't tried this myself, so maybe there are some traps hidden doing it that way...
Just a wild guess, but..: One possible source of weird things happening in your script, might be that you're setting the array length before you're assigning any values to it. I've had best results with midi outputs when the length is first zeroed and the new length is set after assigning new values.
---
And yes, I like scripting - it satifies the geek in me, I think. In addition to give new musical possibilities, of course. I have some more or less finished patches that I'd like to put in Add-ons, but I'm waiting for the new version of Usine to be released.
Bjørn S
Who is online
Users browsing this forum: No registered users and 9 guests
