Reply by Boudewijn Dijkstra October 27, 20112011-10-27
Op Tue, 04 Oct 2011 19:00:46 +0200 schreef Tim Wescott
<tim@seemywebsite.com>:
> Rather than putting together $10 worth of pieces from my junkbox to make > an exercise timer for my wife, I'm thinking of writing a Java app to do > it. > > There seems to be a lot of flexibility in how to generate sound from > Java, and flexibility = confusion. Does anyone know a good, reliable way > to make one damn little beep with perhaps +/- 1/4 of a second of timing > accuracy?
Years ago I created a toy two-channel tone generator application in Java with sliders for frequency, volume and phase shift. The phase shift was fun because it could cause an unsettling feeling to innocent passers-by. ;) Anyway, here you can find a stripped-down version that generates a short single-channel 600Hz tone: http://indes.com/~boudewijn/AudioTest.java -- Gemaakt met Opera's revolutionaire e-mailprogramma: http://www.opera.com/mail/ (Remove the obvious prefix to reply.)
Reply by jebblue October 8, 20112011-10-08
On Tue, 04 Oct 2011 15:06:54 -0500, Tim Wescott wrote:

> On Tue, 04 Oct 2011 13:17:56 -0500, Vladimir Vassilevsky wrote: > >> Tim Wescott wrote: >> >>> Rather than putting together $10 worth of pieces from my junkbox to >>> make an exercise timer for my wife, I'm thinking of writing a Java app >>> to do it. >>> >>> There seems to be a lot of flexibility in how to generate sound from >>> Java, and flexibility = confusion. Does anyone know a good, reliable >>> way to make one damn little beep with perhaps +/- 1/4 of a second of >>> timing accuracy? >> >> Do not use Java. Do the sound by direct WinAPI calls from C. Java sound >> system is a mess. You are at the mercy of particular JVM. If it seems >> to work here and now, there is absolutely no warranty that it works >> anywhere else. Been there, done that, got burned. >> > Dang. I wanted to prototype it on my Linux machine and then give it to > my wife for her Windows machine -- hence the idea to use Java. > > Oh well -- maybe it'll be some 555s, CD4040s and CD4017s after all...
I don't know why that guy advised against it. Many games have been written with Java. Why not go with your original idea and have some fun. Take a break from your normal work. This works great on my machine (Ubuntu 64 bit) and over 5 years old Audigy sound card: http://www.oracle.com/technetwork/java/index-139508.html -- // This is my opinion.
Reply by George Neuner October 6, 20112011-10-06
On Wed, 05 Oct 2011 12:59:55 -0500, Tim Wescott <tim@seemywebsite.com>
wrote:

>Except [Toolkit.Beep()] doesn't seem to work in Ubuntu. Running from >the console, System.out.print('\007') works -- we'll see how it likes Windows 7.
In Windows printing CTRL-G works from the command line but doesn't work in the GUI. AWT.Toolkit.Beep() works in both. George
Reply by George Neuner October 6, 20112011-10-06
On Wed, 05 Oct 2011 12:59:55 -0500, Tim Wescott <tim@seemywebsite.com>
wrote:

>On Tue, 04 Oct 2011 23:58:14 -0400, George Neuner wrote: > >> On Tue, 04 Oct 2011 12:00:46 -0500, Tim Wescott <tim@seemywebsite.com> >> wrote: >> >>>There seems to be a lot of flexibility in how to generate sound from >>>Java, ... >> >> Simplest way is the AWT toolkit. >> >> import java.awt.*; >> public class BeepExample >> { >> public static void main(String[] args) { >> Toolkit.getDefaultToolkit().beep(); >> } >> } >> > >Except that doesn't seem to work in Ubuntu. Running from the console, >System.out.print('\007') works -- we'll see how it likes Windows 7.
So much for portability 8-/ Works on Suse, Windows XP and 7, though. George
Reply by Frank Buss October 5, 20112011-10-05
Tim Wescott wrote:
> Rather than putting together $10 worth of pieces from my junkbox to make > an exercise timer for my wife, I'm thinking of writing a Java app to do > it. > > There seems to be a lot of flexibility in how to generate sound from > Java, and flexibility = confusion. Does anyone know a good, reliable way > to make one damn little beep with perhaps +/- 1/4 of a second of timing > accuracy?
This should work on Linux and Windows: http://www.frank-buss.de/javasound/ Use a static main method as usual for a standalone application, which you can start with javaw instead of an applet. My "beep" research :-) http://www.frank-buss.de/beep/ -- Frank Buss, http://www.frank-buss.de piano and more: http://www.youtube.com/user/frankbuss
Reply by Tim Wescott October 5, 20112011-10-05
On Tue, 04 Oct 2011 23:58:14 -0400, George Neuner wrote:

> On Tue, 04 Oct 2011 12:00:46 -0500, Tim Wescott <tim@seemywebsite.com> > wrote: > >>Rather than putting together $10 worth of pieces from my junkbox to make >>an exercise timer for my wife, I'm thinking of writing a Java app to do >>it. >> >>There seems to be a lot of flexibility in how to generate sound from >>Java, and flexibility = confusion. Does anyone know a good, reliable >>way to make one damn little beep with perhaps +/- 1/4 of a second of >>timing accuracy? >> >>Thanks. > > Simplest way is the AWT toolkit. > > import java.awt.*; > public class BeepExample > { > public static void main(String[] args) { > Toolkit.getDefaultToolkit().beep(); > } > } > > George
Except that doesn't seem to work in Ubuntu. Running from the console, System.out.print('\007') works -- we'll see how it likes Windows 7. -- www.wescottdesign.com
Reply by George Neuner October 5, 20112011-10-05
On Tue, 04 Oct 2011 12:00:46 -0500, Tim Wescott <tim@seemywebsite.com>
wrote:

>Rather than putting together $10 worth of pieces from my junkbox to make >an exercise timer for my wife, I'm thinking of writing a Java app to do >it. > >There seems to be a lot of flexibility in how to generate sound from >Java, and flexibility = confusion. Does anyone know a good, reliable way >to make one damn little beep with perhaps +/- 1/4 of a second of timing >accuracy? > >Thanks.
Simplest way is the AWT toolkit. import java.awt.*; public class BeepExample { public static void main(String[] args) { Toolkit.getDefaultToolkit().beep(); } } George
Reply by David Brown October 4, 20112011-10-04
On 04/10/11 22:06, Tim Wescott wrote:
> On Tue, 04 Oct 2011 13:17:56 -0500, Vladimir Vassilevsky wrote: > >> Tim Wescott wrote: >> >>> Rather than putting together $10 worth of pieces from my junkbox to >>> make an exercise timer for my wife, I'm thinking of writing a Java app >>> to do it. >>> >>> There seems to be a lot of flexibility in how to generate sound from >>> Java, and flexibility = confusion. Does anyone know a good, reliable >>> way to make one damn little beep with perhaps +/- 1/4 of a second of >>> timing accuracy? >> >> Do not use Java. Do the sound by direct WinAPI calls from C. Java sound >> system is a mess. You are at the mercy of particular JVM. If it seems to >> work here and now, there is absolutely no warranty that it works >> anywhere else. Been there, done that, got burned. >> > Dang. I wanted to prototype it on my Linux machine and then give it to > my wife for her Windows machine -- hence the idea to use Java. > > Oh well -- maybe it'll be some 555s, CD4040s and CD4017s after all... >
There are /lots/ of ways to write cross-platform code other than java. I do most of my cross-platform stuff with Python (though I must admit I've never tried sound). You can also use cross-platform toolkits, such as wxWidgets (for C++, Python, and many other languages), GTK, QT, etc. For Python, you might try http://pygame.org/ - it's a toolkit specifically designed to make it easy to write simple cross-platform games in Python. It's bound to easy to make noises with it, and to make a nice bright and cheerful user interface.
Reply by Tim Wescott October 4, 20112011-10-04
On Tue, 04 Oct 2011 13:17:56 -0500, Vladimir Vassilevsky wrote:

> Tim Wescott wrote: > >> Rather than putting together $10 worth of pieces from my junkbox to >> make an exercise timer for my wife, I'm thinking of writing a Java app >> to do it. >> >> There seems to be a lot of flexibility in how to generate sound from >> Java, and flexibility = confusion. Does anyone know a good, reliable >> way to make one damn little beep with perhaps +/- 1/4 of a second of >> timing accuracy? > > Do not use Java. Do the sound by direct WinAPI calls from C. Java sound > system is a mess. You are at the mercy of particular JVM. If it seems to > work here and now, there is absolutely no warranty that it works > anywhere else. Been there, done that, got burned. >
Dang. I wanted to prototype it on my Linux machine and then give it to my wife for her Windows machine -- hence the idea to use Java. Oh well -- maybe it'll be some 555s, CD4040s and CD4017s after all... -- www.wescottdesign.com
Reply by Vladimir Vassilevsky October 4, 20112011-10-04

Tim Wescott wrote:

> Rather than putting together $10 worth of pieces from my junkbox to make > an exercise timer for my wife, I'm thinking of writing a Java app to do > it. > > There seems to be a lot of flexibility in how to generate sound from > Java, and flexibility = confusion. Does anyone know a good, reliable way > to make one damn little beep with perhaps +/- 1/4 of a second of timing > accuracy?
Do not use Java. Do the sound by direct WinAPI calls from C. Java sound system is a mess. You are at the mercy of particular JVM. If it seems to work here and now, there is absolutely no warranty that it works anywhere else. Been there, done that, got burned. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com