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

雖曾與『黑傑克』成功 hi-jack 了『咔嗎衛星』,由於當時尚且不能讀寫『純數據』 pure data 語言︰

Pd-extended_main

testtone.pd

wind0.pd - -home-ccrma-pd-examples-DesigningSoundBookExamples-WIND_0

sketch_jun30a Arduino 1.0.1(in satellite)

果如維基解密上的『Test Run』所言,在登入的個人電腦上,用命令列的『 pd & 』指令,雲端咔嗎將 X 視窗安全的轉送過來;此處的『 & 』表示它之前所冠的執行的命令,比如這裡的 pd ,在背景中執行運作不佔著終端機的輸出入,這樣就可以方便的只用一個終端機,同時做著多件事情。

要想『聽到』聲音,還真像是『益智遊戲』過『』一樣,首先打開 DSP;其次選擇【媒體】選單裡的【聲音和 MIDI 測試】,剛進去的時候,輸出音量是『 OFF 』,需要自作選擇;這樣你就聽到了咔嗎的『第一聲』。如果你不巧卻不行,請用 raspi-config 將樹莓派的『聲音輸出』強制為『 Force 3.5mm (‘headphone’) jack 』,再試一試?!

pdPure Data 一個視覺化程式語言,提供音樂家視覺藝術家演奏者研究者開發者一套『不用寫一行程式』就能創造的工具。遺憾作者知之太晚,並不通熟,用著七試八驗的辦法與東讀西讀的方式,只能『知其然』── 能玩的 ──;不能知『其所以然』──  不能玩的 ──,只好加緊『練功』,以待『來日』!

─── 引自《黑傑克的咔嗎!!明暗之交

 

終究難以一窺堂奧。有鑑於國外多所大學都用這個語言,又因不想遺憾,於是找了本 Tony Hillerson 寫的書一探究竟︰

Programming Sound with Pure Data
Make Your Apps Come Alive with Dynamic Audio

,當真是有趣得很。這也使得維基百科詞條的說明鮮活起來︰

Pure Data

Pure Data (Pd) is a visual programming language developed by Miller Puckette in the 1990s for creating interactive computer music and multimedia works. While Puckette is the main author of the program, Pd is an open source project with a large developer base working on new extensions. It is released under a license similar to the BSD license. It runs on GNU/Linux, Mac OS X, iOS, Android and Windows. Older ports exist for FreeBSD and IRIX.

Pd is very similar in scope and design to Puckette’s original Max program, developed while he was at IRCAM, and is to some degree interoperable with Max/MSP, the commercial successor to the Max language. They may be collectively discussed as members of the Patcher[2] family of languages.

With the addition of the Graphics Environment for Multimedia (GEM) external, and externals designed to work with it (like Pure Data Packet / PiDiP for Linux, Mac OS X), framestein for Windows, GridFlow (as n-dimensional matrix processing, for Linux, Mac OS X, Windows), it is possible to create and manipulate video, OpenGL graphics, images, etc., in realtime with extensive possibilities for interactivity with audio, external sensors, etc.

Pd is natively designed to enable live collaboration across networks or the Internet, allowing musicians connected via LAN or even in disparate parts of the globe to create music together in real time. Pd uses FUDI as a networking protocol.

1280px-Pure_Data_with_many_patches_open_(showing_netpd_project)

 

Language features

Like Max, Pd is a data flow programming language. As with most DSP software, there are two primary rates at which data is passed: sample (audio) rate, usually at 44,100 samples per second, and control rate, at 1 block per 64 samples. Control messages and audio signals generally flow from the top of the screen to the bottom between “objects” connected via inlets and outlets.

Pd supports 4 basic types of text entities: messages, objects, atoms, and comments. Atoms are the most basic unit of data in Pd, and they consist of either a float, a symbol, or a pointer to a data structure (in Pd, all numbers are stored as 32-bit floats). Messages are composed of one or more atoms and provide instructions to objects. A special type of message with null content called a bang is used to initiate events and push data into flow, much like pushing a button.

Pd’s native objects range from the basic mathematical, logical, and bitwise operators found in every programming language to general and specialized audio-rate DSP functions (designated by a tilde (~) symbol), such as wavetable oscillators, the Fast Fourier transform (fft~), and a range of standard filters. Data can be loaded from file, read in from an audio board, MIDI, via Open Sound Control (OSC) through a Firewire, USB, or network connection, or generated on the fly, and stored in tables, which can then be read back and used as audio signals or control data.

220px-Pdobjects.svg

Pure Data objects. The text strings to the right of the boxes are comments.

Data structures

One of the key innovations in Pd over its predecessors has been the introduction of graphical data structures, which can be used in a large variety of ways, from composing musical scores, sequencing events, to creating visuals to accompany Pd patches or even extending Pd’s GUI.

Living up to Pd’s name, data structures enable Pd users to create arbitrarily complex static as well as dynamic or animated graphical representations of musical data. Much like C structs, Pd’s structs are composed of any combination of floats, symbols, and array data, which can be used as parameters to describe the visual appearance of the data structure or, conversely, to control messages and audio signals in a Pd patch. In Puckette’s words:

Pd is designed to offer an extremely unstructured environment for describing data structures and their graphical appearance. The underlying idea is to allow the user to display any kind of data he or she wants to, associating it in any way with the display. To accomplish this Pd introduces a graphical data structure, somewhat like a data structure out of the C programming language, but with a facility for attaching shapes and colors to the data, so that the user can visualize and/or edit it. The data itself can be edited from scratch or can be imported from files, generated algorithmically, or derived from analyses of incoming sounds or other data streams.

600px-Solitude

Score for Hans-Christoph Steiner’s Solitude, created using Pd’s data structures.

Language limitations

Though Pd is a powerful language it has certain limitations in its implementation of Object Oriented concepts.[4] For example it is very difficult to create massively parallel processes because instantiating and manipulating large lists of objects (spawning..etc..) is impossible due to a lack of a constructor function. Further, Pd arrays and other entities are susceptible to name space collisions because passing the patch instance ID is an extra step and is sometimes difficult to accomplish.

 

心想『咔嗎衛星』將之與『 JACK 環境』結合起來,果然是有創見的耶!所以特寫此一專題,作點『純數據』語言入門的介紹。希望能夠開拓讀者的視野,可以為『現象認知』學習環境增色。

 

【節拍體驗】

Connections - JACK Audio Connection Kit_PD連線

 

PD_add-signal

 

sco bridge-6875_PD波形

 

Jack-Alsa Audio Analyser-0.8.4 [jaaa]_PD頻域