Bug in iterating through Regions collection

nolty wrote on 11/14/2004, 1:26 AM
Hi all --

I'm trying to implement something like the Sound Forge regions list functionality in Vegas, using JScript.

First, it appears to me that the region number is just not made visible through the scripting interface. The iterator moving through the Vegas.Project.Regions collection gives all the regions in timeline order, not in the order they were defined (and the order of the number on the flags in the Vegas GUI.)

Also, there is a bug with some kinds of overlapping regions --

I defined a region R1, from 1:00 to 2:00.

I defined a region R2, from 1:00 to 3:00.

I wrote a simple script that iterates through the Region collection, outputting the region name and the start/end points. It prints R1 twice, and never R2. (Actually it seems random -- if I add a few more regions and rerun the script, it may print R2 twice and not R1.) I get the exact same results whether I use the IEnumerator from the GetEnumerator method, or the Item[i] property of the Regions collection.

Bob

Comments

rcampbel wrote on 11/14/2004, 7:51 AM
Bob,

Which version of Vegas are you running? I have not seen the problem with overlapping regions.

Try the following to iterate though the regions:

for (var region : Region in Vegas.Project.Regions)
{
MessageBox.Show("Region #: " + (region.Index + 1) + " Name:" + region.Label);
}

You are correct that the index is the zero based order of the region on the timeline. I don't know of a way to get the number shown on the marker flag.

Randall
johnmeyer wrote on 11/14/2004, 8:20 AM
My "Markers to Regions" script may have some code you can use. It was designed to emulate a SoundForge feature:

Markers to Regions Script
nolty wrote on 11/15/2004, 5:52 PM
Hi --

I have Vegas 5.0b. The bug exists with the code implemented as you suggest.

Thanks!
Bob
rcampbel wrote on 11/16/2004, 5:18 PM
Bob,

I have reproduced this now. In looking at the Vegas scripting code, it appears that they are getting the markers from the Vegas C++ code via its position on the timeline. So, if two regions or markers start at the exact same timecode position, it will probably be random as to which is returned.

I would suggest that you report this to Sony, but it may be working as designed. As a workaround, make sure that the regions start a slightly different times if you can.

Randall
JohnnyRoy wrote on 11/16/2004, 8:50 PM
I doubt if Sony will consider this a bug. You are adding semantics to the region collection that are not implied. The length of the region has nothing to with which region comes first on the timeline. You could override this behavior by supplying your own sorted list that exhibits the behavior you require and then placing all the regions into that list when you iterate over them. (this is what I would do)

~jr
nolty wrote on 11/17/2004, 1:41 AM
Hi again all --

Randall -- I thought posting bugs in this forum *was* reporting them to Sony -- does Sony not monitor this?

jr -- we're not complaining about the order in which the regions are returned but the fact that some regions aren't returned at all, while others are returned twice.

John -- thanks for the pointer, I read through your script.

Bob
JohnnyRoy wrote on 11/17/2004, 5:25 AM
> some regions aren't returned at all, while others are returned twice.

Oops. I missed the part where R2 wasn’t returned at all. I agree THAT sounds like a bug.

~jr
rcampbel wrote on 11/17/2004, 1:15 PM
Bob,

The forum are monitored sometimes by Sony, but it is not the official support channel.

I suspect that this will be considered working as designed, but I was suggesting that you report it via the support email so that Sony can be aware of your issue.

Randall
SonyPJM wrote on 11/22/2004, 9:24 AM
We'll try to fix this bug for Vegas 6. Regions will probably
continue to be sorted primarily by start time and secondarily by
index.