Sending data to Java program?
Hi everybody, I apologize for asking n00b questions, but what can I do?
I'm working on a school project that involves connecting a guitar to a computer with software that will read notes and such (for a Guitar Hero-esque game, except with an actual guitar as the controller). We're either going to have to use a stock Roland GK-2 synth setup and then convert MIDI files into data that we can use or we need to read pickup voltages with a Stamp (plus some damping circuitry...) and send them to a separate Java application running on the computer.
My question is how to send data from a Basic Stamp unit to said Java application as they both run. What's the hardware/software interface that I'd need? For this project, the sampling rate would have to be every 1/4 second at least (for eighth notes at 120 bpm).
I probably just fail at using the forum search function, since sending data between the Stamp and a separate program running on the computer seems like a fairly basic task (these people did it: http://www.parallax.com/tabid/498/Default.aspx), but I haven't found any pointers on how it's done. If someone could point me to some resources, that would be really appreciated.
I'm working on a school project that involves connecting a guitar to a computer with software that will read notes and such (for a Guitar Hero-esque game, except with an actual guitar as the controller). We're either going to have to use a stock Roland GK-2 synth setup and then convert MIDI files into data that we can use or we need to read pickup voltages with a Stamp (plus some damping circuitry...) and send them to a separate Java application running on the computer.
My question is how to send data from a Basic Stamp unit to said Java application as they both run. What's the hardware/software interface that I'd need? For this project, the sampling rate would have to be every 1/4 second at least (for eighth notes at 120 bpm).
I probably just fail at using the forum search function, since sending data between the Stamp and a separate program running on the computer seems like a fairly basic task (these people did it: http://www.parallax.com/tabid/498/Default.aspx), but I haven't found any pointers on how it's done. If someone could point me to some resources, that would be really appreciated.
Comments
The BS2 can send to its programming port with:
Main:
SEROUT 16, 16384, [noparse][[/noparse]"Hi there!", CR]
PAUSE 2000
GOTO MAIN
The "16384" is the "Baud Mode" value you need to do 9600 baud. So, on the Java port, you'd open it at 9600 baud.
Now you just have to add the code to read the value from the guitar -- which I have no idea how to do, sadly. Well, not NO idea -- you could use an A to D converter, or an op-amp interface. But figuring out what "note" was desired might be difficult.
I'll have to learn some more Java, but that can't be too tough... I'll let you know how it goes, I'm sure I'll run into plenty of snags. ^_^
For some reason that I cannot really fathom, JAVA has faded in and out on supporting these serial ports of one's computer. It may have something to do with a conflict between Sun and Microsoft in which Windows wants to dominate all low-level i/o services. I say that because it appears easier to do in both Linux and Solaris.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
http://www.mindview.net/Books/TIJ/
It's a free download and it explains concepts clearly and in detail.
It's slightly dated, but the concepts are the most important details that you'll be pulling from this doc.
Is resetting the Stamp making Java lose the port somehow? If so, I could deal with that.
EDIT: my code was closing my own InputStream.
Thanks for the previous help, folks! I'm pumped, this project might just work out sort of!
For anyone else trying to do Java serial communication, rxtx.org (the gnu.io package) works pretty well.
Post Edited (Ratatoskr) : 5/28/2008 8:57:54 PM GMT
I'm trying for a similar application, except it is the other way around. The java application sends information to the stamp controller, while the stamp controller just awaits data.
Was rxtx very easy to get working? I was looking at simpleserial which seems easy as well.
RXTX is working well for me. I used en.wikibooks.org/wiki/Serial_Programming:Serial_Java for most of the code.
It took me the time to copy a few files into the proper folders, read that wikibooks page, copy+paste+mod the code. Pretty easy if you subtract the time spent getting Java and Netbeans (for some reason I computer I was using had about half of Java) and missing important lines of code like adding the listener, setting the port to notify, and not closing my stream while I was waiting for more data. That wikibooks page makes it pretty easy if you pay attention and don't do silly things.
EDIT: oh, and I needed to use baudmode 16468 on the Stamp for 9600 in Java, IIRC. Currently I'm using 84, which is equivalent (I think). It works.
Post Edited (Ratatoskr) : 5/29/2008 8:39:29 PM GMT