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

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

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

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

Mason McCuskey

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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


Chapter 5, "Control Freak," you''ll learn about the interfaces used for music playback, and in Part Two of the book, you''ll learn the interfaces for dynamic music.

For now though, begin by referring to Figure 3.1 as you read the following sections.


Figure 3.1: Overview of the DirectMusic interfoces used for playing sound effects.


The Loader


It all starts by reading the wave file off disk. In DirectMusic, this is done through a special Loader object. You access this Loader object through the IDirectMusicLoader8 interface.

The loader is by far the most under appreciated of all the DirectMusic interfaces. Loading a wave file is a complex task, as you''ll see later in this chapter. The loader takes care of all the complexities of loading a wave file: figuring out if and how it''s compressed, reading the bytes, and storing them into memory. You simply say, "Loader, please load this wave file, create an object for it, and give me an interface to that object."

The Loader is also very powerful. You can tell it where to look for support files, you can make it read from the resource attached to your EXE, and you can even write custom loading objects to teach it how to load your own sound formats.


Segments


When you tell the loader to load something, it creates a DirectMusic segment and fills that segment with whatever it gets from the drive. You access this DirectMusic segment through the IDirectMusicSegment8 interface.

A segment can contain any segment of audio. This includes wave files, plus any length of music. Each segment can contain multiple tracks (which you can play with through the IDirectMusicTrack8 interface). Think of a track as a single musical staff in a song. Open a piano songbook and you''ll see two tracks—the top track is played by the right hand (usually treble clef), and the second track is played by the left. A typical song might include tracks for bass, percussion, chords, and vocal (or melody). When you load a wave file into a segment, you end up with a segment with one track. Usually you don''t deal directly with tracks, but it''s good to know they''re there.

There are many ways to create segments; you don''t have to load them. For example, if you''re using dynamic music, you have DirectMusic create segments for you. You supply the chord progressions, groove, instruments, and melody, and DirectMusic will create a segment for you. Do this correctly and never bore your player with a song that just repeats over and over again.

Contrary to what you might expect, the IDirectMusicSegment8 interface doesn''t have a Play method. You can''t just tell segments to play themselves. To hear anything, you need to use another object: the Performance Object.


The Performance Object


The Performance object is the main object that controls all of the other objects. When I want to hear music, I pay money for a ticket, which gives me the right to hear a performance. The performance (hopefully) includes several songs, played on several different instruments, played through a variety of speakers using different effects.

Similarly, once I grab an IDirectMusicPerformance8 interface, I can use it to play segments, control what speakers those segments are played out of, and adjust the tempo, volume, and other settings that influence the segment''s playback.

To get a particular segment to play, all one has to do is say, "Mr. Performance object, please play this segment." You can also ask about and set a whole slew of timing controls. For example, you can ask the performance what the current latency time is (latency time is the difference between when you say "play!" and when sound actually starts coming out the speakers).


Other Objects


As mentioned previously, DirectMusic has a whole slew of other objects and interfaces, but the three you just learned about—loader, segment, and performance—are the ones you need to know right now. The other DirectMusic objects are most useful when playing music, so you''ll have to wait until Chapter 5 to learn about them.

Now that you''ve been introduced to the star interfaces of this chapter, you can begin learning how to wrap, tame, and use them to construct the beginnings of an audio engine. But first, you must learn how to handle errors.

/ 127