Example #1
0
        public static bool CheckDevice(int streamID)
        {
            var device = Bass.BASS_ChannelGetDevice(streamID);
            var info   = Bass.BASS_GetDeviceInfo(device);

            if (info != null && (!info.IsDefault || !info.IsEnabled))
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        void Instance_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "ActiveStreamHandle":
                l2.Items.Add(e.PropertyName);
                l2.Items.Add("handle " + Player.Instance.Handle);
                l2.Items.Add("output " + Player.Instance.Output);
                l2.Items.Add("driver ind " + Bass.BASS_ChannelGetDevice(Player.Instance.Handle));
                // l2.Items.Add("driver ind " + Bass.BASS_GetDeviceInfo(Bass.BASS_ChannelGetDevice(Player.Instance.Handle)).driver);
                l2.Items.Add("device " + Bass.BASS_GetDeviceInfo(1).name);
                l2.Items.Add("device flags" + Bass.BASS_GetDeviceInfo(1).flags);


                break;
            }
        }
Example #3
0
        public void Evaluate(int SpreadMax)
        {
            #region Pin Device Changed
            if (this.FPinInDevice.PinIsChanged)
            {
                double dbldevice;
                this.FPinInDevice.GetValue(0, out dbldevice);
                int devid = Convert.ToInt32(dbldevice);

                //0 is for no sound device, so redirect to default
                if (devid <= 0)
                {
                    devid = -1;
                }

                IntPtr ptr = IntPtr.Zero;
                Bass.BASS_Init(devid, 44100, BASSInit.BASS_DEVICE_DEFAULT, ptr, null);
                this.FDevice = devid;

                foreach (ChannelInfo channel in this.FChannels)
                {
                    if (channel.BassHandle.HasValue)
                    {
                        //Update all channels in the device
                        int chandevid = Bass.BASS_ChannelGetDevice(channel.BassHandle.Value);
                        if (this.FDevice != chandevid)
                        {
                            Bass.BASS_ChannelSetDevice(channel.BassHandle.Value, chandevid);
                        }
                    }
                }
            }
            #endregion

            if (this.FPinInBuffer.PinIsChanged)
            {
                double db;
                this.FPinInBuffer.GetValue(0, out db);
                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, Convert.ToInt32(db));
            }
            if (this.FPInInLoop.PinIsChanged)
            {
                double db;
                this.FPInInLoop.GetValue(0, out db);
                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, Convert.ToInt32(db));
            }

            #region Handle Pin Changed
            if (this.FPinInHandle.PinIsChanged)
            {
                //Make sure we use the proper device
                Bass.BASS_SetDevice(this.FDevice);

                ChannelList oldchannels = new ChannelList();
                oldchannels.AddRange(this.FChannels);

                this.FChannels.Clear();

                for (int i = 0; i < this.FPinInHandle.SliceCount; i++)
                {
                    double dblhandle;
                    this.FPinInHandle.GetValue(0, out dblhandle);
                    int hid = Convert.ToInt32(dblhandle);

                    if (this.manager.Exists(hid))
                    {
                        //Get the channel in the list
                        ChannelInfo channel = this.manager.GetChannel(hid);

                        if (channel.BassHandle == null)
                        {
                            //Initialize channel
                            channel.Initialize(this.FDevice);
                        }
                        else
                        {
                            //Check if wrong device, if yes, update it
                            int chandevid = Bass.BASS_ChannelGetDevice(channel.BassHandle.Value);
                            if (this.FDevice != chandevid)
                            {
                                Bass.BASS_ChannelSetDevice(channel.BassHandle.Value, chandevid);
                            }
                        }
                        this.FChannels.Add(channel);
                        //Little trick to refresh
                        channel.Play = channel.Play;
                    }
                }


                //Pause the old channels not in it anymore
                foreach (ChannelInfo info in oldchannels)
                {
                    if (this.FChannels.GetByID(info.InternalHandle) == null)
                    {
                        if (info.BassHandle.HasValue)
                        {
                            Bass.BASS_ChannelPause(info.BassHandle.Value);
                        }
                    }
                }
            }
            #endregion

            #region Updated if pin connected
            if (this.FHandleConnected != this.FPinInHandle.IsConnected)
            {
                if (this.FPinInHandle.IsConnected)
                {
                    this.FChannels.RefreshPlay();
                }
                else
                {
                    this.FChannels.PauseAll();
                }
                this.FHandleConnected = this.FPinInHandle.IsConnected;
            }
            #endregion
        }