Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic