當前位置: 首頁>>代碼示例>>C#>>正文


C# SoundBank.GetWave方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Audio.SoundBank.GetWave方法的典型用法代碼示例。如果您正苦於以下問題:C# SoundBank.GetWave方法的具體用法?C# SoundBank.GetWave怎麽用?C# SoundBank.GetWave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Audio.SoundBank的用法示例。


在下文中一共展示了SoundBank.GetWave方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: XactSound

		public XactSound (SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
		{
			long oldPosition = soundReader.BaseStream.Position;
			soundReader.BaseStream.Seek (soundOffset, SeekOrigin.Begin);
			
			byte flags = soundReader.ReadByte ();
			complexSound = (flags & 1) != 0;
			
			uint category = soundReader.ReadUInt16 ();
			soundReader.ReadByte (); //unkn
			uint volume = soundReader.ReadUInt16 (); //maybe pitch?
			soundReader.ReadByte (); //unkn
			uint entryLength = soundReader.ReadUInt16 ();
			
			uint numClips = 0;
			if (complexSound) {
				numClips = (uint)soundReader.ReadByte ();
			} else {
				uint trackIndex = soundReader.ReadUInt16 ();
				byte waveBankIndex = soundReader.ReadByte ();
				wave = soundBank.GetWave(waveBankIndex, trackIndex);
			}
			
			if ( (flags & 0x1E) != 0 ) {
				uint extraDataLen = soundReader.ReadUInt16 ();
				//TODO: Parse RPC+DSP stuff
				
				// extraDataLen - 2, we need to account for extraDataLen itself!
				soundReader.BaseStream.Seek (extraDataLen - 2, SeekOrigin.Current);
			}
			
			if (complexSound) {
				soundClips = new XactClip[numClips];
				for (int i=0; i<numClips; i++) {
					soundReader.ReadByte (); //unkn
					uint clipOffset = soundReader.ReadUInt32 ();
					soundReader.ReadUInt32 (); //unkn
					
					soundClips[i] = new XactClip(soundBank, soundReader, clipOffset);
				}
			}

			var audioCategory = soundBank.AudioEngine.Categories[category];
			audioCategory.AddSound(this);

			soundReader.BaseStream.Seek (oldPosition, SeekOrigin.Begin);
		}
開發者ID:jonathanpeppers,項目名稱:MonoGameOrientation,代碼行數:47,代碼來源:XactSound.cs

示例2: XactSound

 public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
 {
   long position = soundReader.BaseStream.Position;
   soundReader.BaseStream.Seek((long) soundOffset, SeekOrigin.Begin);
   byte num1 = soundReader.ReadByte();
   this.complexSound = ((int) num1 & 1) != 0;
   uint num2 = (uint) soundReader.ReadUInt16();
   int num3 = (int) soundReader.ReadByte();
   uint num4 = (uint) soundReader.ReadUInt16();
   int num5 = (int) soundReader.ReadByte();
   uint num6 = (uint) soundReader.ReadUInt16();
   uint num7 = 0U;
   if (this.complexSound)
   {
     num7 = (uint) soundReader.ReadByte();
   }
   else
   {
     uint trackIndex = (uint) soundReader.ReadUInt16();
     byte waveBankIndex = soundReader.ReadByte();
     this.wave = soundBank.GetWave(waveBankIndex, trackIndex);
   }
   if (((int) num1 & 30) != 0)
   {
     uint num8 = (uint) soundReader.ReadUInt16();
     soundReader.BaseStream.Seek((long) num8, SeekOrigin.Current);
   }
   if (this.complexSound)
   {
     this.soundClips = new XactClip[(IntPtr) num7];
     for (int index = 0; (long) index < (long) num7; ++index)
     {
       int num8 = (int) soundReader.ReadByte();
       uint clipOffset = soundReader.ReadUInt32();
       int num9 = (int) soundReader.ReadUInt32();
       this.soundClips[index] = new XactClip(soundBank, soundReader, clipOffset);
     }
   }
   soundReader.BaseStream.Seek(position, SeekOrigin.Begin);
 }
開發者ID:tanis2000,項目名稱:FEZ,代碼行數:40,代碼來源:XactSound.cs

示例3: XactClip

		public XactClip (SoundBank soundBank, BinaryReader clipReader, uint clipOffset)
		{
			long oldPosition = clipReader.BaseStream.Position;
			clipReader.BaseStream.Seek (clipOffset, SeekOrigin.Begin);
			
			byte numEvents = clipReader.ReadByte();
			events = new ClipEvent[numEvents];
			
			for (int i=0; i<numEvents; i++) {
				uint eventInfo = clipReader.ReadUInt32();
				
				uint eventId = eventInfo & 0x1F;
				switch (eventId) {
				case 1:
					EventPlayWave evnt = new EventPlayWave();
					
					
					clipReader.ReadUInt32 (); //unkn
					uint trackIndex = clipReader.ReadUInt16 ();
					byte waveBankIndex = clipReader.ReadByte ();
					
					//unkn
					clipReader.ReadByte ();
					clipReader.ReadUInt16 ();
					clipReader.ReadUInt16 ();
					
					evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex);
					
					events[i] = evnt;
					break;
				default:
					throw new NotImplementedException();
				}
				
				events[i].clip = this;
			}
			
			
			clipReader.BaseStream.Seek (oldPosition, SeekOrigin.Begin);
		}
開發者ID:adison,項目名稱:Tank-Wars,代碼行數:40,代碼來源:XactClip.cs

示例4: XactClip

 public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset)
 {
   long position = clipReader.BaseStream.Position;
   clipReader.BaseStream.Seek((long) clipOffset, SeekOrigin.Begin);
   byte num1 = clipReader.ReadByte();
   this.events = new XactClip.ClipEvent[(int) num1];
   for (int index = 0; index < (int) num1; ++index)
   {
     if ((int) (clipReader.ReadUInt32() & 31U) != 1)
       throw new NotImplementedException();
     XactClip.EventPlayWave eventPlayWave = new XactClip.EventPlayWave();
     int num2 = (int) clipReader.ReadUInt32();
     uint trackIndex = (uint) clipReader.ReadUInt16();
     byte waveBankIndex = clipReader.ReadByte();
     int num3 = (int) clipReader.ReadByte();
     int num4 = (int) clipReader.ReadUInt16();
     int num5 = (int) clipReader.ReadUInt16();
     eventPlayWave.wave = soundBank.GetWave(waveBankIndex, trackIndex);
     this.events[index] = (XactClip.ClipEvent) eventPlayWave;
     this.events[index].clip = this;
   }
   clipReader.BaseStream.Seek(position, SeekOrigin.Begin);
 }
開發者ID:tanis2000,項目名稱:FEZ,代碼行數:23,代碼來源:XactClip.cs

示例5: XactClip

		public XactClip (SoundBank soundBank, BinaryReader clipReader, uint clipOffset)
		{
			long oldPosition = clipReader.BaseStream.Position;
			clipReader.BaseStream.Seek (clipOffset, SeekOrigin.Begin);
			
			byte numEvents = clipReader.ReadByte();
			events = new ClipEvent[numEvents];
			
			for (int i=0; i<numEvents; i++) {
				uint eventInfo = clipReader.ReadUInt32();
				
				uint eventId = eventInfo & 0x1F;
				switch (eventId) {
				case 1:
					EventPlayWave evnt = new EventPlayWave();
					
					
					clipReader.ReadUInt32 (); //unkn
					uint trackIndex = clipReader.ReadUInt16 ();
					byte waveBankIndex = clipReader.ReadByte ();
					
					
					var loopCount = clipReader.ReadByte ();
				    // if loopCount == 255 its an infinite loop
					// otherwise it loops n times..
				    // unknown
					clipReader.ReadUInt16 ();
					clipReader.ReadUInt16 ();
					
					evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex);
					evnt.wave.IsLooped = loopCount == 255;
					
					events[i] = evnt;
					break;
				default:
					throw new NotSupportedException();
				}
				
				events[i].clip = this;
			}
			
			
			clipReader.BaseStream.Seek (oldPosition, SeekOrigin.Begin);
		}
開發者ID:GhostTap,項目名稱:MonoGame,代碼行數:44,代碼來源:XactClip.cs


注:本文中的Microsoft.Xna.Framework.Audio.SoundBank.GetWave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。