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

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

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

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

Mason McCuskey

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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





PLAYING SOUNDS CONCURRENTLY

Astute readers may have noticed that there's a significant problem with the audio engine as it stands now: it can't play the same sound repeatedly. In other words, if you have a wave of a bell dinging, you can't make three bells ding concurrently. The best you can do is make one bell start dinging, then stop dinging, and then start again, three times. This section will look at how to correct that problem.


Primary versus Secondary DirectMusic Segments


DirectMusic has the notion of primary and secondary segments. The difference is that there can be many secondary segments, but only one primary segment.

The primary segment is considered the "main" musical track for your game. Sound effects or other music jingles are usually secondary segments, played over the primary segment. The primary segment usually dictates the parameters of the music (for example, the tempo, chord pattern, and so on). You'll learn more about this in the coming chapters; for now, just remember that the only way to have multiple sound effects playing is by making sure they play as secondary segments.


Goodbye PlaySegment, Hello PlaySegmentEx


In the last chapter, you used the PlaySegment method of the DirectMusic performance object as the workhorse for getting sounds to play. This works well for simple one-sound playback, but to get the same sound to play many times, you need to use PlaySegmentEx. PlaySegmentEx lets you tell DirectX Audio whether a segment should be played as a primary or secondary segment.

By using PlaySegmentEx (instead of PlaySegment) inside CSound's Play method, you're able to Play multiple sounds concurrently:


m_Manager->GetPerformance()->PlaySegmentEx(m_Segment, NULL, NULL,
DMUS_SEGF_SECONDARY, 0,
(IDirectMusicSegmentState **)&m_SegmentState, NULL, NULL);

PlaySegmentEx takes more parameters than PlaySegment, so you should look in the docs to figure out what everything means. The really important thing is the DMUS_SEGF_SECONDARY flag, which tells DirectX Audio that it should Play this segment as a secondary segment instead of a primary.

/ 127