Beginning Game Audio Programming [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Beginning Game Audio Programming [Electronic resources] - نسخه متنی

Mason McCuskey

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید


DYNAMIC MUSIC

Now that you have mastered the essentials of recording patterns, creating bands, assembling styles, and unifying everything under a segment track, you can go back to the example song and start adding some dynamic elements. This section will walk you through some basic things you can do to make your song sound different each time it is played.


Adding Variations


The easiest way to get your music sounding dynamic is to add some variations to the parts of your patterns. A variation is simply an alternate track that plays instead of a main track.

The secret to adding variations to your parts is the array of 32 buttons located immediately above the piano roll. Each part can have up to 32 variations, so there are two rows of 16 buttons. Each button conveys three crucial pieces of information: whether the variation is active, whether it's enabled, and whether it contains notes.

First, the easy one—if a variation contains notes, the color of its number will be black. If there are no notes in that variation, the number will be white. Next, if a button is pushed, the variation is active (meaning that its notes are displayed in the piano roll, and you can edit them).

Finally, a button's background color tells you whether its enabled or disabled. A light background means enabled; a dark background means disabled. Being enabled or disabled is different than being active or inactive. An enabled variation is one that can be randomly chosen for playback; a disabled variation is one that DirectMusic can never select.

By default, all variations for a part are active and enabled. The next time you create a pattern, notice that all the variation button numbers are white, meaning that no notes have been entered. As soon as you input your first note, they all turn black.

That's right—little did you know that you were editing all 32 variations simultaneously! This is done so that you can record your base melody into all 32 variations at once, and then tweak each variation individually. So, go ahead and do that now—to start, click the variation 2 button (variation 1 will be the original, unchanged melody). It pops up, meaning that any notes you input now will go to all variations except variation 2. But wait! That's not what you want! To invert all the buttons, double-click on button 2. Now all of them except button 2 should be up (inactive).

Now you can go crazy and start adding subtle variations to the part. You might want to invert an arpeggio, add a frill, syncopate a little—whatever suits your mood. When you've got variation two all set, you can move on to variation three, and so on. Usually two or three variations get the job done quite nicely. It's very rare to use all 32!

When you're done, play your pattern back. Notice that DirectMusic chooses variations at random. If you want it to do something else (for example, play all the variations in order), you can give it new orders via the part properties window (see Figure A.11). To get to part properties, right-click anywhere in the piano roll, except on a note, and select properties. In the variations group, there's a Play drop-down box that lets you choose one of several different behaviors (these behaviors are akin to what you can choose for the groove-level behavior—see the DirectMusic Producer docs for a complete explanation).


Figure A.11: The part properties window.


Creating an Embellishment


An embellishment is a special kind of pattern, usually an intro, fill, break, or end pattern. In this section, you'll create an introduction pattern and set it up to play at the beginning of the segment.

Start by creating the introduction pattern itself—make a new pattern, then go to its properties and press the intro button. This tells DirectMusic that this pattern is an intro pattern. Now, just create a cool introductory pattern (like the one in Figure A.12), and name it "Intro."


Figure A.12: The intro embellishment pattern.

Next, do the same thing to create a break pattern. Input the measures shown in Figure A.13, mark the pattern as a break, and rename it "Break."


Figure A.13: The break embellishment pattern.

Now you need to set up your segment to play your intro and break embellishments. Right-click the icon of your segment in the tree view, and select properties. Put in a new length of 23 bars, then go to the loop tab and set your loop start to bar 4, and your loop end to bar 22. Make sure the Infinite checkbox is checked, so your segment will loop forever.

Okay, now the segment's long enough that you can input your intro and break measures. Rightclick on the beginning entry in your groove track and select properties. In the properties window, highlight the Intro entry in the embellishment list box. Set your groove level to 1. This tells DirectMusic that it can play any pattern marked as an intro that has a groove level of 1.

Now, go to the properties for Pattern1, and set its groove range to 1-1. This makes it so it's only possible for DirectMusic to play Pattern1 when the groove level is set to 1. Do the same thing for Pattern2, setting its groove range to 2-2.

Go back to your segment editing window. Since your intro is three measures long, position your red vertical line cursor at the beginning of measure four, and press the insert key. Now, make sure none of the rows in the embellishment list box are selected, and make sure your groove level is still at 1. Also, make sure that your repeat pattern drop-down box contains Sequential from First. This tells DirectMusic that at measure 4 it should start playing any pattern that's not an embellishment and that has a groove level of 1 (Pattern1 in this case).

Next, go to measure 12 and insert another entry in your groove track that changes the groove level to 2. This is what will force DirectMusic to play Pattern2—Pattern2 is the only pattern with a groove level of 2.

Finally, go to measure 20 and insert another groove track change. This time, put your groove level back at 1 and select Break from the embellishment list box.

If you play your segment at this point, you should hear your Intro pattern, followed by Pattern1 and Pattern2, then your break pattern. After your break pattern, DirectMusic should loop and play Pattern1 again (notice that the loop range excludes the intro measures, since you only want those to play once).

That's all there is to it! Creating an embellishment is as easy as creating a pattern and pushing a button!


Adding Motifs


Dynamic music is cool not only because it's ever-changing, but also because it can respond to events in the game. There are two main types of responses dynamic music can provide. First, if something major happens, you can completely change the sound of the song. For example, if your player gets ambushed by a huge group of enemies, the dynamic music can quickly raise its intensity; when the player defeats them all, it can slowly decrease intensity, back to its idle state.

That's one type of behavior, but you're not going to learn about that one until the section on Creating Alternative Segments. The second thing dynamic music can do is swell momentarily or play a quick jingle when something interesting happens. For example, if your player picks up the Raccoon Helmet powerup, you might want the music to play a few notes from the Theme to the Raccoon Kingdom (bear with me here, I'm making this up as I go). You're not really changing the music so much as you are playing a sound effect over the music; a sound effect that just so happens to be made out of notes.

Traditionally, it's been hard to create musical sound effects that fit with the music because it's been difficult to determine what's going on musically when an event is triggered. If your player picks up the Raccoon Helmet when the background music is in the key of A, and the Theme from the Raccoon Kingdom is in the key of B, you absolutely don't want to mix the two! What you want is for your code to take the Raccoon Theme and transpose it down a step, so that it plays in A, in harmony with the A background music.


Chords for Composition and Chord Tracks


To have DirectMusic do this, you need to tell it a bit more about your music than just your notes. DirectMusic can't automatically infer what key your music is in, so you have to tell it. Take a peek at the track immediately above the first part piano roll in your pattern editor. This is called the "Chords for Composition" track. It tells DirectMusic what key your music is in at that particular moment. You can think of this track as the DirectMusic equivalent to the key signature in traditional music notation.

However, just because a currently playing pattern was written in the key of C doesn't mean it's currently playing in C. You can have DirectMusic transpose your patterns for you, by using a Chord Track inside the segment. For example, you could create a pattern and set its Chords for Composition track to be CM7 (C Major, 7th octave) for the entire pattern, and then create a Chord Track in your segment that's set to DM7 (D Major, 7th octave). When DirectMusic sees that DM7 in your segment chord track, it will think to itself, "hmm, this pattern was written in CM7, and they want it in DM7 now, so I'll transpose it upward two semitones." In more mathematical terms, you can imagine that DirectMusic is "subtracting" 1 key from another, to get the key delta, which it then applies to your pattern.

For this reason, if you want your music to be played exactly as you wrote it, you need to make sure that your pattern's Chords for Composition and your segment's chord track are equal. This will ensure that the delta between composition chord and currently playing chord is zero, and DirectMusic won't transpose your song.

Inputting a Segment


That's the theory. Now you'll put it to use. For starters, create a new motif (right-click on the Motifs folder and select New) and input the motif shown in Figure A.14. As you can see, it's nothing complex—just a few notes, played quickly enough so that they sound more like a sound effect than a measure of music.


Figure A.14: A simple motif pattern.

While you're at it, add a chord track to your segment by right-clicking and selecting Add Tracks. You should see the new chord track appear in your segment editor, defaulted to 2CM7.





Tip

Motifs are just specially-marked patterns, so they can have multiple parts and variations just like normal patterns. Since you now know how to add variations, feel free to create some variations for your motif—it'll make your music slightly more dynamic. Just don't overdo it!


Setting Up the Chords


Think back to how DirectMusic decides to transpose your patterns—it looks at the difference between the Chord for Composition and the current segment's chord. The same thing applies to motifs. When your code tells DirectMusic to play a particular motif, DirectMusic looks at the difference between the motif's Chords for Composition and the current value of the segment's chord track. If your motif is in EM7, and the segment is currently playing GM7, then DirectMusic will transpose your motif up three semitones, so that it plays in GM7, in harmony with the segment.

But, at this point in the tutorial, you haven't modified any chords for composition tracks, or segment chord tracks. So, all chord tracks are set to their default value, CM7. So, no transposition occurs, and all is right with the world. If you don't want to use motifs, leaving everything as CM7 will work fine. But, if you want motifs that transpose themselves into the correct key automatically, you need to manipulate your motif's chords for composition track, and your segment's chord track.

The motif you input in the last section is, in fact, based on CM7. So there's no need to change the motif's chords for composition track. Also, this motif sounds great played over the top of Pattern1. If you don't believe me, start pattern 1 playing, and then use the secondary playback toolbar (shown in Figure A.15) to start your motif playing.


Figure A.15: The secondary playback toolbar.





Tip

Also, while you're experimenting, notice that regardless of when you hit the play button, DirectMusic always starts your motif on a beat boundary. Of course, that's configurable, but in most cases, lining things up on a beat boundary works great.


The problem is when you play your motif over Pattern2. Pattern2 follows an F—G—F—G progression, and your C-based motif doesn't quite fit. Sure, it's not as bad as playing a B chord over an F, but it's not great. Suppose you want your motif to play in the same key of F or G that's currently playing. That is, you want it to play in F during measures 1, 3, 5, and 7, and in G during measures 2, 4, 6, and 8 (following the chords of Pattern2).

To set this up, go to Pattern2 and focus your attention on the Chords for Composition track. You should see 2CM7 listed as the chord for measure 1. Right-click on that and select Properties. This will bring you to the chord properties window, shown in Figure A.16. In this window, you need to do two things.


Figure A.16: The chord properties window.

First, you need to push the base key and octave down from 2C to 1F. Click the bottom spin arrow seven times to move your base key down to 1F. Notice as you do that the red keys shift down with you. These red keys are the notes of the chord the motif is based in. You need to make sure that the four red notes of each channel (1-4) form an F major chord (F-A-C-F). Click a piano key to toggle it.





Tip

When changing the red piano key notes, start at the bottom channel, channel 1. As you change the red notes on channel 1, DirectMusic will automatically change and synchronize channels 2, 3, and 4. Normally, you'll want all four channels to have the same red keys, so this is a useful shortcut.


The text box that currently contains M7 is just a place for you to note, in musical terms, the chord you're inputting using the red piano keys. DirectMusic does not look at the contents of the text box; it's strictly for human musician use.

There are many other fancy things you can do with the chord properties box, but for the purposes of this tutorial, this is all you need to do. Close the properties window, and move your cursor (vertical red line) to the start of the next measure. With the Chords for Composition track highlighted (in light yellow), press the Insert key on your keyboard. Now, follow the same process in the chord properties window to input 1GM7 as the Chord for Composition of this measure. Continue doing this for each measure, alternating between 1FM7 and 1GM7, for all of the measure of Pattern2 and Pattern2HighGroove.

Just to keep things straight, you might want to enter M instead of M7 into each value, and make sure the red notes form a major chord, and not a major seventh chord. Go through all of the patterns and the segment and use the chord properties window to change all of the default 2CM7 values to 2CM.

Wait! You're not done yet! If you play your segment now, you'll notice that DirectMusic is now transposing Pattern2 and Pattern2HighGroove, and it sounds horrible. The reason DirectMusic is transposing is because you've changed Pattern2's Chords for Composition, but you haven't changed the segment's chord track. You need to go to the segment and add values to the chord track that correspond to the chords of the pattern playing underneath. This means you should enter a 2CM value at measure 1 and 20, a 1FM at measures 12, 14, 16, and 18, and a 1GM at measures 13, 15, 17, and 19. If you do this, the segment's chord will always equal the pattern's chord, and DirectMusic won't transpose anything.

Now for the final test—play your motif any time your segment is playing, and notice how DirectMusic automatically transposes it to F or G based on the segment track. Cool, isn't it?

Of course, you can make chords, patterns, and motifs that are much more complicated (and interesting!) than what I've illustrated here. DirectMusic can transpose between practically any two chords. For example, it will happily transpose major to minor—all you have to do is set up the red piano keys correctly in the chord property window. So, experiment!

And Last, a Word about Chord Paths


Before we wrap up this section about chords, I wanted to mention one other powerful feature of DirectMusic—you don't have to feed it the chords for each measure by hand. You can let it choose chords on its own!

When used properly, and with patterns that support it, this can lead to incredibly dynamic music. Essentially, all you do is set up a "chord map," telling DirectMusic the chord progressions it's allowed to make throughout the segment. DirectMusic will automatically pick a path through this chord map, and you'll get truly dynamic music.

For more information on how to do this, consult the DirectMusic Producer documentation, and read the tutorial provided with DirectMusic Producer.


Creating Alternative Patterns


One last thing to do before you're done, and that is to create alternative patterns for a higher groove level. That way, your game can control the intensity of the music. Your code can control a groove-level modifier, which by default is set to zero. This groove-level modifier and the current groove level (set by the segment) are added together to determine the final groove level (and therefore the patterns that can be played).

You've already created two patterns, with groove levels 1 and 2. You'll now create another two patterns at groove levels 11 and 12. These two new patterns (call them Pattern1HighGroove and Pattern2HighGroove) will contain the same music as in Pattern1 and Pattern2, but that music will be more intense. Well, not that much more intense—all it will have is a drum track, but you get the idea: when something happens in your game, your code can set the groove modifier to 10 to play the "high groove," more intense patterns.

There's not much to adding a drum track. Begin by copying pattern1 (use the clipboard) and naming it Pattern1HighGroove. Insert a new part, and make its instrument be your custom drumloop. Then, for that part, just create one big note, played at C5, and lasting for four measures. At measure four, create another four-measure-long note, so your drumloop plays for the last four measures as well.

Do this same thing with Pattern2, naming the copy Pattern2HighGroove. Don't forget to go into the pattern properties and change the patterns' groove levels to 11 and 12!


Save as Runtime (Again)


And now, you're done (Whew!). Save your dynamic music in runtime format, and place it in the same directory as the source code to Chapter 11. That's it!

/ 127