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. -- www.wescottdesign.com
[OT] Sound in Java
Started by ●October 4, 2011
Reply by ●October 4, 20112011-10-04
On Oct 4, 10:00=A0am, Tim Wescott <t...@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 =3D confusion. =A0Does anyone know a good, reliable=way> to make one damn little beep with perhaps +/- 1/4 of a second of timing > accuracy?On what platform? PC or Phones, etc.?
Reply by ●October 4, 20112011-10-04
On Tue, 04 Oct 2011 10:19:39 -0700, linnix wrote:> On Oct 4, 10:00 am, Tim Wescott <t...@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? > > On what platform? PC or Phones, etc.?Sorry -- PC. -- www.wescottdesign.com
Reply by ●October 4, 20112011-10-04
On Oct 4, 11:03=A0am, Tim Wescott <t...@seemywebsite.com> wrote:> On Tue, 04 Oct 2011 10:19:39 -0700, linnix wrote: > > On Oct 4, 10:00=A0am, Tim Wescott <t...@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 =3D confusion. =A0Does anyone know a good, relia=ble> >> way to make one damn little beep with perhaps +/- 1/4 of a second of > >> timing accuracy? > > > On what platform? PC or Phones, etc.? > > Sorry -- PC. > > --www.wescottdesign.comwave or mp3 files? It's overkill, but players are free anyway.
Reply by ●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
Reply by ●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 ●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 ●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 ●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(); > } > } > > GeorgeExcept 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 ●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