mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Posted
2004-06-06 00: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
|
|
|
|
|
oNyx
|
 |
«
Reply #2 - Posted
2004-06-06 09:15:57 » |
|
Just checked it with some modules. It's really great  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:
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)
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Mac_Systems
Junior Devvie  
I love my Java
|
 |
«
Reply #3 - Posted
2004-06-06 12: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
|
|
|
|
oNyx
|
 |
«
Reply #4 - Posted
2004-06-06 13: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  edit²: I guess I could have used %20 aswell (instead of renaming on the server) :>
|
|
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #5 - Posted
2004-06-06 14:25:16 » |
|
Hi there! 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! 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  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. 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  Thanks onyx! 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
|
|
|
|
oNyx
|
 |
«
Reply #6 - Posted
2004-06-06 15:19:40 » |
|
>I'll look into it! Thanks  >I'll fix it. Thanks again 
|
|
|
|
dranonymous
Junior Devvie  
Hoping to become a Java Titan someday!
|
 |
«
Reply #7 - Posted
2004-06-18 15: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>
|
|
|
|
platon79
Senior Newbie 
Java games rock!
|
 |
«
Reply #8 - Posted
2004-07-15 16:48:12 » |
|
It's great!  Now we await an implementation of the famous MicroMod-realTimePlayBack.  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...
|
|
|
|
swpalmer
|
 |
«
Reply #9 - Posted
2004-07-16 03: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!
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #10 - Posted
2004-07-16 11: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  Regards, Martin
|
|
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #11 - Posted
2004-07-16 11:33:26 » |
|
Also, about GC, I'm very careful not to allocate objects during playback, so my player should never trigger a garbage collection.
|
|
|
|
zarr
Junior Newbie
Java games rock!
|
 |
«
Reply #12 - Posted
2004-08-12 05:43:17 » |
|
...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/
|
|
|
|
platon79
Senior Newbie 
Java games rock!
|
 |
«
Reply #13 - Posted
2004-09-25 10:36:45 » |
|
Any new versions coming up?.. 
|
|
|
|
|
zarr
Junior Newbie
Java games rock!
|
 |
«
Reply #15 - Posted
2004-09-27 18:19:52 » |
|
It's also LGPL mmh Yes, it is  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. Btw the the download links are broken. Thanks for pointing that out. A little copy/paste accident...
|
|
|
|
oNyx
|
 |
«
Reply #16 - Posted
2004-09-27 19: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  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.
|
|
|
|
CreoGames
Senior Newbie 
Java games roxor!
|
 |
«
Reply #17 - Posted
2004-11-15 21:04:13 » |
|
Hi, Firstly great work on kbmod  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).  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 );
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();
entry = (JarEntry) entries.nextElement();
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!
|
|
|
|
Grazer
Junior Devvie  
My other avatar is much more flattering.
|
 |
«
Reply #18 - Posted
2004-12-12 23:08:12 » |
|
Yes, it is  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. 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.
|
|
|
|
JoC
Junior Devvie  
I love YaBB 1G - SP1!
|
 |
«
Reply #19 - Posted
2004-12-16 06:13:48 » |
|
Would it be possible to use the modplayer in a applet?
|
|
|
|
JoC
Junior Devvie  
I love YaBB 1G - SP1!
|
 |
«
Reply #20 - Posted
2004-12-16 19: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?
|
|
|
|
jbanes
|
 |
«
Reply #21 - Posted
2004-12-16 19:09:23 » |
|
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.
|
|
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #22 - Posted
2005-01-14 21: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/kbappletThis 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!
|
|
|
|
JuddMan
|
 |
«
Reply #23 - Posted
2005-03-11 04: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.
|
|
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #24 - Posted
2005-03-18 16: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  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 
|
|
|
|
JuddMan
|
 |
«
Reply #25 - Posted
2005-03-21 07:17:45 » |
|
looks more like 2 months of work there... keep us posted.
|
|
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #26 - Posted
2005-03-23 17:45:22 » |
|
Here's a new version. http://geocities.com/sunet2000/kbapplet.htmlI 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
|
|
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #27 - Posted
2005-03-24 00: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
|
|
|
|
c_lilian
Senior Devvie    Projects: 1
Java games will probably rock someday...
|
 |
«
Reply #28 - Posted
2005-03-24 04: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
|
|
|
|
mumart
Junior Devvie   Medals: 1Projects: 1
IBXM Java Music Player
|
 |
«
Reply #29 - Posted
2005-03-24 05: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
|
|
|
|
|