User Tools

Site Tools


tasc:tables_and_arrays

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tasc:tables_and_arrays [2008/07/16 16:01]
scarl
tasc:tables_and_arrays [2009/11/06 08:24] (current)
scarl
Line 1: Line 1:
-**Numeric arrays** are simply ​sequences ​of numbers stored in memory in Pd.  ​**[table]** is an object that can be used to add an array in a patch; ​ the array is stored as a subpatch, ​which means it will not be visible in the main patch unless ​you select "​graph-on-parent"​ in the subpatch ​properties. ​  ​To create an array that is visualized in the patch you need a **graph**.+=== Using Arrays and Graphs === 
 + 
 +An **array** is simply ​a sequence ​of numbers stored in memory in Pd.  ​When an array is created both the size of the array (number of values to store) and range of possible values ​can be specified. ​ Arrays are not automatically visible ​in the patch (which can be cluttered enough without ​table of values taking up precious screen space). ​ Instead, arrays are //​subpatches//​ of the "​parent" ​patch.  Values can be added to arrays using a variety of methods;  ​for example, they can be computed by the patch, read from a file, and so forth. ​ Even though ​the array is a subpatch, you can still modify its properties, inspect its values, and so forth  
 + 
 +Sometimes, however, you want to have a representation of the array on your patch.  ​To create an array that is visualized in the patch you need a **graph**. ​ ​Confusingly enough, you can create arrays with and without graphs, and you can create graphs with and without arrays, and there are several different ways to do each.  Here we try to clearly describe the most common ways to create and use graphs. 
 + 
 +//​[screenshot here?]//
  
 === Create an array === === Create an array ===
Line 5: Line 11:
 There are three ways to create an array: There are three ways to create an array:
  
-  * Select "Array" from the Put menu.  This will automatically ​create ​new graph to place on the patch canvas.+  * Select "Object" from the Put menu and call the object **table**.  This object is used to add an array to a patch. ​ It automatically ​creates the subpatch to store the array. ​ However, if you select "​graph-on-parent"​ in the subpatch properties ​a graph for the array will appear ​on the main patch. ​ See the help on table for creation arguments. ​   ​
   * Select "​Graph"​ from the Put menu to place a graph, then select "​Array"​ and choose "in last graph" to associate it with the graph you just placed.   * Select "​Graph"​ from the Put menu to place a graph, then select "​Array"​ and choose "in last graph" to associate it with the graph you just placed.
-  * Select "Object" from the Put menu and call the object **table**.  This will create ​the subpatch with a graph and array.  ​See the help on table for creation ​arguments.+  * Select "Array" from the Put menu.  This will automatically ​create a new graph to place on the patch canvas.  ​This brings up two dialog boxes, one for the array and one for the graph. ​ Put the names and other creation ​information here. 
 + 
 +//​[screenshots?​]//​
  
 === Initializing Properties === === Initializing Properties ===
Line 14: Line 22:
  
   * At creation time, give the array a name and size (and several miscellaneous choices)   * At creation time, give the array a name and size (and several miscellaneous choices)
-  * Use the **Properties** menu to select the X and Y ranges for the array.  ​For example, ​an array of 100 elements ​will have an X range of 0..99. ​ By default, the Y range is -1..1 for audio values. ​ For control values, change the range to whatever is appropriate for the control. ​ For example, ​0..127 ​for MIDI pitch numbers.+  * Use the **Properties** menu to select the X and Y ranges for the array.  ​The X range is the size of the array; ​ for example, ​if the array is to store 100 elements ​give it an X range of 0..99. ​ By default, the Y range is -1..1 for audio values. ​ For control values, change the range to whatever is appropriate for the control. ​ For example, for an array of MIDI pitch numbers ​you could specify a Y range of 0..127. 
 + 
 +//​[screenshots?​]//​
  
 === Storing Values in an Array === === Storing Values in an Array ===
  
-  * **More to come**+  * To initialize a small number of elements of an array, open **Properties** and in the array dialog, choose **View List**. ​ For a newly created array, all values in the array slots will be zero.  You can then double-click on each slot you wish to change and type in whatever number you want.  Remember that these are stored as floating point values. 
 +  * To initialize an array all at once, you will usually use **[tabwrite]** (or **[tabwrite~]** for audio values). ​ See Help on this object for more information. 
 +  * The values of an array can be initialized or changed via a graph. ​ Simply use the mouse to draw (or change) the graph. ​ While this is not the most precise way to put values in an array, it is a quick way to experiment with new values. ​ Choose **Draw as Polygon** in the array **Properties** for best results. 
 + 
 +//​[screenshots?​]//​
  
 === Reading Values from an Array === === Reading Values from an Array ===
  
 +  * To simply view the values in an array numerically (rather than graphically) use the **View List** mentioned above.
 +  * To read values from an array for use by subsequent portions of a patch, use the objects **[tabread]** or **[tabread~]**
 +  * Reading from an array repeatedly can be accomplished using the **[phasor]** object. This is commonly used in wavetable lookup or sampling.
   * **More to come**   * **More to come**
  
-It is very common ​when working with audio to store values in arrays that exceed the range. ​ This won't (necessarily) cause problems in the patch, but the values will be drawn outside the bounds of the graph. ​ This can be disturbing!+=== Graphs === 
 + 
 +It is possible to create a graph first, before creating the array it will display. ​ It should also be noted that are not the only things that can be displayed as graphs. ​ It is not necessary to associate a graph with an array. 
 + 
 +There are two ways to create a graph: 
 + 
 +  - Choose **Graph** from the **Put** menu.  If you are using the graph to display an array, do this before creating the array. To associate the array with the graph, use the method described above in **Create an array**. 
 + 
 +  - Select "graph on parent" ​when creating an array using **[table]**. ​ This automatically associates the graph with an array. 
 + 
 +//​[screenshots?​]//​ 
 + 
 +When working with audio it is easy to store values in arrays that exceed the initially specified ​range. ​ This won't (necessarily) cause problems in the patch, but the values will be drawn outside the bounds of the graph. ​ This can be disturbing!
  
  
 See also [[http://​crca.ucsd.edu/​~msp/​Pd_documentation/​x2.htm#​s8|numeric arrays]] from the Pd Documentation website. See also [[http://​crca.ucsd.edu/​~msp/​Pd_documentation/​x2.htm#​s8|numeric arrays]] from the Pd Documentation website.
tasc/tables_and_arrays.1216242077.txt.gz · Last modified: 2008/07/16 16:01 by scarl