{"id":156,"date":"2006-07-19T23:55:40","date_gmt":"2006-07-19T21:55:40","guid":{"rendered":"http:\/\/blogs.bl0rg.net\/netzstaub\/?p=156"},"modified":"2006-07-19T23:55:40","modified_gmt":"2006-07-19T21:55:40","slug":"processing-vj-application","status":"publish","type":"post","link":"https:\/\/blogs.bl0rg.net\/netzstaub\/2006\/07\/19\/processing-vj-application\/","title":{"rendered":"Processing VJ application"},"content":{"rendered":"<div align=\"center\"><img decoding=\"async\" alt=\"Alt Tag Added during WordPress Conversion\" src=\"http:\/\/blogs.bl0rg.net\/netzstaub\/images\/poly-shot1.png\" \/><\/div>\n<p>I wanted to have some sort of visuals going on for my next gig (which will be detroit-like techno improvisation<br \/>\nand maybe chillout-dub stuff at <a href=\"http:\/\/freiraumkultur.net\">this party<\/a>), searched a bit on the net and found all those<br \/>\nbeautiful processing sketches, which I could modify to sync to the MIDI coming out of my sequencer. This blog<br \/>\nposting will be a bit chaotic like all my posts, and sprinkled with code, but the main point is: I can load multiple<br \/>\nPApplets, sync them to the incoming MIDI in a simple way, and control everything out of the Ableton Live applicaiton<br \/>\nI use to play my music. You can basically take most processing sketches off the web, modify them slightly, and<br \/>\nrun them in the VJ application. You can get the code at svn co svn:\/\/bl0rg.net\/processing , or the (debug version) at<br \/>\n<a href=\"http:\/\/bl0rg.net\/~manuel\/polymaniac.tar.gz\">here<\/a> (run with java -jar Polymaniac.jar &#8211;standalone). This is a kind of alpha<br \/>\nrelease, it has not been tested really, but I will<br \/>\nin the next few days, and keep updating blog postings, and it&#8217;ll have to work until the 5th august anyway. The posting is<br \/>\nnow about how the application&#8217;s internals, and a kind of reference for me as I keep forgetting everything.<br \/>\nWhen you start the application using the &#8211;standalone switch, you can use the keyboard keys (qwerty layout) to trigger<br \/>\nmidi events. Top row is DRUM notes, middle row is BASS notes, lower row is EVENT notes). A few test applets are loaded, but<br \/>\npeek inside the setup() method of Polymaniac.java to load your own. I&#8217;ll add a dynamic ClassLoader in the next few days.<br \/>\nYou can switch to fullscreen using &#8220;f&#8221;.<\/p>\n<p><!--more--><\/p>\n<p>I first started to modify simple sketches, adding promidi support, but this quickly turned into a bigger endeavour<br \/>\nas I started to refactor code and make abstractions and stuff. The application is now called Polymaniac and is a standalone<br \/>\napplication (not started from the PDE). I quickly switched<br \/>\nover from PDE to eclipse for my development. The goal of Polymaniac is to be able to load existing sketches, and run<br \/>\nmultiple instances of them (either on top of each other, or as background, etc&#8230;). Furthermore, specific methods<br \/>\nout of those sketches can be controlled by MIDI (either using MIDI notes or MIDI controller data).<\/p>\n<p>\nSo for example you can write:\n<\/p>\n<pre>\nMidiApp baumApp = new BaumApp(this, midiHandler, baumReflection.getDefaultMappings());\naddForegroundApp(baumApp);\nmidiHandler.registerMidiAppNote(baumApp, \"addNode\", \"removeNode\", MidiHandler.MIDI_SYNTH_CHANNEL);\n<\/pre>\n<p>\nto create a sketch from the class BaumApp (a straight version of traer&#8217;s physics examples), add it as a foreground<br \/>\napplication (drawn on top of background applications), and map the method &#8220;addNode&#8221; of the newly created app<br \/>\nto any NOTE ON event on the midi synth channel (hardwired for my needs), and the &#8220;removeNode&#8221; to corresponding<br \/>\nNOTE OFF method. So playing a note will create a new node, and remove a node when the note stops.<\/p>\n<div align=\"center\"><img decoding=\"async\" alt=\"Alt Tag Added during WordPress Conversion\" src=\"http:\/\/blogs.bl0rg.net\/netzstaub\/images\/poly-shot2.png\" \/><\/div>\n<p>I started by hardwiring all the MIDImethods, but now I have a central hub (called MidiHandler) distributing incoming<br \/>\n events to registered<br \/>\nsketches. You can use java reflection to set up all this dynamically, and my going goal for the next version of<br \/>\nPolymaniac is to add a GUI with MIDI learn functionality (tweak a knob, click a sketch parameter, the parameter is now<br \/>\nassigned).<\/p>\n<p>The most complicated thing about Polymaniac is actually how the usual order of events of a processing sketch is modified.<br \/>\nFor now only applets using draw() are supported, and there may still be weirdo things going with certain renderings<br \/>\n(I have just tested a few sketches). The main application class Polymaniac is actually an instance of PApplet. It creates<br \/>\nan instance of MidiHandler to handle incoming midi notes, and sets up just like a normal sketch by calling setup(). However,<br \/>\nit keeps a list of foreground and background apps, which are instances of MidiApp and kept in the package bl0rg.vj.apps.<br \/>\nMidiApp is a special version of a PApplet. It draws offscreen. Actually, a MidiApp uses the PGraphics context of the polymaniac<br \/>\napplication to draw. However, this may not be desired in certain cases in which the sketch depends on the screen not being<br \/>\nredrawn (for example particles leaving trails). In this case, we must create a special PGraphics for the class, and copy the frame<br \/>\nof the MidiApp on top of the main frame of Polymaniac. This is done by calling setBuffered(true). This is used in the demo<br \/>\nLineApp for example, taking from processing.unlekker.net . setBuffered(true, RENDERER) may also be used to switch the renderer.<br \/>\nThe main Polymaniac renderer has to be JAVA2D for now, but you can add P3D applets (like for examples CirclesApp).<\/p>\n<p>Setting up parameters works by either modifiying the default mappings of classes at their instantiation, like for example<\/p>\n<pre>MidiApp baumApp = new BaumApp(this, midiHandler, new MidiAppMapping[] { \n\t\t\t\tnew MidiAppNoteMapping(\"blabla\", \"\", MidiHandler.MIDI_DRUM_CHANNEL, -1),\n\t\t\t\tnew MidiAppNoteMapping(\"blabla\", \"\", MidiHandler.MIDI_BASS_CHANNEL, -1) });\n\t\t\n<\/pre>\n<p>\nwhich will create baumApp with mapping blabla() to notes on the drum channel and the bass channel. Or later on by calling<br \/>\none of MidiHandler.midiRegister methods. I defined 4 channels on the midi device, but you can pretty easily change this (I&#8217;ll<br \/>\nadd switches and configuration parameters for that for the first real release). This way, you can use midi clips in ableton to<br \/>\nspecifically trigger visual stuff (using the MIDI_EVENT_CHANNEL), or by using the running midi clips (drums, etc&#8230;) to modify<br \/>\nspecial parameters. For example, each bass drum kick can switch the visible MidiApp, so you can have short subliminal animation<br \/>\nframes on the beat. A lot of cool things are possible this way, I haven&#8217;t began to really think about it, but the first impressions<br \/>\nwere awesome.<\/p>\n<div align=\"center\"><img decoding=\"async\" alt=\"Alt Tag Added during WordPress Conversion\" src=\"http:\/\/blogs.bl0rg.net\/netzstaub\/images\/poly-shot3.png\" \/><\/div>\n<p>You may have noticed that this comes with its own version of processing.core, that&#8217;s because I had to modify the existing<br \/>\nrenderers to be able to render a transparent backgorund, in case a buffered MidiApp wants to only add foreground elements. I<br \/>\nhad to modify the colorspace of the P3D model, and to add real transparent backgorund drawing in JAVA2D. I also added a quick<br \/>\nblit function for offscreen MidiApps in the JAVA2D renderer. Didn&#8217;t implement it in P3D yet.<\/p>\n<p>Another thing which doesn&#8217;t work yet is looping processing apps (not frame based), I&#8217;d have to start a new thread for each added<br \/>\napplet, so that will be added in the next few days too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to have some sort of visuals going on for my next gig (which will be detroit-like techno improvisation and maybe chillout-dub stuff at this party), searched a bit on the net and found all those beautiful processing sketches, &hellip; <a href=\"https:\/\/blogs.bl0rg.net\/netzstaub\/2006\/07\/19\/processing-vj-application\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,19],"tags":[],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-computerstaub","category-english"],"_links":{"self":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":0,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}