Java MOD/XM Playback

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


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?

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


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

Any ide how to solve this?
[/quote]
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.

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!

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.

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 :slight_smile:

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 :slight_smile:

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

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

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

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

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

Thank you

So you’ll have to update the demo applet, which has a class version of ‘49’ (java 1.5).

Lilian

Look forward to a new version!
ive currently got your micromod libraries working in some VERY early game code and the mods play great…until I try to put everything into a jar file and then my code just dies as with a previous members post, couldnt fathom out how to get the mod file loaded from within the jar file etc.!
Searched for more info on the RandomAccessFile to see if I could get it working but no luck (still a newbie so some of the docs may as well be written in Swahili :D)

PS. great to be able to hear some classic Amiga mods again!

A neat trick for getting hold of files inside jars is to make use of a classloader. This works for me with images, so it should work with mods aswell.

If you put the file in the same place as the current class, this should return a URL to the file, whether it’s in a Jar or not:

URL url = this.getClass().getResource(“filename”);

[quote]Thank you

So you’ll have to update the demo applet, which has a class version of ‘49’ (java 1.5).

Lilian
[/quote]
Doh! Will recompile.

Got the classloader getting the file path etc, but just cant fathom out how to then pass the info to the:


module = ModuleLoader.read(new RandomAccessFile(modFile, "r"));

as it keeps throwing an error no matter how i try to pass the url to it (even converting to a String it lets it compile, but then get a NullPointerException :-/)

[quote]Got the classloader getting the file path etc, but just cant fathom out how to then pass the info to the:


module = ModuleLoader.read(new RandomAccessFile(modFile, "r"));

as it keeps throwing an error no matter how i try to pass the url to it (even converting to a String it lets it compile, but then get a NullPointerException :-/)
[/quote]
Here’s a micromod jar with a built-in mod to show you how it’s done.

You’ll probably need Java 1.5 to run the jar, because that’s what I compiled it with. [EDIT] I’ve rebuilt it, and it should work on 1.3+ now.

http://geocities.com/sunet2000/micromod098.jar

Cheers,
Martin

[quote]Thank you

So you’ll have to update the demo applet, which has a class version of ‘49’ (java 1.5).

Lilian
[/quote]
OK, I’ve recompiled the applet with -source 1.3 and -target 1.1, so it’ll work on pretty much anything that has a JavaSound implementation now.

Martin.

Thanks Martin, just about to download the jar file!

Fingers crossed the game will get finished (first EVER game on the PC so its a REALLY slow process hehehe)
so you’ll be able to see your name in lights (well, lots of phosphor dots anyway! hehehe) with the mod player credit! ;D

PS. Just downloaded it! nice music! hehe… takes me back to the mid 70’s when i was a teeny tiny kid! haha…

PPS! works great! thanks m8! much appreciated!

[quote]Thanks Martin, just about to download the jar file!

Fingers crossed the game will get finished (first EVER game on the PC so its a REALLY slow process hehehe)
so you’ll be able to see your name in lights (well, lots of phosphor dots anyway! hehehe) with the mod player credit! ;D

PS. Just downloaded it! nice music! hehe… takes me back to the mid 70’s when i was a teeny tiny kid! haha…
[/quote]
Nice one! Java can be hard work at times. I think the classes are usually well designed, but they don’t seem to do much to help you get things done. Getting drag and drop to work was an exercise in futility!

Cheers,
Martin

OK, I didn’t make the 2-week deadline, but it’s good to put pressure on yourself from time to time!

Here’s an alpha of my new player, called IBXM. I’ve spent the last couple of days tuning it, and it sounds much better than KBXM on a lot of modules.

http://geocities.com/sunet2000/ibxm-alpha26.jar

Plays MOD and XMs. S3M support is not done (but only because I haven’t written the loader yet). SPI is coming soon.

The player is 100% integer arithmetic, and has generally cleaner code than KBXM (which itself wasn’t so bad IMO).

Use the commandline to test (as usual):
java -jar ibxm-alpha26.jar

Cheers,
Martin