Fork It
You have the whole demo on your machine. Now break it. Everything below is just a nudge, not a recipe. Follow whatever you are curious about. Shout if you get stuck or have an idea you want help with. Show a neighbour when something works.
Keep building on the workflow you made in The Live Demo. If you missed a step, copy that exercise's workflow onto your canvas. For bigger finished projects to pull apart, see the Showcase: pose-driven visuals, a camera that follows you, and MilkDrop-style visualizers.
Swap a sensor
- Motion instead of sound. Replace the
Loudnessnode feedingamountwithMotionfrom the toolbox. Now the picture warps when you move. Don't forget to rescale it properly. - Position instead of the mouse. If you did Exercise 4, feed
Positioninto the uniform instead ofMouseMove.Positionis a point in pixels, so right-click it to selectXand rescale it first. A coloured object becomes the controller. - Two microphones, two numbers. Add a second
AudioCapturewith a differentDeviceNameand a second loudness chain. Drivetimefrom one andamountfrom the other. - The kit on the table. Exercise 9 reads one sensor and lights one LED. Swap it for a distance, touch or sound sensor, send its number into
amount, or drive a buzzer or a servo instead of the LED. Ask for a board if you have not got one.
The webcam and microphone are just the sensors every laptop already has. Bonsai talks to a huge range of others: Arduinos and anything you can wire to one (buttons, dials, light, distance, pressure, temperature), game controllers, MIDI and OSC devices, depth cameras, high-speed and machine-vision cameras, eye trackers, heart rate, breathing and brain activity sensors, and lab hardware built for timing to the millisecond. Many have a ready-made package in Tools > Manage Packages.
Change a transformation
- Before the GPU. Put
Canny,Threshold,SmoothorConvertColorbetweenImageandUpdateTexture. The shader warps whatever it is given. - Inside the GPU. Open
shaders/camera.fragfrom the workshop folder in a text editor. Try:- swapping
uv.xanduv.y - multiplying the colour by
vec3(1.0, 0.3, 0.3) - replacing the
sinwithabs(sin(...)) - adding a second ripple at a different frequency
- swapping
- Delay a stream. Put a
DelaybeforeUpdateUniformforamountand setDueTimeto00:00:00.5. The picture reacts half a second late. - Smooth it out. Add a
Bufferto collect the last 10 values from a stream, then add anAverage. Twitchy becomes swoopy.
Remap input to output
- Sound to sound. Add
AudioReaderwith a short sample andAudioPlayback. Trigger it whenMotioncrosses a value:GreaterThan, thenDistinctUntilChanged, thenCondition, then use the result to gate the playback. - Picture to picture. Draw
Positiononto the camera image withCirclebefore it goes to the texture. You are painting with the tracked object. - Everything to the shader.
camera.fragreads two uniforms. Add a third,uniform float hue;, use it in the colour, and drive it from whichever stream you like. - Out to the world. Exercise 10 sends two numbers to Ember Pulse. Send a third: the
XofPosition, rescaled to 0 to 1, to/spin, or the bass band from Exercise 14 to/zoom. Anything that speaks OSC (a DAW, TouchDesigner, Processing, a second Bonsai) can listen. - Machine to machine. Pair up with a neighbour and drive each other's pictures. Find your IP address (type
ipconfigin a Command Prompt) and swap. SetRemoteHostNameon yourCreateUdpClientto their address. On their side, aCreateUdpClientnamedInwithPort8000 listens;ReceiveMessageonIn, thenParsewithAddress/pulseandTypeTagf, turns your movement back into a number they can send into their own shader. If nothing arrives, the venue wifi may block it; a phone hotspot works.
Bigger
- Record the whole performance:
VideoWriteron the camera branch andAudioWriteron the microphone, started together. - Replace the webcam with
FileCaptureand a video file, and run the installation on footage instead of a live feed.
Keep the workflow. Everything you built today is a text file you can email, put on GitHub, or open on any Windows machine with Bonsai installed. The Bonsai documentation and the community forum are where to go next.