Beispiel #1
1
 /// <summary>
 /// Construct a new instance of the SoundTriggerEventArgs class
 /// </summary>
 /// <param name="sim">Simulator where the event originated</param>
 /// <param name="soundID">The sound asset id</param>
 /// <param name="ownerID">The ID of the owner</param>
 /// <param name="objectID">The ID of the object</param>
 /// <param name="gain">The volume level</param>
 /// <param name="flags">The <see cref="SoundFlags"/></param>
 public AttachedSoundEventArgs(Simulator sim, UUID soundID, UUID ownerID, UUID objectID, float gain, SoundFlags flags)
 {
     this.m_Simulator = sim;
     this.m_SoundID = soundID;
     this.m_OwnerID = ownerID;
     this.m_ObjectID = objectID;
     this.m_Gain = gain;
     this.m_Flags = flags;
 }
Beispiel #2
0
 public static void PlaySound(string name, IntPtr hModule, SoundFlags flags)
 {
     if (!PlaySoundW(name, hModule, (uint)flags))
     {
         throw new WinAPIException("Cannot play sound");
     }
 }
        /// <summary>
        ///     Reloads the currently selected sound.
        /// </summary>
        private void ReloadSound()
        {
            if (_soundChannel != null)
            {
                _soundChannel.Stop();
                _soundChannel = null;
            }
            if (_sound != null)
            {
                _sound.Stop();
                _sound = null;
            }
            GC.Collect();

            SoundFlags flags = 0;

            if (_streamed == true)
            {
                flags |= SoundFlags.Streamed;
            }
            if (_positional == true)
            {
                flags |= SoundFlags.Positional;
            }
            if (fileTreeView.SelectedNode != null && File.Exists(Engine.GlobalInstance.AudioPath + "/" + fileTreeView.SelectedNode.FullPath))
            {
                _sound        = AudioManager.LoadSound(Engine.GlobalInstance.AudioPath + "/" + fileTreeView.SelectedNode.FullPath, flags);
                _soundChannel = _sound.Play();
            }
            SyncronizeWindow();
        }
Beispiel #4
0
		public static void PlaySound(string name, IntPtr hModule, SoundFlags flags)
		{
			if(!PlaySoundW(name, hModule, (uint)flags))
			{
				throw new WinAPIException("Cannot play sound");
			}
		}
        /// <summary>
        ///		Initializes a new sample buffer and writes all the audio data in the given
        ///		sample into it.
        /// </summary>
        /// <param name="driver">Audio driver to associate this sound buffer with.</param>
        /// <param name="sample">Sample to load audio data from.</param>
        public DirectSound9SampleBuffer(DirectSound9Driver driver, Sample sample, SoundFlags flags)
        {
            // Store the sample and driver for later use.
            _sample    = sample;
            _dx9Driver = driver;
            _flags     = flags;

            // Naughty people :S.
            // if (sample == null)
            //    return;

            // Create a streaming thread.
            if ((flags & SoundFlags.Streamed) != 0)
            {
                _streamingThread = new Thread(StreamingThread);
                _streamingThread.IsBackground = true;
                _streamingThread.Start();
            }
            else if (_sample != null)
            {
                GC.AddMemoryPressure(_sample.Data.Length);
            }

            // Write the data into the sample buffer.
            RefreshSampleBuffer();
        }
Beispiel #6
0
 static bool PlaySound(
     byte [] ptrToSound,
     UIntPtr hmod,
     SoundFlags flags)
 {
     throw new System.NotImplementedException();
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.GameEngineAssaultEventFlags = ((Flags)(binaryReader.ReadInt16()));
     this.fieldpad                         = binaryReader.ReadBytes(2);
     this.Event                            = ((EventEnum)(binaryReader.ReadInt16()));
     this.Audience                         = ((AudienceEnum)(binaryReader.ReadInt16()));
     this.fieldpad0                        = binaryReader.ReadBytes(2);
     this.fieldpad1                        = binaryReader.ReadBytes(2);
     this.DisplayString                    = binaryReader.ReadStringID();
     this.RequiredField                    = ((RequiredFieldEnum)(binaryReader.ReadInt16()));
     this.ExcludedAudience                 = ((ExcludedAudienceEnum)(binaryReader.ReadInt16()));
     this.PrimaryString                    = binaryReader.ReadStringID();
     this.PrimaryStringDuration            = binaryReader.ReadInt32();
     this.PluralDisplayString              = binaryReader.ReadStringID();
     this.fieldpad2                        = binaryReader.ReadBytes(28);
     this.SoundDelay                       = binaryReader.ReadSingle();
     this.GameEngineAssaultEventSoundFlags = ((SoundFlags)(binaryReader.ReadInt16()));
     this.fieldpad3                        = binaryReader.ReadBytes(2);
     this.Sound                            = binaryReader.ReadTagReference();
     pointerQueue                          = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.ExtraSounds.ReadFields(binaryReader)));
     this.fieldpad4                        = binaryReader.ReadBytes(4);
     this.fieldpad5                        = binaryReader.ReadBytes(16);
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(80));
     return(pointerQueue);
 }
Beispiel #8
0
        /// <summary>
        ///		Initializes a new sound instance, and loads its sample from the given
        ///		file path (and or memory url).
        /// </summary>
        /// <param name="path">File path or memory url to sound to load.</param>
        /// <param name="flags">Describes how this sound should be loaded and played.</param>
        public Sound(object path, SoundFlags flags)
        {
            // Save details.
            _flags = flags;
            _url   = path as string;

            // Load the audio sample then.
            _sample = SampleFactory.LoadSample(path, (flags & SoundFlags.Streamed) != 0);

            // Load one buffer for quick response.
            ISampleBuffer buffer = AudioManager.Driver.CreateSampleBuffer(_sample, flags);

            _frequency = buffer.Frequency;
            _buffers.Add(buffer);

            // If its not dynamic then destroy the samples data as its just cluttering up space.
            if ((_flags & SoundFlags.Dynamic) == 0)
            {
                if (_sample != null)
                {
                    _sampleLength = _sample.Data.Length;
                    _sample.Data  = null;
                }
                //GC.Collect();
                _globalBuffer = buffer; // Save the global buffer as its what we will get our data from.
            }
        }
		static bool PlaySound (
		byte [] ptrToSound,
		UIntPtr hmod,
		SoundFlags flags)
		{
			throw new System.NotImplementedException();
		}
Beispiel #10
0
        /// <summary>
        ///		Initializes a new sound instance, and loads its sample from the given
        ///		file path (and or memory url).
        /// </summary>
        /// <param name="path">File path or memory url to sound to load.</param>
        /// <param name="flags">Describes how this sound should be loaded and played.</param>
        public Sound(object path, SoundFlags flags)
        {
            // Save details.
            _flags = flags;
            _url = path as string;

            // Load the audio sample then.
            _sample = SampleFactory.LoadSample(path, (flags & SoundFlags.Streamed) != 0);

            // Load one buffer for quick response.
            ISampleBuffer buffer = AudioManager.Driver.CreateSampleBuffer(_sample, flags);
            _frequency = buffer.Frequency;
            _buffers.Add(buffer);

            // If its not dynamic then destroy the samples data as its just cluttering up space.
            if ((_flags & SoundFlags.Dynamic) == 0)
            {
                if (_sample != null)
                {
                    _sampleLength = _sample.Data.Length;
                    _sample.Data = null;
                }
                //GC.Collect();
                _globalBuffer = buffer; // Save the global buffer as its what we will get our data from.
            }
        }
Beispiel #11
0
 protected override void DeSerialise(byte[] buf, ref int o, int length)
 {
     SoundId    = BinarySerializer.DeSerializeGuid(buf, ref o, length);
     ObjectId   = BinarySerializer.DeSerializeGuid(buf, ref o, length);
     OwnerId    = BinarySerializer.DeSerializeGuid(buf, ref o, length);
     Gain       = BinarySerializer.DeSerializeUInt32_Le(buf, ref o, buf.Length);
     SoundFlags = (SoundFlags)buf[o++];
 }
Beispiel #12
0
 /// <summary>
 /// Construct a new instance of the SoundTriggerEventArgs class
 /// </summary>
 /// <param name="sim">Simulator where the event originated</param>
 /// <param name="soundID">The sound asset id</param>
 /// <param name="ownerID">The ID of the owner</param>
 /// <param name="objectID">The ID of the object</param>
 /// <param name="gain">The volume level</param>
 /// <param name="flags">The <see cref="SoundFlags"/></param>
 public AttachedSoundEventArgs(Simulator sim, UUID soundID, UUID ownerID, UUID objectID, float gain, SoundFlags flags)
 {
     Simulator = sim;
     SoundID   = soundID;
     OwnerID   = ownerID;
     ObjectID  = objectID;
     Gain      = gain;
     Flags     = flags;
 }
Beispiel #13
0
 /// <summary>
 /// Construct a new instance of the SoundTriggerEventArgs class
 /// </summary>
 /// <param name="sim">Simulator where the event originated</param>
 /// <param name="soundID">The sound asset id</param>
 /// <param name="ownerID">The ID of the owner</param>
 /// <param name="objectID">The ID of the object</param>
 /// <param name="gain">The volume level</param>
 /// <param name="flags">The <see cref="SoundFlags"/></param>
 public AttachedSoundEventArgs(Simulator sim, UUID soundID, UUID ownerID, UUID objectID, float gain, SoundFlags flags)
 {
     this.m_Simulator = sim;
     this.m_SoundID   = soundID;
     this.m_OwnerID   = ownerID;
     this.m_ObjectID  = objectID;
     this.m_Gain      = gain;
     this.m_Flags     = flags;
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.SoundResponseDefinitionSoundFlags = ((SoundFlags)(binaryReader.ReadInt16()));
     this.fieldpad     = binaryReader.ReadBytes(2);
     this.EnglishSound = binaryReader.ReadTagReference();
     pointerQueue      = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.ExtraSounds.ReadFields(binaryReader)));
     this.Probability  = binaryReader.ReadSingle();
     return(pointerQueue);
 }
Beispiel #15
0
 //helper function
 private void PlaySound(SoundFlags flags)
 {
     if (mBuffer != null)
     {
         GCHandle wHandle = GCHandle.Alloc(mBuffer, GCHandleType.Pinned);
         PlaySound((IntPtr)(wHandle.AddrOfPinnedObject().ToInt32() + 4), IntPtr.Zero, SoundFlags.Memory | flags);
         wHandle.Free();
     }
     else
     {
         PlaySound(mSoundLocation, IntPtr.Zero, SoundFlags.FileName | flags);
     }
 }
Beispiel #16
0
        private void LoadAndPlay(SoundFlags flags)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            if (_streamData == null)
            {
                int streamLen = (int)_stream.Length;
                _streamData = new byte[streamLen];
                _stream.Read(_streamData, 0, streamLen);
            }

            Winmm.PlaySound(_streamData, IntPtr.Zero, SoundFlags.SND_MEMORY | SoundFlags.SND_NODEFAULT | flags);
        }
Beispiel #17
0
 public static void Play()
 {
     if (soundBuffer != null)
     {
         //Thread playSoundThread = new Thread(delegate() {
         SoundFlags flags = SoundFlags.SND_ASYNC | SoundFlags.SND_MEMORY | SoundFlags.SND_NOWAIT | SoundFlags.SND_NOSTOP;
         try {
             PlaySound(gcHandle.Value.AddrOfPinnedObject(), (UIntPtr)0, (uint)flags);
         } catch (Exception e) {
             LOG.Error("Error in play.", e);
         }
         //});
         //playSoundThread.Name = "Play camera sound";
         //playSoundThread.IsBackground = true;
         //playSoundThread.Start();
     }
 }
Beispiel #18
0
        public void PlaySound(MemoryStream ms,
                              SoundFlags flags)
        {
            LoadStream(ms);

            if (BytesToPlay != null)
            {
                gcHandle = GCHandle.Alloc(BytesToPlay,
                                          GCHandleType.Pinned);
                PlaySound(gcHandle.Value.AddrOfPinnedObject(),
                          (UIntPtr)0, (uint)flags);
            }
            else
            {
                PlaySound((byte[])null, (UIntPtr)0, (uint)flags);
            }
        }
Beispiel #19
0
        public static void Play()
        {
            SoundFlags flags = SoundFlags.SND_ASYNC | SoundFlags.SND_MEMORY;

            try {
                if (soundBuffer != null)
                {
                    WinMM.PlaySound(gcHandle.Value.AddrOfPinnedObject(), (UIntPtr)0, (uint)flags);
                }
                else
                {
                    WinMM.PlaySound((byte[])null, (UIntPtr)0, (uint)flags);
                }
            } catch (Exception e) {
                LOG.Error("Error in play.", e);
            }
        }
        public static void PlaySound(System.IO.Stream stream, SoundFlags flags)
        {
            LoadStream(stream);
            flags |= SoundFlags.SND_ASYNC;
            flags |= SoundFlags.SND_MEMORY;
            flags |= SoundFlags.SND_NOSTOP;

            if (BytesToPlay != null)
            {
                gcHandle = GCHandle.Alloc(BytesToPlay, GCHandleType.Pinned);
                PlaySound(gcHandle.Value.AddrOfPinnedObject(), (UIntPtr)0, (uint)flags);
            }
            else
            {
                PlaySound((byte[])null, (UIntPtr)0, (uint)flags);
            }
        }
Beispiel #21
0
        public static void PlaySound(System.IO.Stream stream, SoundFlags flags)
        {
            LoadStream(stream);
            flags |= (SoundFlags.SND_MEMORY | SoundFlags.SND_ASYNC);

            if (BytesToPlay != null)
            {
                //  The byte array is pinned so that garbage collector cannot move it.
                gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(BytesToPlay,
                                                                         System.Runtime.InteropServices.GCHandleType.Pinned);
                Win32.PlaySound(gcHandle.Value.AddrOfPinnedObject(), UIntPtr.Zero, (uint)flags);
            }
            else
            {
                Win32.PlaySound((byte[])null, UIntPtr.Zero, (uint)flags);
            }
        }
        /// <summary>
        ///		Loads an sound from a file or memory location.
        /// </summary>
        /// <param name="path">Memory location (or url) of sound file to load.</param>
        /// <param name="cache">If set to true this sound is added to the resource cache to save loading
        ///                     time when this sound is requested again.</param>
        /// <returns>The newly loaded sound.</returns>
        public static Sound LoadSound(object path, SoundFlags flags, bool cache)
        {
            if (ResourceManager.ResourceIsCached(path.ToString()) == true)
            {
                DebugLogger.WriteLog("Loading sound " + path.ToString() + " from cache.");
                return (Sound)ResourceManager.RetrieveResource(path.ToString());
            }

            DebugLogger.WriteLog("Loading sound from " + path.ToString() + ".");
            Sound sound = new Sound(path, flags);
            if (cache == true)
            {
                if ((flags & SoundFlags.Dynamic) != 0)
                    throw new Exception("Dynamic sounds cannot be cached.");
                ResourceManager.CacheResource(path.ToString(), sound);
            }
            return sound;
        }
Beispiel #23
0
 internal void SetDefault()
 {
     Delay           = 0.0f;
     Volume          = 1.0f;
     SoundLevel      = 75;
     Pitch           = 100;
     SpecialDspCount = DemoInfo.NewDemoProtocol ? (int?)null : 0;
     RandomSeed      = DemoInfo.NewDemoProtocol ? 0 : (int?)null;
     EntityIndex     = 0;
     SpeakerEntity   = -1;
     Chan            = Channel.Static;
     SoundNum        = 0;
     Flags           = SoundFlags.None;
     SequenceNumber  = 0;
     IsSentence      = false;
     IsAmbient       = false;
     Origin          = Vector3.Zero;
 }
Beispiel #24
0
        public static bool PlaySound(byte[] data, bool syncron, bool loop)
        {
            SoundFlags flags = SoundFlags.Resource;

            if (syncron)
            {
                flags |= SoundFlags.Syncron;
            }
            else
            {
                flags |= SoundFlags.Asyncron;
            }
            if (loop)
            {
                flags |= SoundFlags.Loop;
            }

            return(WinMM.PlaySound(data, UIntPtr.Zero, (uint)flags));
        }
Beispiel #25
0
        public static bool PlaySound(string filename, bool syncron, bool loop)
        {
            SoundFlags flags = SoundFlags.Filename;

            if (syncron)
            {
                flags |= SoundFlags.Syncron;
            }
            else
            {
                flags |= SoundFlags.Asyncron;
            }
            if (loop)
            {
                flags |= SoundFlags.Loop;
            }

            return(WinMM.PlaySound(filename, UIntPtr.Zero, (uint)flags));
        }
Beispiel #26
0
 public SoundInfo(SoundInfo si) : base(si.DemoRef)
 {
     EntityIndex         = si.EntityIndex;
     SoundNum            = si.SoundNum;
     SoundName           = si.SoundName;
     _soundTableReadable = si._soundTableReadable;
     Flags          = si.Flags;
     Chan           = si.Chan;
     IsAmbient      = si.IsAmbient;
     IsSentence     = si.IsSentence;
     SequenceNumber = si.SequenceNumber;
     Volume         = si.Volume;
     SoundLevel     = si.SoundLevel;
     Pitch          = si.Pitch;
     RandomSeed     = si.RandomSeed;
     Delay          = si.Delay;
     Origin         = si.Origin;
     SpeakerEntity  = si.SpeakerEntity;
 }
Beispiel #27
0
        /// <summary>
        ///		Loads an sound from a file or memory location.
        /// </summary>
        /// <param name="path">Memory location (or url) of sound file to load.</param>
        /// <param name="cache">If set to true this sound is added to the resource cache to save loading
        ///                     time when this sound is requested again.</param>
        /// <returns>The newly loaded sound.</returns>
        public static Sound LoadSound(object path, SoundFlags flags, bool cache)
        {
            if (ResourceManager.ResourceIsCached(path.ToString()) == true)
            {
                DebugLogger.WriteLog("Loading sound " + path.ToString() + " from cache.");
                return((Sound)ResourceManager.RetrieveResource(path.ToString()));
            }

            DebugLogger.WriteLog("Loading sound from " + path.ToString() + ".");
            Sound sound = new Sound(path, flags);

            if (cache == true)
            {
                if ((flags & SoundFlags.Dynamic) != 0)
                {
                    throw new Exception("Dynamic sounds cannot be cached.");
                }
                ResourceManager.CacheResource(path.ToString(), sound);
            }
            return(sound);
        }
Beispiel #28
0
        internal Sound(AudioDevice audioDevice, string file, SoundFlags flags) : base(audioDevice)
        {
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentNullException("file");
            }
            if (!System.IO.File.Exists(file))
            {
                throw new System.IO.FileNotFoundException("file", file);
            }

            this.File       = file;
            this.Flags      = flags;
            this.Supports3D = flags.HasFlag(SoundFlags.Support3D);
            this.IsStreamed = flags.HasFlag(SoundFlags.Streamed);
            this.AllowRead  = flags.HasFlag(SoundFlags.AllowRead);

            instances = new List <WeakReference <SoundInstance> >();

            if (!IsStreamed)
            {
                using (var source = SampleSourceFactory.FromFile(file))
                {
                    var bufferCount  = Supports3D ? source.Channels : 1;
                    var channelCount = Supports3D ? 1 : source.Channels;
                    var sampleRate   = source.SampleRate;
                    var samples      = source.ReadAll();

                    buffers = new List <AudioBuffer <short> >();
                    short[] samplesChannel = new short[samples.Length / bufferCount];
                    for (int i = 0; i < bufferCount; i++)
                    {
                        SampleConverter.To16Bit(samples, samplesChannel, i, bufferCount);
                        var buffer = new AudioBuffer <short>(audioDevice, !AllowRead);
                        buffer.SetData(AudioFormat.Short16, channelCount, samplesChannel, sampleRate);
                        buffers.Add(buffer);
                    }
                }
            }
        }
        /// <summary>
        ///		Initializes a new sample buffer and writes all the audio data in the given
        ///		sample into it.
        /// </summary>
        /// <param name="driver">Audio driver to associate this sound buffer with.</param>
        /// <param name="sample">Sample to load audio data from.</param>
        public DirectSound9SampleBuffer(DirectSound9Driver driver, Sample sample, SoundFlags flags)
        {
            // Store the sample and driver for later use.
            _sample    = sample;
            _dx9Driver = driver;
            _flags     = flags;

            // Naughty people :S.
               // if (sample == null)
            //    return;

            // Create a streaming thread.
            if ((flags & SoundFlags.Streamed) != 0)
            {
                _streamingThread = new Thread(StreamingThread);
                _streamingThread.IsBackground = true;
                _streamingThread.Start();
            }
            else if (_sample != null)
                GC.AddMemoryPressure(_sample.Data.Length);

            // Write the data into the sample buffer.
            RefreshSampleBuffer();
        }
        /// <summary>
        ///		Rewrites the audio data into the buffer and resets the format.
        /// </summary>
        public void RefreshSampleBuffer()
        {
            if (_sample == null)
                return;

            // Create the format description used by the buffer.
            WaveFormat format = new WaveFormat();
            format.BitsPerSample = (short)_sample.BitsPerSample;
            format.Channels = (short)_sample.ChannelCount;
            format.FormatTag = WaveFormatTag.Pcm;
            format.SamplesPerSecond = _sample.SampleRate;
            format.BlockAlign = (short)(format.Channels * (format.BitsPerSample / 8));
            format.AverageBytesPerSecond = format.SamplesPerSecond * format.BlockAlign;

            // Only mono sounds can be used for 3D.
            if ((_flags & SoundFlags.Positional) != 0 && format.Channels != 1)
                _flags &= ~SoundFlags.Positional;

            // Store some sample details.
            _frequency = _sample.SampleRate;
            _streamedBufferSize = MSToBytes(1000, format); // 1 seconds of audio.
            _streamThreshold = MSToBytes(400, format); // 400 millisecond threshold

            // Create the buffer description.
            BufferDescription desc = new BufferDescription(format);
            desc.BufferBytes = ((_flags & SoundFlags.Streamed) != 0) ? _streamedBufferSize : _sample.Data.Length;
            if ((_flags & SoundFlags.Positional) != 0)
            {
                desc.StickyFocus = true;
                desc.Control3D = true;
                desc.Mute3DAtMaximumDistance = true;
                desc.Guid3DAlgorithm = DSoundHelper.Guid3DAlgorithmHrtfFull;
            }
            else
            {
                desc.ControlVolume = true;
                desc.ControlPan = true;
                desc.ControlFrequency = true;
            }

            // Create DirectSound buffer.
            _buffer = new SecondaryBuffer(desc, _dx9Driver.Device);

            // Create the 3D buffer.
            if ((_flags & SoundFlags.Positional) != 0)
            {
                _3dBuffer = new Buffer3D(_buffer);
                _3dBuffer.Mode = Mode3D.Normal;
                _3dBuffer.MaxDistance = 300;
                _3dBuffer.MinDistance = 30;
            }

            // Write in the samples data.
            if (_sample.Data.Length > 0)
            {
                _buffer.Write(0, _sample.Data, LockFlag.EntireBuffer);
                _bufferLength = _sample.Data.Length;
            }
        }
Beispiel #31
0
 private static extern bool PlaySound(byte[] soundData, IntPtr hmod, SoundFlags dwFlag);
		static extern bool PlaySound (
		byte [] ptrToSound,
		UIntPtr hmod,
		SoundFlags flags);
Beispiel #33
0
 public void EmitSound(Edict entity, SoundChannel channel, string sample, float volume, float attenuation, SoundFlags flags, int pitch)
 {
     if (sample?.FirstOrDefault() == '!')
     {
         if (Sentences.GetSentenceIndex(sample, out var name) >= 0)
         {
             EmitSound2(entity, channel, name, volume, attenuation, flags, pitch);
         }
         else
         {
             Log.Alert(AlertType.AIConsole, $"Unable to find ^{sample} in sentences.txt");
         }
     }
     else
     {
         EmitSound2(entity, channel, sample, volume, attenuation, flags, pitch);
     }
 }
Beispiel #34
0
		public static void PlaySound(string name, SoundFlags flags)
		{
			PlaySound(name, IntPtr.Zero, flags);
		}
Beispiel #35
0
 public static extern bool PlaySound(byte[] data, IntPtr hMod, SoundFlags dwFlags);
 public static extern bool PlaySound(string soundName, IntPtr hmod, SoundFlags SoundFlags);
		//helper function
		private void PlaySound(SoundFlags flags)
		{
			if(mBuffer!=null)
			{
				GCHandle wHandle = GCHandle.Alloc(mBuffer, GCHandleType.Pinned);
				PlaySound((IntPtr)(wHandle.AddrOfPinnedObject().ToInt32()+4),IntPtr.Zero, SoundFlags.Memory | flags);
				wHandle.Free();
			}
			else
			{
				PlaySound(mSoundLocation, IntPtr.Zero, SoundFlags.FileName | flags);
			}
		}
Beispiel #38
0
 internal static extern bool PlaySound(IntPtr ptrToSound, UIntPtr hmod, SoundFlags fdwSound);
Beispiel #39
0
		private static extern bool sndPlaySound(string lpszSound, SoundFlags fuSound);
		private extern static bool PlaySound(IntPtr lpszName, IntPtr hModule, SoundFlags dwFlags);
Beispiel #41
0
 public static bool PlaySound(string filename, SoundFlags flags)
 {
     return WinMM.PlaySound(filename, UIntPtr.Zero,
         (uint)(flags | SoundFlags.Filename));
 }
Beispiel #42
0
 public static bool PlaySound(byte[] data, SoundFlags flags)
 {
     return WinMM.PlaySound(data, UIntPtr.Zero,
         (uint)(flags | SoundFlags.Resource));
 }
Beispiel #43
0
 static extern bool PlaySound( string pszSound,
     IntPtr hMod, SoundFlags sf);
 /// <summary>
 ///		Creates and returns a new sample buffer compatible with the current
 ///		audio driver filled with the audio contents of the given sample.
 /// </summary>
 /// <param name="sample">The sample that should be used to create the sound buffer from.</param>
 /// <param name="flags">Describes how this sample buffer should act.</param>
 /// <returns>A newly created ISampleBuffer instance.</returns>
 public static ISampleBuffer CreateSampleBuffer(Sample sample, SoundFlags flags)
 {
     return _driver.CreateSampleBuffer(sample, flags);
 }
Beispiel #45
0
 static extern bool PlaySound(byte[] pszSound, IntPtr hmod, SoundFlags fdwSound);
Beispiel #46
0
 public static void PlayWav(string wavFilename, SoundFlags soundFlags)
 {
     byte[] bname = new Byte[2000];    //Max path length
     PlaySound(wavFilename, IntPtr.Zero, soundFlags);
 }
 /// <summary>
 ///		Creates a new sample buffer capable of being played back by this driver.
 /// </summary>
 /// <param name="sample">Sample to create buffer from.</param>
 /// <param name="flags">Flags describing how to create buffer.</param>
 ISampleBuffer IAudioDriver.CreateSampleBuffer(Sample sample, SoundFlags flags)
 {
     return new DirectSound9SampleBuffer(this,sample,flags);
 }
 public static Sound LoadSound(object path, SoundFlags flags)
 {
     return LoadSound(path, flags, true);
 }
Beispiel #49
0
 public void EmitSound2(Edict entity, SoundChannel channel, string sample, float volume, float attenuation, SoundFlags flags, int pitch)
 {
     EngineSound.EmitSound(entity, channel, sample, volume, attenuation, flags, pitch);
 }
Beispiel #50
0
        public void PlaySound(System.IO.Stream stream,
            SoundFlags flags)
        {
            LoadStream(stream);

            if (BytesToPlay != null)
            {
                gcHandle = GCHandle.Alloc(BytesToPlay,
                                         GCHandleType.Pinned);
                PlaySound(gcHandle.Value.AddrOfPinnedObject(),
                                     (UIntPtr)0, (uint)flags);
            }
            else
            {
                PlaySound((byte[])null, (UIntPtr)0, (uint)flags);
            }
        }
Beispiel #51
0
 internal extern static bool PlaySound(IntPtr lpszName, IntPtr hModule, SoundFlags dwFlags);
 internal static extern bool PlaySound(string lpszName, IntPtr hModule, SoundFlags dwFlags);
Beispiel #53
0
        /// <summary>
        /// Update the sound attached to this part.
        /// </summary>
        /// <param name="sound"></param>
        /// <param name="volume"></param>
        /// <param name="flags"></param>
        public void UpdateSound(UUID soundID, float volume, SoundFlags flags)
        {
            if (volume > 1)
                volume = 1;
            if (volume < 0)
                volume = 0;

            // First, figure out what we should send for a sound.
            byte newFlags = (byte)SoundOptions;
            // Clear all of the flags except the Queue flag.
            newFlags &= (byte)SoundFlags.Queue;
            // Add the specified new flags from the parameter.
            newFlags |= (byte)flags;
            SendSound(soundID, volume, newFlags, false);

            // Next figure out what should persist in the prim.
            if (flags == SoundFlags.Loop)
                Sound = soundID;
            else
                Sound = UUID.Zero;
            SoundGain = volume;
            SoundOptions = newFlags;
            ParentGroup.HasGroupChanged = true;
            // v1 viewers seem to require the update in order to stop playing the sound.
            if (Sound == UUID.Zero)
                ScheduleFullUpdate(PrimUpdateFlags.Sound);
        }
Beispiel #54
0
 public static extern Int32 PlaySound_File(
     String pszSound,
     IntPtr hmod,
     SoundFlags fdwSound);
 public static extern bool PlaySound([MarshalAs(UnmanagedType.LPWStr)] [CanBeNull] string pszSound,
     UIntPtr hmod, SoundFlags fdwSound);
        public static bool PlaySound(object pszSound, object hmod, SoundFlags fdwSound)
        {
            // x:\jsc.svn\examples\c\test\testconsolewriteline\testexport1viaimport\program.cs

            return false;
        }
Beispiel #57
0
 static extern bool PlaySound(
     string pszSound,
     IntPtr hMod,
     SoundFlags sf);
Beispiel #58
0
 public static bool PlayAlias(SoundAlias alias, SoundFlags flags = SoundFlags.Sync)
 {
     return PlaySoundAlias ((UIntPtr)alias,  UIntPtr.Zero, (uint)(SoundFlags.AliasID | flags));
 }