Show Posts
|
|
Pages: [1] 2
|
|
2
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: How to plau a mod sound file in java!
|
on: 2012-05-13 21:57:56
|
I have written several Java mod-player libraries over the years. The source code for the most recent ones can be found at http://code.google.com/p/micromod/My question is how can these files be converted into sound in modern day computers?? (I know they can, JavaModPlayer2 is a good mod player). I'm assuming that the original notes in the mod files were directly fed to the 15 hardware instruments that resides in the Amiga.
Wouldn't this undoubtedly make mod files sound different on practically every computer depending on how the 15 Amiga instruments are emulated?
The Amiga did not have any built-in instruments, the original SoundTracker MOD format could have up to 15 8-bit samples contained within the file. Every mod file contains the sample data for all instruments within it. The early mods all sounded the same because everybody used the instruments provided with SoundTracker, on a disk called "ST-00". How do modern mod players play mod files? Do they decode into another format first, like mp3? Or do they directly feed the information to the sound hardware - how do they do that? Does Java provide an API for this?
Usually they generate a PCM wave-file a fraction of a second at a time (10-100ms depending on the tempo) using sample-rate conversion for each channel and mixing them together. Java can play PCM sample data using an appropriately configured javax.sound.sampled.SourceDataLine. Any differences in the sound between different players is generally due to the quality of the sample rate conversion. The original Amiga hardware did not have any oversampling, and the sound quality was comparable to using nearest-neighbour resampling at a high sample rate such as 96000hz. Cheers, Martin
|
|
|
|
|
8
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: [1.5.0]sampled stuff isn't working anymore
|
on: 2005-04-14 18:47:58
|
Have I hit the same bug? No I haven't. A bug in my read method caused it to return 0 every time. I'm surprised I can get anything I write to work these days  Clips seem to work every time for me, although streaming mods through the clip interface is slow and takes up enormous amounts of memory. It's obviously not designed for that. Have I hit the same bug? I've written a seekable InputStream for my modplayer, and verified that it spits bytes out (so I should hear /something/, even if it is just noise  . The following code is silent: 1 2 3 4 5
| AudioFormat format = new AudioFormat( rate, 16, 2, true, false ); AudioInputStream ais = new AudioInputStream( new IBXMInputStream( i ), format, i.getSongLength() ); Clip c = AudioSystem.getClip(); c.open( ais ); c.start(); |
|
|
|
|
|
9
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: [1.5.0]sampled stuff isn't working anymore
|
on: 2005-04-12 16:08:34
|
Have I hit the same bug? I've written a seekable InputStream for my modplayer, and verified that it spits bytes out (so I should hear /something/, even if it is just noise  . The following code is silent: 1 2 3 4 5
| AudioFormat format = new AudioFormat( rate, 16, 2, true, false ); AudioInputStream ais = new AudioInputStream( new IBXMInputStream( i ), format, i.getSongLength() ); Clip c = AudioSystem.getClip(); c.open( ais ); c.start(); |
|
|
|
|
|
10
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-04-10 01:53:59
|
In the spirit of not keeping things back, here's another alpha! http://geocities.com/sunet2000/ibxm-alpha30.jarThe framework is now feature complete, and the interface is not likely to change. Probably still has quite a few bugs, though. XM is an amazingly quirky format. Some might even say "baroque"  All the effects that I want to implement are now done. I've had some feedback and it appears that playback is very accurate (or as he put it, "blimmin amazing!!") and much better than kbxm. Certainly good enough for gaming! Also there has been a bit more tuning and bugfixing, and the commandline player application now lets you choose the interpolation. Next job is S3M  Cheers, Martin
|
|
|
|
|
11
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-04-08 12:16:34
|
Good work  Did switching to integer arithmetic improve performance? (Do you have some numbers?) I measured the time it takes to mix the entire song at 44100hz with linear interpolation without writing the result on a bunch of different versions, all use integer arithmetic except for KBMod. Tests done on a 1500mhz Sempron with Java 1.5.0: Song: Jogeir Lilljedahl - Guitar Slinger (299 seconds) MicroMod 0.83 : 1516ms MicroMod 0.98 : 2250ms KBMod : 6359ms IBXM: 1672ms IBXM-Fastmix: 1156ms Song: TNT - Once More TNT (195 seconds) MicroMod 0.83 : 906ms MicroMod 0.98 : 1297ms KBMod : 3344ms IBXM: 984ms IBXM-Fastmix: 687ms Even the slowest of these only takes 2% of this cpu  IBXM is nearly 4x faster than KBMod. Floating point has quite a speed penalty! "IBXM-Fastmix" is a test version that directly mixes into a mono 8 bit byte array and only supports forward sample loops. Since it's only 50% faster and poor quality I probably won't follow it up. The fastest player with good quality mixing is MicroMod 0.83, but only by 10% or so, which did surprise me, given how naive the mixing code is in that player. IBXM sounds much better, anyway  I may be able to optimise it to close that gap. The slowness of MicroMod 0.98 comes as no surprise. I'm surprised it's not slower, given how much buffer copying it does. Oh and right now there isn't a way to cleanly exit the demo player. Pressing ctrl+c can result in an endless loop of the last frame (until you reboot), because the cleanup stuff isn't reached. There are several ways to fix it, but it would make the programm more complicated, which isn't necessarly a good thing. So, just print a message that it's better to let it run through  I see, I've never come across that problem before. I'll bear it in mind. Cheers, Martin
|
|
|
|
|
12
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-04-07 21:00:16
|
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.jarPlays 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 <modfile> Cheers, Martin
|
|
|
|
|
13
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-03-25 17:25:58
|
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!  PS. Just downloaded it! nice music! hehe.. takes me back to the mid 70's when i was a teeny tiny kid! haha.. 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
|
|
|
|
|
14
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-03-25 14:58:16
|
Thank you
So you'll have to update the demo applet, which has a class version of '49' (java 1.5).
Lilian 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.
|
|
|
|
|
15
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-03-25 14:20:51
|
Got the classloader getting the file path etc, but just cant fathom out how to then pass the info to the: 1
| 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 :-/) 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.jarCheers, Martin
|
|
|
|
|
17
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-03-24 23:39:38
|
|
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");
|
|
|
|
|
18
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 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
|
|
|
|
|
19
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 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
|
|
|
|
|
20
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2005-03-23 18: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
|
|
|
|
|
21
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 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  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 
|
|
|
|
|
22
|
Game Development / Performance Tuning / Re: New VM performance improvements
|
on: 2005-02-06 00:25:39
|
Operations on streams can be very cool too ( and subject to massive optimizations using MMX, 3DNow, SSE, SSE2, SSE3, etc ). 1 2 3 4 5 6
| void add( int value, int[] stream, int offset, int length ); void mul( float factor, float[] stream, int offset, int length ); void xor( short mask, short[] stream, int offset, int length ); void lshift( int amount, int[] stream, int offset, int length ); void clamp( byte lbound, byte ubound, byte[] stream, int offset, int length ); ... |
Ah yes, the wonderful MMX, where 1*1 = 0.5 I would love to be able to use SIMD from java, though.
|
|
|
|
|
24
|
Game Development / Networking & Multiplayer / Re: Scrambled/Cooked data over HTTP connection.
|
on: 2004-09-26 12:51:37
|
I figured it out eventually! I was parsing the file using the read() methods of a basic InputStream. I didn't realise these were non-blocking calls and not all the data I asked for was guaranteed to be read.  The bug didn't show up when reading from local files because the IO could keep up with the program. Now I'm using a DataInputStream all is OK. Thanks for your help! Martin
|
|
|
|
|
25
|
Game Development / Networking & Multiplayer / Scrambled/Cooked data over HTTP connection.
|
on: 2004-09-26 01:22:33
|
|
I've been doing some small experiments with applets and I've run into some trouble. I'm sure there must be a really simple solution to this.
I have a binary file on a webserver and am using the following code to access it from an applet:
url = new URL( getDocumentBase(), getParameter( "filename" ) ); InputStream i = url.openStream(); // ... Read bytes and close stream
The problem is the data I receive is scrambled. I'm not sure exactly how the scrambling is done but I assume it's being "cooked" (inappropriate ascii cr/lf conversion).
The file is not scrambled when I download it using a web browser so there's no problem with the source. The content-type is "audio/mod". My guess is java doesn't understand this and is treating it as ascii.
I have tried getting a URLConnection and manually setting the "content-type" request property to "application/octet-stream" but that didn't help. Maybe this is only used for sending data?
Hope someone can help!
Martin
|
|
|
|
|
27
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Ok Linux users - Proove your OS!
|
on: 2004-09-11 21:04:13
|
|
The DMA messages suggest that the driver isn't working.
Make sure you have the latest drivers by installing the most recent kernel package. Have a look into apt-rpm, which can be used to automatically update your system.
Redhat 6.2 is quite old, you should consider updating to something like fedora if possible.
|
|
|
|
|
29
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 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  Regards, Martin
|
|
|
|
|
30
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Java MOD/XM Playback
|
on: 2004-06-06 16: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
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|