Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Music, instruments, and sounds and things.  (Read 2375 times)

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Music, instruments, and sounds and things.
« on: September 24, 2015, 10:45:40 pm »

We're getting musical instruments, generated by the game to accompany different cultures with different music styles. Watching that PAX video, the idea the host (Tanya X) had about wrangling some musicians to show off the generated musical instruments is actually not all that unreasonable. I love me some software synthesis.

There are physical modelling solutions to this - grab something like a drum, a string, and a woodwind simulation, and you're mostly already set. Hell, there's even an animal vocal tract sim or two out there waiting to be used for the game's generated animals (Fauna, Oscine Tract). Then there are other synthesis methods like subtractive, FM, etc that can achieve some things more directly. But in the spirit of DF modding, I'd like to suggest something a little bolder: exposing some parts of the game to actual real-life software synths like Skrillex and John Williams use through the use of the raws.

Doing this, you'd have to have a VST or AU host running alongside or within DF. That's not too difficult (famous last words) - there are open source libraries for playback and patching of both. Linux's sound situation is shaky, but everyone with Linux knows that. You're more likely to find a usable AU library with it. I don't know about Mac - I think VST is more easily supported? Anyway...

By default, you could ship with a bare-bones subtractive synth that gets the job done - it might sound like horrible chiptune noise by default, it might even be turned off by default for that reason, but the idea is that each part of a generated instrument - from its overall size, to the way it's played, to how many strings it has, to whether it has a resonator and how big the resonator is - could be attached to a different output tag, and then patched through in the raws. By modders this would be with a bit of assistance from a DAW or plugin host to find the correct VST parameters (or AU equivalent - I haven't worked with it so I don't know). The modding could proceed like this:

Code: [Select]
[INSTRUMENT:STRINGS_COOLFX]
    [TYPE:STRINGS]
    [PLUGIN:VST:COOL_FX]
    [PLUGIN:AU:DEFAULT] (Wouldn't select this plugin at all if VST support was disabled for some reason)
    [STRING_LENGTH:VST:0] (the 0 parameter in the VST is now controlled by the length of the strings in game)
    [STRING_POLYPHONY:VST:1]
    [RESONATOR_NUM:VST:2]
        [MIN:0:MAX:0.25] (minimum of 0, maximum of 0.25 - this sort of tag would be expandable to any other channel. Lots of VSTs only use numbers from 0 to 1 which would be a good default, some VSTs break that because the authors goofed off in VST school, and sometimes you only want a certain range of numbers if they go beyond what's reasonable)
    [RESONATOR_SIZE:VST:3]
        [CURVE:STEP:5] (Gives it a step-like number of values, like 0 - 0.25 - 0.5 - 0.75 - 1. The output now snaps to those values)
        [CURVE:EXP:0.5] (averages with the previous curve, smoothing out the values of the steps so that it looks like a wavey line. No longer quite as snappy)
        [CURVE:NEXP:1] (averages again with a negative exponential, and so on, to make increasingly complex modulations. All the cool kids in music use maths and modulation curves)
    [SIZE:VST:3] (Parameters can be selected more than one time. Whatever curves they have are multiplied together, so you can have volume affected by more than one part of the instrument)
    [SIZE:VST:4] (You can also assign a part of an instrument to more than one parameter of the synth)
    etc.
    [PRIORITY:2] (Could be used to decide on multiple STRINGS type instruments if the player had more than one floating around)

And for plugins:
[PLUGIN:COOL_FX]
    [FILE:VST:"massive.dll"]
    [PARAMETER:0] (selects the zeroeth parameter for modulation)
        [CURVE:STEP:5]
        [CURVE:EXP:0.5]
        [CURVE:SUB:NEXP:1] (More curve-foolery can occur here for metacurviness of multiple instruments)
    [FX:REVERB]
    (yeah, I'm pushing it here, but potentially you could patch instrument plugins through effects (which also come in VST and AU) for extended musicality.
     That's turning the game into a DAW in its own right though, since there are step sequencer effects, which would be really weird. DJ URIST IN THE HOUSE!! ok no)

So every time a game generates a stringed instrument (especially a stringed instrument with a resonator) it has a chance of picking COOL_FX to be its voice. The different parts of the instrument tweak appropriate parameters in the synth, and when a note is played by the wonderful (or not so wonderful) elven bards pestering your fort, a midi signal is sent to COOL_FX through the host, and you can then hear something almost, but not quite, entirely unlike a harp pushed out of a Yamaha keyboard from the 80s. But it will be his harp...board.

I know this suggestion is goofy and frivolous. I know it might not be that interesting to people outside of music, and electronic music in particular. But when Tanya said she knew some musicians that might like to help, I just had to show how easily it could actually be accomplished, and with modding support to boot. Whether or not it's worth the CPU load (for reference, I could run almost all of the synths I use now on my old 3.06 GHZ P4), time invested to program, etc. is up to Toady, but it's not as inaccessible as you might imagine.
« Last Edit: September 24, 2015, 11:06:31 pm by Eagleon »
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Shonai_Dweller

  • Bay Watcher
    • View Profile
Re: Music, instruments, and sounds and things.
« Reply #1 on: September 25, 2015, 11:01:19 pm »

That would be a lot of fun. Just very tiny extracts of a 'tune' as you pass by the tavern would be fine. Plus the ability to extract instruments from Legends for people to fiddle with and produce listenable authentic soundtracks for the more musical let's plays.
Logged

JesterHell696

  • Bay Watcher
  • [ETHIC:ALL:PERSONAL]
    • View Profile
Re: Music, instruments, and sounds and things.
« Reply #2 on: September 26, 2015, 02:18:40 am »

While I do think it sounds interesting its so far down on my priority list that if it took toady more than a couple day's work then I would prefer that time used for something else.
Logged
"The long-term goal is to create a fantasy world simulator in which it is possible to take part in a rich history, occupying a variety of roles through the course of several games." Bay 12 DF development page

"My stance is that Dwarf Fortress is first and foremost a simulation and that balance is a secondary objective that is always secondary to it being a simulation while at the same time cannot be ignored completely." -Neonivek

Scoops Novel

  • Bay Watcher
  • Talismanic
    • View Profile
Re: Music, instruments, and sounds and things.
« Reply #3 on: October 04, 2015, 05:26:07 pm »

It might be easier to filter music and poetry databases for best matches to the RNG.
Logged
Reading a thinner book

Arcjolt (useful) Chilly The Endoplasm Jiggles

Hums with potential    a flying minotaur

tjg92

  • Escaped Lunatic
    • View Profile
Re: Music, instruments, and sounds and things.
« Reply #4 on: December 04, 2015, 12:02:34 pm »

You can script pretty much everything in Reaper. I've been thinking about trying something similar to this minus the DF part.
Logged

Vattic

  • Bay Watcher
  • bibo ergo sum
    • View Profile
Re: Music, instruments, and sounds and things.
« Reply #5 on: December 04, 2015, 01:15:51 pm »

There has been related talk about generating simple music based on the more mechanical parts of the descriptions. Mostly just to give an idea of the music for non-technical folks, and to add some varied character when visiting different inns and the like. There were also similar posts with examples on the DF Reddit (post 1, post 2, post 3).

Logged
6 out of 7 dwarves aren't Happy.
How To Generate Small Islands

Shazbot

  • Bay Watcher
    • View Profile
Re: Music, instruments, and sounds and things.
« Reply #6 on: December 04, 2015, 02:27:43 pm »

From what I can tell of Dwarven music, I'll keep my guitar loop and would turn off such music if it were automatically played. It would be a nice third-party utility, however.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Music, instruments, and sounds and things.
« Reply #7 on: December 04, 2015, 07:57:49 pm »

yo the generated music's gonna have to allow quarter tones

that's not something most music stuff tends to take into account

EDIT: wikipedia's article on quarter tones starts with a .midi file specifically showing off C and C half-sharp, so that's not too much of a problem
« Last Edit: December 04, 2015, 08:05:44 pm by Putnam »
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Music, instruments, and sounds and things.
« Reply #8 on: December 05, 2015, 09:13:38 am »

Yeah, pitch bending gives you access to 100 cents per semitone, which is close enough to a continuous slide for human ears. A 50 cent bend is a quartertone. Conveniently, Toady has used the 1200 cent per octave system in the raws.

In between secret santa stuff this month, I'll dust off an IDE and putter around with reading out an instrument raw into usable data for Csound or similar. A proof of concept couldn't hurt. It looks like the instruments are using descriptive timbres for their primary attributes, which makes things a little more vague, but that's ok - it becomes a game of deciding where in the instrument that sound lies, and hoping for sensible parameters when everything is combined together including other timbres.

I'm on the lookout for a good sound programming library with VST support built-in, rather than as an additional downloadable component - apparently VST's license prohibits the distribution of the SDK, but not programs that have been made to host VST plugins, which makes for confusion. I don't think they necessarily -had- to exclude VST support from their releases, but since the plugin isn't compile-able native for everything they target, they chose not to.
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044