Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Module (music) support for Darkplaces (again) [test it]

#1
Code:
.                              
                               DarkPlaces
                         ___  ___ ____________
                         \  \/  //      ____  \
                          >    <|  Y Y  \ |_>  >
                         /__/\   __|_|  /  ___/
                              \_/     \/|_|
                               empowered

Are there any oldskool module fans out there still?

Git users can clone this now: https://gitlab.com/xonotic/darkplaces/merge_requests/8
(In your darkplaces git folder do this or something similar in a gui)
Code:
git remote add nyov https://gitlab.com/nyov/darkplaces.git
git remote update
git checkout nyov/libxmp
(get libxmp for your system and re-compile)
libxmp sources

Tracked modules are great sound assets, usually only a fraction the size of a
similar length wav or even ogg file, depending on included samples (and less so length).
They can have multiple sequences (sub-tracks) and some fancy looping schemes coded in (play from pos 0 the first time, but only loop from pos 3, etc.)

Last but not least, pretty much all those 2nd gen trackers are free software. So download one (https://en.wikipedia.org/wiki/Music_tracker) and start tracking today Big Grin
Reply

#2
Mods are cool, remember playing around with Milkytracker and sunvox. Smile
Reply

#3
Eh, what's this about? Can you explain a little?
Reply

#4
Absolutely. If I was too brief earlier, sorry for that.

ALSO, FOR A PREVIEW OF THIS, TRY XMP IN JAVASCRIPT (not the greatest modules to show off, but it's something): http://www.wothke.ch/webxmp/
Keep reading while you have a listen.

Currently DP can play both .wav and .ogg sound files. That is rather limited, but good enough for waveform (pcm) style music.

But DarkPlaces previously also had module playback support. LH removed it last year, reasoning "the library is too insecure and barely used by anyone".
In response to that I want to improve awareness of this ex-feature, and provide an alternative library to do it with (libxmp), hopefully gaining some support for including the feature again.
(Debian users using the packaged darkplaces will still have modplug support and can play around with it there.)

To explain the difference between tracked modules and PCM waveforms, I'll try to use some quake references.

A "rendered" pcm (wav,ogg,mp3,...) is essentially comparable to a "baked" BSP map. You can modify it and distort it using programs, but you can't really edit it without the source from which it was rendered/compiled.
A module tracker, on the other hand is a software sampler.
The module file stores a list of instruments and essentially a music sheet (notes to play) for up to 64 channels. Additionally it can store pre-recorded samples to be played as notes.

So that's not much different from software you would use to create a wav in the first place (and of course you can render the result to a wav as well).
Except understanding and playing the module's format directly has a lot of advantages!
First, you never lose the source, since the module itself contains all the relevant bits.
Second, the module can contain logic, which a flat waveform can't (unless you add your own container format with some logic).
Third, the size of the file may be a lot smaller, since all the samples are only included once, no matter how often you play them, and the "music sheet" doesn't take much space. A module that has 50 minutes tracked will only be slightly larger than the same one having notes for only 5 minutes. It's a great compression scheme (and compresses even better on top of that with zip, due to the nature of it's contents).
(I predict they will still see a big renassaince in browser games with the webaudio api, the software is already out there.)

Now that's more like playing on the Cube2 engine, where you can edit the whole map live and ingame.

The sound system of Unreal1 used that to great success. Their music modules usually contained two or three sequences (like tracks) for different moods.
One for the normal ambient and at least one other for action sequences. Now once you hit on an enemy, the system would "switch tracks" to the more aggressive music, which added most of the flair and atmosphere to Unreal back then. Especially if you hit on an ambush, it would get your blood pumping real nice.
Once the threat was over, the module would seemlessly loop back to the "relaxed" track.


To finish this with a possible future outlook, consider the applications in a game engine:
(All this isn't possible with the current state of my code, specifically no QuakeC interface exists for that, and I can't do that alone. Hopefully people might be willing to help code that.)

Having modules as a "sample storage" like an effectinfo.txt or sprite map for sounds.
With a sound mixer api for QuakeC a load of possibilities could be added. (libXMP already contains a mini mixer api which can be used to that end.)
We might have game logic doing the same as Unreal; just using stored samples as sound effects; sound scripting for bot orchestra, or adding a fully interactive piano into a map (I don't remember the map's name. hint hint).
So that's already possible, but new might be changing instruments and sets of samples on the fly; just like you can on your synthesizer keyboard with a button.

Explanation enough? Blush
Reply

#5
Ah, alright! Nifty. Now you've explained too much Big Grin

I have to ask though, how's the latency? What happens when the engine gets overwhelmed with graphic effects and the fps drops?

Also, I guess it's not at all related (in code, I mean) to this midi trick in desertfactory, where map effects are synced to the music? (grep bgmscript in the qc code)
Reply

#6
(11-14-2014, 12:54 AM)Mr. Bougo Wrote: I have to ask though, how's the latency? What happens when the engine gets overwhelmed with graphic effects and the fps drops?
It should behave the same as an OGG sound does now. XMP 'renders' the module to a pcm buffer, same as the libvorbis .ogg decoder does inside the engine.

But I don't know what might happen in case the engine gets overwhelmed with rendering lots of sound effects (through xmp) in parallel, if the library might drop out (though I don't expect it to).
This is what could do with some playertesting. Though I played some 30 modules in parallel without issues.

(11-14-2014, 12:54 AM)Mr. Bougo Wrote: Also, I guess it's not at all related (in code, I mean) to this midi trick in desertfactory, where map effects are synced to the music? (grep bgmscript in the qc code)
I just played desertfactory, but I don't see anything like that in the map. I found the name of the other map though: vitamea. With the pianos.
Did you mean courtfun? I just found that through the code. Awesome stuff I didn't even know was there, before.
I can't say I understand quite what this bgmscript all does, but it seems to do the reverse at least, analyse the bgm music or get the beats (or something) from the .bgs script, then use it for scripting stuff in the map. Thats pretty fancy itself! Code should be better documented though.

I don't think it's very much related indeed, except that this proves one could write a software mixer in QC, loading lots of wav files as samples and possibly emulate a simple tracker software that way (if ya can change pitch of the samples to piano notes, which I don't think you can without engine code.)

So as for playing only select samples from inside a module (instead of the whole thing as a "dumb music file"), more engine-side code support for mixing and a QC extension api would be needed.
But it sure would be nice to have an API like a dumbed down html webaudio where the engine handles samples and mixing which you can control from QC.
Reply

#7
If I understood it correctly, this would allow background sound based on situations, e.g. when someone picked up strength, a flag carrier is about to cap etc, when 3 frags are left in a ffa etc? That would be really cool and unique.
Reply

#8
The code right now, not so much (it's just "dumb" playback support for some 90+ module file formats).
But yes, I would hope we could get to that point.
Reply

#9
@nilyt, I very much like the idea of the background music reflecting what's going on in the game, dynamically. I assume you are thinking when an event is triggered, some tracks are un-muted and possibly some other tracks are muted, so the music switches to a different feel, while maintaining its underlying substance.

Do you think it's possible to record a game playing video (without music), and mux in a temp track later to demonstrate your idea?

About this idea, a few things come to mind:

1. How big is the module music repertoire (that's suitable for Xonotic)? ogg has the benefit of being universal enough so people can either easily find something, or use various tools to produce in this common format. If 99% of the tracks are in ogg (because of the creative community's familiarity, available resources out there, etc.), and only 1% of the tracks are in the module formats, then maintaining the code for a rarely used feature might not be quite costly.

2. Shall we also support a non-sample-based, i.e. pre-rendered, multi-track format? (*.BWF maybe? *.MOGG?)

3. What do you think about using Timidity++ instead? It supports MOD and MIDI (which is supported by more tools). There's also the benefit of having a centralized sample file (that can potentially ship with Xonotic), with optional custom sample file that can ship with a map.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand darkplaces source code wiefie 23 17,365 06-08-2024, 11:40 AM
Last Post: dagelf
  Xonotic 0.8.5/DarkPlaces "Issues" Baker 2 1,251 02-24-2023, 03:01 PM
Last Post: Baker
  [META] DarkPlaces fork Lyberta 24 16,784 02-21-2023, 07:12 PM
Last Post: ballerburg9005
  [TUTORIAL] How to create a command - DarkPlaces engine C programming LegendGuard 1 2,559 03-31-2021, 03:43 PM
Last Post: LegendGuard
  What was easy for you in development? (Darkplaces and QuakeC programming) LegendGuard 2 2,988 08-08-2020, 05:25 PM
Last Post: LegendGuard
  New feature review/test: Private Server List BuddyFriendGuy 17 19,120 01-07-2016, 08:05 AM
Last Post: BuddyFriendGuy
  [SOLVED] misc_model : Support for specular and relief mapping? Maddin 5 7,028 11-10-2013, 06:34 AM
Last Post: Maddin
  [split] Music submission: Archer - Dark Horizon HellYeah 10 12,485 11-30-2012, 12:40 PM
Last Post: Lee_Stricklin
  Big Brother Bot Support Majki 30 28,842 10-16-2012, 12:32 PM
Last Post: Mr. Bougo
  darkplaces wiki down .... hutty 4 7,885 10-13-2012, 09:47 PM
Last Post: hutty

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-