TGC3 Beginners Guide: Difference between revisions

From XPUB & Lens-Based wiki
 
(4 intermediate revisions by the same user not shown)
Line 10: Line 10:


The core of the TGC3 is a single board computer (SBC) called a RaspberryPi and running the GNU/Linux distribution Raspbian. Works are contained on floppy disks and launched on insertion. To be more precise, each floppy contains the programmatic instructions so as to make the tiny computer behave in a certain way, and make use of some of all of its peripherals. This system therefore allows for a rather large range of possibilities, where the TGC can become anything from an audiovisual noise instrument to a poetry broadcasting device or spying and tracking camera. Last but not least, there is no default Internet connectivity on the TGC3, but local websites, stored on each floppy, can be accessed by connecting to the TGC3 local WiFi hotspot. This feature can be used to provide contextual documentation for the work, or publish browser-based art off the Internet.
The core of the TGC3 is a single board computer (SBC) called a RaspberryPi and running the GNU/Linux distribution Raspbian. Works are contained on floppy disks and launched on insertion. To be more precise, each floppy contains the programmatic instructions so as to make the tiny computer behave in a certain way, and make use of some of all of its peripherals. This system therefore allows for a rather large range of possibilities, where the TGC can become anything from an audiovisual noise instrument to a poetry broadcasting device or spying and tracking camera. Last but not least, there is no default Internet connectivity on the TGC3, but local websites, stored on each floppy, can be accessed by connecting to the TGC3 local WiFi hotspot. This feature can be used to provide contextual documentation for the work, or publish browser-based art off the Internet.
== Floppy ==
The setup of the Floppy is key in the functionality of the system. Below we have provided a map of the file and folder structure of your future floppy submission.
<pre>
FLOPPY
├── LICENSE
├── main.pd
├── main.py
├── noweb
│  └── index.html
└── README
</pre>
In the root of the Floppy disk there needs to contain a ''LICENSE'' and ''README'' text file, your initial code file(s) named either ''main'''''.py''' or ''main'''''.pd''' format, and a ''noweb'' folder containing local website files you wish to have accessible over the local hotspot. Any other files you may need can be arranged in any style you choose so long as you correctly reference them in your code.


== Software ==
== Software ==
Line 101: Line 118:


==== noweb ====
==== noweb ====
As the name suggests, the TGC3 is not connected to the Internet but does host local web content. You can utilise this feature in a variety of ways to either display documentation, static work, or function as an interface. So long as your index.html is situated within the noweb folder, it will be accessible when connected to the TGC3 hot-spot.
As the name suggests, the TGC3 is not connected to the Internet but does host local web content. You can utilise this feature in a variety of ways to either display documentation, static work, or function as an interface. So long as your index.html is situated within the noweb folder, it will be accessible when connected to the TGC3 hot-spot. Your nowebsite can be built in plain html, css, but can also incorporate (but is not limited to) javascript, and cgi. 


The breadth of how involved your site and submission can be quite intricate as outlined in the example provided. Here the web content is generated via a '''.cgi''' file where the core of the submission is housed in a bash script that is launched by the main.py file.
Here the submission is controlled by '''.cgi''' code behind an interface built in html to trigger audio files.


<source lang="html5">
<source lang="html5">
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<meta http-equiv="refresh" content="0;url=/cgi-bin/index.cgi" />
<title> Rock Step - Triple Step - Triple Step </title>
</head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<body>
<a href="/cgi-bin/index.cgi">start</a>
</body>
</html>
</source>
 
<source lang="python">
#!/usr/bin/env python
 
import cgi, jinja2, os, json, re
import cgitb; cgitb.enable()
from jinja2 import Template
 
# Directory => ITEMS list (all files with a timestamp name, grouped)
path = "/var/www/static/gait"
try:
    ff = os.listdir(path)
except OSError:
    ff = []
tpat = re.compile(r"^(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)")
items = {}
for f in ff:
    base, ext = os.path.splitext(f)
    ext = ext[1:]
    m = tpat.match(f)
    if m:
        t = m.group(0)
        if t not in items:
            items[t] = {}
        items[t][ext] = f


items = [items[key] for key in sorted(items, reverse=True)]
for i in items[10:]:
    for f in i.items():
        for ext in f:
            fp = os.path.join(path, f[ext])
            try:
                os.unlink(fp)
            except IOError as e:
                print ("Error deleting", e)
                pass
# dump the data (debugging)
# print "Content-type: text/plain"
# print ""
# print json.dumps(items, indent=2)
# Output template with items
print "Content-type: text/html"
print ""
print Template(u"""<html>
<head>
<title>ADOPT A WALK</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../styles/main.css">
</head>
</head>
<body>
<body>
    <div id="wrappper">
   
    <header>
        <img src="../images/headertr3.png" width="100%"/>
    </header>


    <div class="firstline">
<h1> rock step - triple step - triple step </h1>
        <p> Here you can find footage of your walks.</p>
    </div>


    <img src="../images/camera.png" />
<form action="cgi-bin/play.cgi" class="buttons">
   
  <input type="submit" name="p" value="BasicTurn.mp3" />
    <div class="secondline">
  <input type="submit" name="p" value="Follow.mp3" />
        <p> Steal a walk from another person's video. Download it. </p>
    </div>


  <input type="submit" name="p" value="AmericanSpin.mp3" />
  <input type="submit" name="p" value="Bump.mp3" />


    <div class="thirdline">
  <input type="submit" name="p" value="StopAndGo.mp3" />
        <p> Promise me, you're gonna start using this walk for the rest of the day. </p>
  <input type="submit" name="p" value="Windmill.mp3" />
    </div>


    <img src="../images/cover.png" />
  <input type="submit" name="p" value="SpanishArms.mp3" />
  <input type="submit" name="p" value="Hucklebuck.mp3" />


  <input type="submit" name="p" value="Whip.mp3" />
  <input type="submit" name="p" value="ChickenWalks.mp3" />
  <div class="tempo">
</form>


    <div class="movies">
        {% for i in items %}
        <a href="/static/gait/{{i.mp4}}"><img src="/static/gait/{{i.jpg}}" /></a>
        <p>{{i.mp4}}</p>
        {% endfor %}
    </div>
    </div>
</body>
</body>
</html>""").render(items=items).encode("utf-8")
</html>
</source>  
</source>  


<source lang="python">
<source lang="python">
#!/usr/bin/python
#!/usr/bin/env python


import cgi, os
import cgitb; cgitb.enable()
import subprocess
import subprocess


subprocess.call(["bash", "scripts/voiceguide.sh"], cwd="/media/floppy")
f = cgi.FieldStorage()
</source>
p = f.getvalue("p", "Bump.mp3")
p = os.path.join("voice", p)
out = subprocess.check_output(["mpv", p], cwd="/media/floppy/noweb", stderr=subprocess.STDOUT)


<source lang="bash">
# print "Location: /index.html"
# ensure the record folder exists
# print
mkdir -p /var/www/static/gait


v=-v en-gb -s 150
print "Content-type:text/html; charset=utf-8"
espeak "Tetra Gamma Gait Analysis  "  -v en-gb -s 150
print
 
print """<html>
 
<head>
sleep 1
<meta http-equiv="refresh" content="0;url=/index.html" />
 
</head>
espeak "Be ready for the security check."  -v en-gb -s 150
<body>
sleep 1
</body>
 
</html>"""
espeak "Please state your name:" -v en-gb -s 150
sleep 1
 
espeak "Position yourself 2 to 3 meters away from me." -v en-gb -s 150
sleep 2
 
espeak "Walk towards me in a straight line after the bip ."  -v en-gb -s 150
sleep 0.1
 
mpv sweep_up.wav
 
basename=/var/www/static/gait/$(date +%Y-%m-%d-%H-%M-%S)
echo recording $basename.avi...
python scripts/recordwalk.py --output $basename.avi --frames 50 --framerate 4 --width 320 --height 240
# convert to mp4
ffmpeg -i $basename.avi -y $basename.mp4
# make a thumnail image
ffmpeg -i $basename.avi -vframes 1 -ss 0.5 -y $basename.jpg
# rm $basename.avi
 
mpv sweep_up.wav
 
espeak "Position yourself 2 to 3 meters away from me." -v en-gb -s 150
sleep 2
 
espeak "Walk towards me on a zig zag line."  -v en-gb -s150
sleep 0.1
 
mpv sweep_up.wav
 
basename=/var/www/static/gait/$(date +%Y-%m-%d-%H-%M-%S)
echo recording $basename.avi...
python scripts/recordwalk.py --output $basename.avi --frames 50 --framerate 4 --width 320 --height 240
# convert to mp4
ffmpeg -i $basename.avi -y $basename.mp4
# make a thumnail image
ffmpeg -i $basename.avi -vframes 1 -ss 0.5 -y $basename.jpg
# rm $basename.avi
 
mpv sweep_up.wav
 
espeak "Thank you for your cooperation" -v en-gb -s175
sleep 1
 
mpv sweep_up.wav
</source>
</source>
== Floppy ==
The setup of the Floppy is key in the functionality of the system. Below we have provided a map of the file and folder structure of your future floppy submission.
<pre>
FLOPPY
├── LICENSE
├── main.pd
├── main.py
├── noweb
│   └── index.html
└── README
</pre>
In the root of the Floppy disk there needs to contain a ''LICENSE'' and ''README'' text file, your initial code file(s) named either ''main'''''.py''' or ''main'''''.pd''' format, and a ''noweb'' folder containing local website files you wish to have accessible over the local hotspot. Any other files you may need can be arranged in any style you choose so long as you correctly reference them in your code.


[[Category: XPUB]]
[[Category: XPUB]]

Latest revision as of 11:04, 13 October 2017

Intro

The Tetra Gamma Circulaire 3 (TGC3), AKA XPUB Special Issue 2, is an unknown concrete floppy music publication. It is an experimental platform designed to investigate experimental ways of publishing sonic, visual and textual works and instruments.

This work is a collaboration between the polymorph production platform DE PLAYER and the Experimental Publishing (XPUB) study path of the Media Design Master at the Piet Zwart Institute, Willem de Kooning Academie. Current contributions include works on dance, democracy, drones, surveillance, body movement, silence, improvisation, and the fine line between everything and nothing. We encourage anyone to contribute new pieces so as to develop an ever growing library of works to be experienced on the TGC3.

Hardware

The TCG3 is an accumulation of various computer peripherals that can be accessed in many different ways (WiFi, speakers, microphone, camera, Bluetooth, electro-conductive touch pads). It was designed as an open platform to allow for many kinds of applications, and contributions.

The core of the TGC3 is a single board computer (SBC) called a RaspberryPi and running the GNU/Linux distribution Raspbian. Works are contained on floppy disks and launched on insertion. To be more precise, each floppy contains the programmatic instructions so as to make the tiny computer behave in a certain way, and make use of some of all of its peripherals. This system therefore allows for a rather large range of possibilities, where the TGC can become anything from an audiovisual noise instrument to a poetry broadcasting device or spying and tracking camera. Last but not least, there is no default Internet connectivity on the TGC3, but local websites, stored on each floppy, can be accessed by connecting to the TGC3 local WiFi hotspot. This feature can be used to provide contextual documentation for the work, or publish browser-based art off the Internet.

Floppy

The setup of the Floppy is key in the functionality of the system. Below we have provided a map of the file and folder structure of your future floppy submission.

FLOPPY
├── LICENSE
├── main.pd
├── main.py
├── noweb
│   └── index.html
└── README

In the root of the Floppy disk there needs to contain a LICENSE and README text file, your initial code file(s) named either main.py or main.pd format, and a noweb folder containing local website files you wish to have accessible over the local hotspot. Any other files you may need can be arranged in any style you choose so long as you correctly reference them in your code.

Software

Contributions can be made in the form of Python scripts and applications, Pure Data (Pd) patches, JavaScript and static HTML and CSS written websites. Access to the various hardware peripherals can be made using standard Python modules and Pure Data externals, but also via the UNIX filesystem. The main inputs available to read from are the microphone, the camera, the electro-conductive touch pads, and the web interface. The main outputs to send data to are the audio speakers and the web interface. For instance one program, written with Python or Pd, could listen to the incoming sound amplitude captured from the microphone and generates graphics files to be loaded on a simple static website. The website could be visible on mobile devices connected to the TGC3 WiFi network, and a dedicated machine could video-project the website as well to create an interactive installation.

Examples

To give you an idea of the ability of the TGC3, we have provided some examples of possible submissions. You will find here basic setups to get you started and the inner workings of some current submissions to demonstrate the breadth of the possible complexity.

Pure Data

When working with Pure Data, depending on your desired output, there are some minimum requirements in your patch. Below is an example of some of the basic modules that you might want to use when starting your patch.

Basic PD setup for the TGC3

In this example you will notice a few modules that you might want to use. First of all to enable sound the sound engine you will need to place loadbang connected to pd dsp 1. This will initiate the sound engine on load which will allow for sound synthesis, and analysis. Also there is an example for interfacing with external code via network data like the Open Sound Control protocol using the netreceive object. Lastly you can see some basic sound output being generated via the osc~ (oscillator) object generating a tone at 440Hz, which is being made audible by going to the dac~ (digital to analogue converter) object.

The TGC3 can handle very complex patches. The following example is the inner workings of an interactive sound instrument that interfaces over OSC. In this case the netreceive object is replaced by the udpreceive object.

Franc's interactive PD patch for TGC3

You can see even in this patch the building blocks that remain from the basic example. Notice too the loadbang going to the metro (metronome) objects. This makes sure that the patch's functionality, launches along with the sound engine. Outside of the few modifications to the basic example, the patch's complexity only lies in between the input and output stages.

Python

As mentioned, you can also create submissions in python. Here we have provided an example of a basic python block that emits OSC messages to be picked up in Pure Data. However you do not have to interface with Pure Data, and can purely make your submission in Python.

#!/usr/bin/env python

import os, random, time

while True:
	freq = str(random.randint(0,10)*110)
	print(freq)
	os.system('echo "'+freq+';" | pdsend 3000')
	time.sleep(0.25)

In this example a random number is generated and then sent via the command line command pdsend on port 3000. You can see in the corresponding Pure Data patch (in the Pure Data section) that it is listening to this port for incoming signals. You may want to use python in the event that you want to interface with some of the hardware, like the camera, or command line tools, like espeak, available in the TGC3.

Here is an example of a submission that is built entirely in Python that calls command line applications for its audio output.

#! /usr/bin/env python
import re, subprocess, random, os
from time import sleep

devnull = open(os.devnull, 'w')

# requires: espeak and aplay (alsa-utils) to be installed

dic={
"narrator": "en-us",
"Pilot": "m4",
"Sensor": "m7",
"MC": "m2",
"Jag25": "m6",
"Unknown": "f1",
"Bam Bam 41": "m3",
"Safety Observer":"f3"
}

f=open("/media/floppy/transcripts-drone-attack.txt","r")
txt=f.readlines() 
p= re.compile(r"^(\d\d\:\d\d) \((.*?)\)\: (.*)") # regex for capturing groups: time, character, sentence
for line in txt:
        if p.findall(line):
                time,char,sentence = (p.findall(line))[0]
		voice=dic[char]
                # play time
                subprocess.call(["espeak", time +" "+char, "-v", dic['narrator'], "-p", "20"], stdout=devnull, stderr=devnull) # narrator speaks: time and character
                sleep(0.5) #short pause before sentence
                if "*expletive*" in sentence: #"*expletive*" in sentence is True:                   
                    sentence_parts=re.split(r"(\*\w+\*)", sentence)
                    for part in sentence_parts:
                        if part == '*expletive*':
                            subprocess.call(["aplay", '/media/floppy/swear.wav'], stdout=devnull, stderr=devnull)
                        else:
                            subprocess.call(["espeak", part, "-v", voice], stdout=devnull, stderr=devnull) # character speaks: his
                        sleep(float(random.randint(1,10))/100)
                else:
                    subprocess.call(["espeak", sentence, "-v", voice], stdout=devnull, stderr=devnull) # character speaks: his

                    # 
        else:   # line w/out time or character (narrator)
            subprocess.call(["espeak", line, "-v", dic['narrator'], "-p", "20"], stdout=devnull, stderr=devnull)
        sleep(1) # make pause after each text line

noweb

As the name suggests, the TGC3 is not connected to the Internet but does host local web content. You can utilise this feature in a variety of ways to either display documentation, static work, or function as an interface. So long as your index.html is situated within the noweb folder, it will be accessible when connected to the TGC3 hot-spot. Your nowebsite can be built in plain html, css, but can also incorporate (but is not limited to) javascript, and cgi.

Here the submission is controlled by .cgi code behind an interface built in html to trigger audio files.

<!DOCTYPE html>
<html>

<head>
<title> Rock Step - Triple Step - Triple Step </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

</head>
<body>

<h1> rock step - triple step - triple step </h1>

<form action="cgi-bin/play.cgi" class="buttons">
  <input type="submit" name="p" value="BasicTurn.mp3" />
  <input type="submit" name="p" value="Follow.mp3" />

  <input type="submit" name="p" value="AmericanSpin.mp3" />
  <input type="submit" name="p" value="Bump.mp3" />

  <input type="submit" name="p" value="StopAndGo.mp3" />
  <input type="submit" name="p" value="Windmill.mp3" />

  <input type="submit" name="p" value="SpanishArms.mp3" />
  <input type="submit" name="p" value="Hucklebuck.mp3" />

  <input type="submit" name="p" value="Whip.mp3" />
  <input type="submit" name="p" value="ChickenWalks.mp3" />
  <div class="tempo">
</form>

</body>
</html>
#!/usr/bin/env python

import cgi, os
import cgitb; cgitb.enable()
import subprocess

f = cgi.FieldStorage()
p = f.getvalue("p", "Bump.mp3")
p = os.path.join("voice", p)
out = subprocess.check_output(["mpv", p], cwd="/media/floppy/noweb", stderr=subprocess.STDOUT)

# print "Location: /index.html"
# print

print "Content-type:text/html; charset=utf-8"
print
print """<html>
<head>
<meta http-equiv="refresh" content="0;url=/index.html" />
</head>
<body>
</body>
</html>"""