Esempio n. 1
1
        public AudioSpectrum()
        {
            devices  = BassWasapi.BASS_WASAPI_GetDeviceInfos();

            _spectrumdata = new List<float>();
            _process = new WASAPIPROC(Process);

            _fft = new float[1024];

            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false);
            StartAnalysis();
        }
Esempio n. 2
0
        public SoundDataProcessor(int deviceIndex)
        {
            this._wasapiDeviceIndex = deviceIndex;

            BuildLookupTables();
            _wasapiProc = IgnoreDataProc;
        }
Esempio n. 3
0
        public BassWrapper()
        {
            Init();
            curVolume = 100;

            BassProcess = new WASAPIPROC(Process);
        }
Esempio n. 4
0
 public WASAPIOutputDevice(Controller controller)
   : base(controller)
 {
   _streamWriteProcDelegate = OutputStreamWriteProc;
   _onPlaybackEndDelegate = OnPlaybackEnd;
   _deviceNo = GetDeviceNo();
 }
 public WASAPIOutputDevice(Controller controller)
     : base(controller)
 {
     _streamWriteProcDelegate = OutputStreamWriteProc;
     _onPlaybackEndDelegate   = OnPlaybackEnd;
     _deviceNo = GetDeviceNo();
 }
Esempio n. 6
0
        public void start(double delay)
        {
            latency = (float)delay / 10;
            var str   = (inlist.Items[inlist.SelectedIndex] as string);
            var array = str.Split(' ');

            sourceIndex = Convert.ToInt32(array[0]);
            str         = (outlist.Items[outlist.SelectedIndex] as string);
            array       = str.Split(' ');
            outIndex    = Convert.ToInt32(array[0]);
            Console.WriteLine(sourceIndex + " " + outIndex);
            Console.WriteLine(delay);

            stop();
            Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); // "No Sound" device init

            // Garbage collector can't track the reference BassWasapi holds,
            // so we're adding a reference here to prevent garbage collection
            inProc  = sourceWasapiProc;
            outProc = outWasapiProc;
            BassWasapi.BASS_WASAPI_Init(sourceIndex, 44100, 0, 0, 1, 0, inProc, IntPtr.Zero);
            BassWasapi.BASS_WASAPI_Init(outIndex, 44100, 0, 0, 4 * latency, 1 * latency, outProc, IntPtr.Zero);

            BassWasapi.BASS_WASAPI_SetDevice(outIndex);
            pushstr = Bass.BASS_StreamCreatePush(44100, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT, IntPtr.Zero);
            outstr  = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
            BassMix.BASS_Mixer_StreamAddChannel(outstr, pushstr, 0);

            BassWasapi.BASS_WASAPI_SetDevice(sourceIndex);
            BassWasapi.BASS_WASAPI_Start();
            BassWasapi.BASS_WASAPI_SetDevice(outIndex);
            BassWasapi.BASS_WASAPI_Start();
        }
        public AudioAnalyzer(MainWindow inst)
        {
            windowInst = inst;

            BassNet.Registration("youremail", "yourregkey"); //Enter your data here!

            _lInt = new Interface();

            _fft          = new float[1024];
            _lastlevel    = 0;
            _hanctr       = 0;
            _t            = new DispatcherTimer();
            _t.Tick      += timerTick;
            _t.Interval   = TimeSpan.FromMilliseconds(25);
            _t.IsEnabled  = false;
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();
            _vis          = inst.visualizer;
            _initialized  = false;
            devices       = new List <AudioDevice>();
            Init();

            leds = new int[9, 9];

            for (int x = 0; x < 9; x++)
            {
                for (int y = 0; y < 9; y++)
                {
                    leds[x, y] = 0;
                }
            }
        }
Esempio n. 8
0
 public Controller()
 {
     Un4seen.Bass.BassNet.Registration("*****@*****.**", "2X2283720152222");
     AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
     Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false);
     _process = new WASAPIPROC(Process);
 }
Esempio n. 9
0
        private WASAPIPROC _process; //callback function to obtain data

        #endregion Fields

        #region Constructors

        public AudioAnalyzer()
        {
            _fft = new float[1024];
            _process = new WASAPIPROC(Process);
            _initialized = false;
            Init();
        }
Esempio n. 10
0
        private int _lines = 16;            // number of spectrum lines
        //ctor
        public AudioRGBCreator(System.Windows.Controls.Primitives.ToggleButton btnEnable, ProgressBar left, ProgressBar right, Spectrum spectrum, ComboBox devicelist, ComboBox algoChoser, MyRangeSlider mrs, Slider triggerSlider)
        {
            _fft           = new float[1024];
            _lastlevel     = 0;
            _hanctr        = 0;
            _t             = new DispatcherTimer();
            _t.Tick       += _t_Tick;
            _t.Interval    = TimeSpan.FromMilliseconds(25); //40hz refresh rate
            _t.IsEnabled   = false;
            _l             = left;
            _r             = right;
            _l.Minimum     = 0;
            _r.Minimum     = 0;
            _r.Maximum     = ushort.MaxValue;
            _l.Maximum     = ushort.MaxValue;
            _process       = new WASAPIPROC(Process);
            _spectrumdata  = new List <byte>();
            _spectrum      = spectrum;
            _devicelist    = devicelist;
            _initialized   = false;
            _mrs           = mrs;
            _btnEnable     = btnEnable;
            _triggerSlider = triggerSlider;

            algoChoser.Items.Add(new ShowAudioToRGB1());
            algoChoser.Items.Add(new ShowAudioToRGB2());
            algoChoser.Items.Add(new ShowAudioToRGB3());
            algoChoser.Items.Add(new ShowAudioToRGB4());
            algoChoser.Items.Add(new ShowAudioToRGB5());
            algoChoser.Items.Add(new ShowAudioToRGB6());

            Init();
        }
Esempio n. 11
0
        //ctor
        public Analyzer(ProgressBar left, ProgressBar right, Spectrum spectrum, ComboBox devicelist, ComboBox visBoz, Slider colorSlider)
        {
            _fft          = new float[1024];
            _lastlevel    = 0;
            _hanctr       = 0;
            _t            = new DispatcherTimer();
            _t.Tick      += _t_Tick;
            _t.Interval   = TimeSpan.FromMilliseconds(40); //40hz refresh rate
            _t.IsEnabled  = false;
            _l            = left;
            _r            = right;
            _l.Minimum    = 0;
            _r.Minimum    = 0;
            _r.Maximum    = ushort.MaxValue;
            _l.Maximum    = ushort.MaxValue;
            _visBoz       = visBoz;
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();
            _spectrum     = spectrum;
            _devicelist   = devicelist;
            _colorSlider  = colorSlider;
            _initialized  = false;

            Init();
            InitSpot();
            this.IpAddress = IPAddress.Parse("172.19.65.95");
            this.Enable    = true;
        }
Esempio n. 12
0
 //ctor
 public Analyzer(ProgressBar left, ProgressBar right, Views.Spectrum spectrum)
 {
     _enable      = true;
     _fft         = new float[1024];
     _lastlevel   = 0;
     _hanctr      = 0;
     _t           = new DispatcherTimer();
     _t.Tick     += _t_Tick;
     _t.Interval  = TimeSpan.FromMilliseconds(25); //40hz refresh rate
     _t.IsEnabled = false;
     _t2          = new DispatcherTimer();
     _t2.Interval = TimeSpan.FromSeconds(1);
     _t2.Tick    += _t2_Tick;
     //_t2.Start();
     _l            = left;
     _r            = right;
     _l.Minimum    = 0;
     _r.Minimum    = 0;
     _r.Maximum    = ushort.MaxValue;
     _l.Maximum    = ushort.MaxValue;
     _process      = new WASAPIPROC(Process);
     _spectrumdata = new List <byte>();
     _spectrum     = spectrum;
     _initialized  = false;
     NewInit();
 }
Esempio n. 13
0
 public DelayTool(ComboBox inlist, ComboBox outlist)
 {
     BassNet.Registration("*****@*****.**", "2X531420152222");
     this.inlist = inlist;
     this.outlist = outlist;
     init();
     sourceProcess = new WASAPIPROC(sourceWasapiProc);
     outProcess = new WASAPIPROC(outWasapiProc);
 }
Esempio n. 14
0
 public static extern bool BASS_WASAPI_Init(
     int device,
     int freq,
     int chans,
     int flags,
     float buffer,
     float period,
     WASAPIPROC proc,
     IntPtr user
     );
Esempio n. 15
0
 public Analyzer(int lines)
 {
     fftBuffer   = new float[1024];
     lastLevel   = 0;
     hanCtr      = 0;
     initialized = false;
     process     = new WASAPIPROC(Process);
     devices     = new List <string>();
     Init();
     SpectrumData = new float[lines];
 }
        public SpectrumAnalyzer()
        {
            _fft          = new float[8192];
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <float>();

            InitializeSpectrumData();

            Init();
            CaptureDevice(0);
        }
Esempio n. 17
0
        /// <summary>
        /// Initializes an instance of the class <see cref="AudioAnalyzer"/>
        /// </summary>
        public AudioAnalyzer()
        {
            this._fftDataBuffer = new float[1024];
            this._wasapiProcessCallback = new WASAPIPROC(this.WasapiProcessCallBack);

            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false);
            Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

            var devEnum = new MMDeviceEnumerator();
            this._mmAudioDevice = devEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
            this._mmAudioDevice.AudioEndpointVolume.OnVolumeNotification += this.AudioEndpointVolume_OnVolumeNotification;
        }
Esempio n. 18
0
 //flag for enabling and disabling program functionality
 private void Init()
 {
     if (!this.initialized)
     {
         this.process = new WASAPIPROC(Process);
         bool result = BassWasapi.BASS_WASAPI_Init(this.device, 0, 0, BASSWASAPIInit.BASS_WASAPI_BUFFER, 1f, 0.05f, this.process, IntPtr.Zero);
         if (result)
         {
             this.initialized = true;
         }
     }
     BassWasapi.BASS_WASAPI_Start();
 }
Esempio n. 19
0
        private int _lines = 16;            // number of spectrum lines

        public Analyzer(ComboBox devicelist, Spectrum spectrum)
        {
            BassNet.Registration("*****@*****.**", "2X28911852937");
            _fft          = new float[1024];//default 1024
            _lastlevel    = 0;
            _hanctr       = 0;
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();
            _devicelist   = devicelist;
            _spectrum     = spectrum;
            _initialized  = false;
            Init();
        }
Esempio n. 20
0
        private int _lines = 64;            // number of spectrum lines

        //ctor
        public Analyzer(ProgressBar left, ProgressBar right, Spectrum spectrum, ComboBox devicelist, Chart chart, GroupBox optionen, RadioButton red_btn, RadioButton green_btn, RadioButton blue_btn, RadioButton yellow_btn, RadioButton cyan_btn, RadioButton magenta_btn, RadioButton white_btn, RadioButton fade_btn)
        {
            BassNet.Registration("*****@*****.**", "2X2232923152222");

            _fft          = new float[8192];
            _lastlevel    = 0;
            _hanctr       = 0;
            _t            = new DispatcherTimer();
            _t.Tick      += _t_Tick;
            _t.Interval   = TimeSpan.FromMilliseconds(25); //40hz refresh rate//25
            _t.IsEnabled  = false;
            _l            = left;
            _r            = right;
            _l.Minimum    = 0;
            _r.Minimum    = 0;
            _r.Maximum    = (ushort.MaxValue);
            _l.Maximum    = (ushort.MaxValue);
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();
            _spectrum     = spectrum;
            _chart        = chart;
            _devicelist   = devicelist;
            _initialized  = false;

            _optionen    = optionen;
            _red_btn     = red_btn;
            _green_btn   = green_btn;
            _blue_btn    = blue_btn;
            _yellow_btn  = yellow_btn;
            _cyan_btn    = cyan_btn;
            _magenta_btn = magenta_btn;
            _white_btn   = white_btn;
            _fade_btn    = fade_btn;

            chart.Series.Add("wave");
            chart.Series["wave"].ChartType = SeriesChartType.FastLine;
            chart.Series["wave"].ChartArea = "ChartArea1";

            chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
            chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
            chart.ChartAreas["ChartArea1"].AxisY.Maximum           = 255;
            chart.ChartAreas["ChartArea1"].AxisY.Minimum           = 0;
            chart.ChartAreas["ChartArea1"].AxisX.Maximum           = 32;
            chart.ChartAreas["ChartArea1"].AxisX.Minimum           = 0;
            for (int i = 0; i < chart.ChartAreas["ChartArea1"].AxisX.Maximum; i++)
            {
                chart.Series["wave"].Points.Add(0);
            }

            Init();
        }
Esempio n. 21
0
        public AudioSpectrumDevice(BASS_WASAPI_DEVICEINFO device, int devindex, int channels)
        {
            _lines = channels;
            for (int i = 0; i < channels; i++)
            {
                JoyAxis channel = new JoyAxis("Channel " + (i + 1).ToString(), DataFlowDirection.Input, "")
                {
                    min_Value = 0, max_Value = 1
                };
                Channels.Add(channel);
            }

            this.devindex   = devindex;
            this.device     = device;
            this.DeviceName = device.name;
            this.StatusIcon = Properties.Resources.audio.ToImageSource();
            _fft            = new float[1024];
            _lastlevel      = 0;
            _hanctr         = 0;
            _t          = new DispatcherTimer();
            _t.Tick    += _t_Tick;
            _t.Interval = TimeSpan.FromMilliseconds(25); //40hz refresh rate
            //_t.IsEnabled = true;
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <double>();
            _initialized  = false;


            //var str = (_devicelist.Items[_devicelist.SelectedIndex] as string)
            //            var array = str.Split(' ');
            //devindex = Convert.ToInt32(array[0]);
            bool result = BassWasapi.BASS_WASAPI_Init(devindex, 0, 0,
                                                      BASSWASAPIInit.BASS_WASAPI_BUFFER,
                                                      1f, 0.05f,
                                                      _process, IntPtr.Zero);

            if (!result)
            {
                var error = Bass.BASS_ErrorGetCode();
                MessageBox.Show(error.ToString());
            }
            else
            {
                _initialized = true;
            }
            BassWasapi.BASS_WASAPI_Start();
            _t.IsEnabled = true;
            _t.Start();
        }
Esempio n. 22
0
        public Form1()
        {
            InitializeComponent();

            fft     = new float[8192];
            process = new WASAPIPROC(Process);
            chart1.SendToBack();

            for (int i = 0; i < chart1.ChartAreas["ChartArea1"].AxisX.Maximum - 1; i++)
            {
                chart1.Series["wave"].Points.Add(0);
            }

            Init();
        }
Esempio n. 23
0
        public ESPRGB()
        {
            if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1)
            {
                exceptions exitMessage = new exceptions(0, "ESPRGB-Exception", "App is already opened!");
                exitMessage.StartPosition = FormStartPosition.CenterParent;
                exitMessage.ShowDialog();
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
            string paths = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ESPRGB-Client\\config.json");

            fileLocation = new FileInfo(paths);
            fileLocation.Directory.Create();
            settingsWindow = new settingsWindow();
            if (File.Exists(fileLocation.FullName))
            {
                string  jsonString = File.ReadAllText(fileLocation.FullName);
                JObject loadedData = JObject.Parse(jsonString);
                if (loadedData.ContainsKey("Settings"))
                {
                    JObject settings = (JObject)loadedData["Settings"];
                    if (settings.ContainsKey("startApp"))
                    {
                        settingsWindow.startState.SelectedItem = (string)settings["startApp"];
                    }
                    if (settings.ContainsKey("closeButtonMinimize"))
                    {
                        settingsWindow.exitButtonBehavior.Checked = (bool)settings["closeButtonMinimize"];
                    }
                    if (settings.ContainsKey("savedAudioDevice"))
                    {
                        selectedaudioDevices["fullName"] = (string)settings["savedAudioDevice"];
                    }
                }
            }
            settingsWindow.StartPosition = FormStartPosition.CenterParent;
            BassNet.Registration("*****@*****.**", "2X5291323152222");
            updateAudioDevices();
            InitializeComponent();
            tabDevices.Visible = false;
            tabDevices.Visible = true;
            tabDevices.TabPages.Clear();
            _process = new WASAPIPROC(Process);
            InitializeAudioDevice((string)selectedaudioDevices["fullName"]);
            windowState = this.WindowState;
            curVersion  = typeof(ESPRGB).Assembly.GetName().Version;
            settingsWindow.versionLabel.Text = curVersion.ToString();
        }
Esempio n. 24
0
        private int _lines = 16;            // number of spectrum lines

        //ctor
        public Analyzer(ComboBox devicelist)
        {
            _fft          = new float[1024];
            _lastlevel    = 0;
            _hanctr       = 0;
            _t            = new Timer();
            _t.Elapsed   += _t_Tick;
            _t.Interval   = 17; //60hz refresh rate
            _t.Enabled    = false;
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();
            _devicelist   = devicelist;
            IsInitialized = false;

            devCount = BassWasapi.BASS_WASAPI_GetDeviceCount();
        }
Esempio n. 25
0
        /// <summary>
        /// Initializes a WASAPI device by its identifier, using the specified sample rate (frequency) 
        /// and initialization flags. To get the deviceId, use the DeviceHelper class. Requires a data callback.
        /// </summary>
        /// <param name="deviceId">Device identifier</param>
        /// <param name="frequency">Sample rate (in Hz)</param>
        /// <param name="channels">Number of channels</param>
        /// <param name="init">Intiailization flags</param>
        /// <param name="wasapiInit">WASAPI initialization flags</param>
        /// <param name="buffer">Buffer size</param>
        /// <param name="period">Update period</param>
        /// <param name="proc">WASAPI callback</param>
        public static void Init(int deviceId, int frequency, int channels, BASSInit init, 
            BASSWASAPIInit wasapiInit, float buffer, float period, WASAPIPROC proc)
        {
            // Initialize base device
            if (!Bass.BASS_Init(-1, frequency, init, IntPtr.Zero))
            {
                // Check for error (throw exception if the error is found)
                Base.CheckForError();  
            }

            // Initialize WASAPI device
            if (!BassWasapi.BASS_WASAPI_Init(deviceId, frequency, 2, wasapiInit, buffer, period, proc, IntPtr.Zero))
            {
                // Check for error (throw exception if the error is found)
                Base.CheckForError();
            }
        }
Esempio n. 26
0
 public MusicAnalyzer(StationController sc)
 {
     this.sc             = sc;
     this.color          = new Color(255, 255, 255);
     _fft                = new float[1024];
     _hanctr             = 0;
     _t                  = new DispatcherTimer();
     _t.Tick            += _t_Tick;
     _t.Interval         = TimeSpan.FromMilliseconds(5); //25 -> 40hz refresh rate
     _t.IsEnabled        = false;
     _process            = new WASAPIPROC(Process);
     spectrumdata        = new List <byte>();
     spectrumdataHistory = new List <List <byte> >();
     _devicelist         = new List <AudioDevice>();
     _initialized        = false;
     Init();
 }
Esempio n. 27
0
        private ComboBox _devicelist;                         //device list

        //ctor
        public Analyzer(BaseSpectrumVisualizer[] audioSpectrumVisualizer, ComboBox devicelist)
        {
            _fft       = new float[8192];
            _lastlevel = 0;
            _hanctr    = 0;
            // init timer
            _t           = new DispatcherTimer();
            _t.Tick     += _t_Tick;
            _t.Interval  = TimeSpan.FromMilliseconds(25); //40hz refresh rate//25
            _t.IsEnabled = false;

            _process            = new WASAPIPROC(Process);
            _spectrumdata       = new List <byte>();
            _spectrumVisualizer = audioSpectrumVisualizer;
            _devicelist         = devicelist;
            _initialized        = false;
            Init();
        }
Esempio n. 28
0
        // constructor
        public Analyzer(ComboBox devicelist, MainWindow mW, int lines)
        {
            _lines       = lines;
            _fft         = new float[4096];
            _lastlevel   = 0;
            _hanctr      = 0;
            _t           = new DispatcherTimer();
            _t.Tick     += _t_Tick;
            _t.Interval  = TimeSpan.FromMilliseconds(25); // 40hz refresh rate
            _t.IsEnabled = false;

            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();
            _devicelist   = devicelist;
            _initialized  = false;
            Init();
            mainWindow = mW;
        }
Esempio n. 29
0
 public Analyzer(int SpectrumBarsCount, int DisplayRefreshRate)
 {
     this.SpectrumBarsCount = SpectrumBarsCount;
     fft                    = new float[1024];
     lastlevel              = 0;
     hanctr                 = 0;
     DisplayTimer           = new DispatcherTimer();
     DisplayTimer.Tick     += DisplayTimerTick;
     DisplayTimer.Interval  = TimeSpan.FromMilliseconds(DisplayRefreshRate);
     DisplayTimer.IsEnabled = false;
     process                = new WASAPIPROC(Process);
     spectrumdata           = new List <byte>();
     SoundVisualizerViewModel.ToggleStance += TurnOnOff;
     SoundVisualizerViewModel.SetDevice    += SetDevice;
     initialized = false;
     devicelist  = new List <string>();
     Init();
 }
Esempio n. 30
0
        private int _lines = 64;                    // number of spectrum lines

        //ctor
        //
        public Analyzer(ProgressBar left, ProgressBar right, Spectrum spectrum, ComboBox devicelist, Chart chart)
        {
            _fft          = new float[8192];
            _lastlevel    = 0;
            _hanctr       = 0;
            _t            = new DispatcherTimer();
            _t.Tick      += _t_Tick;
            _t.Interval   = TimeSpan.FromMilliseconds(25);           //40hz refresh rate//25
            _t.IsEnabled  = false;
            _l            = left;
            _r            = right;
            _l.Minimum    = 0;
            _r.Minimum    = 0;
            _r.Maximum    = (ushort.MaxValue);
            _l.Maximum    = (ushort.MaxValue);
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();
            _spectrum     = spectrum;
            _chart        = chart;
            _devicelist   = devicelist;
            _initialized  = false;

            chart.Series.Add("wave");
            chart.Series["wave"].ChartType = SeriesChartType.FastLine;
            chart.Series["wave"].ChartArea = "ChartArea1";

            chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled  = false;
            chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled  = false;
            chart.ChartAreas["ChartArea1"].AxisY.Maximum            = 255;
            chart.ChartAreas["ChartArea1"].AxisY.Minimum            = 0;
            chart.ChartAreas["ChartArea1"].AxisX.Maximum            = 64;
            chart.ChartAreas["ChartArea1"].AxisX.Minimum            = 0;
            chart.ChartAreas["ChartArea1"].InnerPlotPosition.Width  = 100;
            chart.ChartAreas["ChartArea1"].InnerPlotPosition.Height = 70;
            chart.ChartAreas["ChartArea1"].InnerPlotPosition.X      = 5;
            chart.ChartAreas["ChartArea1"].InnerPlotPosition.Y      = 20;

            for (int i = 0; i < chart.ChartAreas["ChartArea1"].AxisX.Maximum; i++)
            {
                chart.Series["wave"].Points.Add(0);
            }

            Init();
        }
Esempio n. 31
0
        private int devindex;                                       //used device index


        public AudioProcessor()
        {
            _fft                   = new float[1024];
            lastOutLevel           = 0;
            lastOutputLevelCounter = 0;
            timer                  = new DispatcherTimer();
            timer.Tick            += OnTimerTick;
            timer.Interval         = TimeSpan.FromMilliseconds(20); //40hz refresh rate
            timer.IsEnabled        = false;
            leftChannelIntensity   = 0;
            rightChannelIntensity  = 0;
            rightChannelIntensity  = ushort.MaxValue;
            leftChannelIntensity   = ushort.MaxValue;
            _process               = new WASAPIPROC(Process);
            _spectrumdata          = new List <byte>();

            devindex     = 0;
            _initialized = false;
        }
Esempio n. 32
0
        private int devindex;              //used device index



        //ctor

        public AudioProcessor(int deviceIndex, bool trimEnd = true)
        {
            _fft          = new float[1024];
            _lastlevel    = 0;
            _hanctr       = 0;
            _t            = new DispatcherTimer();
            _t.Tick      += _t_Tick;
            _t.Interval   = TimeSpan.FromMilliseconds(20); //40hz refresh rate
            _t.IsEnabled  = false;
            _l            = 0;
            _r            = 0;
            _r            = ushort.MaxValue;
            _l            = ushort.MaxValue;
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <byte>();

            devindex     = deviceIndex;
            _initialized = false;
        }
        public Analyzer()
        {
            _fft                           = new float[1024];
            _lastlevel                     = 0;
            _hanctr                        = 0;
            _displayRefreshTimer           = new DispatcherTimer();
            _displayRefreshTimer.Tick     += _t_Tick;
            _displayRefreshTimer.Interval  = TimeSpan.FromMilliseconds(25); //40hz refresh rate
            _displayRefreshTimer.IsEnabled = false;
            _process                       = Process;
            _spectrumdata                  = new List <byte>();
            _initialized                   = false;

            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false);
            var result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

            if (!result)
            {
                throw new Exception("Init Error");
            }
        }
Esempio n. 34
0
        private int _variableColor;        //Bar color depends on level

        public Analyser(Chart ch, ComboBox devicelist)
        {
            _fft           = new float[1024];
            output         = new char[_lines];
            _lastlevel     = 0;
            _hanctr        = 0;
            _t             = new DispatcherTimer();
            _t.Tick       += _t_Tick;
            _t.Interval    = TimeSpan.FromMilliseconds(20); //40hz refresh rate
            _t.IsEnabled   = false;
            _process       = new WASAPIPROC(Process);
            _spectrumdata  = new List <byte>();
            _devicelist    = devicelist;
            _initialized   = false;
            _chart         = ch;
            _realMode      = false;
            _variableColor = 0;
            _sb            = new StringBuilder(91);
            max            = new byte[90];
            Init();
        }
Esempio n. 35
0
        public SpectrumAnalyzer()
        {
            Plugins.Bass.Start();

            _timer = new Timer {
                Interval = 1
            };
            _timer.Tick += Getter;

            this.Count    = 10;
            this.Interval = 1;

            _ftt          = new Single[8192];
            _spectrumData = new List <Byte>();
            _process      = new WASAPIPROC(Process);
            _lastLevel    = 0;
            _hanctr       = 0;
            _initialized  = false;

            this.Init();
        }
Esempio n. 36
0
        private void CaptureDefaultDevice()
        {
            _process = new WASAPIPROC(Process);
            var defaultDevice = BassWasapi.BASS_WASAPI_GetDeviceInfos().FirstOrDefault(d => d.IsDefault && !d.IsInput);
            var devices       = BassWasapi.BASS_WASAPI_GetDeviceInfos(); // MUST be compiled as x86 since basswasapi.dll is ancient

            DefaultAudioDevice = devices.FirstOrDefault(d => d.IsEnabled && d.IsLoopback && d.name == defaultDevice?.name);
            if (DefaultAudioDevice == null)
            {
                return;
            }

            Un4seen.Bass.Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false);
            Un4seen.Bass.Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

            var deviceIndex = Array.FindIndex(devices, d => d == DefaultAudioDevice);

            BassWasapi.BASS_WASAPI_Init(deviceIndex, 0, 0, BASSWASAPIInit.BASS_WASAPI_BUFFER, 1f, 0.05f, _process, IntPtr.Zero);
            BassWasapi.BASS_WASAPI_Start();
            _updateSpectrumDispatcherTimer.Start();
        }
Esempio n. 37
0
 //ctor
 public Analyzer(ProgressBar left, ProgressBar right, Spectrum spectrum, ComboBox devicelist)
 {
     _fft          = new float[1024];
     _lastlevel    = 0;
     _hanctr       = 0;
     _t            = new DispatcherTimer();
     _t.Tick      += _t_Tick;
     _t.Interval   = TimeSpan.FromMilliseconds(16); //60hz refresh rate
     _t.IsEnabled  = false;
     _l            = left;
     _r            = right;
     _l.Minimum    = 0;
     _r.Minimum    = 0;
     _r.Maximum    = ushort.MaxValue;
     _l.Maximum    = ushort.MaxValue;
     _process      = new WASAPIPROC(Process);
     _spectrumdata = new List <byte>();
     _spectrum     = spectrum;
     _devicelist   = devicelist;
     _initialized  = false;          // Инициализация
     Init();
 }
        private Timer _t; //timer that refreshes the display

        #endregion Fields

        #region Constructors

        //ctor
        public Analyzer(ProgressBar left, ProgressBar right, ComboBox devicelist)
        {
            _fft = new float[1024];
            _lastlevel = 0;
            _hanctr = 0;
            _t = new Timer();
            _t.Tick += _t_Tick;
            _t.Interval = 25; //40hz refresh rate
            //_t.Interval = 50; //20 Hz
            //_t.Interval = 400;
            _t.Enabled = false;
            _l = left;
            _r = right;
            _l.Minimum = 0;
            _r.Minimum = 0;
            _r.Maximum = ushort.MaxValue;
            _l.Maximum = ushort.MaxValue;
            _process = new WASAPIPROC(Process);
            _spectrumdata = new List<byte>();
            _devicelist = devicelist;
            _initialized = false;
            Init();
        }
Esempio n. 39
0
    /// <summary>
    /// Create a mixer using the stream attributes
    /// </summary>
    /// <param name="stream"></param>
    /// <returns></returns>
    public bool CreateMixer(MusicStream stream)
    {
      Log.Debug("BASS: ---------------------------------------------");
      Log.Debug("BASS: Creating BASS mixer stream");

      bool result = false;

      BASSFlag mixerFlags = BASSFlag.BASS_MIXER_NONSTOP | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_NORAMPIN;

      if (Config.MusicPlayer == AudioPlayer.Asio || Config.MusicPlayer == AudioPlayer.WasApi)
      {
        mixerFlags |= BASSFlag.BASS_STREAM_DECODE;
      }

      int outputChannels = _bassPlayer.DeviceChannels;
      _mixingMatrix = null;

      // See, if we need Upmixing
      if (outputChannels > stream.ChannelInfo.chans)
      {
        Log.Debug("BASS: Found more output channels ({0}) than input channels ({1}). Check for upmixing.", outputChannels,
                 stream.ChannelInfo.chans);
        _mixingMatrix = CreateMixingMatrix(stream.ChannelInfo.chans);
        if (_mixingMatrix != null)
        {
          outputChannels = Math.Min(_mixingMatrix.GetLength(0), outputChannels);
          _upmixing = true;
        }
        else
        {
          outputChannels = stream.ChannelInfo.chans;
        }
      }
      else if (outputChannels < stream.ChannelInfo.chans)
      {
        // Downmix to Stereo
        Log.Debug("BASS: Found more input channels ({0}) than output channels ({1}). Downmix.", stream.ChannelInfo.chans,
                 outputChannels);
        outputChannels = Math.Min(outputChannels, 2);
      }

      Log.Debug("BASS: Creating {0} channel mixer with sample rate of {1}", outputChannels, stream.ChannelInfo.freq);
      _mixer = BassMix.BASS_Mixer_StreamCreate(stream.ChannelInfo.freq, outputChannels, mixerFlags);
      if (_mixer == 0)
      {
        Log.Error("BASS: Unable to create Mixer.  Reason: {0}.",
                  Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
        return false;
      }

      switch (Config.MusicPlayer)
      {
        case AudioPlayer.Bass:
        case AudioPlayer.DShow:

          if (!Bass.BASS_ChannelPlay(_mixer, false))
          {
            Log.Error("BASS: Unable to start Mixer.  Reason: {0}.", Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
            return false;
          }

          result = true;

          break;

        case AudioPlayer.Asio:

          Log.Info("BASS: Initialising ASIO device");

          if (BassAsio.BASS_ASIO_IsStarted() && !BassAsio.BASS_ASIO_Stop())
          {
            Log.Error("BASS: Error stopping Asio Device: {0}", BassAsio.BASS_ASIO_ErrorGetCode());
          }

          // Disable and Unjoin all the channels
          if (!BassAsio.BASS_ASIO_ChannelReset(false, -1, BASSASIOReset.BASS_ASIO_RESET_ENABLE))
          {
            Log.Error("BASS: Error disabling Asio Channels: {0}", BassAsio.BASS_ASIO_ErrorGetCode());
          }

          if (!BassAsio.BASS_ASIO_ChannelReset(false, -1, BASSASIOReset.BASS_ASIO_RESET_JOIN))
          {
            Log.Error("BASS: Error unjoining Asio Channels: {0}", BassAsio.BASS_ASIO_ErrorGetCode());
          }

          _asioProc = new ASIOPROC(AsioCallback);

          BassAsio.BASS_ASIO_ChannelSetVolume(false, -1, (float)Config.StreamVolume / 100f);

          // enable 1st output channel...(0=first)
          Log.Debug("BASS: Joining Asio Channel #{0}", "0");
          BassAsio.BASS_ASIO_ChannelEnable(false, 0, _asioProc, new IntPtr(_mixer));

          // and join the next channels to it
          int numChannels = Math.Max(stream.ChannelInfo.chans, outputChannels);
          for (int i = 1; i < numChannels; i++)
          {
            Log.Debug("BASS: Joining Asio Channel #{0}", i);
            BassAsio.BASS_ASIO_ChannelJoin(false, i, 0);
          }

          // since we joined the channels, the next commands will apply to all channles joined
          // so setting the values to the first channels changes them all automatically
          // set the source format (float, as the decoding channel is)
          if (!BassAsio.BASS_ASIO_ChannelSetFormat(false, 0, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT))
          {
            Log.Error("BASS: Error setting Asio Sample Format: {0}", BassAsio.BASS_ASIO_ErrorGetCode());
          }

          // set the source rate
          Log.Debug("BASS: Set sample rate to {0}", stream.ChannelInfo.freq);
          if (!BassAsio.BASS_ASIO_ChannelSetRate(false, 0, (double)stream.ChannelInfo.freq))
          {
            Log.Error("BASS: Error setting Asio Channel Samplerate: {0}", BassAsio.BASS_ASIO_ErrorGetCode());
          }

          // try to set the device rate too (saves resampling)
          if (!BassAsio.BASS_ASIO_SetRate((double)stream.ChannelInfo.freq))
          {
            Log.Error("BASS: Error setting Asio Samplerate: {0}", BassAsio.BASS_ASIO_ErrorGetCode());
          }

          // and start playing it...start output using default buffer/latency
          if (!BassAsio.BASS_ASIO_Start(0))
          {
            Log.Error("BASS: Error starting Asio playback: {0}", BassAsio.BASS_ASIO_ErrorGetCode());
          }
          Log.Info("BASS: Finished initialising ASIO device");
          result = true;

          break;

        case AudioPlayer.WasApi:

          Log.Info("BASS: Initialising WASAPI device");

          try
          {
            BassWasapi.BASS_WASAPI_Free();
            Log.Debug("BASS: Freed WASAPI device");
          }
          catch (Exception ex)
          {
            Log.Error("BASS: Exception freeing WASAPI. {0} {1}", ex.Message, ex.StackTrace);
          }

          BASSWASAPIInit initFlags = BASSWASAPIInit.BASS_WASAPI_AUTOFORMAT;

          _wasapiProc = new WASAPIPROC(WasApiCallback);

          bool wasApiExclusiveSupported = true;

          // Check if we have an uneven number of channels
          var chkChannels = outputChannels % 2;
          if (chkChannels == 1)
          {
            Log.Warn("BASS: Found uneven number of channels {0}. increase output channels.", outputChannels);
            outputChannels++; // increase the number of output channels
            wasApiExclusiveSupported = false; // And indicate that we need a new mixer
          }

          // Handle the special cases of 3.0, 4.0 and 5.0 files being played on a 5.1 or 6.1 device
          if (outputChannels == 3)  // a 3.0 file
          {
            Log.Info("BASS: Found a 3 channel file. Set upmixing with LFE, LR, RR set to silent");
            _mixingMatrix = CreateThreeDotZeroUpMixMatrix();
            outputChannels = _bassPlayer.DeviceChannels;   // WASAPI device should be initialised with all channels active
            wasApiExclusiveSupported = false; // And indicate that we need a new mixer
          }
          else if (outputChannels == 4)  // a 4.0 file
          {
            Log.Info("BASS: Found a 4 channel file. Set upmixing with Center and LFE set to silent");
            _mixingMatrix = CreateFourDotZeroUpMixMatrix();
            outputChannels = _bassPlayer.DeviceChannels;   // WASAPI device should be initialised with all channels active
            wasApiExclusiveSupported = false; // And indicate that we need a new mixer
          }
          else if (outputChannels == 5)  // a 5.0 file
          {
            Log.Info("BASS: Found a 5 channel file. Set upmixing with LFE set to silent");
            _mixingMatrix = CreateFiveDotZeroUpMixMatrix();
            outputChannels = _bassPlayer.DeviceChannels;   // WASAPI device should be initialised with all channels active
            wasApiExclusiveSupported = false; // And indicate that we need a new mixer
          }

          // If Exclusive mode is used, check, if that would be supported, otherwise init in shared mode
          if (Config.WasApiExclusiveMode)
          {
            initFlags |= BASSWASAPIInit.BASS_WASAPI_EXCLUSIVE;
            _wasapiShared = false;
            _wasapiMixedChans = 0;
            _wasapiMixedFreq = 0;

            BASSWASAPIFormat wasapiFormat = BassWasapi.BASS_WASAPI_CheckFormat(_bassPlayer.DeviceNumber,
                                                                               stream.ChannelInfo.freq,
                                                                               outputChannels,
                                                                               BASSWASAPIInit.BASS_WASAPI_EXCLUSIVE);
            if (wasapiFormat == BASSWASAPIFormat.BASS_WASAPI_FORMAT_UNKNOWN)
            {
              Log.Warn("BASS: WASAPI exclusive mode not directly supported. Let BASS WASAPI choose better mode.");
              wasApiExclusiveSupported = false;
            }
          }
          else
          {
            Log.Debug("BASS: Init WASAPI shared mode with Event driven system enabled.");
            initFlags |= BASSWASAPIInit.BASS_WASAPI_SHARED | BASSWASAPIInit.BASS_WASAPI_EVENT;

            // In case of WASAPI Shared mode we need to setup the mixer to use the same sample rate as set in 
            // the Windows Mixer, otherwise we wioll have increased playback speed
            BASS_WASAPI_DEVICEINFO devInfo = BassWasapi.BASS_WASAPI_GetDeviceInfo(_bassPlayer.DeviceNumber);
            Log.Debug("BASS: Creating {0} channel mixer for frequency {1}", devInfo.mixchans, devInfo.mixfreq);
            _mixer = BassMix.BASS_Mixer_StreamCreate(devInfo.mixfreq, devInfo.mixchans, mixerFlags);
            if (_mixer == 0)
            {
              Log.Error("BASS: Unable to create Mixer.  Reason: {0}.",
                        Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
              return false;
            }
            _wasapiShared = true;
          }

          Log.Debug("BASS: Try to init WASAPI with a Frequency of {0} and {1} channels", stream.ChannelInfo.freq, outputChannels);

          if (BassWasapi.BASS_WASAPI_Init(_bassPlayer.DeviceNumber, stream.ChannelInfo.freq, outputChannels,
                                      initFlags | BASSWASAPIInit.BASS_WASAPI_BUFFER, Convert.ToSingle(Config.BufferingMs / 1000.0), 0f, _wasapiProc, IntPtr.Zero))
          {
            BASS_WASAPI_INFO wasapiInfo = BassWasapi.BASS_WASAPI_GetInfo();

            Log.Debug("BASS: ---------------------------------------------");
            Log.Debug("BASS: Buffer Length: {0}", wasapiInfo.buflen);
            Log.Debug("BASS: Channels: {0}", wasapiInfo.chans);
            Log.Debug("BASS: Frequency: {0}", wasapiInfo.freq);
            Log.Debug("BASS: Format: {0}", wasapiInfo.format.ToString());
            Log.Debug("BASS: InitFlags: {0}", wasapiInfo.initflags.ToString());
            Log.Debug("BASS: Exclusive: {0}", wasapiInfo.IsExclusive.ToString());
            Log.Debug("BASS: ---------------------------------------------");
            Log.Info("BASS: WASAPI Device successfully initialised");

            // Now we need to check, if WASAPI decided to switch to a different mode
            if (Config.WasApiExclusiveMode && !wasApiExclusiveSupported)
            {
              // Recreate Mixer with new value
              Log.Debug("BASS: Creating new {0} channel mixer for frequency {1}", wasapiInfo.chans, wasapiInfo.freq);
              _mixer = BassMix.BASS_Mixer_StreamCreate(wasapiInfo.freq, wasapiInfo.chans, mixerFlags);
              if (_mixer == 0)
              {
                Log.Error("BASS: Unable to create Mixer.  Reason: {0}.",
                          Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
                return false;
              }
            }

            BassWasapi.BASS_WASAPI_SetVolume(BASSWASAPIVolume.BASS_WASAPI_CURVE_DB, (float)Config.StreamVolume / 100f);
            BassWasapi.BASS_WASAPI_Start();
            result = true;
          }
          else
          {
            Log.Error("BASS: Couldn't init WASAPI device. Error: {0}", Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
          }
          break;
      }

      if (result)
      {
        Log.Debug("BASS: Successfully created BASS Mixer stream");
      }
      return result;
    }
Esempio n. 40
0
        /// <summary>
        /// Initializes a device for playback.
        /// </summary>
        /// <param name="device">Device to use for playback</param>
        /// <param name="frequency">Mixer sample rate/frequency</param>
        private void InitializeDevice(Device device, int frequency)
        {
            // Set properties
            this.device = device;

            // Check driver type
            if (device.DriverType == DriverType.DirectSound)
            {
                // Initialize sound system
                Base.Init(device.Id, frequency, BASSInit.BASS_DEVICE_DEFAULT);
            }
#if !IOS && !ANDROID
            else if (device.DriverType == DriverType.ASIO)
            {
                // Initialize sound system
                BaseASIO.Init(device.Id, frequency, BASSInit.BASS_DEVICE_DEFAULT, BASSASIOInit.BASS_ASIO_THREAD);              
            }
            else if (device.DriverType == DriverType.WASAPI)
            {
                // Create callback
                wasapiProc = new WASAPIPROC(WASAPICallback);

                // Initialize sound system
                BaseWASAPI.Init(device.Id, frequency, 2, BASSInit.BASS_DEVICE_DEFAULT, BASSWASAPIInit.BASS_WASAPI_SHARED, 0, 0, wasapiProc);
            }
#endif
        }
        public BASSPlayer()
        {
            _VizAGC = new DSP_VizAGC();
              _ReplayGainDSP = new DSP_Gain();
              _ASIOEngine = new AsioEngine();

              _StreamWriteProcDelegate = new STREAMPROC(StreamWriteProc);
              _VizRawStreamWriteProcDelegate = new STREAMPROC(VizRawStreamWriteProc);
              _DSOutputStreamWriteProcDelegate = new STREAMPROC(DSOutputStreamWriteProc);
              _MetaTagSyncProcDelegate = new SYNCPROC(StreamMetaTagSyncProc);
              _WasapiProcDelegate = new WASAPIPROC(WasApiProc);

              // Make sure threads are stopped in case Dispose does not get called.
              Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

              _WakeupMainThread = new AutoResetEvent(false);
              _WakeupMonitorThread = new AutoResetEvent(false);
              _WakeupBufferUpdateThread = new AutoResetEvent(false);
              _BufferUpdated = new ManualResetEvent(false);

              _MainThread = new Thread(new ThreadStart(ThreadMain));
              _MonitorThread = new Thread(new ThreadStart(ThreadMonitor));
              _BufferUpdateThread = new Thread(new ThreadStart(ThreadBufferUpdate));

              _MainThread.Name = "PureAudio.Main";
              _MainThread.Start();

              _BufferUpdateThread.Name = "PureAudio.BufferUpdate";
              _BufferUpdateThread.IsBackground = true;
              _BufferUpdateThread.Start();

              _MonitorThread.Name = "PureAudio.Monitor";
              _MonitorThread.IsBackground = true;
              _MonitorThread.Start();
        }
Esempio n. 42
0
        /// <summary>
        /// Initializes a specific audio device for playback.
        /// </summary>
        /// <param name="device">Audio device</param>
        /// <param name="mixerSampleRate">Mixer sample rate (in Hz)</param>
        public void InitializeDevice(Device device, int mixerSampleRate)
        {
            _device = device;
            _mixerSampleRate = mixerSampleRate;

            Tracing.Log("Player -- Initializing device (SampleRate: " + mixerSampleRate.ToString() + " Hz, DriverType: " + device.DriverType.ToString() + ", Id: " + device.Id.ToString() + ", Name: " + device.Name + ", BufferSize: " + _bufferSize.ToString() + ", UpdatePeriod: " + _updatePeriod.ToString() + ")");

            // Check driver type
            if (device.DriverType == DriverType.DirectSound)
            {
                // Initialize sound system                
                Base.Init(device.Id, mixerSampleRate, BASSInit.BASS_DEVICE_DEFAULT | BASSInit.BASS_DEVICE_LATENCY);
            }
#if !IOS && !ANDROID
            else if (device.DriverType == DriverType.ASIO)
            {
                // Initialize sound system
                BaseASIO.Init(device.Id, mixerSampleRate, BASSInit.BASS_DEVICE_DEFAULT, BASSASIOInit.BASS_ASIO_THREAD);
            }
            else if (device.DriverType == DriverType.WASAPI)
            {
                // Create callback
                wasapiProc = new WASAPIPROC(WASAPICallback);

                // Initialize sound system                
                //Base.InitWASAPI(device.Id, mixerSampleRate, 2, BASSInit.BASS_DEVICE_DEFAULT, BASSWASAPIInit.BASS_WASAPI_SHARED, 10.0f, 0, wasapiProc);
                BaseWASAPI.Init(device.Id, mixerSampleRate, 2, BASSInit.BASS_DEVICE_DEFAULT, BASSWASAPIInit.BASS_WASAPI_SHARED, 0.5f, 0, wasapiProc);
                //Base.InitWASAPI(device.Id, mixerSampleRate, 2, BASSInit.BASS_DEVICE_DEFAULT, BASSWASAPIInit.BASS_WASAPI_EXCLUSIVE, 1, 0, wasapiProc);

                //BASS_WASAPI_INFO info = BassWasapi.BASS_WASAPI_GetInfo();
            }
#endif

            // Default BASS.NET configuration values for Windows *AND* Linux:
            //
            // BASS_CONFIG_BUFFER: 500
            // BASS_CONFIG_UPDATEPERIOD: 100
            // BASS_CONFIG_UPDATETHREADS: 1
			
			if(OS.Type == OSType.Windows)
			{
	            // Set configuration for buffer and update period
            	// This only works for the default BASS output (http://www.un4seen.com/forum/?topic=13429.msg93740#msg93740)
            	Base.SetConfig(BASSConfig.BASS_CONFIG_BUFFER, _bufferSize); 
            	Base.SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, _updatePeriod);	
			}
            else if (OS.Type == OSType.Linux)
            {				
				// 10ms update period does not work under Linux. Major stuttering
                Base.SetConfig(BASSConfig.BASS_CONFIG_BUFFER, _bufferSize);
                Base.SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 100);

#if ANDROID
                Base.SetConfig(BASSConfig.BASS_CONFIG_DEV_BUFFER, 500); // Default on Android: 30ms
#endif                
            }
            else if (OS.Type == OSType.MacOSX)
            {
                Base.SetConfig(BASSConfig.BASS_CONFIG_BUFFER, _bufferSize);
                Base.SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, _updatePeriod);					
            }		

            _isDeviceInitialized = true;
        }
 public SoundDataProcessor(int deviceIndex)
 {
     BuildLookupTables();
     WASAPIDeviceIndex = deviceIndex;
     WasapiProc = new WASAPIPROC(IgnoreDataProc);
 }
Esempio n. 44
0
 /// <summary>
 /// Initializes the default WASAPI device at 44100 Hz. Requires a data callback.
 /// </summary>
 /// <param name="proc">WASAPI data callback</param>
 public static void Init(WASAPIPROC proc)
 {
     Init(-1, 44100, 2, BASSInit.BASS_DEVICE_DEFAULT, BASSWASAPIInit.BASS_WASAPI_SHARED, 0, 0, proc);
 }