Friday, October 18, 2013

Clonal Colonies at Seeing Sound Symposium

Clonal Colonies will be screened at this year's Seeing Sound Symposium at Bath Spa University, running the 23rd and 24th of November, 2013. The programme will include a new collaborative work by animation pioneer Larry Cuba and choreographer Yolande Yorke-Edgell, screenings of classic Whitney brothers films, live audiovisual performance, papers, and more…

Sunday, September 29, 2013

Clonal Colonies Receives First Prize, Fresh Minds 2012-13

My audiovisual composition Clonal Colonies received First Prize last week from the Fresh Minds Festival 2012-13. The festival is a public performance of audiovisual artworks by professional artists, student-curated under the direction of a multi-disciplinary team of faculty at Texas A&M University. I was honoured to be recognised along with 2nd- and 3rd-prize winners Ryo Ikeshiro and gruppoGruppo. We had an enjoyable time meeting staff and students, trying out real Texas BBQ, and having great conversations about the places where art, image, sound and science meet.


Nodewebba Generative Music Software Now Available!

The first release of Nodewebba software is now available from BatHatMedia.com, free and open source for Macintosh and Windows.

Nodewebba brings some distinctly wild and crazy music algorithms out of the research lab and into the home and professional studio. The musician can easily create a "web" of feedback-based pattern generators, producing surprisingly fresh and dynamic interlocking melodic and rhythmic patterns for use realtime performance or for studio-based productions.

See the Welcome to Nodewebba video for a taste of what it can do:




Sunday, August 4, 2013

Using CoreImage filters in Openframeworks

Macintosh OSX CoreImage has some nice filter implementations, so it can be attractive to use some of these within Openframeworks. The Gaussian Blur filter, for example, is flexible and fast. So the trick is to get CoreImage to work with an Openframeworks OpenGL textures.

I implemented the following solution in Openframeworks v0.7.4, working on Mac OS version 10.7.5, Xcode 4.6.3. It involves drawing the image to a framebuffer and then passing the texture ID for the framebuffer to CoreImage.

Note that the filename of "testApp.cpp" needs to be changed to "testApp.mm" and "main.cpp" to "main.mm". This changes these files to an Objective-C++ type, which can handle both C++ and Objective-C calls.

Note also that (apparently) the QuartzCore framework needs to be manually added to the Xcode project frameworks list.

N.B.: I have found that on occasional runs of this and similar code that occasionally (1 out of every 4-8 runs), the code generates a CoreImage: ROI is not tilable error, and the CI Filter doesn't run, even if the project is configured at a humble screen size like 800x600. I haven't been able to find a solution online, so if you know the solution, I'm all ears.

The "testApp.h" file:

#pragma once
//  *****************************************************************
//  Demonstration of using Max OSX Core Image filters in an
//  Open Frameworks 0.7.4 project
//
//  Bret Battey / BatHatMedia.com
//  August 4, 2013
//  *****************************************************************

#include "ofMain.h"
#include "QuartzCore/QuartzCore.h"  // One way to get the CI classes


class testApp : public ofBaseApp{

 public:
  void setup();
  void update();
  void draw();

  void keyPressed  (int key);
  void keyReleased(int key);
  void mouseMoved(int x, int y );
  void mouseDragged(int x, int y, int button);
  void mousePressed(int x, int y, int button);
  void mouseReleased(int x, int y, int button);
  void windowResized(int w, int h);
  void dragEvent(ofDragInfo dragInfo);
  void gotMessage(ofMessage msg);

    // Basics
    int     outWidth, outHeight;
    ofFbo   sourceFbo;

    
    // Core Image
    CGLContextObj   CGLContext;
    NSOpenGLPixelFormatAttribute*   attr;
    NSOpenGLPixelFormat*    pf;
    CGColorSpaceRef genericRGB;
    CIContext*  glCIcontext;
    CIImage*    inputCIImage;
    CIFilter*   blurFilter;
    CIImage*    blurredCIImage;
    CGSize      texSize;
    GLint       tex;
    CGRect      outRect;
    CGRect      inRect;

    
};


The "testApp.mm" file, up through the draw() call:

//  *****************************************************************
//  Demonstration of using Max OSX Core Image filters in an
//  Open Frameworks 0.7.4 project
//
//  Note that this has to be a .mm file (Objective-C++), since it
//  combines Objective-C and C++. >>> ALSO main.cpp needs to be changed
//  to main.mm
//
//  On Xcode, you must manually add the QuartzCore framework to the
//  Project / Target / Summary list of frameworks for the build to
//  succeed.
// 
//  Bret Battey / BatHatMedia.com
//  August 4, 2013
//  *****************************************************************


#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup(){

    ofSetFrameRate(30);
    outWidth  = ofGetViewportWidth();
    outHeight = ofGetViewportHeight();
    ofEnableSmoothing();
    ofBackground(0);
    ofNoFill();
    ofSetLineWidth(4);

    // Setup a framebuffer for the drawing. Perhaps there is some way to do this
    // without a framebuffer, but this is the only way I could figure out how to
    // enable grabbing an OpenGL texture to pass to the CoreImage filter
    sourceFbo.allocate(outWidth, outHeight, GL_RGBA32F_ARB); //32-bit framebuffer for smoothness
    
    // SETUP THE CORE IMAGE CONTEXT, FILTERS, ETC
    // The appended .autorelease methods should auto cleanup the memory at exit.
    // Use a generic RGB color space:
    genericRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    // Create the pixel format attributes... The Core Image Guide for processing images says:
    // "It’s important that the pixel format for the context includes the NSOpenGLPFANoRecovery constant as an
    // attribute. Otherwise Core Image may not be able to create another context that shares textures with this one."
    NSOpenGLPixelFormatAttribute attr[] = {
        NSOpenGLPFAAccelerated,
        NSOpenGLPFANoRecovery, 
        NSOpenGLPFAColorSize, 32,
        0
    };
    CGColorSpaceRelease(genericRGB);
    // Setup the pixel format object:
    pf=[[NSOpenGLPixelFormat alloc] initWithAttributes:attr].autorelease;
    // Setup the core image context, tied to the OF Open GL context:
    glCIcontext = [CIContext contextWithCGLContext: CGLGetCurrentContext()
                                       pixelFormat: CGLPixelFormatObj(pf)
                                        colorSpace: genericRGB
                                           options: nil].autorelease;
    // Setup a Gaussian Blur filter:
    blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"].autorelease;
    // Supporting stuff
    texSize = CGSizeMake(outWidth, outHeight);
    inRect = CGRectMake(0,0,outWidth,outHeight);
    outRect = CGRectMake(0,0,outWidth,outHeight);


}

//--------------------------------------------------------------
void testApp::update(){
    
    sourceFbo.begin();
    
    // For feedback fun, let's not clear the Fbo after the first frame
    if(ofGetFrameNum()==1) {
        ofClear(0);
    }
    // Draw circle
    ofSetColor(20, 130, 250);
    ofCircle(outWidth/2,outHeight/2,10+(ofGetFrameNum()%40)*6);
    // Get the texture ID of the fbo:
    tex = sourceFbo.getTextureReference().texData.textureID; 
    // set the CI Image to link with the Fbo texture
    inputCIImage = [CIImage imageWithTexture:tex
                                        size:texSize
                                     flipped:NO
                                  colorSpace:genericRGB];
    // Blur filter
    [blurFilter setValue:inputCIImage forKey:@"inputImage"];
    [blurFilter setValue:[NSNumber numberWithFloat: 8] forKey:@"inputRadius"];
    blurredCIImage = [blurFilter valueForKey:@"outputImage"];
    // Draw it
    ofSetColor(255);
    [glCIcontext drawImage:blurredCIImage
                    inRect:outRect
                  fromRect:inRect];
    
    sourceFbo.end();
}

//--------------------------------------------------------------
void testApp::draw(){

    sourceFbo.draw(0,0);

}

Bézier-Spline Control Curves in Max/MSP/Jitter

I have made my Max/MSP 6 abstractions for generating Bézier-spline curves available on the software section of my web site. The package includes a Bernstein-polynomial abstraction, a 3rd-order Bézier-spline generator, and a wrapper that expresses a constrained Bézier-spline over time in a form excellent for creating control signal nuance or for reshaping linear inputs to have ease-in and ease-out characteristics.

Sunday, July 21, 2013

404 Festival / Fresh Minds

The 404 International Festival of Art and Technology in Rosario, Argentina (Aug 28-31) will be screening the first movement of Clonal Colonies.

I will be participating in an invited residency at the Fresh Minds Festival at Texas A&M University on Sep 26, 2013 to present Clonal Colonies and work with students from theatre, music, performance studies, architecture and visualization.