RRADical Pd
| Author: | Frank Barknecht |
|---|
Abstract
RRADical Pd is a project to create a collection of Pd patches, that make Pd easier and faster to use for people who are more comfortable with commercial software like Reason(tm) or Reaktor(tm). RRAD as an acronym stands for "Reusable and Rapid Audio Development" or "Reusable and Rapid Application Development", if it includes non-audio patches, with Pd. In the design of this system, a way to save state flexibly in Pd (persistence) had to be developed. For communication among each other the RRADical patches integrate the Open Sound Control protocol.
What it takes to be a RRADical
RRAD as an acronym stands for "Reusable and Rapid Audio Development" or "Reusable and Rapid Application Development", if it includes non-audio patches, with Pd. It is spelled RRAD, but pronounced "Rradical" with a long rolling "R".
The goal of RRADical Pd is to create a collection of patches, that make Pd easier and faster to use for people who are more used to software like Reason(tm) or Reaktor(tm). For that I would like to create patches, that solve real-world problems on a higher level of abstraction than the standard Pd objects do. Where suitable these high level abstractions should have a graphical user interface (GUI) built in. As I am focused on sound production the currently available RRADical patches mirror my preferences and mainly deal with audio, although the basic concepts would apply for graphics and
video work using for example the Gem and PDP extensions as well.
Pre-fabricated high-level abstractions may not only make Pd easier to use for beginners, they also can spare lot of tedious, repeating patching work. For example building a filter using the lop~ object of Pd usually involves some way of changing the cutoff frequency of the filter. So another object, maybe a slider, will have to be created and connected to the lop~. The typing and connecting work has to be done almost every time a filter is used. But the connections between the filter's cutoff control and the filter can also be done in advance inside of a so called abstraction, that is, in a saved Pd patch file. Thanks to the Graph-On-Parent feature of Pd the cutoff slider even can be made visible when using that abstraction in another patch. The new filter abstraction now carries its own GUI and is immediately ready to be used.
Of course the GUI-filter is a rather simple example (although already quite useful). But building a graphical note sequencer with 32 sliders and 32 number boxes or even more is something, one would rather have to do only once, and then reuse in a lot of patches.
Problems and Solutions
To build above, highly modularized system several problems have to be solved. Two key areas turned out to be very important:
- Persistence
- How to save the current state of a patch? How to save more than one state (state sequencing)?
- Communication
- The various modules are building blocks for a larger application. How should they talk to each other. (In Reason this is done by patching the back or modules with horrible looking cables. We must do better.)
It turned out, that both tasks are possible to solve in a consistent way using a unique abstraction. But first lets look a bit deeper at the problems at hand.
Persistence
Pd offers no direct way to store the current state of a patch. Here's what Pd author Miller S. Puckette writes about this in the Pd manual in section "2.6.2. persistence of data":
Among the design principles of Pd is that patches should be printable, in the sense that the appearance of a patch should fully determine its functionality. For this reason, if messages received by an object change its action, since the changes aren't reflected in the object's appearance, they are not saved as part of the file which specifies the patch and will be forgotten when the patch is reloaded.
Still, in a musician's practice some kind of persistence turns out to be an important feature, that many Pd beginners do miss. And as soon as a patch starts to use lots of graphical control objects, users will - and should - play around with different settings until they find some combination they like. But unless a way to save this combination for later use is found, all this is temporary and gone, as soon as the patch is closed.
There are several approaches to add persistence. Max/MSP has the preset-object, Pd provides the similar state-object which saves the current state of (some) GUI objects inside a patch. Both objects also support changing between several different states.
But both also have at least two problems: They only save the state of GUI objects, which might not be everything that a user wants to save. And they don't handle abstractions very well, which are crucial when creating modularized patches.
Another approach is to (ab)use some of the Pd objects that can persist itself to a file, especially textfile, qlist and table, which works better, but isn't standardized.
A rather new candidate for state saving is Thomas Grill's pool external. Basically it offers something, that is standard in many programming languages: a data structure that stores key-value-pairs. This structure also is known as hash, dictionary or map. With pool those pairs also can be stored in hierarchies and they can be saved to or loaded from disk. The last but maybe most important feature for us is, that several pools can be shared by giving them the same name. A pool MYPOOL in one patch will contain the same data as a pool MYPOOL in another patch. Changes to one pool will change the data in the other as well. This allows us to use pool MYPOOLs inside of abstractions, and still access the pool from modules outside the abstractions, for example for saving the pool to disk.
A pool object is central to the persistence in RRADical patches, but it is hidden behind an abstracted "API", if one could name it that. I'll come back to how this is done below.
Communication
Besides persistence it also is important to create a common path through which the RRADical modules will talk to each other. Generally the modules will have to use, what Pd offers them, and that is either a direct connection through patch cords or the indirect use of the send/receive mechanism in Pd. Patch cords are fine, but tend to clutter the interface. Sends and receives on the other hand will have to make sure, that no name clashes occur. A name clash is, when one target receives messages not intended for it. A patch author has to remember all used send-names, which might be possible, if he did write the whole patch himself and kept track of the send-names used. But this gets harder to impossible, if he uses prefabricated modules, which might use their own senders, maybe hidden deep inside of the module.
So it is crucial, that senders in RRADical abstractions use local names only with as few exceptions as possible. This is achieved by prepending the RRADical senders with the string "$0-". So instead of a sender named send volume, instead one called send $0-volume is used. $0 makes those sends local inside their own patch borders by being replaced with a number unique to that patch. Using $0 that way is a pretty standard idiom in the Pd world.
Still we will want to control a lot of parameters and do so not only through the GUI elements Pd offers, but probably also through other ways, for example through hardware Midi controllers, through some kind of score on disk, through satellite navigation receivers or whatever.
This creates a fundamental conflict:
- We want borders
- We want to separate our abstraction so they don't conflict with each other.
- We want border crossings
- We want to have a way to reach their many internals and control them from the outside.
The RRADical approach solves both requirements in that it enforces a strict border around abstractions but drills a single hole in it: the OSC inlet. This idea is the result of a discussion on the Pd mailing list and goes back to suggestions by Eric Skogen and Ben Bogart. Every RRADical patch has (to have) a rightmost inlet that accepts messages formatted according to the OSC protocol. OSC stands for Open Sound Control and is a network transparent system to control (audio) applications remotely and is developed at CNMAT in Berkley by Matt Wright mainly.
The nice thing about OSC is that it can control many parameters over a single communication path (like a network conneciton using a definite port). For this OSC uses a URL-like scheme to address parameters organized in a tree. An example would be this message:
/synth/fm/volume 85
It sends the message "85" to the "volume" control of a "fm" module below a "synth" module. OSC allows many parameters constructs like:
/synth/fm/basenote 52 /synth/virtualanalog/basenote 40 /synth/*/playchords m7b5 M6 7b9
This might set the base note of two synths, fm and virtualanalog and send a chord progression to be played by both -- indicated by the wildcard * -- afterwards.
The OSC-inlet of every RRADical patch is intended as the border crossing: Everything the author of a certain patch intends to be controlled from the outside can be controlled by OSC messages to the OSC-inlet. The OSC-inlet is strongly recommended to be the rightmost inlet of an abstraction. At least all of my RRADical patches do it this way.
Trying to remember it all: Memento
To realize the functionality requirements laid out so far I resorted to a so called Memento. "Memento" is a very cool movie by director Christopher Nolan where - quoting IMDB:
A man, suffering from short-term memory loss, uses notes and tattoos to hunt down his wife's killer.
The movie's main character Leonard has a similar problem as Pd: he cannot remember things. To deal with his persistence problem, his inability to save data to his internal harddisk (brain) he resorts to taking a lot of photos. These pictures act as what is called a Memento: a recording of the current state of things.
In software development Mementos are quite common as well. The computer science literature describes them in great detail, for example in the Gang-Of-Four book "Design Patterns" [Gamma95]. To make the best use of a Memento science recommends an approach where certain tasks are in the responsibility of certain independent players.
| [Gamma95] | E. Gamma and R. Helm and R. Johnson and J. Vlissides: "Design Patterns: Elements of Reusable Object-Oriented Software" Addison-Wesley 1995 |
The Memento itself, as we have seen, is the photo, i.e. some kind of state record. A module called the "Originator" is responsible for creating this state and managing changes in it. In the movie, Leonard is the Originator, he is the one taking photos of the world he is soon to forget.
The actual persistence, that could be the saving of a state to harddisk, but could just as well be an upload to a webserver or a CVS check-in, is done by someone called the "Caretaker" in the literature. A Caretaker could be a safe, where Leonard puts his photos, or could be a person, to whom Leonard gives his photos. In the movie Leonard also makes "hard saves" by tattooing himself with notes he took. In that case, he is not only the Originator of the notes, but also the Caretaker in one single person. The Caretaker only has to take care, that those photos, the Mementos, are in a safe place and no one fiddles around with them. Btw: In the movie some interesting problems with Caretakers, who don't always act responsible, occur.
Memento in Pd
I developed a set of abstractions, of patches for Pd, that follow this design pattern. Memento for Pd includes a caretaker and an originator abstraction, plus a third one called commun which is responsible for the internal communication. commun basically is just a thin extension of originator and should be considered part of it. There is another patch, the careGUI which I personally use instead of the caretaker directly, because it has a simple GUI included.
Here's how it looks:

The careGUI is very simple: select a FILE-name to save to, then clicking SAVE you can save the current state, with RESTORE you can restore a state previously saved. After restore, the outlet of careGUI sends a bang message to be used as you like.
Internally caretaker has a named pool object using the global pool called "RRADICAL". The same pool RRADICAL also is used inside the originator object. This abstraction handles all access to this pool. A user should not read or write the contents of pool RRADICAL directly. The originator patch also handles the border crossing through OSC messages by its rightmost inlet. The patch accepts two mandatory arguments: The first on is the name under which this patch is to be stored inside the pool data. Each originator SomeName secondarg stores it's data in a virtual subdirectory inside the RRADICAL-pool called like its first argument - SomeName in the example. If the SomeName starts with a slash like "/patch" , you can also access it via OSC through the rightmost inlet of originator under the tree "/patch"
The second argument practically always will be $0. It is used to talk to those commun objects which share the same second argument. As $0 is a value local and unique to a patch (or to an abstraction to be correct) each originator then only can talk to communs inside the same patch and will not disturb other commun objects in other abstractions.
The commun objects finally are where the contents of a state are read and set. They, too, accept two arguments, the second of which was discussed before and will most of the time just be $0. The first argument will be the key under which some value will be saved. You should use a slash as first character here as well to allow OSC control. So an example for a usage would be commun /vol $0.
commun has one inlet and one outlet. What comes in through the inlet is send to originator who stores it inside its Memento under the key, that is specified by the commun's first arg. Actually originator. The outlet of a commun will spit out the current value stored under its key inside the Memento, when originator tells it to do so. So communs are intended to be cross-connected to some thing that can change. And example would be a slider which can be connected as seen in the next picture:

In this patch, every change to the slider will be reflected inside the Memento. The little print button in careGUI can be used to print the contents to the console from which Pd was started. Setting the slider will result in something like this:
/mypatch 0 , /volume , 38
Here a comma separates key and value pairs. "mypatch" is the top-level directory. This contains a 0, which is the default subdirectory, after that comes the key "/volume", whose value is 38. Let's add another slider for pan-values:

Moving the /pan slider will let careGUI print out:
/mypatch 0 , /volume , 38 /mypatch 0 , /pan , 92
The originator can save several substates or presets by sending a substate #number message to its first inlet. Let's do just this and move the sliders again as seen in the next picture:

Now careGUI prints:
/mypatch 0 , /volume , 38 /mypatch 0 , /pan , 92 /mypatch 1 , /volume , 116 /mypatch 1 , /pan , 27
You see, the substate 0 is unaffected, the new state can have different values. Exchanging the substate message with a setsub message will autoload the selected state and "set" the sliders to the stored values immediately.
OSC in Memento
The whole system now already is prepared to be used over OSC. You probably already guess, how the message looks like. Any takers? Thank you, you're right, the messages are built as /mypatch/volume #number and /mypatch/pan #number as shown in the next stage:

Sometimes it is useful to also get OSC messages out of a patch, for example to control other OSC software through Pd. For this the OSC-outlet of originator can be used, which is the rightmost outlet of the abstraction. It will print out every change to the current state. Connecting a print OSC debug object to it, we get to see what's coming out of the OSC-outlet when we move a slider:
OSC: /mypatch/pan 92 OSC: /mypatch/pan 91 OSC: /mypatch/pan 90 OSC: /mypatch/pan 89
Putting it all to RRADical use
Now that the foundation for a general preset and communication system are set, it is possible to build real patches with it that have two main characteristics:
- Rapidity
- Ready-to-use high-level abstraction can save a lot of time when building larger patches. Clear communication paths will let you think faster and more about the really important things.
- Reusability
- Don't reinvent the wheel all the time. Reuse patches like instruments for more than one piece by just exchanging the Caretaker-file used.
I already developed a growing number of patches that follow the RRADical paradigm, among these are a complex pattern sequencer, some synths and effects and more. All those are available in the Pure Data CVS, which currently lives at pure-data.sourceforge.net in the directory "abstractions/rradical". The RRADical collection comes with a template file, called rrad.tpl.pd that makes deploying new RRADical patches easier and lets developers concentrate on the algorithm instead of bookkeeping. Some utilities help with creating the sometimes needed many commun-objects. Several usecases show example applications of the provided abstractions.
Much, but not all is well yet
Developing patches using the Memento system and the design guidelines presented has made quite an impact on how my patches are designed. Before Memento quite a bit of my patches' content dealed with saving state in various, crude and non-unified ways. I even tried to avoid saving states at all because it always seemed to be too complicated to bother with it. This limited my patches to being used in improvisational pieces without the possibility to prepare parts of a musical story in advance and to "design" those pieces. It was like being forced to write a book without having access to a sheet of paper (or a harddisk nowadays). This has changed: having "paper" in great supply now has made it possible to "write" pieces of art, to "remember" what was good and what rather should not be repeated, to really "work" on a certain project over a longer time.
RRADical patches also have proven to be useful tools in teaching Pure Data, which is important as usage of Pd in workshops and at universities is growing -- also thanks to its availability as Free Software. RRADical patches directly can be used by novices as they are created just like any other patch, but they already provide sound creation and GUI elements that the students can use immediately to create more satisfactory sounds that the sine waves used as standard examples in basic Pd tutorials. With a grown proficiency the students later can dive into the internals of a RRADical patch to see what's inside and how it was done. This allows a new top-down approach in teaching Pd which is a great complement (or even alternative) to the traditional, bottom-up way.
Still the patches suffer from a known technical problem of Pd. Several of the RRADical patches make heavy use of graphical modules like sliders or number boxes, and they create a rather high number of messages to be send inside of Pd. The message count is alleviated a bit by using OSC, but the graphical load is so high, that Pd's audio computation can be disturbed, if too many GUI modules need updating at the same time. This can lead to dropouts and clicks in the audio stream, which is of course not acceptable.
The problem is due to the non-sufficient decoupling of audio and graphics rsp. message computations in Pd, a technical issue that is known, but a solution to my knowledge could require a lot of changes to Pd's core system. Several developers already are working on this problem, though.
The consistent usage of OSC throughout the RRADical patches created another interesting possibility, that of collaboration. As every RRADcial patch not only can be controlled through OSC, but also can control another patch of its own kind, the same patch could be used on two or more machines, and every change on one machine would propagate to all other machines where that same patch is running. So jamming together and even the concept of a "Pd band" is naturally build into every RRADcial patch.
comments
- unknown visitor wrote:
(lap!clap!clap!clap!clap!clap!clap!clap!c) - matt wrote:
thanks for the help! - unknown visitor wrote:
bravo ! bravissimo - ac wrote:
really really interesting, I don't agreee with the reason issues but the idea of the project is really great let it be something else sooner than we can imagine - Louis Goddard wrote:
Fantistic ideas here. As a fairly recent Pd convert (and now obsessive), I'm really looking forward to trying out pure:dyne, which, I think, includes the RRADical patches. - qbas wrote:
thank you! It is very helpfully! - andy wrote:
just what i need (reason user, pd newbie) - unknown visitor wrote:
grazie, mitico!!! - andrew garton wrote:
did you mention this last week? awesome! ^-^ - unknownvisitor wrote:
bczduqrebkxbnzhplzbengzxnlxare - sefskyclegync wrote:
Hello NEW YORK (CNNMoney.com) -- The Nasdaq slipped Tuesday, but the Dow and S&P 500 ended higher for the third straight session as investors welcomed the government's latest efforts to jumpstart lending, but remained cautious. Treasury prices surged, lowering the corresponding yields. The dollar tumbled versus major currencie and oil prices slumped. The Dow Jones industrial average (INDU) gained 0.4%, ending higher for the third session in a row. The last time the Dow gained for three straight sessions was in late August. The Standard & Poor's 500 (SPX) index added 0.7%. The Nasdaq composite (COMP) lost 0.5%. Stocks rose in the morning after the government announced a pair of new programs that will provide roughly $800 billion to increase the availability of consumer and mortgage lending. (Full story) But the advance petered out and stocks plunged through the afternoon as investors sorted through weak economic readings and opted to cash out of some of the recent technology winners. The market ended in mixed territory. "It's positive that the federal government is being proactive and the bond market certainly loves it today, because it's explicit demand for bonds," said Brian Battle, vice president at Performance Trust Capital Partners. "But the stock market is less certain." He said stock investors may also be taking the scope of Tuesday's $800 billion announcement as a sign that things are actually as bad as some fear. The GDP and housing market reports added to those concerns. There may also be frustration that despite the massive amounts of money being put to work by the government, the tangible improvement has been minimal, said Robert Loest, portfolio manager at Integrity Funds. "All of this money is being used in an ad-hoc fashion that doesn't seem to be helping the job market or stabilizing the financial system," Loest said. "I think we are creating a huge debt load and we're not really getting anywhere," he said. On the plus side, he thinks the market is setting itself up for a short-term technical rally, due to both the psychology having gotten so bad recently and the enormous amount of cash on the sidelines. Wednesday brings a buffet of economic reports, including readings on jobless claims, income and spending, manufacturing, housing and consumer sentiment. Stocks surged Monday in a broad rally as Citigroup (C, Fortune 500)'s massive rescue package and President-elect Barack Obama's picks for his economic team pushed investors off the sidelines. Including Friday's advance, the Dow gained 891.10 points for the period, its biggest two-session gain ever, according to Dow Jones. The two-day percentage gain of 11.8% was the biggest since October 1987. The S&P 500's rise of 13.2% was also its biggest two-session percentage gain since October 1987. All financial markets are closed Thursday for Thanksgiving. Markets have a shortened session on Friday. Economy: The U.S. economy saw its worst quarterly decline in seven years, the Commerce Department reported Tuesday. GDP declined at an annual rate of 0.5% in the third quarter versus an earlier reading of a decline of 0.3%. The drop in GDP was in line with expectations. Although the U.S. is not officially considered to be in recession, it is generally believed to have been in recession since at least the start of the third quarter. The fourth quarter is expected to be the low point of the economic cycle and the first quarter of next year is expected to show weakness as well. Another report showed the continued weakness of the housing market. The S&P Case-Shiller Home Price national index posted a 16.6% decline in the third quarter, the biggest drop on record. But another report was a bit more upbeat, showing that consumer confidence recovered a bit in November from a record low hit in October. Separately, the Federal Deposit Insurance Corp. (FDIC) said its watch list of problem banks spiked in the third quarter. On the move: Big financial stocks continued to rise for a third session, including Citigroup (C, Fortune 500), JPMorgan Chase (JPM, Fortune 500), Morgan Stanley (MS, Fortune 500) and Goldman Sachs (GS, Fortune 500). But many of the tech advancers of the last few sessions retreated, including Cisco Systems (CSCO, Fortune 500), Apple (AAPL, Fortune 500), Oracle (ORCL, Fortune 500) and Microsoft (MSFT, Fortune 500). Late Monday, Hewlett-Packard (HPQ, Fortune 500) reported better-than-expected sales and revenue and forecast upbeat fiscal 2009 profit, matching its pre-announcement from a week earlier. However, analysts Tuesday questioned whether it would be able to maintain its sales pace considering the slowdown in tech spending. Shares fell 7%. GM (GM, Fortune 500) shares continued to plunge amid worries about the ability of the company and the industry to stay afloat. (Full story) In other news, BHP Billiton (BHP) is giving up its $68 billion all-stock hostile bid for fellow miner Rio Tinto (RTP), due to the downturn in commodities amid the economic slowdown. BHP shares gained 14.5%, while Rio shares fell 27%. Market breadth was mixed and volume was moderate. On the New York Stock Exchange, winners beat losers two to one on volume of 1.88 billion shares. On the Nasdaq, decliners topped advancers five to four on volume of 2.52 billion shares. Other markets: Asian markets rallied, with the Japanese Nikkei closing up 5.2%. European markets closed with moderate gains, with the London FTSE adding 0.4%. U.S. light crude oil for January delivery fell $3.73 to settle at $50.77 a barrel on the New York Mercantile Exchange. Gasoline prices continued to slump to 3-1/2 year lows, with gas down 2.3 cents to a national average of $1.885 a gallon, according to a survey of credit-card activity released Tuesday by AAA. Prices have been dropping for over two months. In that time, prices have lost $1.97 a gallon, or over 51%. The dollar gained versus the euro and the yen. Bonds: Treasury prices rallied, lowering the yield on the benchmark 10-year note to 3.10% from 3.34% Monday. Last week, the 2-year, 10-year and 30-year government bonds all hit the lowest levels since the Federal Reserve started keeping records in 1962. The yield on the 3-month Treasury bill rose to 0.115% from 0.105% Tuesday, not far from 68-year lows of zero. The 3-month - seen as the safest place to put money in the short term - last hit these levels in September as investor panic peaked. The low yield means nervous investors would rather preserve their money despite no interest rather than risk the stock market. Lending rates rose a bit. The 3-month Libor rate rose to 2.2% from 2.17% Monday, while overnight Libor rose to 0.93% from 0.8% Monday, according to Dow Jones. Libor is a key bank lending rate. <a href=http://money.cnn.com/2008/11/25/markets/bondcenter/credit_market/index.htm?postversion=2008112517>Full story</a> G'night - aNNxoRRazXXO - unknownvisitor wrote:
ceguyomvpaxcetgolubxagbjzlwlcr





