This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Java Sound API problems

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've been using the Java Sound API's to play some audio tracks (Ogg Vorbis and mp3). I've been using the VorbisSPI and MP3SPI from Javazoon.net to support these file formats. I have code sucessfully playing these formats, starting, stopping, pausing resuming. However when I first create my 'Line', it takes around 2-3 seconds for each audio track to play. The code is something like this:



I then have code in a seperate thread which reads in the bytes of audio data and writes them out to the currentLnie, something like this:



As I have said, by doing this, it takes 2-3 seconds between calling this method and my audio to start playing. I originally thought it to be a problem with my creation of the Thread. So when my object is created it now creates the Thread and starts it. This then sits in a while loop sleeping for 100ms at a time whilst not playing. Yet it still takes 203 seconds before the audio starts to play. If I do the following:



To essentially 'pause' the audio, and then sometime later I do:



Which essentially 'resumes' my audio playing again, it resumes instantly.
Therefore the only thing I can put this down to is the time it's taking to create all of the objects to eventually end up with the currentLine object that I use to play that audio.

So... can anyone suggest a way that I can either rewrite this to speed it up, so it plays the audio instantly. Or is there a way I can create a Line or maybe two Line's that I can keep open and use ti play audio instantly each time (if that actually makes sense)?

Ahy help with this is greatly appreciated.

Thanks
 
I'm sure glad that he's gone. Now I can read this tiny ad in peace!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic