Question about Structures and File Tools

mekohler's picture

Hello Wonderful Community of QC Developers,

I am looking to make a simple composition that generates a file containing a list of the time stamps of when a button is pressed. I have most of it figured out but I cannot figure out how to generate a structure of infinite length as the structure tools require me to set a number of inputs. I feel like there should be a way to do this with iterators.

Can anyone point me in the right direction? Thank you, M

franz's picture
Re: Question about Structures and File Tools

use the Queue patch it is a a buffer that outputs a structure. Hook the queue to file out then ...

mekohler's picture
Re: Question about Structures and File Tools

Thank you. Do I just input individual timestamp strings into the que in real time or do i need to feed it from an iterator?

usefuldesign.au's picture
Re: Question about Structures and File Tools

The queue works by either constantly evaluating (ie. taking sample values) or sampling when the value changes. Select the second option in the Queue patch settings. Each time you change the input value queue adds an element to the structure until the structure is full (as set by Size). Then it will push new values to the top (and so drop values from the bottom).

You don't need an iterator with queue to load it but one to use or display it can come in handy. See attached patch.

An alternative to this method would be to have the constantly changing Time value patched to the Queue Value and therefore toggle the filling input on/off when mouseDown occurs.

PreviewAttachmentSize
Queue of timestamps.qtz22.77 KB

dust's picture
Re: Question about Structures and File Tools

also once you fill up the queue you can save the data to a file with a structure to file patch. so you can have a file of the data if you need it for another program or something else. to output it to a file just connect a structure count to a conditional and once the structure is filled up use the boolean truth value to trigger a save of the queue with the structure to file patch. this should put the data into a dictionary array or .plist format. now lets say you wanted to use the structure info from the file you will need to use structure key member then use a string printer to combine your iterations with your key so you can read in the file perhaps to another queue buffer that uses your time stamps. now as far as i know infinity is math term and you can have a set of infinite values. im still grasping that concept of how can there be an infinite infinities ? well in computer science lets say a dynamic array seems infinite meaning you don't set the length but its not infinite its actually finite held to the bounds of your computers hardware limits. so if you want to dynamically save your time stamps than you have to save your queue to a file and change the name of the file on each save. i would use a timestamp for the name of the file but you could use a simple counter to pull your data back chronologically. meaning save your file by namespace of 0 then 1 then 2 then 3 etc... that way you will know that lets say an arbitrary 99 length on your queue will trigger the save once the queue is filled. so you will have data sets of 100 timestamps for each saved file. that way you can always subtract one from the current count to get a set of the last 100 stamps from a file.

im attaching a counter for you. you might want to use it to get a time stamp that is more friendly for reading. this basically counts up from start. i think i stopped at weeks counted but you will get the idea it will be simple to implement the count from mil seconds to years as it all ready prints sec, min, hours, days. if you know the real time when you start the count then you could make it count to years accurately although i think maybe javascript would be a better solution for dates and times as it pulls that stuff from your system. check cyberos java script for info on that.

PreviewAttachmentSize
counter.qtz30.23 KB

bAjA's picture
Re: Question about Structures and File Tools

I'm trying to do a similar thing where i record cue points from an audio track playing in the composition. So that i can recall these cue points from a plist when using the composition in a performance.

But i'm falling down at the first hurdle, as i'm unable to write a plist from a structure. I have attached a test comp and hope someone can have a look at whats wrong.

cheers - bAjA

PreviewAttachmentSize
struc2file-test.qtz2.88 KB

bAjA's picture
Re: Question about Structures and File Tools

its sorted - I just upgraded to the beta release of file tools and now my test patch works... happy days..