Sorry if this is a newbie question.
I know someone must have already done this, and don't want to reinvent the wheel.
I know how to do this in a different language like Perl, which has very rich data structures for scalars (strings, integers, floats), lists (arrays of scalars), and hashes (arrays with a string index), including multi-dimensional ones....
What I want to do is to be able to store and recall a symbol and also a list given an integer index.
Like given index 7 might return "SUS4" and [1 4 5( and index 9 might return "MAJ7" and [1 3 5 7(.
I would be grateful to learn a PD native way of dealing with data structures like this.
Basically looking for a) multi dimensional arrays (nice, but optional) b) arrays which contain symbols, lists, or floats c) persistence
Many thanks!
Vanilla solutions preferred, but don't limit yourself to that :)
BH
Hi,
On Mon, May 04, 2015 at 01:18:46AM -0400, William Huston wrote:
What I want to do is to be able to store and recall a symbol and also a list given an integer index.
Like given index 7 might return "SUS4" and [1 4 5( and index 9 might return "MAJ7" and [1 3 5 7(.
a long while ago I wrote an [symbolarray] abstraction: http://lists.puredata.info/pipermail/pd-list/2009-04/069840.html
This already allows storing symbols into an array. By extending the [struct $0-sym symbol name] structure with an "array" field, you could also make it to store the interval lists.
Frank
Frank Barknecht _ ______footils.org__
In the pd conv in Weimar I gave a workshop on data structures, where
mainly I adapted Frank's tutorial and added content of my own. Afaik, this
is the most accessible tutorial for data structures for now. I wanted to
steal Frank's symbol-array as well, but since I didn't redo this workshop
again, it's not included yet (although I used it for myself at some point).
You can find it at
https://dl.dropboxusercontent.com/u/6624940/data-s.workshop.jmmmp.zip
Data structures are vanilla-only, there aren't any extended objects that
work with them.
You might be able to do what you want without data structures (probably
much faster with a [coll], as they're cumbersome to program), but
Best,
Joao
Hi,
On Mon, May 04, 2015 at 01:18:46AM -0400, William Huston wrote:
What I want to do is to be able to store and recall a symbol and also a list given an integer index.
Like given index 7 might return "SUS4" and [1 4 5( and index 9 might return "MAJ7" and [1 3 5 7(.
a long while ago I wrote an [symbolarray] abstraction: http://lists.puredata.info/pipermail/pd-list/2009-04/069840.html
This already allows storing symbols into an array. By extending the
[struct $0-sym symbol name] structure with an "array" field, you could also make
it to store the interval lists.Ciao
On Mon, May 04, 2015 at 08:53:59AM +0200, João Pais wrote:
You might be able to do what you want without data structures (probably much faster with a [coll], as they're cumbersome to program), but
Actually for the problem at hand (storing lists like "Maj7 1 3 5 7") the best approach would be to use the [text] object in recent Pd vanilla versions.
Frank Barknecht _ ______footils.org__
On 04/05/15 16:29, Frank Barknecht wrote:
On Mon, May 04, 2015 at 08:53:59AM +0200, João Pais wrote:
You might be able to do what you want without data structures (probably much faster with a [coll], as they're cumbersome to program), but
Actually for the problem at hand (storing lists like "Maj7 1 3 5 7") the best approach would be to use the [text] object in recent Pd vanilla versions.
Here is a hash-map mimic built on [text]:
https://github.com/chr15m/blockhead/raw/master/u_map.pd https://github.com/chr15m/blockhead/raw/master/u_map-help.pd
It lets you set, get, delete lists by key. Lists can contain floats, symbols etc.
There is also a messaging API style of access for interfacing with u_map without having to connect directly to it. Makes for cleaner patching:
https://github.com/chr15m/blockhead/raw/master/u_map-api.pd https://github.com/chr15m/blockhead/raw/master/u_map-api-help.pd
You can include the blockhead library as a submodule in your Pd project if you are using git like this:
git submodule add https://github.com/chr15m/blockhead.git
[map] was developed as part of SyncJams, a network synchronised metronome protocol: https://github.com/chr15m/SyncJams
Cheers,
Chris.