PDA

View Full Version : Redundant keyframes while recording sparse data


julie.jenkinson
04-30-2007, 04:33 PM
Hi

I'm trying to record knob movements off a midi device. The problem I'm having is that the device is sending data at about a 10 hz rate (about one value every 3 frames at 25fps) and Motionbuilder seems to think that I need more than that.

You can see on the first image below that for every new value sent in, there is one redundant one right after, and two others right before the next new value. I know they were not sent by the device because when I check the midi device input values, there are no 2 values that are the same. So the problem comes from motionbuilder.

And if there's no way I can prevent this from happening, is there a way I can automate the process of getting rid of the extra keyframes (image 2) ? Using a 'key reducing' filter didn't do anything.

Many thanks,

Julie

http://img47.imageshack.us/img47/1794/captureddatawc7.jpg (http://imageshack.us)

http://img443.imageshack.us/img443/2308/cleaneddatadb1.jpg (http://imageshack.us)

GiantG
05-03-2007, 07:06 AM
I don't think that a filter can do this for you. It's to specific.
The only way is to write a python script.

julie.jenkinson
05-03-2007, 11:28 AM
Would you happen to know what lines of code would delete three keyframes every four of them? I'm doing a project that heavily relies on the capture of this data, so cleaning the curves manually represents an impossibly huge amount of time.. :sad:

Anssi
05-03-2007, 11:30 AM
Hi,
did you try selecting the keys and using key reducing filter with larger value than the default 1.0?

..then again I don't think it is going to solve the whole problem.

Anssi

LoneCanuck
05-03-2007, 12:39 PM
Hi Julie,

How about using the Constant Key Reduction filter? If those values are just duplicates, this should remove them.

Lone Canuck

julie.jenkinson
05-03-2007, 02:45 PM
The "constant key reduction" filter doesn't work in my case. That's actually the filter I was referring to in my first post. And as far as the key reducing filter goes, it does get rid of extra keyframes but not always the ones I want, so the curve ends up looking fairly different than the reference one.

I've seen a mention of the keyRemove command in Python. Isn't there a simple way to code a little loop like this? (but in actual script, not monkey code like i've done..)

go to next keyframe
keyRemove
go to next keyframe
keyRemove
go to next keyframe
keyRemove
go to next keyframe
go to next keyframe
keyRemove

So that 3/4 keyframes are removed?

J.

LoneCanuck
05-04-2007, 02:16 PM
Thinking about this further.

Do you want to keep the curve shape or do you only care about the keys at certain frames?

I'll look into seeing how to do this in Python and let you know.


-=LoCK=-

julie.jenkinson
05-04-2007, 08:18 PM
Hi Lock

I only really care about keeping the first keyframe of each series of four,
As far as the curve shape is concerned, i just have to select the whole curve and set the interpolation to auto bezier, once the extra keyframes have been removed..

I've written this little code in Mel. It does what I want but I'd rather not have to open Maya and Export/Import - Import/Export everytime I want to clean the curves (which is gonna be very often)

------------
// when the position in the timeline is set to the first keyframe of the curve

while (`currentTime -q`< 123)
{
NextKey;
selectKey -t `currentTime -q`;
cutKey -cl;
NextKey;
selectKey -t `currentTime -q`;
cutKey -cl;
NextKey;
selectKey -t `currentTime -q`;
cutKey -cl;
NextKey;
}
------------

I appreciate you looking for the equivalent in python :)

julie.jenkinson
05-09-2007, 01:47 PM
So... no solution, Peter?

LoneCanuck
05-09-2007, 01:55 PM
Hi Julie,

Working on it. I've been coding other work-related things that handle non-key related things. It's an interesting challenge and I have been researching it a bit in my spare time to see how I would handle it.

Can you tell me more about what is holding the keyframe information? Is it the Device or is it an object? This will determine how the keys are accessed and then changed, I believe.

Devices might be a bit trickier to access and change than an object, but I could be wrong.

/LoCK/

julie.jenkinson
05-09-2007, 06:03 PM
Hi,

Well, at first the keys are placed on the midi device, which is then use to control objects' attributes with a relation constaint, before the keys are plotted on the end object.
So if it's more simple to do operations on the object instead of the device, it's the same for me.

Thanks a lot for looking into this!

j.

CGTalk Moderation
05-09-2007, 06:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.