Structure headaches

waxtastic's picture

I'm working right now on a music visualizer using the GL tools. Here's an example video. Takes the audio input and converts it into a structure to be used by the Kineme GL patches.

That real-time stuff is working perfectly. No problems with that.

Today I started to work on a composition that would allow me to save the structure that was drawn by the audio in order to visually represent different songs as line drawings. I thought that I could use the Kineme Structure Tools to do this, but I ran in to some problems.

My structure is being created by the Queue patch and it's just saved with the Structure To File patch. When I open it in plist editor I noticed the first problem. The order of the entries is wrong. I get this (.plist is attached):

qcStructure_0, qcStructure_1, qcStructure_10, qcStructure_100...

When I would need them to be in this order:

qcStructure_0, qcStructure_1, qcStructure_2...

Now I understand why this happen. It's to be expected when the structures are named like that, but something even weirder happens when I try to load the .plist as a structure back to QC.

The order in which the Kineme Structure From File patch arranges them seems to be quite random. This is what I'm getting with one example:

qcStructure_1447, qcStructure_999, qcStructure_1940, qcStructure_152,...

Is there a way to sort the structure back to the order I would need them to be in? Either in QC or just using some sort of external editor. Or even better, is there a way to save the structure in the correct order in the first place.

Attached is the .plist file(test.zip) and before/after image.

PreviewAttachmentSize
beforeandafter.jpg
beforeandafter.jpg61.81 KB
test.zip99.13 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cwright's picture
Re: Structure headaches

waxtastic wrote:
Is there a way to sort the structure back to the order I would need them to be in? Either in QC or just using some sort of external editor. Or even better, is there a way to save the structure in the correct order in the first place.

Don't use index order for hash tables.

Structures in QC are a hybrid Array (ordered/indexed) and Dictionary (keyed/hashed) data storage mechanism. The general case is a Dictionary, because each element has 2 pieces of data, a key, and a value. Arrays, on the other hand, have an index, and a value.

There isn't a good way to save a general QC structure as an Array (because you'd lose all the Key information) -- thus, it's stored as an NSDictionary, whcih doesn't preserve order.

When loading an NSArray from a plist, order is preserved. However, loading NSDictionaries from plists results in them being unordered (because it's expected that you'll access by key, not index).

So, stop using indexes entirely, or have us write special-case NSArray-only structure-file stuff.

dust's picture
Re: Structure headaches NSDictionary

im trying to add phoneme opcode output to the speech synth plugin so i can use kineme 3d to make a talking head or video eventually i want to add rate pitch etc...?

having problem with NSDictionary i think not exactly sure. it seems things are all changed since a few years ago when i tried this in carbon depreciated ;(

so i have my plug in dictionary set like this with a @dynamic

if([key isEqualToString:@"opcode"]) return [NSDictionary dictionaryWithObject:@"outputText" forKey:QCPortAttributeNameKey];

im trying to grab the phonemes from the input string just to test.

self.outputText = [_synthetizer phonemesFromText:self.inputText];

just to test and having a structure headache.

optionally but more importantly i want to extract the just the phonemeCode from SpeechStatusInfo.

i just want the stringurl of the opcode right now but having an output problem . i don't get any errors on build but QC gives me this.

so this is my first Plugin Mod. the Dicitionary looks right to me but like i said all the plugs i have built someone else coded now im just trying to add some functionality and getting headaches.

-[QCPlugInPatch _addOutputPortWithClass:forKey:attributes:]: Inconsistent state

0x91880b4e: GFException 0x91882791: GFThrowException 0x9186d6f0: -[QCPlugInPatch _addOutputPortWithClass:forKey:attributes:] 0x9186d0d0: -[QCPlugInPatch initWithIdentifier:] 0x917d1115: +[GFNode(Private) newWithIdentifier:] 0x917d0fac: -[QCNodeManager instantiateNodeWithName:] 0x0001174f 0x93f484cb: -[NSApplication sendAction:to:from:] 0x93f48408: -[NSControl sendAction:to:] 0x93f90407: -[NSTableView _sendAction:to:row:column:] 0x93f8e771: -[NSTableView mouseDown:] 0x93f45133: -[NSWindow sendEvent:] 0x93f11cd9: -[NSApplication sendEvent:] 0x0000e41d 0x93e6f62f: -[NSApplication run]

any help would be better than none.

thanks

ac's picture
Re: Structure headaches NSDictionary

dust wrote:
so i have my plug in dictionary set like this with a @dynamic

self.outputText = [_synthetizer phonemesFromText:self.inputText];

-[QCPlugInPatch _addOutputPortWithClass:forKey:attributes:]: Inconsistent state

This is usually the case if you're trying to set an output port in a patch configured as consumer (Consumer patches may not have outputs!). Make sure you select "kQCPlugInExecutionModeProcessor" in +executionMode:

Best, ac

mattgolsen's picture
Re: Structure headaches NSDictionary

Have any luck with this?

dust's picture
Re: Structure headaches NSDictionary

no still need help on this one. im really trying to get the status phoneme opcode out as a string ? here is the xcode file if your any good with cocoa. its still like programming in german to me a bit. its just a modification to the example file.

PreviewAttachmentSize
SpeechSynthesis 2.zip15.66 KB

dust's picture
Re: Structure headaches NSDictionary

yeah that fixed the qc errors but im not getting opcode output as string not sure what im doing wrong tell you the truth i will try and get speech status out in a bit instead of trying to get the opcode from the text input ???