|
|
TITLE:: FluidDataSet
|
|
|
summary:: Container for labelled, multidimensional data
|
|
|
categories:: UGens>FluidManipulation
|
|
|
related:: Classes/FluidLabelSet, Classes/FluidKDTree, Classes/FluidKNN, Classes/FluidKMeans
|
|
|
|
|
|
DESCRIPTION::
|
|
|
A server-side container associating labels with multi-dimensional data. FluidDataSet is identified by its name.
|
|
|
|
|
|
|
|
|
|
|
|
CLASSMETHODS::
|
|
|
|
|
|
PRIVATE:: asUGenInput
|
|
|
|
|
|
METHOD:: new
|
|
|
Create a new instance of the dataset, with the given name. If a Dataset with this name already exists, an exception will be thrown (see link::Classes/FluidDataSet#at:: to access an extant Dataset)
|
|
|
|
|
|
ARGUMENT:: server
|
|
|
The link::Classes/Server:: on which to create the data set
|
|
|
ARGUMENT:: name
|
|
|
A symbol or string with the name of the dataset.
|
|
|
|
|
|
returns:: The new instance
|
|
|
|
|
|
METHOD:: at
|
|
|
Retreives a cached instance of a FluidDataSet with the given name, or returns nil if no such object exists.
|
|
|
|
|
|
ARGUMENT:: server
|
|
|
The server associated with this dataset instance
|
|
|
ARGUMENT:: id
|
|
|
The name of the Dataset to retreive from the cache
|
|
|
|
|
|
|
|
|
INSTANCEMETHODS::
|
|
|
|
|
|
PRIVATE:: init,id,cache
|
|
|
|
|
|
METHOD:: addPoint
|
|
|
Add a new point to the data set. The dimensionality of the dataset is governed by the size of the first point added.
|
|
|
Will report an error if the label already exists, or if the size of the data does not match the dimensionality of the dataset.
|
|
|
ARGUMENT:: label
|
|
|
A symbol or string with the label for the new point
|
|
|
ARGUMENT:: buffer
|
|
|
A link::Classes/Buffer:: with the new data point
|
|
|
ARGUMENT:: action
|
|
|
A function to run when the point has been added
|
|
|
|
|
|
METHOD:: updatePoint
|
|
|
Update an existing label's data. Will report an error if the label doesn't exist, or if the size of the data does not match the given dimensionality of the dataset.
|
|
|
ARGUMENT:: label
|
|
|
symbol or string with the label
|
|
|
ARGUMENT:: buffer
|
|
|
A link::Classes/Buffer:: containing the updated data
|
|
|
ARGUMENT:: action
|
|
|
A function to run when the server has updated
|
|
|
METHOD:: size
|
|
|
Report the number of items currently in the data set
|
|
|
|
|
|
METHOD:: getPoint
|
|
|
Retreive a point from the data set into a link::Classes/Buffer::. Will report an error if the label or buffer doesn't exist
|
|
|
ARGUMENT:: label
|
|
|
symbol or string with the label to retreive
|
|
|
ARGUMENT:: buffer
|
|
|
link::Classes/Buffer:: to fill
|
|
|
ARGUMENT:: action
|
|
|
function to run when the point has been retreived
|
|
|
|
|
|
|
|
|
METHOD:: deletePoint
|
|
|
Remove a point from the data set. Will report an error if the label doesn't exist.
|
|
|
ARGUMENT:: label
|
|
|
symbol or string with the label to remove
|
|
|
ARGUMENT:: action
|
|
|
Function to run when the point has been deleted
|
|
|
|
|
|
METHOD:: clear
|
|
|
Empty the data set
|
|
|
ARGUMENT:: action
|
|
|
Function to run when the data set has been emptied
|
|
|
|
|
|
METHOD:: free
|
|
|
Destroy the object on the server
|
|
|
|
|
|
METHOD:: cols
|
|
|
Report the dimensionality of the data set. If action is nil, will default to posting result.
|
|
|
ARGUMENT:: action
|
|
|
A function to run when the server responds, whose argument is the data set dimensionality. By default, the method will print the response to the post window.
|
|
|
|
|
|
METHOD:: size
|
|
|
Report the number of points in the data set. If action is nil, will default to posting result.
|
|
|
ARGUMENT:: action
|
|
|
A function to run when the server responds, whose argument is the data set size. By default, the method will print the response to the post window.
|
|
|
|
|
|
|
|
|
METHOD:: read
|
|
|
Read a data set from a JSON file on disk
|
|
|
ARGUMENT:: filename
|
|
|
The absolute path of the JSON file to read
|
|
|
ARGUMENT:: action
|
|
|
A function to run when the file has been read
|
|
|
|
|
|
METHOD:: write
|
|
|
Write the data set to disk as a JSON file.
|
|
|
ARGUMENT:: filename
|
|
|
Absolute path for the new file
|
|
|
ARGUMENT:: action
|
|
|
A function to run when the file has been written
|
|
|
|
|
|
METHOD:: dump
|
|
|
(buggy, please use Print for now) Post the content of the dataset in JSON format in the window by default, but you can supply a custom action instead;
|
|
|
|
|
|
METHOD:: print
|
|
|
Post an abbreviated content of the dataset in the window by default, but you can supply a custom action instead;
|
|
|
|
|
|
METHOD:: asString
|
|
|
Responds with the name of the data set as a pretty(ish) string
|
|
|
|
|
|
METHOD:: asSymbol
|
|
|
Responds with the name of the data set as a symbol
|
|
|
|
|
|
METHOD:: synth
|
|
|
The internal synth the object uses to communicate with the server
|
|
|
|
|
|
returns:: A link::Classes/Synth::
|
|
|
|
|
|
METHOD:: server
|
|
|
The server instance the object uses
|
|
|
|
|
|
returns:: A link::Classes/Server::
|
|
|
|
|
|
EXAMPLES::
|
|
|
|
|
|
CODE::
|
|
|
// Make a one-dimensional data set called 'simple1data'
|
|
|
(
|
|
|
~ds = FluidDataSet.new(s,\simple1data,1);
|
|
|
)
|
|
|
|
|
|
(
|
|
|
Routine{
|
|
|
~ds.clear;
|
|
|
// Make a buffer to use for adding points
|
|
|
~point = Buffer.alloc(s,1,1);
|
|
|
//Add 10 points, using the index as a label.
|
|
|
s.sync;
|
|
|
10.do{|i|
|
|
|
~point.set(0,i);
|
|
|
~ds.addPoint(i.asString,~point,{("addPoint"+i).postln});
|
|
|
s.sync;
|
|
|
}
|
|
|
}.play
|
|
|
)
|
|
|
|
|
|
//Inspect the dataset using print (abbreviated output) or dump (JSON output)
|
|
|
|
|
|
~ds.print //to post window by default, but you can supply a custom action instead
|
|
|
~ds.dump //likewise
|
|
|
//for example
|
|
|
~ds.dump{ |d| ~dict = d }
|
|
|
//Now we have a Dictionary of our data and IDs
|
|
|
~dict.postcs
|
|
|
|
|
|
::
|