[PD] note data record / playback

Frank Barknecht fbar at footils.org
Tue Sep 12 17:19:32 CEST 2006


Hallo,
David Powers hat gesagt: // David Powers wrote:

> I'm sure that's true, but I'm I had problems understanding the
> existing data structure tutorials. Just the definition of the term
> "scalar" confused me, for starters. It's not even entirely clear, from
> the tutorials, that structures might be useful, if you don't care
> about the graphic part. For some reason, the struct in C makes much
> more sense. Probably it's just some new terminology that I don't
> recognize.

hm, did you read this: 
http://puredata.info/community/projects/convention04/lectures/tk-barknecht/tut.tgz

It's trying to explain all this stuff in very small steps, and
reportedly people seem to get along with it quite well. There also is
a pdf on puredata.info, but I don't have URL availabl atm. Check the
archives. 

Regarding the sequencer-example: I admit it's not documented, but it's
kind of too advanced anyways if you didn't yet do or understand the
basics tutorial.

But to give a broad overview: In your array-based approach you have
different arrays for different needs: One to store time stamps,
another to store note value etc. 

timestamp [table ts]: t0 t1 t2 ... tn
notes [table note]:   n0 n1 n2 ... nn
...

A data structure in Pd is similar to this, but it's like one column of
all these tables crammed into one single "thing": 

[struct ds float ts float note]

      ts note
      |  |
ds 0: t0 n0 ...
ds 1: t1 n1 ...
ds 2: t2 n2 ...
...
ds n: tn nn ...


You then use the [set] and [get] objects to access or change these
fields: 


 1028
 |      60      pointer
 |      |       |
 [set ds ts note]

 pointer
 |
 [get ds ts note]
 |      |
 |      60
 1028


The "pointer" in the graphic above is used to select a data structure
instance to work on with get or set. You may think of the pointer as
equivalent to the number you would use to index all the tables from
your table-based approach: 

 [struct ds float ts float note] <=>  [table ts], [table note]
 pointer                         <=>  [f]: index from 0, 1, 2, ... ,n
 get                             <=>  tabread
 set                             <=>  tabwrite
 "next"                          <=>  increment index: [+ 1]
 "traverse pd-data"              <=>  reset index to 0 and "set table" 
                                      message for tabwrite/-read

Whereas with tables you have lots of tables to store data, with data
structures, you have one definition (struct ...) and then one or more
subpatches to hold the actual data.

So data structures can be seen as an extension of [table]. In fact,
they even share part of their implementation AFAIK. A [table] in Pd is
just a special kind of data structure that's predefined.

Ciao
-- 
 Frank Barknecht                 _ ______footils.org_ __goto10.org__




More information about the Pd-list mailing list