Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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  
  OggInputStream  (Read 2424 times)
0 Members and 1 Guest are viewing this topic.
Offline tom
« Posted 2004-01-07 20:01:30 »

I made it so that I could stream music in the background of my game. It seems like others might find it usefull, so I've released the code:
http://home.halden.net/tombr/ogg/ogg.html

Enjoy!

Offline lebasti

Senior Newbie




Java games rock!


« Reply #1 - Posted 2004-01-08 09:48:26 »

Thanks for this nice piece of code. It helped me to solve an important problem in our game for university.

basti

....I and I nah signature....
Offline tom
« Reply #2 - Posted 2004-01-08 12:18:18 »

Glad you found it usefull.

I'm a bit curious. What was the problem you had?

Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline lebasti

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-01-09 16:53:06 »

The only problem was that I've been to silly to get that ogg-stuff working for backgroundmusic Smiley. maybe i should smoke less and learn more...

....I and I nah signature....
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #4 - Posted 2005-05-10 09:28:34 »

Bug report:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
   public long skip(long n) throws IOException
   {
      int bytesRead = 0;
      while (bytesRead < n)
      {
         int res = read();
         if (read() == -1)
         {
            break;
         }

         bytesRead++;
      }

      return bytesRead;
   }


Note:

1  
2  
3  
4  
5  
         int res = read();
         if (read() == -1)
         {
            break;
         }


If you skip(n) you actually skip n*2 bytes.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #5 - Posted 2005-05-10 09:59:48 »

Presuming you're talking about the int:

read() actually reads only a single byte, not an int, it just returns an int. If it read an int, it was actually be n*4, not n*2?

Kev

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #6 - Posted 2005-05-10 10:15:08 »

No.

read() is called TWICE every loop-iteration Roll Eyes

I didn't expect the need to clarify that, because
it was so obvious, but it seems I should have
done it in my first reply. Wink

Fix:

1  
2  
3  
4  
5  
int res = read();
if(res == -1)
{
   break;
}

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #7 - Posted 2005-05-10 10:31:46 »

Doh!

Kev

Offline tom
« Reply #8 - Posted 2005-05-10 18:22:56 »

Thanks Skippy! It's fixed and website updated.

Offline MasterOfDisaster

Junior Member




O_o


« Reply #9 - Posted 2005-05-16 10:55:49 »

... and who's too dumb to get it up and running? it's me (again)  :-/

i download lwjgl and jorbis according to the instructions, placed the jar's and dll's in my classpath but it doesn't compile:

OggPlayer.java:52: cannot resolve symbol
symbol  : method alGenBuffers (java.nio.IntBuffer)
location: class org.lwjgl.openal.AL
       AL.alGenBuffers(buffers);

the import of org.lwjgl.openal.AL is recognized, so i guess i mounted the jars correctly. but why is this method not recognized?

Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Offline tom
« Reply #10 - Posted 2005-05-16 15:26:04 »

I wrote the code a year ago using lwjgl version 0.94 or something. Everytime lwjgl comes in a new version it breaks, and I haven't been updating the source on the website.

I think all you have to do is replace all "AL." with "AL10."

Offline MasterOfDisaster

Junior Member




O_o


« Reply #11 - Posted 2005-05-16 18:00:28 »

did that and it fixed a lot of the compiler errors. thx.
but i still have "unknown symbol" errors on these three lines:

163: AL10.alBufferData(buffer, format, dataBuffer, bytesRead, oggInputStream.getRate());

250: AL10.create();

261: AL10.destroy();

sorry for bothering you with this but i have absolutely no knowledge of openal and i really want to use your  class because streaming ogg sound seems to be the perfect solution for my game.

Offline tom
« Reply #12 - Posted 2005-05-16 20:54:15 »

AL10.alBufferData(buffer, format, dataBuffer, oggInputStream.getRate());

AL.create();

AL10.destroy();

Lwjgl javadoc. I have to warn you that the OggPlayer is not perfect, and is only there to give you an example of how to use OggInputStream. You may have to improve it yourself.

Offline MasterOfDisaster

Junior Member




O_o


« Reply #13 - Posted 2005-05-18 19:52:13 »

works now, thanks. lets see if i can modify that thing to loop the ogg file...

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (78 views)
2013-05-17 21:29:12

alaslipknot (89 views)
2013-05-16 21:24:48

gouessej (122 views)
2013-05-16 00:53:38

gouessej (114 views)
2013-05-16 00:17:58

theagentd (126 views)
2013-05-15 15:01:13

theagentd (113 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (179 views)
2013-05-12 15:36:09

UnluckyDevil (186 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.126 seconds with 21 queries.