Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            cmbDevice.Items.AddRange(AsioOut.GetDriverNames());

            signalNetworkForm = new SignalNetworkForm();
            signalNetworkForm.Show();
        }
Esempio n. 2
0
        static Audio()
        {
            var asioDrivers = AsioOut.GetDriverNames();

            if (asioDrivers.Length == 0)
            {
                Console.WriteLine("please install http://www.asio4all.org/");
                Console.WriteLine("press any key to exit");
                Console.ReadKey();
                Environment.Exit(0);
            }
            asioOut = new AsioOut(asioDrivers[0]);
            mixer   = new MixingWaveProvider32();
            hit     = new WaveChannel32(new AudioFileReader("hitsound.wav"))
            {
                Volume = 0.2f,
            };
            miss = new WaveChannel32(new AudioFileReader("miss.wav"))
            {
                Volume = 0.2f,
            };
            var err = new SignalGenerator()
            {
                Type = SignalGeneratorType.SawTooth,
                Gain = 0.2,
            }.Take(TimeSpan.FromSeconds(0.1d)).ToWaveProvider();

            mixer.AddInputStream(hit);
            mixer.AddInputStream(miss);
            asioOut.Init(mixer);
            asioOut.Play();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please select an ASIO driver to use: ");

            int asioDriverCount = AsioOut.GetDriverNames().Length;

            for (int i = 0; i < asioDriverCount; i++)
            {
                Console.WriteLine(i + ": " + AsioOut.GetDriverNames()[i]);
            }

            string input     = Console.ReadLine();
            int    selection = Int32.Parse(input);

            SineWaveTable.Instance.GenerateWaveTable();
            SawWaveTable.Instance.GenerateWaveTable();

            MIDIHandler io = new MIDIHandler(selection);

            Console.WriteLine("To stop audio playback, type \'stop\'");
            input = Console.ReadLine();
            while (input != "stop")
            {
                Console.WriteLine(String.Format("\'{0}\' is not a recognised command.", input));
                input = Console.ReadLine();
            }

            Console.WriteLine("Exiting program...");
            io.Dispose();
        }
Esempio n. 4
0
        protected override IWavePlayer GetWavePlayer()
        {
            string driverName;

            string[] driverNames = AsioOut.GetDriverNames();

            if (driverNames.Length == 0)
            {
                throw new InvalidOperationException("No ASIO driver found.");
            }
            else if (driverNames.Length == 1)
            {
                driverName = driverNames[0];
            }
            else
            {
                driverName = _driverSelector(driverNames);
            }

            if (string.IsNullOrWhiteSpace(driverName))
            {
                throw new InvalidOperationException("A driverName was not selected.");
            }

            return(new AsioOut(driverName));
        }
Esempio n. 5
0
        public AudioPlaybackForm()
        {
            InitializeComponent();

            // Disable ASIO if no drivers are available
            if (!AsioOut.isSupported())
            {
                radioButtonAsio.Enabled    = false;
                buttonControlPanel.Enabled = false;
                comboBoxAsioDriver.Enabled = false;
            }
            else
            {
                // Just fill the comboBox AsioDriver with available driver names
                String[] asioDriverNames = AsioOut.GetDriverNames();
                foreach (string driverName in asioDriverNames)
                {
                    comboBoxAsioDriver.Items.Add(driverName);
                }
                comboBoxAsioDriver.SelectedIndex = 0;
            }

            if (Environment.OSVersion.Version.Major < 6)
            {
                // WASAPI supported only on Windows Vista and above
                radioButtonWasapi.Enabled           = false;
                checkBoxWasapiEventCallback.Enabled = false;
                checkBoxWasapiExclusiveMode.Enabled = false;
            }
        }
Esempio n. 6
0
        protected override IReadOnlyDictionary <string, object> GetEntries()
        {
            Dictionary <string, object> devices = new Dictionary <string, object>();

            for (int i = 0; i < WaveOut.DeviceCount; i++)
            {
                var caps = WaveOut.GetCapabilities(i);
                var name = caps.ProductName;
                devices[$"WaveOut: {name}"] = new WaveOutFactory(i);
            }

            foreach (var device in DirectSoundOut.Devices)
            {
                var name = device.Description;
                devices[$"DS: {name}"] = new DirectSoundOutFactory(device.Guid);
            }

            var enumerator = new MMDeviceEnumerator();

            foreach (var wasapi in enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active))
            {
                var name = wasapi.FriendlyName;
                devices[$"Wasapi: {name}"] = new WasapiOutFactory(wasapi.ID);
            }

            foreach (var asio in AsioOut.GetDriverNames())
            {
                devices[$"ASIO: {asio}"] = new AsioOutFactory(asio);
            }

            return(devices);
        }
Esempio n. 7
0
        internal static void updateAudioDevices()
        {
            var deviceEnum = new MMDeviceEnumerator();

            String[] devices = AsioOut.GetDriverNames();
            deviceMap.Add(new Device(new AsioOut("UMC ASIO Driver")));
            int deviceCount = devices.Count();

            deviceCount = 0;
            // try adding all devices to a device list to be displayed as a selection of drivers
            for (byte i = 0; i < deviceCount; i++)
            {
                try
                {
                    deviceMap.Add(new Device(new AsioOut(devices[i])));
                }
                catch (InvalidOperationException e)
                {
                    Console.WriteLine(i + ": " + devices[i] + " failed with error:");
                    Console.WriteLine(e);
                }
            }
            configureInputForm.clearItems();
            configureInputForm.addItems(deviceMap);
        }
Esempio n. 8
0
        public static void ShowControlPanel(string asioDriverName)
        {
            if (asioOut != null)
            {
                asioOut.Dispose();
            }

            int i = 0;

            foreach (string s in AsioOut.GetDriverNames())
            {
                if (asioDriverName == s)
                {
                    break;
                }
                i++;
            }
            int retry = 3;

            do
            {
                try
                {
                    asioOut = new AsioOut(i);
                }
                catch
                {
                    asioOut = null;
                    Thread.Sleep(1000);
                    retry--;
                }
            } while (asioOut == null && retry > 0);

            asioOut.ShowControlPanel();
        }
Esempio n. 9
0
    private void frmConfig_Load(object sender, EventArgs e)
    {
        List <float> flist = new List <float>();

        flist.Add(0);
        flist.Add(2);
        flist.Add(4);
        flist.Add(6);
        flist.Add(8);
        flist.Add(10);
        DiscDraw.Draw(pictureBox1, flist);
        DiscDraw.Draw(pictureBox2, flist);

        _config = Config.ReadXML(configFilename);

        lstMIDIEvent.Items.Clear();
        //ASIOドライバー一覧取得
        foreach (string device in AsioOut.GetDriverNames())
        {
            cboAsioDriver.Items.Add(device);
        }
        if (cboAsioDriver.Items.Count > 0)
        {
            cboAsioDriver.SelectedIndex = 0;
        }
        //MIDI入力デバイス一覧取得
        for (int device = 0; device < MidiIn.NumberOfDevices; device++)
        {
            cboMIDIINDEVICE.Items.Add(MidiIn.DeviceInfo(device).ProductName);
        }
        if (cboMIDIINDEVICE.Items.Count > 0)
        {
            cboMIDIINDEVICE.SelectedIndex = 0;
        }
    }
 public MainWindow()
 {
     String[] drivernames = AsioOut.GetDriverNames();
     ASIODriver = new AsioOut(drivernames[0]);
     buffer     = new BufferedWaveProvider(new WaveFormat());
     ASIODriver.AudioAvailable += new EventHandler <AsioAudioAvailableEventArgs>(ASIODriver_AudioAvailable);
     ASIODriver.InitRecordAndPlayback(buffer, 2, 44100);
     ASIODriver.Play();
 }
Esempio n. 11
0
 void fillDeviceList()
 {
     string[] drvn = AsioOut.GetDriverNames();
     driverNames = new List <string>();
     driverNames.Add("None");
     for (int i = 0; i < drvn.Length; i++)
     {
         driverNames.Add(drvn[i]);
     }
 }
Esempio n. 12
0
 private void InitialiseAsioControls()
 {
     // Just fill the comboBox AsioDriver with available driver names
     var asioDriverNames = AsioOut.GetDriverNames();
     foreach (string driverName in asioDriverNames)
     {
         comboBoxAsioDriver.Items.Add(driverName);
     }
     //comboBoxAsioDriver.SelectedIndex = 0;
 }
Esempio n. 13
0
        public void Setup()
        {
            var drives = AsioOut.GetDriverNames();

            asioOut = new AsioOut("ASIO4ALL v2");

            //asioOut.InputChannelOffset = inputNumber;
            asioOut.InitRecordAndPlayback(null, 1, sampleRate);
            asioOut.AudioAvailable += OnAsioAudioAvailable;
        }
Esempio n. 14
0
 private static List <string> GetAsioDriverNames()
 {
     if (IsAsioSupported())
     {
         return(AsioOut.GetDriverNames().ToList());
     }
     else
     {
         return(new List <string>());
     }
 }
Esempio n. 15
0
        private static AsioOut PrepareAsioOut()
        {
            var names = AsioOut.GetDriverNames();

            var asioDriverName = names[0];
            var asioOut        = new AsioOut(asioDriverName);

            //var inputChannels = asioOut.DriverInputChannelCount;
            asioOut.InputChannelOffset = 0;
            asioOut.InitRecordAndPlayback(null, 1, SampleRate);
            return(asioOut);
        }
Esempio n. 16
0
        private void StartMonitoringMidi()
        {
            string[] drivers = AsioOut.GetDriverNames();

            try
            {
                MidiIn midi = new MidiIn(0);
                midi.MessageReceived += Midi_MessageReceived;
                midi.Start();
            }
            catch { }
        }
Esempio n. 17
0
 public AsioDirectPanel()
 {
     InitializeComponent();
     Disposed += OnAsioDirectPanelDisposed;
     foreach (var device in AsioOut.GetDriverNames())
     {
         comboBoxAsioDevice.Items.Add(device);
     }
     if (comboBoxAsioDevice.Items.Count > 0)
     {
         comboBoxAsioDevice.SelectedIndex = 0;
     }
 }
Esempio n. 18
0
 public AsioRecordingPanel()
 {
     InitializeComponent();
     this.Disposed += new EventHandler(AsioDirectPanel_Disposed);
     foreach (var device in AsioOut.GetDriverNames())
     {
         this.comboBoxAsioDevice.Items.Add(device);
     }
     if (this.comboBoxAsioDevice.Items.Count > 0)
     {
         this.comboBoxAsioDevice.SelectedIndex = 0;
     }
 }
Esempio n. 19
0
        private static IEnumerable <IWaveInDevice> InitWaveInDevices()
        {
            var waveDevices = Enumerable
                              .Range(0, WaveIn.DeviceCount)
                              .Select(i => new WindowsWaveInDevice(i))
                              .Cast <IWaveInDevice>();

            var asioDevices = AsioOut.isSupported()
                ? AsioOut.GetDriverNames()
                              .Select(d => new AsioWaveInDevice(d))
                : Enumerable.Empty <IWaveInDevice>();

            return(new ReadOnlyCollection <IWaveInDevice>(waveDevices.Concat(asioDevices).ToList()));
        }
Esempio n. 20
0
        public NAudioAsioOutNode()
        {
            var drivers = AsioOut.GetDriverNames();

            if (drivers.Length > 0)
            {
                EnumManager.UpdateEnum("NAudioASIO", drivers[0], drivers);
            }
            else
            {
                drivers = new string[] { "No ASIO!? -> go download ASIO4All" };
                EnumManager.UpdateEnum("NAudioASIO", drivers[0], drivers);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// WasapiOutから再生デバイスを列挙する
        /// </summary>
        /// <returns>再生デバイスのリスト</returns>
        public static List <PlayDevice> EnumlateDevicesByAsioOut()
        {
            var list = new List <PlayDevice>();

            foreach (var name in AsioOut.GetDriverNames())
            {
                list.Add(new PlayDevice()
                {
                    ID   = name,
                    Name = name,
                });
            }

            return(list);
        }
Esempio n. 22
0
        private void UpdateAudioDeviceList()
        {
            //Clear lists
            this.AudioDevices.Clear();
            this.GUI.AudioDeviceNameList.Clear();

            //WaveIn
            for (int n = -1; n < WaveIn.DeviceCount; n++)
            {
                var device = new WaveIn();
                device.DeviceNumber = n;
                this.AudioDevices.Add(device);
                var caps = WaveIn.GetCapabilities(n);
                this.GUI.AudioDeviceNameList.Add($"WaveIn - {caps.ProductName}");
            }

            //WASAPI
            var audioEndPoints = (new MMDeviceEnumerator()).EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active);

            foreach (var wasapi in audioEndPoints)
            {
                if ((wasapi.DataFlow & DataFlow.Capture) != 0)
                {
                    this.AudioDevices.Add(new WasapiCapture(wasapi));
                }
                else
                {
                    this.AudioDevices.Add(new WasapiLoopbackCapture(wasapi));
                }
                this.GUI.AudioDeviceNameList.Add($"WASAPI - {wasapi.FriendlyName}");
            }

            //ASIO
            foreach (var asio in AsioOut.GetDriverNames())
            {
                this.AudioDevices.Add(asio);
                this.GUI.AudioDeviceNameList.Add("ASIO - " + asio);
            }

            //Set GUI in combobox to first entry (if available)
            try
            {
                this.GUI.AudioDeviceName.SelectedIndex = 0;
            }
            catch
            {
            }
        }
Esempio n. 23
0
        protected override IReadOnlyDictionary<string, object> GetEntries()
        {
            Dictionary<string, object> driverNames = new Dictionary<string, object>();

            foreach (var driverName in AsioOut.GetDriverNames())
            {
                //the return dictionary holds the names of the entries as key with an optional "tag"
                //here the tag is null but you can provide any object that you want to associate with the entry
                driverNames[driverName] = null;
            }

            if (driverNames.None())
                driverNames["No ASIO!? -> get yours from http://www.asio4all.org/"] = null; 

            return driverNames;
        }
Esempio n. 24
0
        public AudioPlaybackEngine(int driverSelection, int sampleRate = 44100, int channelCount = 2)
        {
            this.sampleRate = sampleRate;
            midiTools       = new MIDITools();

            outputDevice    = new AsioOut(AsioOut.GetDriverNames()[driverSelection]);
            mixer           = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channelCount));
            mixer.ReadFully = true;
            saver           = new SavingSampleProvider(mixer, "test.wav");


            InitialiseActiveNotes(128);

            outputDevice.Init(saver);
            outputDevice.Play();
        }
 public MainWindow()
 {
     InitializeComponent();
     foreach (var device in AsioOut.GetDriverNames())
     {
         comboAsioDevices.Items.Add(device);
     }
     if (comboAsioDevices.Items.Count > 0)
     {
         comboAsioDevices.SelectedIndex = 0;
     }
     Closing += (sender, args) => Stop();
     sliderVolume1.ValueChanged += (sender, args) => SetSliders();
     sliderVolume2.ValueChanged += (sender, args) => SetSliders();
     sliderPan1.ValueChanged    += (sender, args) => SetSliders();
     sliderPan2.ValueChanged    += (sender, args) => SetSliders();
 }
Esempio n. 26
0
 public static string[] driverNames()
 {
     // Prefer ASIO drivers for output (low-latency), fallback to DirectSound if not present
     if (AsioOut.isSupported())
     {
         return(AsioOut.GetDriverNames());
     }
     else
     {
         var      devs    = DirectSoundOut.Devices;
         string[] _result = new string[devs.Count()];
         for (var x = 0; x < devs.Count(); x++)
         {
             _result[x] = devs.ElementAt(x).ModuleName;
         }
         return(_result);
     }
 }
Esempio n. 27
0
        private void InitAudio()
        {
            if (FAudioOutputs != null)
            {
                foreach (var _ao in FAudioOutputs)
                {
                    _ao.Dispose();
                }
            }

            List <AudioOutput> aos = new List <AudioOutput>();

            FDefaultAudioOutput = null;
            using (var e = new MMDeviceEnumerator())
            {
                string defaultId = e.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia).ID;

                foreach (MMDevice d in e.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active))
                {
                    var ao = new AudioOutput(d);
                    if (d.ID == defaultId)
                    {
                        FDefaultAudioOutput = ao;
                    }
                    aos.Add(ao);
                }
            }

            if (AsioOut.isSupported())
            {
                foreach (var n in AsioOut.GetDriverNames())
                {
                    aos.Add(new AudioOutput(n));
                }
            }

            FAudioOutputs = aos.ToArray();
            if (FDefaultAudioOutput == null)
            {
                FDefaultAudioOutput = FAudioOutputs.First();
            }
        }
Esempio n. 28
0
        public AudioEngineNode()
        {
            FEngine = AudioService.Engine;

            var drivers = AsioOut.GetDriverNames();

            if (drivers.Length > 0)
            {
                EnumManager.UpdateEnum("NAudioASIO", drivers[0], drivers);
            }
            else
            {
                drivers = new string[] { "No ASIO!? -> go download ASIO4All" };
                EnumManager.UpdateEnum("NAudioASIO", drivers[0], drivers);
            }

            //also add a default entry to the sampling rate enum
            var samplingRates = new string[] { "44100" };

            EnumManager.UpdateEnum("ASIODriverSampleRates", samplingRates[0], samplingRates);
        }
Esempio n. 29
0
        public AudioPlaybackForm()
        {
            InitializeComponent();

            // Disable ASIO if no drivers are available
            if (!AsioOut.isSupported())
            {
                radioButtonAsio.Enabled    = false;
                buttonControlPanel.Enabled = false;
                comboBoxAsioDriver.Enabled = false;
            }
            else
            {
                // Just fill the comboBox AsioDriver with available driver names
                String[] asioDriverNames = AsioOut.GetDriverNames();
                foreach (string driverName in asioDriverNames)
                {
                    comboBoxAsioDriver.Items.Add(driverName);
                }
                comboBoxAsioDriver.SelectedIndex = 0;
            }
        }
Esempio n. 30
0
        public IActionResult ListDevices()
        {
            for (int n = -1; n < WaveOut.DeviceCount; n++)
            {
                var caps = WaveOut.GetCapabilities(n);
                log.LogInformation($"WaveOut: {n}: {caps.ProductName}");
            }
            foreach (var dev in DirectSoundOut.Devices)
            {
                log.LogInformation($"DirectSoundOut: {dev.Guid}; {dev.ModuleName}; {dev.Description}");
            }
            var enumerator = new MMDeviceEnumerator();

            foreach (var wasapi in enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active))
            {
                log.LogInformation($"wasapi: {wasapi.DataFlow}; {wasapi.FriendlyName}; {wasapi.DeviceFriendlyName}; {wasapi.State}");
            }
            foreach (var asio in AsioOut.GetDriverNames())
            {
                log.LogInformation($"AsioOut: {asio}");
            }
            return(new EmptyResult());
        }