Greg Donahue

Greenhorn
+ Follow
since Oct 07, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Greg Donahue

Okay, I figured it out.

I looked at the MidiDevices obtained from calling MidiSystem.getMidiDeviceInfo(), and observed that they were all closed. So I knew right away that something was fishy. I guess that calling MidiSystem.getSequencer() and MidiSystem.getSynthesizer() doesn't give you the default objects for those MIDI devices.

To correct the problem, I had to set the sequencer and synthesizer to the default sequencer and synthesizer in the MidiDevice.Info list, rather than using MidiSystem.getSequencer() and MidiSystem.getSynthesizer(). It looks like:



...and that did the trick. Now my volume works perfectly.
-Greg
14 years ago
Hi there,
I'm writing a simple MIDI player to teach myself how to use the javax.sound.midi package. So far, I have a basic program that can play, pause, stop, open a new MIDI sequence, and display file information (name and length in minutes:seconds). I'm having a hard time getting the volume control to work, though.
I have googled extensively on this. The conventional wisdom seems to be that you control MIDI volume by instantiating and opening a Sequencer, instantiating and opening a Synthesizer, binding the Synthesizer to the Sequencer via a Transmitter/Receiver pair, setting your Sequence, starting your Sequencer, and collecting the MidiChannels via a call to the Synthesizer, then doing a controlChange of controller #7 (major volume control) on each channel. It's easier to see what's going on by looking at the code; this method should turn all channels on the synthesizer down to zero:



The effect of this code is that the volume of the playing synthesizer is indeed lowered, but not silenced. This is driving me up the wall; I'm not a MIDI guru, so I don't know what I'm missing, and reading the specs isn't helping. Some caveats:

1) Apparently, MIDI controller 39 is another volume controller (the least significant 7 bits of the volume control for the channel) but when you reset controller 7, you also zero out controller 39.

2) I have tried rearranging the instructions in the above code, to see if I was doing something in the wrong order. Nothing helped.

3) I tried setting controller 7 to -1, thinking that maybe MIDI works differently on my machine than everywhere else in the universe. It raised the volume to the maximum value, an earsplitting 127.

4) It's almost as if there are two sound-generating elements here, the Synthesizer I'm using and something else which the Synthesizer can't touch. Calls to setMute() and allNotesOff() don't work, either.

5) Another way to make this work is to go into the Sequence and change the volume of every single MidiMessage individually. I won't do this, it's too slow. I want my volume to change in real time, as the user drags the volume slider up and down.

6) Another caveat: I did the obvious check. I added the following code, which checks each channel's controller #7, to the above:



...and each channel is indeed set to zero.

Any ideas? Thanks!
-Greg
[ December 31, 2004: Message edited by: Greg Donahue ]
14 years ago
Hi,
I need to be able to send email from an app I'm designing, but none of my email accounts allows relaying, even with authentication. Is there a Java package which either (a) allows you to forego SMTP servers or (b) sets one up locally, just so you can send the email?
Thanks,
Greg D
14 years ago
Aha. You have to *display* the image first.



...right after the BufferedImage initialization. Kind of makes sense, and then it kind of doesn't, since you aren't really displaying the image anywhere...
15 years ago
Hi,

I'm writing a servlet that accepts the following params thru the URL:

1) a filename for an image sitting on my server, and
2) a pair of X and Y dimensions.

The servlet is supposed to scale the image appropriately and send the result to the response OutputStream. My strategy is: take the image file, load it into a BufferedImage, modify it appropriately, and send it from there to an OutputStream. Here's the code that is supposed to accomplish this:



...that makes sense, right? Currently, getImageFileName() returns the name of a JPEG which I know is valid, and alterImage() does nothing. But here's the thing: when I run this, the image produced is a big black box, and not the expected image at all, and the box has the same dimensions as the expected image.

What am I doing wrong?
15 years ago
Hi,
Does anyone know where in the Tomcat 4 documentation I can find details on creating "overlapping" security constraints? What I'm trying to do is guard URL patterns of the form:
/root
and
/root/*
from everyone except users with role "general_user", but then I also want to put added protections on URL patterns of the form:
/root/username/private
and
/root/username/private/*
so that these resources are guarded from everyone except users with role "specific_user:username". I know how to create roles and security constraints in my app's memory realm and the web.xml, but when I tried to do the above, the "general_user" users are allowed to access files in /root/username/private. Does anyone know what I should do?
Thanks,
Greg
15 years ago
Hi,
I'm trying to set up a web application so that all kinds of server errors (400, 401, 403, 404) redirect to a single JSP. My idea was the following, in web.xml, we can specify how redirection is supposed to happen, right? Like so:
<web-app>
<error-page>
<error-code>404</error-code>
<location>/jsp/error.jsp?ec=404</location>
</error-page>
</web-app>
My reasoning was that I could just add ?ec=404 to the URL and then read the request object's "ec" parameter from within /jsp/error.jsp. This isn't working, for some reason. Does doing redirection in this way invalidate the request object? Is there some other way of redirecting multiple errors to one page, then figuring out which is which on the page?
Thanks,
Greg D
15 years ago
Hello,
Sorry in advance if this is the wrong forum for a Lucene question...
I'm preparing an online search tool using Lucene; the target data is citations from scientific literature. Each Document has a few fields, such as "Article Title," "Abstract," "Journal Name," "Volume," and so on. Right now, my system is set up so that Lucene only searches the "Abstract" fields. I need to get it to search other fields as well. I'm constructing the Query using a QueryParser and using "Abstract" as the default field. Is there any way to use "All" for the default field?
One solution (during indexing) is to dump all the fields into one aggregate field called "All" and re-index the entire data set. Unfortunately, my data set is huge. I don't want to have to re-index it. Another solution (during searching) is to search on each desired field, then interleave the results somehow. Unfortunately, I don't know how to do such interleaving.
Any thoughts?
-Greg
15 years ago
Here's a suggestion: restart Apache. The simplest paths are often the best.

Thanks anyway,
Greg D
15 years ago
Hi.
I've been working at this problem all day, so pardon me if I don't lay it out clearly at first. My brain has turned into delicious jam.
I have Apache 1.3.29 and Tomcat 3.3.1 running on RH 7.2. Currently, Apache is listening and serving on port 80, and Tomcat is listening and serving on port 8888. I need to set things up so that both Tomcat and Apache listen on port 80, with Tomcat handling my web application (the same way it handles the examples and the admin webapps on port 80) and Apache handling everything else. I have tried configuring the mod_jk.conf files in %tomcat%/conf and %tomcat%/conf/auto to no avail.
Any suggestions?
Thanks,
Greg D
15 years ago
Okay, I figured out what was going on.
In my Servlet class, I created a method which returns the canonical path of the current directory. In short:

I discovered something strange...the directory returned was the Tomcat bin directory. Then I had a hunch; I stopped Tomcat and restarted it from my home directory. Wouldn't you know it, now the directory returned by the servlet was my home directory.
So it seems that, for this app, the root is wherever Tomcat was started from. Does this ring any bells? How do I get the application's root to map to somewhere else?
Thanks, Greg D
15 years ago
Additionally, nothing was re-installed when the machine rebooted. And if there are any hard-coded paths, they are definitely not in the servlet/JSP/bean code, as I have rewritten all of that myself. That leaves the configuration files, I assumed.
15 years ago
So, here's the problem in (perhaps) more detail:
I'm keeping a registry file (registry.txt) in the WEB-INF directory. I figured that would be the safest place for it, since the registry contains sensitive info and shouldn't be visible to http clients. The servlets in this app need to be able to read the registry file. For whatever reason, before the server crashed the servlets could read /app/WEB-INF/registry.txt, and now they cannot. This leads me to suspect that somehow I "lost" an alias when the server crashed. So I decided to look at how to configure Tomcat and webapps. I know that you can do some aliasing in server.xml, and you can do app-specific aliasing in web.xml, but I cannot find a web.xml for this app (as I mentioned before, I'm not the original author). There is no stack info to speak of, since the most my app does is say "file not found, can't read the registry" when it doesn't find the file.
Does this sound at all familiar to you guys?
Thanks,
Greg D
15 years ago
Hello,
I'm working on a webapp. The app is running on a PC; the PC is running RH 7.3 as its OS and Tomcat 3.3.1 as its http server. I took over the project a few months ago from a guy who is no longer working with the group. The webapp is set up to maintain a registry of usernames and passwords and saved sessions in WEB-INF/registry; the webapp's servlet classes can read this directory and check usernames/passwords, load/save sessions, etc. At least, the servlet classes *could* read that directory up until a week ago, when the machine crashed and brought Tomcat down with it. When we restarted Tomcat, the servlets couldn't find that directory any more.
What I need to do is create a "registry" type directory in my WAR hierarchy that can't be read through http but can be read by classes in the WEB-INF/classes directory. I don't really know a lot about Tomcat, and I don't want to slog through the entire tutorial detailing the ten million Tomcat configuration files. Can anybody give me any quick pointers?
Thanks, Greg D
15 years ago
Hello,
A program I'm working on calls a Perl script using Runtime.exec(). The Perl script makes use of a user-defined system variable. I need to reset this variable from within the Java program, and I would like to do it without resorting to another Process fork. Is this possible in Java?
Ideally, I would change the Perl script so that it doesn't rely on any system variables, but I'm not really allowed to mess with the code.
Any help will be greatly appreciated.
-Greg
15 years ago