Ejemplo n.º 1
0
        private void DefaultASIOAudioOutput_Load(object sender, EventArgs e)
        {
            try
            {
                int n;
                int selecteddeviceprev    = (int)KeppySynthConfiguratorMain.SynthSettings.GetValue("defaultAdev", 0);
                BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO();
                BassAsio.BASS_ASIO_GetDeviceInfo(selecteddeviceprev, info);
                DefOut.Text = String.Format("Def. ASIO output: {0}", info.ToString());
                for (n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++)
                {
                    DevicesList.Items.Add(info.ToString());
                }

                if (n < 1)
                {
                    Functions.ShowErrorDialog(1, System.Media.SystemSounds.Asterisk, "Error", "No ASIO devices installed!\n\nClick OK to close this window.", false, null);
                    Close();
                    return;
                }

                DevicesList.SelectedIndex = selecteddeviceprev;
                MaxThreads.Text           = String.Format("ASIO is allowed to use a maximum of {0} threads.", Environment.ProcessorCount);
                BassAsio.BASS_ASIO_Init(DevicesList.SelectedIndex, 0);

                DeviceTrigger();
                DevicesList.SelectedIndexChanged += new System.EventHandler(this.DevicesList_SelectedIndexChanged);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to load the dialog.\nBASS is probably unable to start, or it's missing.\n\nError:\n" + ex.Message.ToString(), "Oh no! Keppy's Synthesizer encountered an error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                Dispose();
            }
        }
Ejemplo n.º 2
0
        public DefaultASIOAudioOutput()
        {
            InitializeComponent();

            try
            {
                if (GetASIODevicesCount() < 1)
                {
                    Functions.ShowErrorDialog(ErrorType.Error, System.Media.SystemSounds.Asterisk, "Error", "No ASIO devices installed!\n\nClick OK to close this window.", false, null);
                    Close();
                    Dispose();
                }

                BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO();

                // Populate devices list
                for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++)
                {
                    DevicesList.Items.Add(info.ToString());
                }

                // Load previous device from registry
                String PreviousDevice = (String)OmniMIDIConfiguratorMain.SynthSettings.GetValue("ASIOOutput", "None");
                DefOut.Text = String.Format("Def. ASIO output: {0}", PreviousDevice);

                DevicesList.SelectedIndex = 0;
                for (int n = 0; n < DevicesList.Items.Count; n++)
                {
                    if (DevicesList.Items[n].Equals(PreviousDevice))
                    {
                        DevicesList.SelectedIndex = n;
                        break;
                    }
                }

                MaxThreads.Text = String.Format("ASIO is allowed to use a maximum of {0} threads.", Environment.ProcessorCount);

                BassAsio.BASS_ASIO_Init(DevicesList.SelectedIndex, BASSASIOInit.BASS_ASIO_THREAD | BASSASIOInit.BASS_ASIO_JOINORDER);
                GetASIODeviceInfo();

                DeviceTrigger(true);
                DevicesList.SelectedIndexChanged += new EventHandler(DevicesList_SelectedIndexChanged);

                /*
                 * Unavailable at the moment
                 *
                 * if (Convert.ToInt32(OmniMIDIConfiguratorMain.SynthSettings.GetValue("ASIOSeparateThread", 0)) == 1)
                 * ASIOSeparateThread.Checked = true;
                 *
                 */
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to load the dialog.\nBASS is probably unable to start, or it's missing.\n\nError:\n" + ex.Message.ToString(), "Oh no! OmniMIDI encountered an error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                Dispose();
            }
        }
 private void DefaultASIOAudioOutput_Load(object sender, EventArgs e)
 {
     try
     {
         int selecteddeviceprev    = (int)KeppySynthConfiguratorMain.SynthSettings.GetValue("defaultAdev", 0);
         BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO();
         BassAsio.BASS_ASIO_GetDeviceInfo(selecteddeviceprev, info);
         DefOut.Text = String.Format("Def. ASIO output: {0}", info.ToString());
         for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++)
         {
             DevicesList.Items.Add(info.ToString());
         }
         DevicesList.SelectedIndex = selecteddeviceprev;
         MaxThreads.Text           = String.Format("ASIO is allowed to use a maximum of {0} threads.", Environment.ProcessorCount);
         BassAsio.BASS_ASIO_Init(DevicesList.SelectedIndex, 0);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to load the dialog.\nBASS is probably unable to start, or it's missing.\n\nError:\n" + ex.Message.ToString(), "Oh no! Keppy's Synthesizer encountered an error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Close();
         Dispose();
     }
 }
Ejemplo n.º 4
0
        /// <summary>Initialize the base ASIO streams, and actually start ASIO running.</summary>
        /// <remarks>[MainThread]</remarks>
        internal void StartASIO()
        {
            // not playing anything via BASS, so don't need an update thread
            CheckError(Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0));

            // setup BASS - "no sound" device but SampleFrequencyHz (default for ASIO)
            CheckError(Bass.BASS_Init(0, Clock.TimepointRateHz, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero));
            CheckError(BassAsio.BASS_ASIO_Init(AsioDeviceId, BASSASIOInit.BASS_ASIO_THREAD));

            CheckError(BassFx.LoadMe());

            if (UseVst) {
                CheckError(BassVst.LoadMe());

                // testing scaffolding; retain for reference
                TempFrobBassVst();
            }

            // register all effects once VST is set up
            EffectRegistrar.RegisterAll();

            ////////////////////// DEVICE SETUP

            CheckError(BassAsio.BASS_ASIO_SetDevice(AsioDeviceId));

            BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO();
            System.Text.StringBuilder b = new System.Text.StringBuilder();
            for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++) {
                b.AppendLine("device #" + n + ": " + info.ToString());
            }
            b.AppendLine("done");
            string all = b.ToString();
            b.Clear();

            for (int chan = 0; chan < 16; chan++) {
                BASS_ASIO_CHANNELINFO cinfo = BassAsio.BASS_ASIO_ChannelGetInfo(true, chan);
                if (cinfo != null) {
                    b.AppendLine(cinfo.ToString());
                }
                cinfo = BassAsio.BASS_ASIO_ChannelGetInfo(false, chan);
                if (cinfo != null) {
                    b.AppendLine(cinfo.ToString());
                }
            }
            all = b.ToString();

            CheckError(BassAsio.BASS_ASIO_SetRate(Clock.TimepointRateHz));

            BASS_ASIO_INFO asioInfo = BassAsio.BASS_ASIO_GetInfo();
            int inputLatency = BassAsio.BASS_ASIO_GetLatency(IsInputChannel);
            int outputLatency = BassAsio.BASS_ASIO_GetLatency(IsOutputChannel);

            m_asioBufferPreferredSize = 128; // B4CKIN: asioInfo.bufpref;

            ////////////////////// OUTPUT SETUP

            // converted away from BassAsioHandler, to enable better viewing of intermediate data
            // (and full control over API use, allocation, etc.)

            m_mixerHStream = (StreamHandle)BassMix.BASS_Mixer_StreamCreate(
                Clock.TimepointRateHz,
                StereoChannels,
                BASSFlag.BASS_MIXER_RESUME | BASSFlag.BASS_MIXER_NONSTOP | BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);

            BASS_CHANNELINFO mixerInfo = new BASS_CHANNELINFO();
            CheckError(Bass.BASS_ChannelGetInfo((int)m_mixerHStream, mixerInfo));

            // connect to ASIO output channel
            CheckError(BassAsio.BASS_ASIO_ChannelEnable(IsOutputChannel, AsioOutputChannelId, m_mixerToOutputAsioProc, new IntPtr((int)m_mixerHStream)));

            // Join second mixer channel (right stereo channel).
            CheckError(BassAsio.BASS_ASIO_ChannelJoin(IsOutputChannel, 1, AsioOutputChannelId));

            CheckError(BassAsio.BASS_ASIO_ChannelSetFormat(IsOutputChannel, AsioOutputChannelId, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT));
            CheckError(BassAsio.BASS_ASIO_ChannelSetRate(IsOutputChannel, AsioOutputChannelId, Clock.TimepointRateHz));

            ////////////////////// INPUT SETUP

            CheckError(BassAsio.BASS_ASIO_SetDevice(HolofunkBassAsio.AsioDeviceId));

            m_input0 = new HolofunkBassAsioInput(this, 0, m_bass.AudioAllocator);
            m_input1 = new HolofunkBassAsioInput(this, 1, m_bass.AudioAllocator);

            ////////////////////// ASIO LAUNCH

            CheckError(BassAsio.BASS_ASIO_Start(m_asioBufferPreferredSize));

            // get the info again, see if latency has changed
            asioInfo = BassAsio.BASS_ASIO_GetInfo();
            inputLatency = BassAsio.BASS_ASIO_GetLatency(IsInputChannel);
            outputLatency = BassAsio.BASS_ASIO_GetLatency(IsOutputChannel);
        }