My goal is to create a single collection of events encompassing multiple tracks in order by each event's start time. I feel like there must be a better way than what I am doing.
I didn't have any success using the Track.Events.CopyTo() method. It kept telling me my target index was too low. Or it was too small. Or it was the wrong type. Picky picky..
I used this round about method and it works but it's really ugly! I made a function to convert the Track.Events into arrays and then .concat'd them into a single Array.
var eventArray = new Array;
eventArray = eventArray.concat( getArrayfromCollection(track1.Events) , getArrayfromCollection(track2.Events) , getArrayfromCollection(track3.Events) , getArrayfromCollection(audio_track.Events));
eventArray.sort(compareStartTimes);
function getArrayfromCollection(col) {
c = new Enumerator (col);
var a = new Array;
while(!c.atEnd()) {
a.push(c.item());
c.moveNext();
}
return a;
}
function compareStartTimes(a,b) {
var num_a = a.Start.ToMilliseconds();
var num_b = b.Start.ToMilliseconds();
if (num_a < num_b) return -1;
else {
if (num_a > num_b) return 1;
else return 0;
}
}
I didn't have any success using the Track.Events.CopyTo() method. It kept telling me my target index was too low. Or it was too small. Or it was the wrong type. Picky picky..
I used this round about method and it works but it's really ugly! I made a function to convert the Track.Events into arrays and then .concat'd them into a single Array.
var eventArray = new Array;
eventArray = eventArray.concat( getArrayfromCollection(track1.Events) , getArrayfromCollection(track2.Events) , getArrayfromCollection(track3.Events) , getArrayfromCollection(audio_track.Events));
eventArray.sort(compareStartTimes);
function getArrayfromCollection(col) {
c = new Enumerator (col);
var a = new Array;
while(!c.atEnd()) {
a.push(c.item());
c.moveNext();
}
return a;
}
function compareStartTimes(a,b) {
var num_a = a.Start.ToMilliseconds();
var num_b = b.Start.ToMilliseconds();
if (num_a < num_b) return -1;
else {
if (num_a > num_b) return 1;
else return 0;
}
}