Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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 2847 times)
0 Members and 1 Guest are viewing this topic.
Offline tom
« Posted 2004-01-07 19: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 08: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 11: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!
Legends of Yore - The Casual Retro Roguelike
Offline lebasti

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-01-09 15: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: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2005-05-10 07: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
Offline kevglass

JGO Kernel


Medals: 153
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2005-05-10 07: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: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2005-05-10 08: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
Offline kevglass

JGO Kernel


Medals: 153
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


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

Doh!

Kev

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

Thanks Skippy! It's fixed and website updated.

Offline MasterOfDisaster

Junior Member




O_o


« Reply #9 - Posted 2005-05-16 08: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!
Legends of Yore - The Casual Retro Roguelike
Offline tom
« Reply #10 - Posted 2005-05-16 13: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 16: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 18: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 17: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.

 

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

The first screenshot will be displayed as a thumbnail.

atombrot (27 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!