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.
yes. you can generate whatever bytes you want to write to a SourceDataLine… look at javax.sound… and I guess the GAGE stuff…
[quote]yes. you can generate whatever bytes you want to write to a SourceDataLine… look at javax.sound… and I guess the GAGE stuff…
[/quote]
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.
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.
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.
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.
[/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.
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.
[/quote]
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.
[/quote]
Then maybe you should do just that. Off-topic complaining like this won’t have much of a positive effect I’m afraid.
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.
[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.
[/quote]
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? :)). 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.
[/quote]
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?
Erik,
To play a RMF (or Rich Music Format ™ 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:
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.
Aahhh I see, thanks.
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
Erik
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 ?
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.
[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.
[/quote]
Ah yes, that’s the general problem of using sampling for sound synthesis (the imfamouse ‘donald duck’ effect :)). 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.
Just thought I would through these links into the thread (Java MOD players - I haven’t tried them)
http://java.sun.com/products/java-media/sound/techReference/mantis.html
…mentions improved MIDI support in 1.4.2 have you tried the beta?
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.