Loading...
Logo
Processing Forum
interstar's Profile
5 Posts
4 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Hi,

    I'd like to do a project which involves creating sound-buffers in Minim, reading sample files into them, analysing them with FFT, processing them with both the Minim effects such as filters and my own algorithms (which means acting on the array of sample points), and finally saving transformed buffers to disk. I don't need to do this in real time.

    Is there an object in Minim that I can use for this? The audio buffer objects I can find seem to be read-only. And the effects seem to be designed to be part of a chain rather than just applied to a buffer. Or can they be used in an "off-line" mode?

    cheers

    phil
    Has anyone successfully used Antlr in a Processing sketch?

    I downloaded the antlr-3.3-complete.jar file from the site and put it in ~/sketchbook/libraries/antlr/library/ which is where I would expect Processing to find it, but no luck.

    Anyone done this? And if so, where do you put the library?

    cheers

    phil
    A few days ago I asked a question about creating PDFs without recording them ( http://forum.processing.org/topic/problem-creating-with-pdfs-behind-the-scenes )

    Thanks to someone here, that problem was solved but I can't quite figure out how to create a PDF of a particular size, manipulate it, and then save it again.

    What I can do is this :

    1. PGraphicsPDF pdf;
    2. pdf = (PGraphicsPDF)beginRaw(PDF, "find.pdf");
    3. pdf.beginDraw();
    4. // do some stuff with pdf as the graphics canvas
    5. pdf.endDraw();
    6. endRaw();


    This works to create a pdf, draw on it and save it to disk. But using beginRaw this way doesn't allow me to set the size / resolution of the pdf file.

    Alternatively I can do this :

    1. PGraphicsPDF pdf;
    2. pdf = (PGraphicsPDF)createGraphics(paper_x, paper_y, PDF, "find.pdf");
    3. pdf.beginDraw();
    4. // do some stuff with pdf as the graphics canvas
    5. pdf.endDraw();
    Which would seem to let me define the width and height of the pdf file. But I can't find any example online of then saving the pdf into a file. In every pdf file writing example I've discovered, writing to file just seems to happen at endRaw()

    But there must be another way of achieving this if you aren't using the beginRaw / endRaw methods.

    cheers

    phil

    Update :

    I should mention. If I just try to do a

    pdf.save("fileName.pdf");

    after the pdf.endDraw() I get the following exception :

    1. java.lang.RuntimeException: No save() for PGraphicsPDF
    2.     at processing.pdf.PGraphicsPDF.nope(Unknown Source)
    3.     at processing.pdf.PGraphicsPDF.save(Unknown Source)
     
    Clearly, something in Processing's PDF library knows how to write a PDF file. But it seems that that knowledge hasn't been incorporated into the PGraphicsPDF class.
    I'm trying to create PDFs from my Processing sketch. But, crucially, the PDFs are not recordings of what I'm doing on the main screen. I want to treat them as any other PGraphics and have some code that knows about PGraphics to write on them while the screen shows something completely different.

    Here's what I'm trying :
    1.   PGraphicsPDF pdf;
    2.   pdf = (PGraphicsPDF)createGraphics(paper_x, paper_y, PDF, "find.pdf");
    3.   pdf.noFill(); 
    4.   pdf.pushMatrix();
    5.     pdf.translate(width/2,height/2);
    6.     pdf.scale(2);
    7.     myThing.draw(pdf);
    8.   pdf.popMatrix(); 
     
    The problem occurs in 4. It throws a NullPointerException :

    1. Exception in thread "Animation Thread" java.lang.NullPointerException
    2.     at processing.core.PGraphicsJava2D.pushMatrix(Unknown Source)
    Which suggests to me that something in the PGraphicsPDF didn't get constructed properly.

    Is that because I haven't something I should have done? Or is it a bug in the pdf class?

    Note that this isn't just a problem for pushMatrix(). If I comment that line, the problem just gets thrown in the next line, the translate. ( Though, interestingly, doesn't happen in the pdf.noFill )

    Anyone got any ideas?

    cheers

    phil