LaserBoy

Software => Laser Software => Laser Agent => Topic started by: Agent C on October 09, 2009, 02:46:49 pm

Title: Laser Agent Code Development
Post by: Agent C on October 09, 2009, 02:46:49 pm
These are the files.  You'll need the Processing IDE or whatever from processing.org.  After you unarchive the files, open lasershow4.pde

You will also need several libraries.  Please see the library post further down in this thread.

The code is currently very messy.  Maybe having people looking at it will give me an incentive to clean it up - kind of like my basement.

Let's keep specific code changes and what-not in this thread.

Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 09, 2009, 03:30:16 pm
d-loading now
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 09, 2009, 03:38:26 pm
Note that release 1.0, libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.


tried to get jama-1.0.2.jar and put it in the lib folder, the libraries/jama folder
in the sketchbook folder under both the processing folder and the lasershow4 folder.. none worked.. how to i install Jama library corectly?
Title: Re: Laser Agent Code Development
Post by: Agent C on October 09, 2009, 04:22:04 pm
Oh yeah, good point.  ;D I should package or at least list the needed libraries.  I will check when I get home.  The Jsyn sound library is one of the most important for good multichannel sound out in java.

If I recall, I had to install Jsyn as a library in the system Java lib folder.  Again, I'll check when I get home as I've installed it on mac and pc.

PS>  I don't know if it's worse to reply to my own post or edit an old post like James, but I'll follow convention of the site.

There is a DLL associated with JSyn that talks to the hardware for better performance.  This needs to be in the java libs folder if I'm not mistaken.  That's why this library needs to be installed for java, which processing relies on.

I have not finished the sound engine to work in windows.  It would be nice if it automagically worked but it doesn't because windows does not report the c-media sound card as one interface with 6 channels.  Instead it reports something like 3 stereo interfaces and I haven't invested the time to write a platform specific adaptation layer.  J-syn is not a high level enough library to do this on its own and there has been discussion about it in the forum.  I also think that this may change under windows vista or 7 as the underlying sound architecture has changed.  Professional mutli-channel cards on windows can use ASIO drivers I'm told, and there is an ASIO version of Jsyn for windows but it isn't free to download.  I'll burn that bridge when I get to it.
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 09, 2009, 04:40:12 pm
kool thnx..
Title: Re: Laser Agent Code Development
Post by: James on October 09, 2009, 08:42:35 pm
Quote
PS>  I don't know if it's worse to reply to my own post or edit an old post like James

That cracks me up!  ;D

You're pretty much screwed either way!  %)

James.  :)
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 09, 2009, 09:28:12 pm
its better to reply to your own post FYI..

that way someone that read the post but did not reply, will see that a new post has been entered on the front page.

Title: Re: Laser Agent Code Development
Post by: Fanny Pack on October 09, 2009, 10:17:24 pm
If a post has been editted I see a new post indicator but I can't tell which item was editted.  9 out of 10 times I won't bother to search for it.  So, if you want to edit a post that is fine with me but don't expect me to read it.  If you add a new reply I will always read it, though.
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 09, 2009, 10:57:19 pm
i rest my case :)
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 10, 2009, 01:29:41 am
ok so thats all well and good..

lets get back to Jama...
Title: Re: Laser Agent Code Development
Post by: Agent C on October 10, 2009, 02:26:14 pm
There are two kinds of libraries, processing libraries and java libraries.  Processing being java with icing can take advantage of both.

General Java Libraries you will need:

Jama - The Java Matrix Package, useful for rotations and transforms, supposedly highly optimized math routines
JSyn V144 - A low level soft synth package that can talk to multichannel hardware

Processing Libraries you will need

Promidi - Talk to midi controllers
DXF - To load dxf files, this might be included in processing now

How I installed them:
Everything went into the libraries folder of processing, which on a windows system lives in My Documents by default. This includes the general java libraries contrary to what I said in an earlier post.

For example, on my windows box:
C:\Documents and Settings\Administrator\My Documents\Processing\libraries
contains the folders

jama, jsyn, objloader, promidi

and in each one of those folders there is another folder called library, and inside that folder there is the .jar for the library
C:\Documents and Settings\Administrator\My Documents\Processing\libraries\jama\library\jama.jar


For Jsyn, which has a platform specific library (dll, lib, so, etc), you have to copy the platform specific library to the appropriate place described in the docs (eg C:\Windows\system32).

I have edited the first post to direct people to look at this post.
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 10, 2009, 06:32:17 pm
bleh.. so confusing... got any links to the libraries?


Title: Re: Laser Agent Code Development
Post by: Agent C on October 11, 2009, 11:12:23 am
JAMA - http://math.nist.gov/javanumerics/jama/
JSyn - http://www.softsynth.com/jsyn/
promidi - http://creativecomputing.cc/p5libs/promidi/
DXF - distributed with processing
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 14, 2009, 09:45:55 am
great.. but your instructions are lacking..

i would be glad to play with it but i cant even get it to compile..

Title: Re: Laser Agent Code Development
Post by: James on October 14, 2009, 01:42:59 pm
"instructions" ? ???

What?

I thought you were a laserists!

We don't need no stinkin' instructions!  8)

James.  :)
Title: Re: Laser Agent Code Development
Post by: Agent C on October 14, 2009, 04:06:31 pm
What OS are you working with?

The code posting is more to satisfy the curiosity of those who wanted to see how the sound engine works  and how I get from openGL to audio.  There are really all of 12 or so trickfilms (to borrow terminology from the Lasergraph), so there isn't much to do anyway.  I'll try to help everyone get it to compile on their platform of choice.

On another note, I'm going to have to rip apart the openGL engine and rebuild it anyway.  There is a fundamental flaw in how I handle the laser shape classes that causes unwanted blanks.  The way I have it written now automatically inserts a blank at the end of a laser segment.  The problem I'm seeing is that a simple closed shape, like a circle, will have a little blank notch in it from when the segment ends, the laser is momentarily blanked, and the segment begins again from the beginning.  A more complicated problem is in shapes with multiple segments with closed geometry like a circle of circles.  Each circle has a little notch in it.  Bleh.
Title: Re: Laser Agent Code Development
Post by: James on October 14, 2009, 06:14:29 pm
That little "bleh" is a real p.i.t.a!

I just fiddled with that exact same thing!

This is where just the right amount of dwell (extra samples) and perfect timing between the colors and the galvos is super critical.

James.  :)
Title: Re: Laser Agent Code Development
Post by: BlinkenLights on October 14, 2009, 11:10:57 pm
windows 7 is my OS
Title: Re: Laser Agent Code Development
Post by: Agent C on October 15, 2009, 12:04:15 am
That little "bleh" is a real p.i.t.a!

I just fiddled with that exact same thing!

This is where just the right amount of dwell (extra samples) and perfect timing between the colors and the galvos is super critical.

James.  :)

There are a couple of possibilities, and I agree that dwell is important part.  DPSS lasers have a warm up time with analog modulation.  I think the warm up time is making the problem look worse.  The next thing is sample shifting.
 Let's say I want to draw a circle with 1000 points. 
I'll start from the buffer as it comes back from the graphics card
Buffer is parsed, x,y,r,g,b values are placed into an array.
x,y values are copied to sample queues that is sent to the sound card at a fixed rate
r,g,b values are shifted 5 points, then copied to their respective sample queues.
Thread grabs the buffer for next graphics frame, which is the circle again.
Meanwhile, scanners start moving, 5 points later the laser comes on, stays on for 1000 samples.
Hopefully there isn't a buffer under-run, and the thread responsible for stuffing data into the queues has managed to stuff another 1000 points in by the time its needed. 
The scanners come back to the top of the circle, then start moving again.  The laser shuts off 5 samples later, and powers back on 5 samples after that.  Hence the gap.
Title: Re: Laser Agent Code Development
Post by: James on October 15, 2009, 12:41:31 am
Sample shifting is not an easy thing to code!

The offsets have to be maintained through the entire play of the stream.

James.  :)
Title: Re: Laser Agent Code Development
Post by: Agent C on October 22, 2009, 11:28:10 pm
I think I will save a few samples from the previous frame, try to ascertain if the last point is lit and the first point of the next buffer is lit and if they are close enough to keep the laser lit.  We'll see this weekend if it works.
Title: Re: Laser Agent Code Development
Post by: Agent C on November 10, 2009, 02:08:23 pm
Inspired by a failed battery and a 5 year old chip on my mac laptop, I'm going to be switching development over to windows until I can afford a newer laptop.  With this in mind, I'll do a much better job of abstracting the platform dependent portions of the code (ie audio out and maybe now video in).  I'm hoping this will get more people testing the software out, too.
Title: Re: Laser Agent Code Development
Post by: James on November 10, 2009, 04:42:46 pm
Might I suggest using Dev-C++ ?

It is GNU GCC, as you probably know.

James.  :)
SimplePortal 2.3.7 © 2008-2024, SimplePortal