Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Java Beeping

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I attempting to do is to play a short jingle off of the internal system speaker/beeper. I researched this on java.sun.com and found the following sollution:


The problem is that, when I print instruments.length it is -1. I am working on a computer without any speakers but it does have onboard sound. Also System.out.println("\07"); will beep but Toolkit.getDefaultToolkit().beep(); does not. If anyone knows what is wrong with this code or another way to beep other pitches please help.
Thanks in advance for your time,
Em
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Toolkit's beep() uses the system's beep sound, not the bell character.
 
Emmy Rauch
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That explains why it doesnt beep, but my main question is how to beep other pitches, even if I must use the JNI to do this can someone give me an example? Thanks
 
Emmy Rauch
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should I repost this in advanced or give up on life? Eh... I'll do both to have my bases covered.
 
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thou hast cross-posted... for shame!
 
Sheriff
Posts: 16922
284
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I remember back in the days of the Apple ][ (yeah, I'm showing my age but hey, at least I can still remember that far back ) when we could produce tones by toggling the onboard speakers at different frequencies. Of course with that approach you had to take into account the clock speed. I won't even pretend to remember how it was done back then, much less how it can be done on your modern PC. I tried googling around for more info but couldn't find anything.
 
Emmy Rauch
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I cross posted and still didnt get any info ;-( ... perhaps its not possible? That would be a sad day when you cant produce other tones out of a system speaker in java
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The big idea with Java is that it's platform-independent, isn't it? (rhetorical) Is it even possible to interface to the system speaker (or bleepy thing, whatever!) in a platform-independent way? Surely it would depend on the hardware you have installed. Given that, there would at least have to be some sort of consistent API on a given platform so that a native implementation could be built and accessed through JNI.

I don't really know enough about it, so maybe I should just shut up.

Jules
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic