Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3
  ignore  |  Print  
  Java MOD/XM Playback  (Read 24199 times)
0 Members and 1 Guest are viewing this topic.
Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Posted 2004-06-06 02:41:51 »

After a long delay, and prompted by the mysterious disappearance of the Ana-mp project, I am pleased to announce the initial release of the kbmod and kbxm java module players.

These are going to need a little bit of work before they are totally suitable for game development, but I suppose you have to start somewhere.

You can download the players from http://www.geocities.com/sunet2000/

Regards,
Martin
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #1 - Posted 2004-06-06 09:28:31 »

Ooooh XM Grin

Micromod was already really nice but this is a really sweet surprise... and it isn't even xmas Smiley

Right now it's LGPLed, wich doesn't really work for Java (the license itself is absolutely ok for C/C++ stuff). Since most people doesn't like having legal gray areas involved, it might be a good idea to switch to a more appropriated license (BSD style or something similar to the license of lwjgl).

See this thread:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=announcements;action=display;num=1081963711

Oh and welcome to the board Smiley

弾幕 ☆ @mahonnaiseblog
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #2 - Posted 2004-06-06 11:15:57 »

Just checked it with some modules. It's really great Smiley

Unfortunately one of the modules caused kbxm to bomb out (at the very end of the track) for some weird reason.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
 KBXM Fast Tracker 2 Replay ALPHA 0.7
 Copyright (C)2004 Martin Cameron (sunet2000@yahoo.com)
 Website - http://www.geocities.com/sunet2000/

 Filename : Spr-stil.xm
 Song Name: still with me?      
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 35
      at kbxm.Sequencer.setrow(Sequencer.java:87)
      at kbxm.Sequencer.tick(Sequencer.java:80)
      at kbxm.KBXM.getAudio(KBXM.java:94)
      at xmplayer.XMPlayer.main(XMPlayer.java:45)


Here is the file:
--deleted many moons ago-- (~1.8mb)

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mac_Systems

Junior Member




I love my Java


« Reply #3 - Posted 2004-06-06 14:47:11 »

Hmm,

i tested it with serveral .mod's from Amiga Demo Archiv, but no one was falid, i allways get the "No Vaild Mod" Exception.

Stay Tuned,
Jens

The Network is the Music
http://www.mac-systems.de
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #4 - Posted 2004-06-06 15:03:00 »

Try this one:
--deleted many moons ago-- (~246kb)

The mod player is somewhat restricted. 4 channel NoiseTracker and most ProTracker modules.

edit: yabb doesnt like urls with spaces Tongue
edit²: I guess I could have used %20 aswell (instead of renaming on the server) :>

弾幕 ☆ @mahonnaiseblog
Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #5 - Posted 2004-06-06 16:25:16 »

Hi there!

Quote

Right now it's LGPLed, wich doesn't really work for Java (the license itself is absolutely ok for C/C++ stuff). Since most people doesn't like having legal gray areas involved, it might be a good idea to switch to a more appropriated license (BSD style or something similar to the license of lwjgl).


I'll look into it!

Quote

Unfortunately one of the modules caused kbxm to bomb out (at the very end of the track) for some weird reason.
Code:


Well, I didn't call it alpha for no reason! At least it let you hear the tune before crashing Smiley It looks like a bad module with an invalid pattern break (I don't do a lot of checking for things like that). I'll fix it.

Quote

The mod player is somewhat restricted. 4 channel NoiseTracker and most ProTracker modules.


Well, my collection is 100% 4 channel amiga mods, so that's what I focused on. I wasn't sure if anybody used the "multichannel" mod formats like FTK (I added support to micromod after 1 request). Also the extra panning command added to FTK conflicts with some of my amiga mods which used the effect for video synchronization.
Adding FTK support with panning etc is literally about 10 lines of code. I'll put that on my todo list Smiley Thanks onyx!

Quote

i tested it with serveral .mod's from Amiga Demo Archiv, but no one was falid, i allways get the "No Vaild Mod" Exception.

Stay Tuned,
Jens


This might be a stupid question, but are you trying to load .mods into kbxm? You need to use kbmod to play mods. I've got a good reason for splitting the two players up. XM is really not very similar to MOD and each format has it's own quirks. It's much better for good playback to use separate code. I suppose I should be reusing some of the common bits like the mixer and front end. That's a job for later I suppose.

Cheers!
Martin
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #6 - Posted 2004-06-06 17:19:40 »

>I'll look into it!

Thanks Smiley

>I'll fix it.

Thanks again Cheesy

弾幕 ☆ @mahonnaiseblog
Offline dranonymous

Junior Member




Hoping to become a Java Titan someday!


« Reply #7 - Posted 2004-06-18 17:38:32 »

Playing mods is great!  I used to love listening to them on my Amiga.  This sounds like it would be better than trying to use rmf files.

Keep it up!

Regards,
Aaron R>
Offline platon79

Senior Newbie




Java games rock!


« Reply #8 - Posted 2004-07-15 18:48:12 »

It's great!  Grin Now we await an implementation of the famous MicroMod-realTimePlayBack. Wink I modified the code to use normal java-buffering without blocking, but the test-animation would take some small regular pauses from time to time...
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #9 - Posted 2004-07-16 05:29:29 »

What garbage collection algorithm were you using?  Try the incremental collector or -XX:+UseConcMarkSweepGC.

That might eliminate any pauses if they were GC related.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #10 - Posted 2004-07-16 13:28:17 »


Hi!

Garbage collection tweaking will not help with this problem unfortunately. It is caused by the fact that JavaSound is a load of crap. You can only do blocking writes to the sound device because the available() and getMicroSecondPosition() methods of DataLine are too inaccurate (they return values that only change when the buffer is half full).

I solved this in MicroMod by using a timer that estimated the amount of data that could be written to the buffer without blocking, and mixed only the amount of samples that were required. This meant that you could calculate the audio in the graphics thread, eg every frame. This required some quite complicated code because of things like volume ramping.

The current players are simplified as much as possible, and so this is not implemented. The best you can try right now is reducing the buffer size to about 20ms (which is the default "tick" length in MOD).

In the next version (when I get around to it!), I will put this feature back in. I'm also planning on getting it integrated into a gaming library and converting it to use integer arithmetic for J2ME Smiley

Regards,
Martin

Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #11 - Posted 2004-07-16 13:33:26 »


Also, about GC, I'm very careful not to allocate objects during playback, so my player should never trigger a garbage collection.
Offline zarr

Junior Newbie




Java games rock!


« Reply #12 - Posted 2004-08-12 07:43:17 »

Quote
...prompted by the mysterious disappearance of the Ana-mp project


I'm sorry about that... The explanation is simple: My old university account finally expired. The new home of ana-mp is at http://ana-mp.sourceforge.net/
Offline platon79

Senior Newbie




Java games rock!


« Reply #13 - Posted 2004-09-25 12:36:45 »

Any new versions coming up?..  Wink
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #14 - Posted 2004-09-25 14:17:07 »

Oh... there's another mod lib Shocked

It's also LGPL mmh :-/

Y'know the LGPL is somewhat scary for the java folks, because it doesn't fit. I read the license several times and followed alot of discussions and I'm still not sure what I should think of it.

Please consider another license (BSD style is preferred for java stuff these days Wink).

Btw the the download links are broken. They contain an additonal '\', which doesn't belong there.

Eg:
https://sourceforge.net/project/showfi\les.php?group_id=103725

instead of:

https://sourceforge.net/project/showfiles.php?group_id=103725

弾幕 ☆ @mahonnaiseblog
Offline zarr

Junior Newbie




Java games rock!


« Reply #15 - Posted 2004-09-27 20:19:52 »

Quote
It's also LGPL mmh  


Yes, it is Smiley I use the lgpl simply because I want modifications to it to be free, while I don't really care about software that only uses (links to) it. If you know of a (non-obscure) license that let me express the same thing, please let me know. I suspect though, that If I _had_ to change the license, I'd go for the gpl, not something bsd'ish.

Quote
Btw the the download links are broken.


Thanks for pointing that out. A little copy/paste accident...
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #16 - Posted 2004-09-27 21:42:00 »

Yes, I know. LGPL sounds great - theoretically. However, how it has to be applied to java is pretty much undefined, which means it's a risk.

GPL would prevent 95% or even more from using it. It's highly unlikely that I'll ever use any GPLed lib.

BSD sounds like a bad deal at the first glace... but y'know there is common sense. If I find a bug or a way to improve it, I'll let those guys know about it. Everything else would be plain silly, because I would have to change each upcoming version again and again and again - there is really no benefit doing so Wink

Or let's say I need some kind of flag for changing the behaviour of parts of a lib for *one* special case. Let's also asume that no one else could use something like that or that it's a very cheap thing. A forced release of this oddly forked lib wouldn't do any good.

弾幕 ☆ @mahonnaiseblog
Offline CreoGames

Senior Newbie




Java games roxor!


« Reply #17 - Posted 2004-11-15 22:04:13 »

Hi,

Firstly great work on kbmod Smiley

I seem to have a problem though. I want load my .mod's from their own .jar. This is so I can update my game code (in another .jar) whenever I like and users don't need to redownload the music files.

I have written some code to perform this, but for some reason I always have a corrupt inputstream, the music plays ok to begin with (just), then gets worse.

Any ideas where i'm going wrong on this (code below)?

Ideally, however, I would like to use some other .mod code that I have already within my game (it'll be a nightmare to switch to kbmod at this point). This, however, uses RandomAccessFile for loading the .mod, not streams.

I understand from trying to do this all day that I can't use that directly as the file is in .jar, and a seperate one from the playback code, at that, so streams, I was informed was the only way to go. Then I found kbmod and tried to get it working.

Is there an easy way to make JNLP work with RandomAccessFile at all? Somebody suggested extracting the file on execution and using that, but I don't see an easy way to do that.

Is there something obvious i'm overlooking for using RandomAccessFiles within JNLP jar's?

On a side note I gave a shareware JNLP creator a whirl and it seemed to fix up my original (definately non-JNLP compatible - playing the .mods from the same .jar, however) code somehow. Still a big step ahead of me (who currently sees no easy way to play .mods with JNLP/JARs). Sad



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
public class Player {

      JarFile jar = null;
      InputStream entryStream = null;
      Module m = null;
      SourceDataLine line = null;
      JarEntry entry = null;

      public Player()
      {

            PlayStream();

      }

      public void PlayStream()
      {

            try
            {
                  m = new Module(this.load());
            }
            catch (Exception e)
            {}

            KBMod player = new KBMod( m );
            System.out.println( " Song Name : " + m.name );

            // Allocate the output buffers.
           float[] lBuf = new float[3600];
            float[] rBuf = new float[3600];
            byte[] output = new byte[14400];

            AudioFormat format = new AudioFormat( 44100, 16, 2, true, false );
            DataLine.Info lineInfo = new DataLine.Info( SourceDataLine.class, format );
            try
            {
                  line = (SourceDataLine)AudioSystem.getLine(lineInfo);

                  line.open( format );
                  line.start();
            }
            catch (Exception e)
            {
            }

            while( true )
            {
                  int len = player.getAudio( lBuf, rBuf );
                  int outpos = 0;
                  for( int n=0; n<len; n++ )
                  {
                        short l = (short)( lBuf[n]*32767 );
                        short r = (short)( rBuf[n]*32767 );
                        lBuf[n] = 0;
                        rBuf[n] = 0;
                        output[outpos++] = (byte)(l&0xFF);
                        output[outpos++] = (byte)(l>>8);
                        output[outpos++] = (byte)(r&0xFF);
                        output[outpos++] = (byte)(r>>8);
                  }
                  line.write( output, 0, len<<2 );
            }
      }

      public InputStream load()
      {

            try
            {
                  jar = new JarFile("Music.jar");
            }
            catch (Exception e)
            {}
            Enumeration entries = jar.entries();

            // Get the next entry.
           entry = (JarEntry) entries.nextElement();

            // Get an input stream for the entry.

        try
        {
              entryStream = jar.getInputStream(entry);
            }
            catch (Exception e){}

            return entryStream;
      }

      public static void main( String[] args ) throws Exception
      {
            Player p = new Player();
      }
}


kbmod outputs these errors:

Instrument 1 : 903 samples missing!
Instrument 3 : 365 samples missing!
Offline Grazer

Junior Member




My other avatar is much more flattering.


« Reply #18 - Posted 2004-12-13 00:08:12 »

Quote

Yes, it is Smiley I use the lgpl simply because I want modifications to it to be free, while I don't really care about software that only uses (links to) it.

LGPL has lots of stupid little clauses that slip your attention but actually prevent a lot of commercial applications from using LGPL code.
One example is that programs that use LGPL code must be released under a licence that permits reverse engineering.

Quote
If you know of a (non-obscure) license that let me express the same thing, please let me know.

I think the Apache Licence does what you want.
I use it for all my (free) projects.
I'm pretty sure (98%) that modifications have to be released under the same licence.
Anybody who knows better, please correct me.

Current Project: Easy Decal
Other Stuff: grlea online
Offline JoC

Junior Member




I love YaBB 1G - SP1!


« Reply #19 - Posted 2004-12-16 07:13:48 »

Would it be possible to use the modplayer in a applet?
Offline JoC

Junior Member




I love YaBB 1G - SP1!


« Reply #20 - Posted 2004-12-16 20:01:42 »

ok, i made a simple applet but I get this error:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
java.security.AccessControlException: access denied (java.io.FilePermission her2.mod read)
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkRead(Unknown Source)
      at java.io.FileInputStream.<init>(Unknown Source)
      at java.io.FileInputStream.<init>(Unknown Source)
      at player.Playerapplet.<init>(Playerapplet.java:44)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance0(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at sun.applet.AppletPanel.createApplet(Unknown Source)
      at sun.plugin.AppletViewer.createApplet(Unknown Source)
      at sun.applet.AppletPanel.runLoader(Unknown Source)
      at sun.applet.AppletPanel.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)


Any ide how to solve this?
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #21 - Posted 2004-12-16 20:09:23 »

Quote
ok, i made a simple applet but I get this error:

1  
java.security.AccessControlException: access denied (java.io.FilePermission her2.mod read)


Any ide how to solve this?


Yep. Don't use an Applet. Applets explicitly disallow you from accessing the local file system. So unless there's a URL method for loading the file (which there may well be, make sure you check), you really can't play the files in an applet.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #22 - Posted 2005-01-14 22:07:13 »

Sorry about the lack of communication/effort etc. I'm a lazy git. For an example of using kbmod in an applet and loading mods over http visit http://geocities.com/sunet2000/kbapplet

This uses some slightly tweaked code which prevents the data being trashed by the loader.

A greatly improved, integer-only mod/ftk/s3m/xm player is on the way!
Offline JuddMan

Senior Member


Medals: 1


Your Ad Here


« Reply #23 - Posted 2005-03-11 05:48:26 »

the XM player is really excellent. just one problem where if you're doing a lot of scrolling around in internet explorer with it in the background, it gets all choppy.

if that bug gets cleared up, i'm going to be swapping my midi/rmf code for this...

or maybe i'll keep them both.
Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #24 - Posted 2005-03-18 17:03:02 »

I'm going to do an SPI for the next version, so it should be much easier to integrate (this would make any choppiness purely the fault of Java and nothing to do with me Smiley

I haven't made much progress on it these past few months, but I'm laying down the gauntlet now.

Within 2 weeks:

BSD Licence.
Robust MOD/S3M/XM playback.
32bit accumulator Integer arithmetic throughout.
J2ME compatible replay engine.
Will include an SPI for easy JavaSound integration.
Sample accurate song length calculation.
FAST 16 point FIR interpolator (already written, uses a really cool fully vectorisable algorithm)

Or your money back Smiley
Offline JuddMan

Senior Member


Medals: 1


Your Ad Here


« Reply #25 - Posted 2005-03-21 08:17:45 »

looks more like 2 months of work there... keep us posted.
Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #26 - Posted 2005-03-23 18:45:22 »

Here's a new version.

http://geocities.com/sunet2000/kbapplet.html

I haven't fixed any playback bugs (probably added
a few). MOD playback is still limited to 4 channels,
but I'll fix that and maybe add S3M within the next
few days.

Here are the obvious changes.

BSD licence!

New integer mixing algorithms with improved quality
(but slower because I have used a big piece of glue to
adapt the new resampling interface to the old one).

More reliable XM loading.

MOD/XM playback in a single codebase.

Simple Applet included.

Have fun!
Martin
Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #27 - Posted 2005-03-24 01:12:54 »

I have just been gathering some more of my code in one place. Now most MODs with more than 4 channels will play, and if you download the jar and run it with "java -jar" (or double-click it in recent Windows JVMs) you will be greeted with a craptacular, barely functional drag+drop GUI which lets you adjust the interpolation.

Tomorrow I'll do some work on fixing some more crashing bugs (ie some of those reported last year)

Cheers,
Martin
Offline c_lilian

Senior Member


Projects: 1


Java games will probably rock someday...


« Reply #28 - Posted 2005-03-24 05:46:13 »

Hi, is java 1.5 really needed ? (couldn't test on a Mac).

I'll check out the source later to verify it, but if you already have an answer, it will save up time from me...

Thanks !

Lilian

Offline mumart

Junior Member


Medals: 1
Projects: 1


IBXM Java Music Player


« Reply #29 - Posted 2005-03-24 06:24:00 »

The player should work on Java 1.3 or above. You should have no trouble running it with the MacOS X built-in Java.

The engine code should theoretically work with Java 1.1, but stock Java 1.1 only supports 8khz mono audio, and even then you can only perform streaming by using undocumented classes.

Cheers,
Martin
Pages: [1] 2 3
  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.

CogWheelz (14 views)
2014-08-01 22:53:16

CogWheelz (14 views)
2014-08-01 22:51:43

CopyableCougar4 (15 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

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

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

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

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

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
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!