Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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  
  Procedural Instruments  (Read 3967 times)
0 Members and 1 Guest are viewing this topic.
Offline zingbat

Senior Member




Java games rock!


« Posted 2003-05-02 00:59:07 »

Is there any way to create procedural instruments (like wav sounds but procedural) ? And if possible can they be used to replace instruments from a previously loaded midi music file ? Thanks.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #1 - Posted 2003-05-02 15:53:00 »

yes.  you can generate whatever bytes you want to write to a SourceDataLine.. look at javax.sound... and I guess the GAGE stuff..

Offline zingbat

Senior Member




Java games rock!


« Reply #2 - Posted 2003-05-03 12:14:58 »

Quote
yes.  you can generate whatever bytes you want to write to a SourceDataLine.. look at javax.sound... and I guess the GAGE stuff..


What i want to do with it is this: i have some midi musics from a old game with very bad instruments, so i wanted to convert that midi music to my own format (probably xml) and replace those instruments by procedural ones, which should take much less space. And besides procedural instruments can avoid that problem of distortion of the instrument sound when changing its tone.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #3 - Posted 2003-05-03 23:47:08 »

Ah.. I see.. not sure about that.. I would dig deeper into the source code that comes with the JDK - it might be possible..  I thought at one time there was a download of MIDI instruments onthe Java site.  But how they are actually played internally I don't know.

Offline Woz

Senior Newbie




A Troll who lives in a hole


« Reply #4 - Posted 2003-05-05 12:55:52 »

Zigbat it is quite possible to create procedual instruments, if you are prepared to spent $299.

In yet another big mistake made by SUN they decided to use proprietary technology to try and improve Java, rather than use open standards.

This is not the first time they've done this and it wont be the last (deciding not to use OpenGL, was another big mistake - although this appears to be a spat between the Java Community Process [JCP] and the ARB).

Of course I would argue that this would never have happened if Java was Open Source in the first place, but then Java is very much product (it wont ever be open source unless IBM buys SUN) and is the only thing that keeps SUN visible in the computer market place (Java this, Java that, J-blahblah).

No hires timer, only mono support for 8Khz .au files in Java 1.1.4, the list goes on.

This behaviour seem to be on purpose too, because they are just not address the issues relevant to game developers. Sure they've always got something round the corner...  This is called vapourware!


It's interesting to note that Microsofts J++ allows access to Direct X, but sun still haven't got things sorted out to an equivalent level.

Does Java support 24bit audio? Does it support 96Khz? Does it support > 32 channels? Will it ever? Not that its got the processing power to use it.

Have they fixed the audio latency problem yet? No, of course this could very well be classes as not possible due to audio being classified as "Hard Real Time", in that any slight pause will cause the audio stream to stop and cause crackling and stutters.

Hard real time applications are very difficult to do in Java, which is why there is a LARGE audio buffer to stop the crackling, this is not helped by Javas poor timing, in both threads and system clock ms accuracy is FAR to low we should be having Mhz timing not some pathetic sub 1 Khz range.

Anyway I'm sure your not that interested in all this so what you need to be doing is creating a RMF file, which is capable of storing both music and instruments of your own creation. You can then just open it like a standard wave file to play in Java.

They still have latency problems though apparently (50-100ms), and from the sun examples I've played with they have timing problems too. But I could hardly say I'm an expert in using them so have a play around yourself rather than taking my word.

Do a search in your JDK/SDK (not JRE) for *.RMF files, there will be a demo for you to try:
SDK 1.3 : There is a Java2D demo containing RMF playback, look for the mix tab (bottom left) "Java Media".
JDK 1.2.1 : Had a separate JavaSound.class demo, that requires running with java demos.Mix.JavaSound

It's quite simple to use (if memory serves correct), something like:
       URL url = JavaSound.class.getResource( name );
       clip = Applet.newAudioClip(url);

In order to create RMF files you will need the Beatnik Editor located here:
http://www.beatnik.com/products/editor.html

The trial version will not save RMF files. The Beatnik Editor is the only piece of software that will allow you to create RMF files (unless things have changed radically since I last looked).

The sound channels (all 32 of them) are at least mixed natively, so you will actually be able to do other things whilst it is playing.

Personally I'd try an XM player, which Beatnik is based on anyway and they are either free or shareware. It's also an open standard so you can write your own player if you so wish.

There are also plenty of Midi to XM converters floating around.

------
Woz.

P.S. This sounds like trolling, but the only way to get SUN to fix it is to get on their back. Have they changes anything since the Java Media Framework implementation??? No.

P.P.S. You don't have to go far to find someone having difficulty implementing JavaX.Sound.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #5 - Posted 2003-05-05 13:53:26 »

It's true that MIDI using java is not really great (you'll get horrible timing issues).

Quote
And besides procedural instruments can avoid that problem of distortion of the instrument sound when changing its tone.

What kind of distortion do you mean? If you mean 'zipper noise' (caused by MIDI's low controller resolution), than this can (and I believe most recent synths have) also be solved in the specific MIDI implementation by interpolation.

I'd go for a MIDI to .wav translation (sort of like the 'CSound way') as well instead of trying to do it realtime.
It would be a lot of work though, and maybe it would be easier to just load up the MIDI files in Cubase SX and reassign the program changes and maybe use SX's VST Instruments?

Quote
Zigbat it is quite possible to create procedual instruments, if you are prepared to spent $299.

How's that?

Quote
P.S. This sounds like trolling, but the only way to get SUN to fix it is to get on their back.

Then maybe you should do just that. Off-topic complaining like this won't have much of a positive effect I'm afraid.

Offline Woz

Senior Newbie




A Troll who lives in a hole


« Reply #6 - Posted 2003-05-05 15:32:49 »

In order to create RMF files, you need the Beatnik Editor http://www.beatnik.com/products/editor.html which will cost you $299.

Should have made that clearer.

There is no Linux version at all, although it is available for the Mac & Windows.

Using a midi to wave convertor is often a cunning solution when CPU usage is tight, but unfortunately generates some large files unsuitable for modem access. 31Meg for 3 minutes at CD stereo quality.

MP3 would normally be a good idea but prending a lisensing issue MP3 encoding and decoding has been removed from JMF 2.1.1b (Available since, 29-Aug-02, and works with Java 1.4 ).

Personally I would have thought that it was an encoding issue.

------
Woz.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #7 - Posted 2003-05-05 19:06:05 »

Quote
Using a midi to wave convertor is often a cunning solution when CPU usage is tight, but unfortunately generates some large files unsuitable for modem access. 31Meg for 3 minutes at CD stereo quality.

Yes that's true. Although you could opt to generate the wav's (or maybe a compressed format) at install time. Might take a bit of time though...
And... zingbat, you'll have to be prepared to create your own procedural instruments (which are bound to be 'synthy' sounds, not realistic sounding ones). I heard some time ago that there is a java implementation of CSound though, which might be interesting (although, IIRC, it performs about 1/6th of the speed of the C version, and 1/3 of the C++ version. So much for the 'with recent JIT VM's, java is not really slower than C/C++ anymore' argument. Well, at least in this case anyhow; we all now we shouldn't make general assumptions based on numbers like that, right? Smiley). It might help, but it has a learning curve.
Look for CSound on google if you're interested. It's been more than 10 years ago since I did anything with CSound so I can't be of any help in that I'm afraid.

Quote
Anyway I'm sure your not that interested in all this so what you need to be doing is creating a RMF file, which is capable of storing both music and instruments of your own creation. You can then just open it like a standard wave file to play in Java.

I don't understand: open an RMF file as a WAV file? You mean after exporting the RMF to WAV, I suppose? This WAV will be too large for us poor dial-up folks too, no?  Smiley

Offline Woz

Senior Newbie




A Troll who lives in a hole


« Reply #8 - Posted 2003-05-05 21:26:18 »

Erik,

To play a RMF (or Rich Music Format (tm) to give it's full name) is no different from play a wav file in java.

It uses the same AudioClip class the only difference is the file name.

For example to play the standard "Ambient.rmf" file that comes with all SDK's in your applet, place the following code in your start() method:

1  
2  
3  
        URL url = MyApplet.class.getResource("Ambient.rmf" );
        AudioClip clip = Applet.newAudioClip(url);
        clip.play();


Where "MyApplet" is the name of your applet class, the "Ambient.rmf" must be placed in the same directory as the generated class files.

The RMF file allows you to create your own instruments, which are stored in the RMF file as well. These are not General Midi instruments (although you have access to all the "soundbank.gm" instruments that comes with Java if you so wish).

These RMF files, even though they contain the insturments as well as the note information are considerably smaller than the same peice of music converted to a wav file. Which just about brings them into the size range for modem users, although it will depend on the size/type/range of instruments used.

Beatnik's .pdf description of the RMF file, albeit a short one, can be found here:
http://www.beatnik.com/pdf_files/rmf_datasheet.pdf.

Which should make clear what a RMF file is, and what it contains.

------
Woz.

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #9 - Posted 2003-05-06 10:02:46 »

Aahhh I see, thanks.  Smiley
Would be neat if there were open technologies available to create RMF's (or even more than 1 tool). Now it's close to useless as I'd never spend $299 for a tool that I don't need for anything else then some obscure file format Sad

Erik

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

Senior Member




Java games rock!


« Reply #10 - Posted 2003-05-06 20:52:52 »

It seams that RMF would do what i need for a better midi, but since its commercial its out of the question.

I am a little rookie on java sound. I used to make musics some years ago with an Amiga and an application called Impulsetracker. At that time music files where called mods.

Java sound may have a potetntial to create my own sequence format (midi format) in xml so the problems with java midi would be avoided.

Wav may be limited in the java api but we can create our own unlimited format for sample data (wavs) right ? What about streamlining a wav from a procedure that would generate the data ?

Quote

What kind of distortion do you mean? If you mean 'zipper noise' (caused by MIDI's low controller resolution), than this can (and I believe most recent synths have) also be solved in the specific MIDI implementation by interpolation.


No i mean that when i used Impulsetracker back in the Amiga there was only one instrument per musical note. The waves for notes where recorded for the middle of the scale so If i wanted to use another note say from C to D the player would simply change the frequency of the note which would cause a distortion.

The solution with impulsetracker was to add several waves for the same instrument but different musical notes , say B, D, E for instance to avoid the frequency change distortion. But the size of the music file was much bigger.

With procedural instruments this would be easly avoided while mantaining a good file size. Not counting with the realism of course.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #11 - Posted 2003-05-07 07:12:35 »

Quote
No i mean that when i used Impulsetracker back in the Amiga there was only one instrument per musical note. The waves for notes where recorded for the middle of the scale so If i wanted to use another note say from C to D the player would simply change the frequency of the note which would cause a distortion.


Ah yes, that's the general problem of using sampling for sound synthesis (the imfamouse 'donald duck' effect  Smiley). You could completely rely on sound synthesis on the fly, but depending on how complex you want your sounds to be, you could be in for a performance drop, and you might still encounter timing issues. 'Tracker' music is still used in games (unreal for example), but I don't like the sound of it (because of the problem mentioned amongst others) and the files tend to get as big as an MP3.
You could still consider generating OGG's, MP3's or WAV's at install time using procedural instruments like you mentioned. You would avoid timing issues too (which I believe are not specific to javasound, but to timing issues in java in general).
BTW, JEF (Java Emulation Framework) has a few soundchip emulators (simple blockpulse/noise generators, but also a yamaha FM synthesizer chip and namco sound system is a soundgenerator with different waveforms stored in ROM) which might help.

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #12 - Posted 2003-05-07 15:27:25 »

Just thought I would through these links into the thread  (Java MOD players - I haven't tried them)

http://website.lineone.net/~martin.cameron/

http://t2.technion.ac.il/~shlomif/jmikmod/

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #13 - Posted 2003-05-07 15:39:49 »

http://java.sun.com/products/java-media/sound/techReference/mantis.html

...mentions improved MIDI support in 1.4.2  have you tried the beta?

Offline zingbat

Senior Member




Java games rock!


« Reply #14 - Posted 2003-05-08 22:39:05 »

By the way if you don't know already check out all the Amiga mods for all games. There are tons of great musics in here:

http://www.mirsoft.info/gamemods-archive.php?selection=1

To reap the instruments  from the mods you will need a couple of composing tools that can read the old format. Those can be found here:

http://www.modarchive.com/software/

Those tools are great for learning about the old ways of making music. Some of my preferred are Turrican, Flashback and Shadow of The Beast that can be downloaded from the first link above.
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.

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

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

pw (38 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00
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

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24: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!