Пример #1
0
        public static float[] BASS_WASAPI_GetLevel(float length = 0.02f, BASSLevel flags = BASSLevel.BASS_LEVEL_ALL)
        {
            BASS_WASAPI_INFO bass_WASAPI_INFO = BassWasapi.BASS_WASAPI_GetInfo();

            if (bass_WASAPI_INFO == null)
            {
                return(null);
            }
            int num = bass_WASAPI_INFO.chans;

            if ((flags & BASSLevel.BASS_LEVEL_MONO) == BASSLevel.BASS_LEVEL_MONO)
            {
                num = 1;
            }
            else if ((flags & BASSLevel.BASS_LEVEL_STEREO) == BASSLevel.BASS_LEVEL_STEREO)
            {
                num = 2;
            }
            float[] array = new float[num];
            if (BassWasapi.BASS_WASAPI_GetLevel(array, length, flags))
            {
                return(array);
            }
            return(null);
        }
Пример #2
0
 private static void InitBassWasapi()
 {
     if (!BassNet.OmitCheckVersion)
     {
         BassWasapi.CheckVersion();
     }
 }
Пример #3
0
        public static Version BASS_WASAPI_GetVersion(int fieldcount)
        {
            if (fieldcount < 1)
            {
                fieldcount = 1;
            }
            if (fieldcount > 4)
            {
                fieldcount = 4;
            }
            int     num    = BassWasapi.BASS_WASAPI_GetVersion();
            Version result = new Version(2, 3);

            switch (fieldcount)
            {
            case 1:
                result = new Version(num >> 24 & 255, 0);
                break;

            case 2:
                result = new Version(num >> 24 & 255, num >> 16 & 255);
                break;

            case 3:
                result = new Version(num >> 24 & 255, num >> 16 & 255, num >> 8 & 255);
                break;

            case 4:
                result = new Version(num >> 24 & 255, num >> 16 & 255, num >> 8 & 255, num & 255);
                break;
            }
            return(result);
        }
Пример #4
0
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             int num = BassWasapi.BASS_WASAPI_GetDevice();
             if (num != this._device)
             {
                 BassWasapi.BASS_WASAPI_SetDevice(this._device);
             }
             this.RemoveFullDuplex();
             BassWasapi.BASS_WASAPI_Stop(true);
             Bass.Bass.BASS_StreamFree(this._internalMixer);
             this._internalMixer = 0;
             BassWasapi.BASS_WASAPI_Free();
             BassWasapi.BASS_WASAPI_SetDevice(num);
         }
         if (this._outputChannel != 0)
         {
             Bass.Bass.BASS_StreamFree(this._outputChannel);
             this._outputChannel = 0;
         }
         if (this._inputChannel != 0)
         {
             Bass.Bass.BASS_StreamFree(this._inputChannel);
             this._inputChannel = 0;
         }
     }
     this.disposed = true;
 }
Пример #5
0
        public bool Pause(bool pause)
        {
            bool flag = true;
            int  num  = BassWasapi.BASS_WASAPI_GetDevice();

            if (pause)
            {
                if (num != this._device)
                {
                    flag &= BassWasapi.BASS_WASAPI_SetDevice(this._device);
                }
                if (flag)
                {
                    flag &= BassWasapi.BASS_WASAPI_Stop(false);
                }
            }
            else if (flag)
            {
                flag &= BassWasapi.BASS_WASAPI_SetDevice(this._device);
                if (flag)
                {
                    flag &= BassWasapi.BASS_WASAPI_Start();
                }
            }
            BassWasapi.BASS_WASAPI_SetDevice(num);
            return(flag);
        }
Пример #6
0
        public static BASS_WASAPI_INFO BASS_WASAPI_GetInfo()
        {
            BASS_WASAPI_INFO bass_WASAPI_INFO = new BASS_WASAPI_INFO();

            if (BassWasapi.BASS_WASAPI_GetInfo(bass_WASAPI_INFO))
            {
                return(bass_WASAPI_INFO);
            }
            return(null);
        }
Пример #7
0
        public static bool LoadMe()
        {
            bool flag = Utils.LoadLib("basswasapi", ref BassWasapi._myModuleHandle);

            if (flag)
            {
                BassWasapi.InitBassWasapi();
            }
            return(flag);
        }
Пример #8
0
        public static bool LoadMe(string path)
        {
            bool flag = Utils.LoadLib(Path.Combine(path, "basswasapi"), ref BassWasapi._myModuleHandle);

            if (flag)
            {
                BassWasapi.InitBassWasapi();
            }
            return(flag);
        }
Пример #9
0
        public static BASS_WASAPI_DEVICEINFO BASS_WASAPI_GetDeviceInfo(int device)
        {
            BASS_WASAPI_DEVICEINFO bass_WASAPI_DEVICEINFO = new BASS_WASAPI_DEVICEINFO();

            if (BassWasapi.BASS_WASAPI_GetDeviceInfo(device, bass_WASAPI_DEVICEINFO))
            {
                return(bass_WASAPI_DEVICEINFO);
            }
            return(null);
        }
Пример #10
0
        public static bool BASS_WASAPI_GetDeviceInfo(int device, BASS_WASAPI_DEVICEINFO info)
        {
            bool result;

            try
            {
                bool flag = BassWasapi.BASS_WASAPI_GetDeviceInfoInternal(device, ref info._internal);
                if (flag)
                {
                    if (info._internal.name != IntPtr.Zero)
                    {
                        if (Bass.Bass._configUTF8)
                        {
                            info.name = Utils.IntPtrAsStringUtf8(info._internal.name);
                        }
                        else
                        {
                            info.name = Utils.IntPtrAsStringAnsi(info._internal.name);
                        }
                    }
                    else
                    {
                        info.name = string.Empty;
                    }
                    if (info._internal.id != IntPtr.Zero)
                    {
                        if (Bass.Bass._configUTF8)
                        {
                            info.id = Utils.IntPtrAsStringUtf8(info._internal.id);
                        }
                        else
                        {
                            info.id = Utils.IntPtrAsStringAnsi(info._internal.id);
                        }
                    }
                    else
                    {
                        info.id = string.Empty;
                    }
                    info.type      = info._internal.type;
                    info.flags     = info._internal.flags;
                    info.minperiod = info._internal.minperiod;
                    info.defperiod = info._internal.defperiod;
                    info.mixfreq   = info._internal.mixfreq;
                    info.mixchans  = info._internal.mixchans;
                }
                result = flag;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Пример #11
0
        public static int BASS_WASAPI_GetDeviceCount()
        {
            BASS_WASAPI_DEVICEINFO info = new BASS_WASAPI_DEVICEINFO();
            int num = 0;

            while (BassWasapi.BASS_WASAPI_GetDeviceInfo(num, info))
            {
                num++;
            }
            BassWasapi.BASS_WASAPI_GetCPU();
            return(num);
        }
Пример #12
0
        public static BASS_WASAPI_DEVICEINFO[] BASS_WASAPI_GetDeviceInfos()
        {
            List <BASS_WASAPI_DEVICEINFO> list = new List <BASS_WASAPI_DEVICEINFO>();
            int num = 0;
            BASS_WASAPI_DEVICEINFO item;

            while ((item = BassWasapi.BASS_WASAPI_GetDeviceInfo(num)) != null)
            {
                list.Add(item);
                num++;
            }
            BassWasapi.BASS_WASAPI_GetCPU();
            return(list.ToArray());
        }
Пример #13
0
 private static void CheckVersion()
 {
     try
     {
         if (Utils.HighWord(BassWasapi.BASS_WASAPI_GetVersion()) != 516)
         {
             Version                 version         = BassWasapi.BASS_WASAPI_GetVersion(2);
             Version                 version2        = new Version(2, 4);
             FileVersionInfo         fileVersionInfo = null;
             ProcessModuleCollection modules         = Process.GetCurrentProcess().Modules;
             for (int i = modules.Count - 1; i >= 0; i--)
             {
                 ProcessModule processModule = modules[i];
                 if (processModule.ModuleName.ToLower().Equals("basswasapi".ToLower()))
                 {
                     fileVersionInfo = processModule.FileVersionInfo;
                     break;
                 }
             }
             if (fileVersionInfo != null)
             {
                 MessageBox.Show(string.Format("An incorrect version of BASSWASAPI was loaded!\r\n\r\nVersion loaded: {0}.{1}\r\nVersion expected: {2}.{3}\r\n\r\nFile: {4}\r\nFileVersion: {5}\r\nDescription: {6}\r\nCompany: {7}\r\nLanguage: {8}", new object[]
                 {
                     version.Major,
                     version.Minor,
                     version2.Major,
                     version2.Minor,
                     fileVersionInfo.FileName,
                     fileVersionInfo.FileVersion,
                     fileVersionInfo.FileDescription,
                     fileVersionInfo.CompanyName + " " + fileVersionInfo.LegalCopyright,
                     fileVersionInfo.Language
                 }), "Incorrect BASSWASAPI Version", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
             else
             {
                 MessageBox.Show(string.Format("An incorrect version of BASSWASAPI was loaded!\r\n\r\nVersion loaded: {0}.{1}\r\nVersion expected: {2}.{3}", new object[]
                 {
                     version.Major,
                     version.Minor,
                     version2.Major,
                     version2.Minor
                 }), "Incorrect BASSWASAPI Version", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
     catch
     {
     }
 }
Пример #14
0
        public bool Stop()
        {
            bool flag = true;
            int  num  = BassWasapi.BASS_WASAPI_GetDevice();

            if (num != this._device)
            {
                flag &= BassWasapi.BASS_WASAPI_SetDevice(this._device);
            }
            if (flag && BassWasapi.BASS_WASAPI_IsStarted())
            {
                flag &= BassWasapi.BASS_WASAPI_Stop(true);
            }
            BassWasapi.BASS_WASAPI_SetDevice(num);
            return(flag);
        }
Пример #15
0
        static BassWasapi()
        {
            string text = string.Empty;

            try
            {
                text = new StackFrame(1).GetMethod().Name;
            }
            catch
            {
            }
            if (!text.Equals("LoadMe"))
            {
                BassWasapi.InitBassWasapi();
            }
        }
Пример #16
0
 public BassWasapiHandler(int device, bool exclusive, bool eventSystem, int freq, int chans, float buffer, float period)
 {
     this._device      = device;
     this._exclusive   = exclusive;
     this._eventSystem = eventSystem;
     if (!BassWasapi.BASS_WASAPI_GetDeviceInfo(device, this._wasapiDeviceInfo))
     {
         throw new ArgumentException("Invalid device: " + Enum.GetName(typeof(BASSError), Bass.Bass.BASS_ErrorGetCode()));
     }
     if (exclusive)
     {
         this._numchans = chans;
     }
     else
     {
         this._numchans = this._wasapiDeviceInfo.mixchans;
     }
     if (exclusive)
     {
         this._samplerate = freq;
     }
     else
     {
         this._samplerate = this._wasapiDeviceInfo.mixfreq;
     }
     this._updatePeriod = period;
     if (buffer == 0f)
     {
         this._bufferLength = ((this._updatePeriod == 0f) ? this._wasapiDeviceInfo.defperiod : this._updatePeriod) * 4f;
     }
     else
     {
         this._bufferLength = buffer;
     }
     if (this.IsInput)
     {
         this.UseInput = true;
         return;
     }
     this._internalMixer = BassMix.BASS_Mixer_StreamCreate(this._samplerate, this._numchans, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_AAC_FRAME960);
     if (this._internalMixer == 0)
     {
         throw new NotSupportedException("Internal Mixer: " + Enum.GetName(typeof(BASSError), Bass.Bass.BASS_ErrorGetCode()));
     }
 }
Пример #17
0
        public bool Init(bool buffered = false)
        {
            BASSWASAPIInit basswasapiinit = BASSWASAPIInit.BASS_WASAPI_SHARED;

            if (this._exclusive)
            {
                basswasapiinit |= BASSWASAPIInit.BASS_WASAPI_EXCLUSIVE;
            }
            if (this._eventSystem)
            {
                basswasapiinit |= BASSWASAPIInit.BASS_WASAPI_EVENT;
            }
            if (buffered)
            {
                basswasapiinit |= BASSWASAPIInit.BASS_WASAPI_BUFFER;
            }
            if (this.IsInput)
            {
                this._internalWasapiProc = new WASAPIPROC(this.WasapiInputCallback);
                return(BassWasapi.BASS_WASAPI_Init(this._device, this._samplerate, this._numchans, basswasapiinit, this._bufferLength, this._updatePeriod, this._internalWasapiProc, IntPtr.Zero));
            }
            this._internalWasapiProc = new WASAPIPROC(this.WasapiOutputCallback);
            return(BassWasapi.BASS_WASAPI_Init(this._device, this._samplerate, this._numchans, basswasapiinit, this._bufferLength, this._updatePeriod, this._internalWasapiProc, IntPtr.Zero));
        }
Пример #18
0
 public static BASSWASAPIFormat BASS_WASAPI_CheckFormat(int device, int freq, int chans, BASSWASAPIFormat format)
 {
     return(BassWasapi.BASS_WASAPI_CheckFormat(device, freq, chans, (BASSWASAPIInit)Utils.MakeLong(1, (int)format)));
 }
Пример #19
0
        public static bool BASS_WASAPI_Init(int device, int freq, int chans, BASSWASAPIInit flags, BASSWASAPIFormat format, float buffer, float period, WASAPIPROC proc, IntPtr user)
        {
            flags |= BASSWASAPIInit.BASS_WASAPI_EXCLUSIVE;

            return(BassWasapi.BASS_WASAPI_Init(device, freq, chans, (BASSWASAPIInit)Utils.MakeLong((int)flags, (int)format), buffer, period, proc, user));
        }