User Forum    :: Powered by YaBB
  « MIDI-OX User Forum - That nasty sustain pedal »
Welcome, Guest. Please Login or Register.
Oct 19th, 2024, 7:54pm


Home Home Help Help Search Search Members Members Login Login Register Register


   MIDI-OX User Forum
   MIDI-OX
   Questions and Discussion
(Moderator: Jamie OConnell)
   That nasty sustain pedal
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: That nasty sustain pedal  (Read 1075 times)
rumborak
New Member
*



MIDI-OX Rules!

   


Posts: 3
That nasty sustain pedal
« on: Nov 3rd, 2002, 2:07am »
Quote Quote Modify Modify

Hi all,
 
I have a MIDI problem and I was hoping someone might have a solution to this:
 
I'm using my soundcard's MIDI function mostly for playing piano (hooking it up with my MIDI keyboard).
 
However, everytime I press the sustain pedal, I run into the obvious problem: Polyphony.
After a few seconds, there aren't any free oscillators anymore and even though I'm still hitting keys, there's no nothing happening anymore.
 
The stupid thing (I find) however is that hitting the same note twice in a row does *not* result in the first oscillator starting from the beginning of the sample again, but rather a second oscillator being used.  
Result: Polyphony issues and nasty phasing effects.
 
Now, I understand this is all done *inside* the soundcard (ie the handling of the sustain pedal), so there's no way to directly change it, however, shouldn't it be possible to
 
<algorithm>
catch the sustain pedal MIDI event and *not* transmit it to the card but store the information locally (in the program), then
 
*not* transmit the "Note off" event to the soundcard when the pedal is pushed, and
 
transmit the "Note on" events to the soundcard but put a "Note off" event immediately in front of it.
</algorithm>
 
If I'm not mistaken, that should result in exactly the same effect as the original soundcard handling, with the difference that there never will be more than one oscillator playing the same note and unless you really hit more than 32 keys at once, you won't run out of polyphony.
 
Is there any way to do this in MidiOx ?
If not, I think this would be a great feature (and I think quite easy to implement also)
IP Logged
rumborak
New Member
*



MIDI-OX Rules!

   


Posts: 3
Re: That nasty sustain pedal
« Reply #1 on: Nov 3rd, 2002, 3:11pm »
Quote Quote Modify Modify

Ah ! I found the answer myself.
Here it goes (for those interested):
Awesome ! No longer polyphony problems when playing piano !
(As long as I don't play more than 32 keys at once  Grin)
 
----------------- JScript ---------------------------
var Pedal_pressed = 0;
var del_noff = new Array(256); // This array stores if we need to send a delayed note off event when the pedal is released
 
function Mox_OnMidiInput( timestamp, port, status, d1, d2 ) {  
 if ((status == 176)&&(d1 == 64)) { // Pedal event
   if (d2 > 64) {
     Pedal_pressed = 1;
   }else{
     Pedal_pressed = 0;
     for (var count = 0;count < 255;count++) {
  if (del_noff[count] == 1) {
    Mox.OutputMidiMsg( -1,144,count,0);  
  del_noff[count] = 0;
  }
     }
   }
 }else if (status == 144) { //Note event
   if (d2 == 0) { // Note off
     if (Pedal_pressed == 0) {
  Mox.OutputMidiMsg( -1,status,d1,d2);  
     }else{
  del_noff[d1] = 1;
     }
   }else{ // Note on
  Mox.OutputMidiMsg( -1,status,d1,0);
  Mox.OutputMidiMsg( -1,status,d1,d2);
  del_noff[d1] = 0;
   }
 }
}  
 
var Mox = WScript.CreateObject("MIDIOX.MOXScript.1","Mox_On");  
var dev = Mox.GetFirstOpenMidiInDev();  
dev = Mox.GetFirstOpenMidiOutDev();  
 
Mox.ShutdownAtEnd = 1;  
Mox.FireMidiInput = 1;  
Mox.DivertMidiInput = 1;  
 
while( !Mox.ShouldExitScript ) {  
  Mox.sleep(10);  
}  
 
WScript.Quit();  
-----------------------------------------------------
 
IP Logged
rumborak
New Member
*



MIDI-OX Rules!

   


Posts: 3
Re: That nasty sustain pedal
« Reply #2 on: Nov 3rd, 2002, 3:16pm »
Quote Quote Modify Modify

Oh, for those not familiar with the scripting functionality in Midi-OX:
Copy the stuff between the "------.." lines into Notepad and save as "Sustainer.js". Double-click on the file and there you go !
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »


MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.