Jump to content

Log after every note event?


Recommended Posts

could you post the script so we can look? if not, I'd make the created random number a property of the note event itself and add a method to the Note object that traces said property. Alternatively prototype displaying the property to the built in .trace method in the Note (or actually Event) object. But all this might be way too complicated depending on what you are trying to do.
Link to comment
Share on other sites

Sure:

 

ResetParameterDefaults = true;

var CutArray = [500, 600];
var RandomCut = CutArray[Math.floor(Math.random() * CutArray.length)];

function Randy(min,max) {

var max = 500;
var min = 50;

return Math.floor(Math.random()*(max-min+1)+min);

}

function RandomPitch(min,max) {

var max = 12;
var min = 2 ;

return Math.floor(Math.random()*(max-min+1)+min);

}

function RandomRepeats(min,max) {

var max = 9;
var min = 1 ;

return Math.floor(Math.random()*(max-min+1)+min);

}

function HandleMIDI(event) {
  if (event instanceof Note) {
     var i = 1;
     while (i <= RandomRepeats() ) {
       event.pitch += (RandomPitch() );
        event.sendAfterMilliseconds( (i-1) * Randy() );
        i++
     }
     event.velocity = 0;
  }

  else if (event instanceof NoteOff){
  event.sendAfterBeat(randomCut);

}
 

}


Trace("The Random ms offset is " + Randy() );
Trace("The Random pitch is " + RandomPitch() );
Trace("The Random cuttoff is " + RandomCut );

 

I need to study some more to implement your suggestions guys :)

Link to comment
Share on other sites

A couple things..

 

One, if you didn't figure this out already, if you randomly change the pitch of NoteOn's and NoteOff's, you're going to end up with some stuck notes.

 

Two, In your code you are checking for instanceof Note, and I think you meant to use "instanceof NoteOn"

 

Three, just move the Trace functions inside HandleMIDI to see more messages... you can put the Trace anywhere..put inside the randy functions if you want... But Scripter might start complaining if you try to send too many messages to the console too quickly. there are ways to work around that, but its complicated...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...