tisdag 9 mars 2010

Slut

Kursen är slut, och trots allt arbete blev bordet ganska enkelt till slut.

Visst hade produkten ett egenvärde i att vara relativt monolitisk, och black-box-artad. Man förstod inte riktigt vad man skulle göra, och besökarna på mässan tyckte att det var kul och roligt ett tag eller så. Men frågan är om de kom för skärmen eller för teet och kakorna :)

Bland annat pongspelet lyckades med en mycket intrikat interaktion med tämligen enkla medel - de hade inte ens behövt sina poängstaplar. Vårt bord blev betydligt enklare på det sättet.

Vi hamnade i "sensor-koma" två gånger under kursen. Dels för hypnosmaskinen, och delvis under bordsbyggandet. Att ha två olika sensorer för att detektera tekopparna var tämligen krångligt och i efterhand ganska ondödigt. Mycket hade kunnat göras med bara fotosensorer (faktum var att man med finurlig programmering hade kunnat läsa av otroligt mycket med dem).

Nåja, det var bara prototyper. Jag har lärt mig väldigt mycket, som jag trodde att jag redan kunde, det var en befrielse att äntligen få hålla på med arduino och liknande.

Vad hade jag gjort annorlunda till nästa gång? Jag hade tittat ännu mer på vilken interaktion som varit önskvärd, och gjort ordenliga skisser redan från början, vi började någonstans och sedan såg vi vad det blev. Att vi var tre i gruppen, med lite olika önskemål, gjorde också sitt till för att få en sammanhängade tanke bakom det hela.

Intryck och upplevelse
Effekter då? Fick man en bra upplevelse? Jag upplevde att skärmen var svår att arbeta med på ett sätt, vi hade stora problem med att hitta motiv som inte kom upp och ner för en av användarna. Det problemet förekommer ju inte i datordesign som den ser ut idag (eftersom att alla ser skärmen med samma orientering). Hur det skulle användas på ett kreativt sätt var svårt. Vi försökte dels med symmetriska motiv, och dels med sådana som syntes uppifrån.

En av de mest intressanta applikationerna var att visa bilder från en webkamera i bordet. Att ha en dedikerad maskin som inte riktigt är en dator som man känner till den, som visar bilder någon annanstans, det kändes lite magiskt. Vi provfikade bordet samtidigt som vi filmade ut mot Valhallavägen, och blev efter en stund varse bussar och små människor, trafikens växlingar, fåglar som flög och annat man vanligtvis inte ser.

Det vore fantastiskt spännande att göra mer genomtänkt implementation med det innehållet - alltså bilder utifrån. I synnerhet i rum med dålig utsikt.

Tekniska lösningar
Att använda olika programmeringsspråk och utvecklingsmiljöer var ett visst problem. Genom att vara väldigt van vid Processing tog jag mycket av programmeringsarbetet, vilket gjorde uppgiften på ett bra sätt.

Att använda Arduino var också väldigt bra, den känns ganska robust, och vi använde Firmata, och kunde ganska enkelt debugga och konfigurera med ett exempelprogram för debugging som följde med i arduinobiblioteket.

Sensorerna tejpades och löddes hejvilt. Det blev bra till slut. Vi upptäckte att man egentligen hade kunnat dektera mycket mer med bara fotocellerna, medans värmesensorerna var mycket långsammare i att "svara".

Det var vissa problem med att programmera på dedikerad hårdvara. Bara en dator var konfigurerad för ändamålet, vilket gjorde det svårt för andra att få någon direkt känsla för den till slut ganska röriga koden.

Det finns stor kommersialiseringspotential i sådana här saker.

Bilder och mer kommer.

måndag 1 mars 2010

Bordet nästan klart - för mycket sensorer


Hidden and forgotten underside of the table. Screen + breadboard + arduino.
Another groups marvellous artwork. I love it.
Our table in action, a self laying puzzle! You can se the two magic cup-places, and the screen with the pussle "Afrika".

The table did also work as a workspace for the project, very practical. It was nice for the other teammembers to see and discuss the same source code as the one programming. That made the programming faster.






I helgen programmerade jag e bildbytesalgoritm för bordet. Den kan ta serier av bilder (tio i varje) och växla mellan dem genom transparens och så.

Idag lyckades vi få till det så att den blev temperaturkänslig och faktiskt kunde känna av om det stod koppar eller inte på bordet.

Vi la även till en snygg bordsduk och ett antal nya serier.

Från början var tanken att man skulle få upp citat på bordet, så att man kunde diskutera kring dem. Det verkar numera vara möjligt, och Johan byggde några snygga citat här på kvällskvisten.

Det var betydligt svårare än jag trodde att få programmeringen hyffsad. Interaktionen är ganska bra, men det är alltid en avvägning om den är för snabb eller för långsam. Några användartestar har vi inte hunnit med, förutom att prova bordet själva - vilket har varit mycket mycket lärorikt. Så fort man ställer undan datorn det kör på, märker man vilken dålig kontroll man har, och vilka brister som finns. Interaktionsmöjligheterna är ju dessutom verkligen små.

Om man är lite efterklok skulle man kunna ha tidsinställt allt, så att det enda som spelade in på vilka bilder som visades är hur länge kaffekopparna har stått på ett ställe - det är egentligen det enda viktiga. Alltså har vi gjort en hel del i onödan, kanske för att vi inte prototypade ordentligt innan. Då hade vi kanske kommit fram till att den funktionalitet vi ville ha, egentligen bara krävde ljus-känsliga sensorer idag.

Bildvisningen är inte heller optimal - transparensen gör att bilderna liksom försvinner iväg mellan varven. Det duger för en prototyp, dock. Hade jag gjort bordet igen, hade jag nog bara använt ljus-sensorer.

Redovisningen ska vi arbeta hårt med, den kan göras väldigt bra.

De andra grupperna hade väldigt ambitiösa byggen, och nästan alla var betydligt större än vårt. Kanonen var nog ett av de mest spännande, med tanke på hur enkelt det egentligen var. Pongspelet hade en elegant enkelhet (vi diskuterade att man skulle kunna implementera det på vårt kaffebord också, genom att låta racketet åka uppåt när det var ljus, och ner när det var mörkt).

Apropå galna extraimplementationer, har vi diskuterat otroliga mängder saker man fakitskt kan göra med bordet, allt från spel till väldigt platsspecifika roliga saker, till exempel att det springer runt en mus och äter ost, eftersom det finns ett litet "råtthål" vid skärmen för att kunna slå på skärmen.

Tyvärr har vi inte fått med minnesfunktionen - att när det fanns koppar på bordet, skulle det byggas upp någon typ kristall i närheten av den koppen, så att bordet kunde fungera som en historia - och berätta vad som hänt tidigare under dagen.

onsdag 24 februari 2010

halvfärdigt bord


Bord med skärm - rolig idé, men inte så ergonomiskt för Jonas.
Provar temuggsdetektor.



Efter vår session igår, när vi gjorde skärmen i bordet (bilder kommer), blev jag helt förhäxad av att man kunde använda bordet för att visa bilder. Bilderna fick en helt annan närvaro när de visades liggandes på bordet av någon anledning.

Vi satte in fotosensorer och värmesensorer i bordet, som är kopplade till en arduino som sedan är kopplat till processing.

Efter en kort brainstorming kom vi fram till att bordet ska känna av om någon ställer en kopp på bordet och då börja visa en bildserie. Bildserien ska sedan gå framåt ju varmare sensorerna blir. Om man ställer på bara en kopp, får man se ungefär halva serien, om två koppar får man se hela.

När sensorerna svalnar igen går "filmen" baklänges.

Arbetar på att få till kul saker att visa och göra en enkel bildbytare i Processing.

måndag 22 februari 2010

A hole in the table

Today I saw what my projekt mates had decided and programmed during the week away.

A really good job, with some really nice processing code that morphed in and out a text, and fun interface based on heat and simple object detection with photocells.

Today we essentially just made a about A4-sized hole in a table bought by Johan and a screen also brought by Johan. Really good job of him to buy it.

I'm really happy my project mates didn't use my idea of using a medusa lamp, because that would not bring good interaction in a simple way. I have to explore the medusa lamp interaction system further, but with another project.

We had good help from elab with drills and so on for making the hole. Unfortunantley they didn't have a "stich saw" (sticksåg) which made it nescessary to use a drill and saws in a creative way. We missed some holes for the On-button for the screen - embarrasing. Luckily we can go drill tomorrow as well.

Tomorrow we will maybe paint the table (but where?) and make sure the interaction works as expected.

We also have problems with configuring the sensors to map well to the program (especially since the light condition "always" changes, depending on the position and so on). I will investigate a way to dynamically adjust the "strengt" of the "light" by some simple integration method from control theory. The main problem seems to be to detect when a photocell is covered (and hence not should be integrated to compensate) and when a photocell is open to the light. We need to explore that with some different dataseries. Hopefully some processing and controlled experiments can give answers to good limits. This is engineering!

måndag 8 februari 2010

two entries for the main blog

I made two entries for the main course blog, one about photosynth, and one about the interesting libavg.

onsdag 3 februari 2010

Dagsrapport 3 feb







Genomgångar av Arduino och lite elektronik.

I jämförelse med Phidgets tycker jag att Arduino verkar vara en dröm att programmera. Men den har andra problem. Till exempel stötte vi direkt på patrull när vi ville överföra flera data på en gång från Arduinon till datorn. Direkt måste man börja ta hänsyn till vilken datatyp det är etc.

Kanske är Firmata något för oss.


Böjsensorer genom spänningsdelare (1 k motstånd) in i Arduinon. Bara ett av motstånden används!

Böjsensoroutput i processing (utgick från potentionmeter-exempel från Arduinos hemsida)


Arduino inkopplad. Bara ett av motstånden används!

Exempel (med dåligt ljud) som visar det hela in action.

Dagens källkod:

Arduino
/*
Graph
A simple example of communication from the Arduino board to the computer:
the value of analog input 0 is sent out the serial port. We call this "serial"
communication because the connection appears to both the Arduino and the
computer as a serial port, even though it may actually use
a USB cable. Bytes are sent one after another (serially) from the Arduino
to the computer.
You can use the Arduino serial monitor to view the sent data, or it can
be read by Processing, PD, Max/MSP, or any other program capable of reading
data from a serial port. The Processing code below graphs the data received
so you can see the value of the analog input changing over time.
The circuit:
Any analog input sensor is attached to analog in pin 0.
created 2006
by David A. Mellis
modified 14 Apr 2009
by Tom Igoe and Scott Fitzgerald

*/


void setup() {
// initialize the serial communication:
Serial.begin(9600);
}
void loop() {
// send the value of analog input 0:
Serial.println(analogRead(3));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(100);
}

Processing:
Instansierar en sinusoscillator och ritar grafen på skärmen. Vid varje serial-event uppdaterar den kurvhöjd och sätter frekvensen på skärmen.

// Graphing sketch


// This program takes ASCII-encoded strings
// from the serial port at 9600 baud and graphs them. It expects values in the
// range 0 to 1023, followed by a newline, or newline and carriage return

// Created 20 Apr 2005
// Updated 18 Jan 2008
// by Tom Igoe

import processing.serial.*;

Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph


// SOUND:

import ddf.minim.*;
import ddf.minim.signals.*;
Minim minim;
AudioOutput out;
SineWave sine;

void setup () {
// set the window size:
size(400, 300);

// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0);
//sound
minim = new Minim(this);
// get a line out from Minim, default bufferSize is 1024, default sample rate is 44100, bit depth is 16
out = minim.getLineOut(Minim.STEREO);
// create a sine wave Oscillator, set to 440 Hz, at 0.5 amplitude, sample rate from line out
sine = new SineWave(440, 0.5, out.sampleRate());
// set the portamento speed on the oscillator to 200 milliseconds
sine.portamento(200);
// add the oscillator to the line out
out.addSignal(sine);
}
void draw () {
// everything happens in the serialEvent()
}

void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');

if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);

// draw the line:
stroke(127,34,255);
line(xPos, height, xPos,map(inByte,9,34,0,height));
//System.out.println(inByte);
float freq = map(inByte, 9,34, 1500, 60);
sine.setFreq(freq);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
}
else {
// increment the horizontal position:
xPos++;
}
}

}

void stop()
{
out.close();
minim.stop();
super.stop();
}


MIDI from Processing to Ableton Live!


There was success! I can now send MIDI messages from Processing to Ableton Live.
I use the MidiBus for Processing, which had some basic example that got me started, and the internal Midi loopback device in Mac OS X (called busses, reachable from Applications/Utilities/Sound and Midi. It's just to go into the Midi View through the Window menu and be sure that the IAC-driver is enabled, like in the picture.

Then it's just to enable that midi-input as a Track (or remote) in Ableton.

The Basic.pde, that followed midibus, shows the following devices:

Available MIDI Devices:
----------Input----------
[0] "Buss 1"
[1] "Port 1"
[2] "Real Time Sequencer"
----------Output----------
[0] "Buss 1"
[1] "Port 1"
[2] "Real Time Sequencer"
[3] "Java Sound Synthesizer"
If i initialize the midi-object with the Buss1 as output, I can speak to Live with midi!

I found a handy midi-reference (but then I know midi from before quite well). This one is on bit-level. This one is also on bitlevel, and is the Midis own.

However, there are some problems involved in handling midi-events. First and foremost: Notes have to be turned of. This can be solved by using some kind of queue for all the events. A more serious problem is that every program handles midi in different ways - after all, it has very rudimentary "data types" - notes on, control changes and patch-changes.

This can be overcomed by making a special setup in Live, which always is loaded when one want to work with the prototype. That's acceptable.

Now - it's just to start working! :)

Interface of wireless router


It would be nice to have a better interface to a wireless router. In a seminar I heard someone had checked that, and they had checked in peoples home how they used the routers - they even hid them behind their radiators to get rid of them (with overheating as a problem). I'm not satisfied with my own either. It's there, taking up space and an electrical outlet.

It would also be much better to be able to control the elementary functions with switches instead of an interface. That way, you don't need network cables attached to be able to configure it. Maybe switches and buttons, and a little window displaying the wifi-password.

That contradicts the possible to hide it away, though...



Midicontrollerideas from Arduino seminar



http://itp.nyu.edu/physcomp/Labs/MIDIOutput

A very easy way to implement MIDI with Arduino! Maybe I could build a pattern trigger for Ableton Live. It would look like a little matrix of buttons to make an analogue to the pattern trigger in Live.

This is mostly a copy of the Akai APC20, so it's probably cheaper to buy one, though-


What else can one do with a similar setup? Maybe a more probable patterntrigger? Something you could keep laying around on you desktop? Or put on your synthesizer or guitar? Something for loop-based performance?

Maybe something with servos? Or flexsensors?

tisdag 2 februari 2010

The language hunt

To be able to express oneself in a good way, one need a good language. After reading Paul Grahams book "Hackers and Painters", I got quite overwhelmed by the idea about how a language should be to be good. He is talking about efficiency and endours Lisp, a quite theoretical but also quite pragmatic language. Even though it's very efficient in many ways, it has some severe losses, one of them is the libraries and coherent support for such things as threads.

I've been trying with the implementation Clojure a bit, but it's actually been a bit abstract so far. However, when I start programming Java, I feel restricted in some sence.

An intrestng speach by Rich Hickney, the creator of Clojure.

Ericsson, the famous telephone company, developed a language Erlang. Their main focus was reliability and "updateability", and that's really what you get. When most programs needs to be restarted, or, in the case of windows or mac os, often be rebooted, Erland can change the program while it's running. No downtime whatsoever.

http://ftp.sunet.se/pub/lang/erlang/about.html


Feedback-pan-test




And the day after, I tried it with pans (which was a possibility I found by systematicly exploring the design space of materials to build the lear-synthesizer with, everything from porcelain to tin foil was on that list).

A quite different result compared to my hand-test. It was hard to shape the resonance in the way needed to express different tones. The pans actually worked better for dub-delay-effect typed sounds, and was quite hard to be able to resonate in different tones, even tough I used a resonator. It was hard to "find" the tones.

It would be highly intressting to test it on some more appropiate form, a trumpet, for example.

The setup is that my built in microphone records the sound coming out of the loudspeakers, filters it, delays it because of latency and sends it out.



The chain is Mic->Saturator (distoritive amplifier) -> Resonator (narrow banded musical eq) -> Compressor with high ratio/limiter -> Speaker (mic)


Feedback-hand-test

I couldn't resist to test how the feedback could be handcontrolled. Starring: My hand, my computer and Ableton live 7.

It took some amount of time to able to choose between tones, the possibility to control the sound is rather limited with only the hand as reflector.


Phidgetmania





Dagens hacking var inte särskillt produktiv. Vi hittade först inte servo-controller-kortet, och letade desperat efter lösningar. Jonas anslöt sig till gruppen, så nu var vi fyra personer. Alldeles för många för att kunna göra arbete produktivt - det verkar nästan om att effektiviteten är omvänt proportionell mot antalet personer i gruppen.

Vi ville detektera närvaro, att en person var närvarande, och detta genom en trycksensor. Tyvärr var det omöjligt att processing att fungera med två olika phidgetkort anslutna, samtidigt som webkameran var igång. Programmet gav mycket svårdiagnogstiserade spårutskrifter, och krashade då och då. Vi förbannade java-threadsen, och jag undrar i mitt stilla sinne om det verkligen inte finns ett bättre sätt att programmera interaktion. Nåja, det var ett skissprogram, och fungerade som ett sådant.

Redovisningen gick väl ganska bra, men många andra hade nästan mer fantastifulla och fina prototyper, det var faktiskt mycket hög klass på dem.

Lärdomar
  • Ha inte för stor grupp
  • Boka undan det som behövs
  • Använd inte för många sensorer/tekniker på en gång
  • Använd Eclipse (kanske?) för bättre tillgång till olika bibliotek
  • Planera för interaktionen och avsätt tid för att konfigurera den ordentligt
Det sista är väl att vi missade att faktiskt konfigurera interaktionen.

Jag ser mig om efter ett annat programmeringsspråk än Java, eftersom att jag tycker att det är för babbligt. Det tar många sidor kod att beskriva det man egentligen ville skriva på ett fåtal rader. Självklart går det ut över det färdiga resultatet. Kanske är Python bättre.


måndag 1 februari 2010

Brain wave sensors

Google: Brain wave sensor

gave some intresting results:

Brainwave Sensor Headsets Control Computers, Mobile Phones or Games using Thoughts & Emotions in Mind


"NeuroSky is a technology, reports MyTreo, that captures a person’s brainwave signals, eye movements, and other bio-signals via a patented Dry-Active sensor headset allowing users to control a computer or a mobile device with thoughts in the mind."

"During a keynote presentation at the conference, Ambient’s Callahan demonstrated this technology by using the device to place the world’s first voiceless cellphone call to Mike Hames, a TI senior vice president. The Audeo can send information to a mobile phone using Bluetooth. The company has also successfully controlled a wheelchair without the need of physical movementagain using brain signals. Ambient expects its first product to enable speech for individuals with ALS will be available before the end of 2008. More information can be found at http://www.theaudeo.com."

Now that's cool.

Let's see what we can do with it. It would be awesome to be able to connect to someone in a "non-intrusiv way" and say hello to them. The sexual posibilities of this is not be underestimated. Porno industry have been very innovative. Very.

lördag 30 januari 2010

Localization of sound

Just note to self:

for 3D-sound placement with 4 microphones.

Need better understanding of cross-correlation.

Maybe one could use really simple mics and place them on a table. It's almost only time-difference that matters. 2D-case is much simpler.

fredag 29 januari 2010

Lear synth conceptual sketch




Let me introduce the Lear Synth, a collaborative soundscape-synthesizer. The synthesizer is furniture sized, and have a lot of different cavities, with a slight similarity of an ear.

Loudspeakers and microphones are placed in the cavities and the sound is generated partly by the cavities shaping the sound, and partly the digital signal processing in the built-in computer.

The sound is affected and shaped by placing bodyparts or other objects in the cavities and thereby changing the geometry and resonance in the cavities.



The sound experience gets richer than with headphones or stereo speakers since the different sound sources are heard on their own.

Alternative ways of interacting with sound

When I was young, I tried to build a modular syntesizer, one there one could make any sound imaginable (for a really crazy modular, check out extensive interview with Joe Paradiso, MIT).

However, you want quality knobs, and they costs like 60 kr/each, complete with knobs, frontplates and so on. The whole case would be very expensive and actually, you need a lot of knobs. And the syntesizer would not start to be fun until you had at least a half dozen effects and generators. That would be a huge investment. And since I had some nice softwares at hand, the interaction part would be the more important than the sound genereating one (since that could be solved in my computer).

I actually sketched at least a hundred sketches of interaction possibilities, some optical, some knobs and others even more freaked out (inspired by the group 8Tunnel2, who made music by slicing broccoli with electronic knifes...).

The light interaction part was really fruitful. Light is easy to mix (an important property), and can be led in plastic fibers, leds and photosensors are indeed unexpensive. It can also have different colors, and be filtered through colored plastic. It's also visible, nondangerous and can be shut of by a hand or any non-transparent object. Building gain-like things would be very easy (especially compared to the knobs). Negative aspects is that it can not be "negative" in an easy way, you cannot show negative voltages with light (because that would be the negative absence of light). You need some kind of microphones to convert light to electricity and "sound" again (in my world, all sound is electric, loudspeakers are usually not that intresting to me).

However, I eventually realized that the ac in the walls would put a nice 50 Hz "light hum" through light bulbs in all the sounds if the box wheren't totally sealed. However, one could work with it bit more. I will explore it further.

Hypnosis 2000


Idag får det bli svenska.

När jag kom till lektionen, hade alla redan börjat. Jag tog min dator (hur skulle jag klara mig utan dator) och började pyssla med phidget-servona. Jag insåg att jag aldrig någonsin ägnat mig åt kontrollerade stegmotorer. Det är en ganska dyr alternativt krånglig teknik för hemmapulare, eftersom att man behöver både DACar och mikrokontrollers, och om man ska implementera dem från scratch behövs dessutom ett hum om reglerteknik och induktiva laster, vilket inte är så enkelt.

Nåväl, tack och lov fick jag igång ett java-program, som SimpleServo.java, som kunde ställa ut motorn och vrida den. Programmet krashade en smula då det försökte ställa motorn för långt.

Jag kom att tänka på att det vore roligt att bygga en hypnosmaskin, Austin Powers och sedan den absurda karaktären Percy Nilegård kom upp i mitt inre:


Och titta vad han har i handen! En hypnosmaskin! Man kunde helt enkelt göra liknande spiralmönstrade plattor och sätta på servomotorn. När någon kom i närheten kunde den börja snurra och datorn som styrde den kunde spela upp hypotiserande Sirensång och datorn kunde genom en lugn röst styra människor i sin omgivning. Bra idé!

Johan och Anna anslöt. Eftersom att datorn var min och ingen av dem kan Mac särskilt bra fortsatte jag att vara datoroperatör. Jag är ganska bra på det också, det är väl inget konstigt, men jag insåg att det var ganska svårt att programmera med som sitter bredvid. Ofta ville de kolla referenser, och så, när jag ville programmera. Nåja, det gick bra, även om det måste varit väldigt tråkigt för dem att titta på när andra jobbar.

Det gick i alla fall framåt. Vi diskuterade min idé, hypnotisören, och hur man skulle kunna kontrollera människor - till exempel genom att titta hur mycket de rörde sig genom att filma dem med en kamera. Om de rörde sig skulle de sägas åt att stå stilla. Datorn som befallare.

Interaktionsdesignern kom förbi och pratade om hjärnvågor och så, för att genom dem kunna beräkna vad en människa höll på med. Jag har inte gått vidare med den idén riktigt, eftersom att jag inte har någon bra idé på hur man skulle göra.

Ett problem var att vi både behövde se till att personen stod still framför kameran, men samtidigt inte "försvann" och maskinen fortsatte sin hypnos i onödan. En IR-sensor, värme eller en ljusstråle som bröts skulle kunna lösa problemet.

Diskussionsgenomgång med hela klassen. Intressant att höra de andras idéer, men extra roligt att höra att hypnosmaskinen var något helt nytt. Anna berättade om pendeln, vilket var en fullkomligt lysande idé. Anna var tvungen att gå på något ärende, och jag och Johan implementerade pendeln, med hjälp av ett bit sladd och en vikt.

Genom formeln 2*pi*sqrt(L/g) fick vi fram periodtiden, vilken vi implementerade i servot, så att den slog fram och tillbaka i rätt takt. Inget utjämnande, den går från 10° till 30° i dagsläget, vilket var tillräckligt bra för att vikten skulle börja pendla bra.

Intressant var när vi hängde upp pendeln i taket, och satte igång maskineriet. Folk tittade förbluffat på pendeln. Uppenbarligen fungerar maskinen bättre än vi vågade hoppas.

Vi hittade en algoritm för motion detection i processing på http://www.learningprocessing.com/examples/chapter-16/example-16-13/ som vi blev väldigt nöjda med, vi lade till en räknare som räknade alla svarta pixlar för varje bildruta, och det blev bara svarta pixlar när det var en stor förändring i bilden. Det blev tillräckligt bra. Genom en finurlig medelvärdesalgoritm kunde vi säga när personen rörde sig för mycket.

Det återstod bara att koppla ihop webkamera-applikationen (processing) och servokontrollen (java). Efter att försökt använda processing-kärnan i java men gett upp, lyckades vi, genom att Johan förstod att vi behövde fånga exceptions, och Anna som förstod att vi var tvugna att bygga allt som objekt och jag som förstod att vi behövde threads för att inte bli knäppa vid implementationen. Till slut fungerade det! Vi kopplade det till en början bara till att servot rörde sig när man rörde på sig i kameran, och bara det var en verkligt rolig applikation.

När man satt framför datorn kunde man alltså gunga och så började pendeln också gunga. Fantastiskt roligt. Så långt kom vi idag.

Här är några bilder:







Och en film:


Man ser i tur och ordning datorn med en skymt av motion-detection-programmet och sedan pendeln.

Här är källoden för programmet också (fungerar på macbook, annars måste man göra något åt kamera-raden, antagligen):

import processing.video.*;
import com.phidgets.*;
import com.phidgets.event.*;

float lengthofpendulum = 0.55; // meter!
int periodtime = int( 1000 * 2 * PI * sqrt ( lengthofpendulum / 9.82)); // milliseconds!

Capture video; // Variable for capture device
PImage prevFrame; // Previous Frame

float threshold = 70; //// How different must a pixel be to be a "motion" pixel
int movtresh = 50; //how many frames that need motion detected to be able to move
int movement=0; //increases when a videoframe have a lot of black dots (have been moved)

int blackthreshold = 4000; //how many black pixels are nescessary befor


// Create the object with the run() method
Runnable runnable = new PendelThread();

// Create the thread supplying it with the runnable object
Thread pendelthread = new Thread(runnable);

//Thread controlthread = new Thread(controller);

// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com

// Example 16-13: Simple motion detection

void setup() {
size(320,240);
video = new Capture(this, width, height, 30);
// Create an empty image the same size as the video
prevFrame = createImage(video.width,video.height,RGB);
pendelthread.start();
}

void draw() {

// Capture video
if (video.available()) {
// Save previous frame for motion detection!!
prevFrame.copy(video,0,0,video.width,video.height,0,0,video.width,video.height); // Before we read the new frame, we always save the previous frame for comparison!
prevFrame.updatePixels();
video.read();
}

loadPixels();
video.loadPixels();
prevFrame.loadPixels();
long blackamt = 0; //reset the black-counter between every frameupdate
// Begin loop to walk through every pixel
for (int x = 0; x <>
for (int y = 0; y <>

int loc = x + y*video.width; // Step 1, what is the 1D pixel location
color current = video.pixels[loc]; // Step 2, what is the current color
color previous = prevFrame.pixels[loc]; // Step 3, what is the previous color

// Step 4, compare colors (previous vs. current)
float r1 = red(current);
float g1 = green(current);
float b1 = blue(current);
float r2 = red(previous);
float g2 = green(previous);
float b2 = blue(previous);
float diff = dist(r1,g1,b1,r2,g2,b2);

// Step 5, How different are the colors?
// If the color at that pixel has changed, then there is motion at that pixel.
if (diff > threshold) {
// If motion, display black
pixels[loc] = color(0);
blackamt++;

}
else {
// If not, display white
pixels[loc] = color(255);
}
}
if (blackamt > blackthreshold) {
movement++; //if we hade over
}
}
updatePixels();
//println(blackamt); //DEBUG: how many black pixels are there?
}



// Start the thread

class PendelThread implements Runnable {

void run() {
println("Pendel: Pendel starta");
// This method is called when the thread runs
//här ska koden ligga
try { //because listeners can throw phidgetexception, which must handled by processing. //simple solution
ServoPhidget servo;
System.out.println(Phidget.getLibraryVersion());
servo = new ServoPhidget();
servo.addAttachListener(new AttachListener() {
public void attached(AttachEvent ae) {
System.out.println("attachment of " + ae);
}
}
);

servo.addDetachListener(new DetachListener() {
public void detached(DetachEvent ae) {
System.out.println("detachment of " + ae);
}
}
);

servo.addErrorListener(new ErrorListener() {
public void error(ErrorEvent ee) {
System.out.println("error event for " + ee);
}
}
);

servo.addServoPositionChangeListener(new ServoPositionChangeListener()
{
public void servoPositionChanged(ServoPositionChangeEvent oe)
{
System.out.println(oe);
}
}
);

servo.openAny();
System.out.println("waiting for Servo attachment...");
servo.waitForAttachment();
System.out.println("Serial: " + servo.getSerialNumber());
System.out.println("Servos: " + servo.getMotorCount());
servo.setPosition(0,0);
Thread.sleep(1000);
int pos=10;
while (true) //isch ok
{
println("Gungar!");
if (pos==10 && movement > movtresh){
pos=30;
servo.setPosition(0,90);
}
else if (movement > movtresh) {
pos=10;
servo.setPosition(0,10);
}
movement = 0;
//servo.setPosition(0, i);
Thread.sleep(periodtime);
System.out.println("Position: " + servo.getPosition(0));
}
/*System.out.println("Outputting events. Input to stop.");
System.in.read();
servo.setPosition(0, 0);
System.out.print("closing...");
servo.close();
servo = null;
System.out.println(" ok");*/
}
catch (Exception e) {
println("fel!");
}
}
}

torsdag 28 januari 2010

Regarding control of modern sounds

Electronically generated music have been around for more than a century. From Léon Theremin's hand played theremin, where the player controlls the sound by manipulating the capacitance between his body and the antenna of the instrument, resulting in beating between two radio frequency oscillators) to the most modern highly evolved musical hardware, ie Elektrons Machinedrum, and the totally spaced out Eigenharp and eventually the total transitation into the software domain, with for example Native Instruments Reaktor where soundcapabilities is way beyond imagination.

The possibilities for electronic music making have exploded during the last years. But still people pay excessively high prices for the actual music hardware. The sonicly quite limited Roland SH-101 is still selled for prices well over 6000 SEK (which is probably more than it costed originally). How come?

If you ever have had the pleasure of playing a subtractive analogue synthesizer, with all the knobs, arpeggiators and such thing (or a modern equivalent) you know you quickly gets totally stunned by the high degree of control you can have. The direct feedback from the sound must be experienced to be understood.

Which are the factors for this experience? I see several factors:
  • the constraing of price have forced the designers to chose a simple, yet general architechture
  • a few (not many) quirks in the architechture gives important character to the instrument, which are often discussed and loved among the users (some parameter that can be driven out of range, a special distortion when driven to loud, a sinus tone coming from the resonance filter).
  • the parameters range and scales are carefully chosen, for good precision when using the knobs and other controllers
  • the non-chaning spatial mapping to parameters in the sound gives the possibility to predict how a sound probably will sound, which is gotten from experience.
  • A fairly straight forward architechture, with not too many uncontrolled feedback loops (this is not true for modulars).
  • constraint in how many tones can be played, sometimes monophone
  • a very responsive instrument ("infinitley fast", low latency)
During the 90ties (80-talet in swedish), the digital technology came and actually destroyed most of the usability in the previous analogue instruments. This was mainly because of cost and engineering effiency. Buttons are cheaper and even easier to program than knobs (which are very analogue). However, by reducing the previously very inituitive, and organic method of shaping sound, both the model (non-inituitive FM-synthesis, wavetables) and the interface (buttons and abstract parameters and choosable models) rendered the soundprogramming to some kind of black art. The sounds were also percepted as more harsh and metallic, which is to expect because of the richer and more complex overtones.

This can be heard in the songs as well - the arrangements are more complex (because of the increased amount of polyphony and different timbres played at once), but the sound went in a sense more strict and repeating, probably beacuse the sequencers of the time made it harder to get a less perfect sound. The use of samples gave a new touch to the music, but it was still often not as organic as with the old analogue synthesizers.

After around 1994 everything went crazy, and, among others, the swedish company Clavia introduced the Nord Lead (pictured above), a digital synthesizer with analogue knobs that worked as an analogue synthesizer, and the music production changed totally again, and techno and more esoteric electronic music like did get widely spread, like.

Artists like Aphex Twin made song like Isopropohlex (in Spotify playlist), which is has a very simple "melody", but all the sounds in the song evolve very intensive. This would have been impossible to do in the 90-ties without a very large and expensive analogue modularsynthesizer.

Do you remeber the Trance music from around 2002? This evolved from the gated patterned arpeggio of the Access Virus synthesizer, which eventuallty moved straight into the software realm. Nowadays the electronic music have diffused into most of modern radio productions (Röyksopp - Girl and the robot, among many others, just look at the swedish eurovision song contest).

It's stunning to see what deep impact the music hardware (and software) have on the music created. When new features arrive, they are of course used in new creative ways, and old ways of using the instruments can get out fashion quickly.

Here is a video of the japanse artist Denkitribe using two quite small instruments (the Korg ER-1 drum machine and the Clavia Micro Modular) for a quite catchy tune.

The basics, the history

My name is Linus Ericsson, I study Engineering Physics, Teknisk Fysik, although I have been fiddling around with computers and electronics from when I was about 9 years old. I sometimes wonder how it would be if I got into the physical interaction design course already then...

I won an iPod shuffle yesterday, in a short workshop at Excitera innovation challenge. It was something about P2P-networks between mobiles, and possible uses of them, I suggested that one could use it for transmitting subversive information among dissidents in totalarian states. The problem was not mine, since I lunched with Erik Jennische, who works as some kind of assistant to the policitican Madeleine Sjöstedt in the Stockholm City hall. Erik traveled to Cuba and handed out books about things like economic theory, free speach, democrazy and more, since the government keeps its power through restricting information. The books were passed on 100 times and more!

P2P network on the mobile phones would solve the problem of copying the information (a laser printer does not work on Cuba of mainly logistical reasons). There are still other problems as well. The government probably likes to forbid things with these features.

Technology changes societys. People with power but without technology always fears that.