勇闖新世界︰ W!o《卡夫卡村》變形祭︰品味科學‧教具教材‧【專題】 GEM‧PD‧gpio

在進入 Pd GEM 的天空前,先引用卡內基美隆大學 Carnegie Mellon University 對『物理計算』與『純數據』的一段論述︰

4.6. Physical Computation with Pure Data

This section is an introduction to physical computing using dataflow programming. This style expresses computation as a graph in which data messages flow over connections between objects which act on the data. We will be using the open-source real-time Pure Data (Pd) visual programming language, which stems from the same work as the commercial Max/MSP system.

Dataflow languages lend themselves well to expressing parallelism, event-driven actions, interactive and incremental programming, and real-time operation. Pd presents the program as a visual graph which follows a visual analogy of graphical modules that intake and process data and pass it along to other modules. Pd programs can be edited as they are running by making and breaking connections, editing parameters, and adding new operators. Pd includes many GUI objects so that controls can be embedded directly in the program.

4.6.1. Takeaway Lessons

Pure Data offers tremendous flexibility: in one environment you can work with physical computing, audio analysis and synthesis, video analysis and synthesis, and more. Pure Data is free and open source, and it works on personal computers (Windows, OS X, Linux), smart phones (iOS, Android), embedded platforms (Raspberry Pi, Udoo, BeagleBone).

Pure Data is good at: rapid prototyping of interactive audio/visual systems, controlling multiple parallel processes with complex timing; audio analysis and synthesi.

Pure Data is bad at: recursive programming, general graphical user interfaces, integration of documentation, adhering to computer science conventions for naming. The Pd third-party libraries in particular are quirky and poorly documented, but many, many features are available.

Pure Data is very extensible: you can extend Pure Data’s functionality with C/C++, Python or a range of other text-based programming languages. Pd has a simple API for compiling binary extensions which can be dynamically loaded into a Pd program and operate like native Pd objects.

Pd programs are called patches. Pd patches can instantiate multiple copies of other patches and treat them as a single object; these other patches are then called abstractions. This is the primary means for creating re-usable modules and subroutines. Patches can also incorporate internal subgraphs called subpatches which exist in only one copy, but allow for organizing a hierarchy of code within a single file.

Pd abstractions implementing GUIs often use a graph-on-parent mode which allows a region of the abstraction patch to be visible in the parent patch. This is typically used to provide GUI control objects within a panel.

4.6.3. Project Idea: Dream Machine

A suggested PureData project is inspired by the Dreamachine, “a stroboscopic flicker device that produces visual stimuli.” Artist Brion Gysin and William S. Burroughs‘s “systems adviser” Ian Sommerville created the dreamachine after reading William Grey Walter‘s book, The Living Brain.

The goal is to make an enchanted object that uses sound, light and movement to create a dream-like state for the viewer. These machines can be simultaneously performed for a coordinated, collaborative, dream experience. This is a very open-ended assignment: results may include pure-software sound synthesis, physical artifacts which create sound or light, physical interfaces for allowing performers to interact with the system.

This project will familiarize you with processes you have already explored with micro-controllers, but now with a personal computer or Raspberry Pi. They will also familiarize you with the work flow for using Pure Data on a laptop to communicate with a micro-controller, as well as Pure Data on a Raspberry Pi.

───

 

希望能帶給讀者不同的視野。

既然談及『物理計算』,也藉此機會一併介紹

pdwiringPi

This repository contains an ‘external’ (plugin) for Pure Data to communicate with hardware on a Raspberry Pi using the wiringPi library.

This code should be assumed to be alpha-quality, it has been minimally tested but is under active development.

The main [wiringPi] object can act either as a generic wrapper for the library or can be bound to a specific I/O pin. In the pin-specific mode, a [bang] input will read the pin and a numeric input will change the pin state. In the generic mode, messages on the input are interpreted as function calls and are mapped to the supported library API calls.

If pd is run as root (e.g. using sudo), then the object uses the direct hardware API which is faster and more versatile. Without root permission, the object falls back to the slower and less capable /sys/class/gpio interface.

The object assumes that the wiringPi installation includes the ‘gpio’ program and will run it using system() if needed.

………

 

在樹莓派上的編譯和安裝。

git clone https://github.com/garthz/pdwiringPi.git
cd pdwiringPi/
make

sudo cp * /usr/lib/pd-extended/extra/

 

冀盼能幫學習者打開『純數據』的『 GPIO 』之一扇應用小窗。

 

wiringPi-help.pd - -usr-lib-pd-extended-extra_wiringPiHelp

 

Pd-extended_wiringPi