|
Loading a .dat file. Pat2dat and soundfonts. |
Tony A
Member #12,673
March 2011
|
Hello, I have been reading about .dat files and their use in Allegro. I am a little confused about the .dat role in loading and reading soundfonts in Allegro. Am I correct in my understanding, that I cannot use (load and read) a .sf2 (soundfont) file directly in Allegro? And that if you wish to use a .sf2 file, it must first be converted or "prepared" via the pat2dat utility? Does the pat2dat utility convert the .sf2 file into a .pat file, and then wraps that .pat file (or files) into a .dat all at once like; .sf2 --> .pat --> .dat I used pat2dat last night and it produced a "patches.dat" file and a .cfg file from my soundfont (.sf2 file). Now that I have this "patches.dat" how can I use it in my program to read and play music? I have: //define objects in the datafile. DATAFILE *data; //My patches.dat file seems to load correctly when tested with; Now that the patches.dat file seems to be loaded, how do I play the .pat file contained in it? data[MACHINE_SF2].dat //Does this extract the .pat file defined above? Thank you for any clarifications or references anyone might be able to offer me. |
Audric
Member #907
January 2001
|
In the allegro configuration file : allegro.cfg Note that this system is only useful if the samples sound much better than your soundcard's MIDI instruments. The "cost" is that allegro will play (and mix) one digital sound for each note being played, so it takes a bit of CPU time, especially if you start playing super complex music with many sounds at the same time. Allegro has an example program miditest.c in "tests/" directory of the source distribution, it simulates a kind of piano. It can be helpful for testing the various instruments from your sound font. Be sure to replace the install_sound() line, because it will certainly have MIDI_AUTODETECT by default. |
Tony A
Member #12,673
March 2011
|
Hello, Thank you for the info and link, I sincerely appreciate it. Tony |
Audric
Member #907
January 2001
|
I haven't used allegro's DIGMID since I upgraded from a Soundblaster 16 (FM synthesis) to a Sound Blaster Live, almost 10 years ago. I'm even surprised that there are bad enough soundcards nowadays that make DIGMID useful. |
Thomas Fjellstrom
Member #476
June 2000
|
Audric said: I'm even surprised that there are bad enough soundcards nowadays that make DIGMID useful. Sure, most machines have integrated audio chips which do NOT do hardware midi, or even wavetable type midi like the sblive. The only choice on such systems is DIGIMID or somehow making use of timidity++ on linux, or the softsynths on windows. -- |
Tony A
Member #12,673
March 2011
|
I believe I am using old info. I was looking for a solution to use soundfonts in my program, rather than wav & mp3 samples. The only info I could find was about using pat2dat and GUS patches with Allegro. With midi I could define the music, but not the sound (on someone else's computer). I would like to be able to define both, have the music sound exactly the same no matter what system or sound card. Any ideas what could be a good, modern solution? Thanks again, |
Thomas Fjellstrom
Member #476
June 2000
|
DIGIMID is ok if you don't mind midi music. These days though people tend to use ogg voribs or mp3 for sounds and music. -- |
Audric
Member #907
January 2001
|
For this, you'll need to distribute the patches.dat together with the game, so be careful of file size. Instead of providing a complete allegro.cfg that might be unsuitable for the end-user, I think you can provide a minimalistic .cfg file with only the line "patches=./patches.dat", and in your code, call override_config_file() to load it. (Click for details) An alternative for distributable music that sounds the same on all machines is MOD music: .MOD, .S3M, .IT, .XM ... The common part of all these formats is that they contain the instrument samples as well as the musical track and effects. There are plenty of free composition software, a huge collection of free(*) music in modarchive.org, and several libraries allow playback in allegro programs, like DUMB, FMod, JGMOD... |
Tony A
Member #12,673
March 2011
|
"An alternative for distributable music that sounds the same on all machines is MOD music: .MOD, .S3M, .IT, .XM ... The common part of all these formats is that they contain the instrument samples as well as the musical track and effects." This is what I have been thinking. I don't know anything about MOD music, but it sounds like just what I need. Thanks again for the info! (I'll be looking into this "MOD music" now.) T. |
|