예제 #1
0
        protected virtual void Dispose(bool disposing)
        {
            // If you need thread safety, use a lock around these
            // operations, as well as in your methods that use the resource.
            if (!m_disposed)
            {
                if (disposing)
                {
                    if (m_descriptionListener != null)
                    {
                        m_descriptionListener.Dispose();
                    }

                    if (m_primary3d != null)
                    {
                        m_primary3d.Dispose();
                    }

                    if (m_listener3d != null)
                    {
                        m_listener3d.Dispose();
                    }
                }

                m_descriptionListener = null;
                m_primary3d           = null;
                m_listener3d          = null;

                // Indicate that the instance has been disposed.
                m_disposed = true;
            }
        }
        public Listener(System.Windows.Forms.Form form, Object3D object_listening)
        {
            m_listener = object_listening;
            Sound.BufferDescription description = new Sound.BufferDescription();
            Sound.WaveFormat        fmt         = new Sound.WaveFormat();
            description.PrimaryBuffer = true;
            description.Control3D     = true;
            Sound.Buffer buff = null;

            fmt.FormatTag             = Sound.WaveFormatTag.Pcm;
            fmt.Channels              = 2;
            fmt.SamplesPerSecond      = 22050;
            fmt.BitsPerSample         = 16;
            fmt.BlockAlign            = (short)(fmt.BitsPerSample / 8 * fmt.Channels);
            fmt.AverageBytesPerSecond = fmt.SamplesPerSecond * fmt.BlockAlign;

            applicationDevice.SetCooperativeLevel(form, Sound.CooperativeLevel.Priority);

            // Get the primary buffer and set the format.
            buff        = new Buffer(description, Device);
            buff.Format = fmt;

            applicationListener = new Listener3D(buff);
            listenerParameters  = applicationListener.AllParameters;
        }
예제 #3
0
        public SoundListener3d(DirectSound.Device device)
        {
            // 3d setup
            m_descriptionListener = new DirectSound.BufferDescription();

            m_descriptionListener.ControlEffects = false;
            m_descriptionListener.Control3D      = true;
            m_descriptionListener.ControlVolume  = true;
            m_descriptionListener.PrimaryBuffer  = true;

            m_primary3d  = new DirectSound.Buffer(m_descriptionListener, device);
            m_listener3d = new DirectSound.Listener3D(m_primary3d);

            // default orientation
            DirectSound.Listener3DOrientation o = new DirectSound.Listener3DOrientation();
            o.Front = new Microsoft.DirectX.Vector3(0, 0, 1);   // facing forward
            o.Top   = new Microsoft.DirectX.Vector3(0, 1, 0);   // standing upright

            m_listener3d.Orientation = o;
        }
예제 #4
0
        /// <summary>
        /// Funkcja inicjujaca dzialanie silnika dzwiekowego (laczy sie z karta
        /// dzwiekowa, tworzy niezbedne obiekty (tablica dzwiekow, listener,
        /// glowny bufor dzwiekowy, obiekt szukajacy sciezek do plikow)
        /// </summary>
        /// <param name="owner">Obiekt (Forms), w ktorym ma byc umieszczony 
        /// silnik dzwiekowy</param>
        /// <param name="distanceFactor">Czynnik odleglosci</param>
        /// <param name="roloffFactor">Czynnik roloff</param>
        /// <param name="volume">Glosnosc</param>
        public static void InitializeEngine(Control owner, int volume,
            float distanceFactor, float roloffFactor)
        {
            //karta dzwiekowa
            soundCard = new DS.Device();
            soundCard.SetCooperativeLevel(owner, CooperativeLevel.Normal);

            //lista dzwiekow
            soundList = new ArrayList();

            //listener
            primaryBufferDescription = new BufferDescription();
            primaryBufferDescription.ControlEffects = false;
            primaryBufferDescription.Control3D = true;
            primaryBufferDescription.PrimaryBuffer = true;
            primaryBufferDescription.ControlVolume = true;
            primaryBuffer = new DS.Buffer(primaryBufferDescription, soundCard);
            primaryBuffer.Volume = volume;

            listener = new Listener3D(primaryBuffer);
            listener.DistanceFactor = distanceFactor;
            listener.RolloffFactor = roloffFactor;

            //muzyka w tle

            //SourceNameFinder
            nameFinder = new SourceNameFinder();
        }