How should I understand audio levels in FCP7 xml? I'm a software developer working on an application which takes a Final Cut Pro 7 xml file as input, and reads the audio in that XML file (for reporting purposes). 

For any given &lt;clipitem&gt; which represents an audio file there is often an &lt;effect&gt; which represents audio levels. The audio level &lt;effect&gt; element has a child &lt;parameter&gt; element which contains multiple &lt;keyframe&gt; elements.

&lt;filter&gt;
  &lt;effect&gt;
    &lt;name&gt;Audio Levels&lt;/name&gt;
    &lt;effectid&gt;audiolevels&lt;/effectid&gt;
    &lt;effectcategory&gt;audiolevels&lt;/effectcategory&gt;
    &lt;effecttype&gt;audiolevels&lt;/effecttype&gt;
    &lt;mediatype&gt;audio&lt;/mediatype&gt;
    &lt;parameter&gt;
      &lt;name&gt;Level&lt;/name&gt;
      &lt;parameterid&gt;level&lt;/parameterid&gt;
      &lt;valuemin&gt;0&lt;/valuemin&gt;
      &lt;valuemax&gt;3.98109&lt;/valuemax&gt;
      &lt;keyframe&gt;
        &lt;when&gt;0&lt;/when&gt;
        &lt;value&gt;0&lt;/value&gt;
      &lt;/keyframe&gt;
      &lt;keyframe&gt;
        &lt;when&gt;94.1429&lt;/when&gt;
        &lt;value&gt;0.125893&lt;/value&gt;
      &lt;/keyframe&gt;
    &lt;/parameter&gt;
  &lt;/effect&gt;
&lt;/filter&gt;


I need to figure out what the audio level at any given point in time is for the given &lt;clipitem&gt;. 

What I don't get is that the &lt;clipitem&gt; may have &lt;start&gt; set to 1757 and &lt;end&gt; set to 2523. That's a duration of 766 frames.

However, for that very same clip I see the below which to me indicates that the audio level changes to 0.0562341 in frame 1252.57. 

&lt;keyframe&gt;
  &lt;when&gt;1252.57&lt;/when&gt;
  &lt;value&gt;0.0562341&lt;/value&gt;
&lt;/keyframe&gt;


How can a keyframe occur at 1252.57 for a clip that has a duration of 766 frames?

The documentation says...


  The first keyframe always has a value of 0 for when, and the last
  keyframe always has the duration of the clipitem as the value for when
How can a keyframe occur at 1252.57 for a clip that has a duration of 766 frames?


Because the user could have used a clip that was longer than 1252 frames, set a keyframe, then trimmed the clip down to 766 frames. If the user later decides to make the clip longer again by changing the out point to a later time, the keyframe will still be in the place they originally placed it. So your calculations should treat the keyframes as they are, even if they are outside of the clip times.