Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (784)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (858)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Question on javax.sound and java.nio  (Read 1796 times)
0 Members and 1 Guest are viewing this topic.
Offline cknoll

Junior Devvie

Flame On!

« Posted 2003-10-17 13:40:31 »

Hi, I'm finally starting to dig into adding sound to my applications since there's been some improvements in the 1.4 API.  I made a simple program to read a streamed .ogg file (which i converted from a .mp3) and that worked very well.  Basically, it just converts the ogg stream into a PCM_SIGNED encoded stream, and reads the bytes from the stream and writes it to the line.

By itself, this program runs fine.  However, I have a very old game that I helped someone with and decided to add a soundtrack to (Rage Against the Machine's Renegades of Funk if you are curious), and I'm definitely seeing some jerks in the app from pauses...I'm not sure if the jerks are a result of GC pauses because i'm reading from a stream or if that the separate thread that is playing the music (reading from the stream and writing to the line) is causing problems.

Which brings me to my main question:  I'm assuming that directly allocated ByteBuffers will result in better perfomrance/less lag, and I am wondering if anyone knows if the javax.sound classes (such as AudioInputStream) utilize the java.nio classes (or direct ByteBuffers) for performing it's work....or if it is possible to use a Channel object to wrap the AudioInputStream in a channel and use a ReadableByteChannel to read from the stream (in a hopefully more efficient manner) and then write the bytes to the line from the ByteBuffer.

Has anyone done anything like this?  I'm thinking that part of the problem could be the conversion from the OGG stream into the PCM_SIGNED stream for playback.  Or it could be that my timer to make the animation fluid is out of whack and now that I have another thread eating cycles, i need to use the HighRes timer or something.  So many questions.  If anyone has experience with streams and the java.nio package wrt Java Sound, lemme hear from you.

Pages: [1]
  ignore  |  Print  

hadezbladez (1655 views)
2018-11-16 13:46:03

hadezbladez (666 views)
2018-11-16 13:41:33

hadezbladez (1642 views)
2018-11-16 13:35:35

hadezbladez (350 views)
2018-11-16 13:32:03

EgonOlsen (2702 views)
2018-06-10 19:43:48

EgonOlsen (2970 views)
2018-06-10 19:43:44

EgonOlsen (1656 views)
2018-06-10 19:43:20

DesertCoockie (2370 views)
2018-05-13 18:23:11

nelsongames (2285 views)
2018-04-24 18:15:36

nelsongames (2977 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!