コード例 #1
0
        private static int GetDeviceId(Options.MainConfig config)
        {
            var devices = Bass.BASS_GetDeviceInfos();
            var id      = GetDeviceFromName(devices, config.DeviceSoundEffect);

            if (id >= 0)
            {
                return(id);
            }
            IEnumerable <string> devicesList = devices.Select(d => d.name);

            // TRANSLATORS: Error message. In BassWrapper. {0} is name of sound device. {1} is list of available sound device(s).
            throw new Exception(T._("Sound device \"{0}\" is not found.\nAvailable sound devices:\n{1}", config.DeviceSoundEffect, " * " + string.Join("\n * ", devicesList)));
        }
コード例 #2
0
 public static void Initialize(Options.MainConfig config)
 {
     if (BassWrapper.IsInitialized)
     {
         return;
     }
     BassWrapper.IsInitialized = false;
     // Bass.Net
     // get sound device
     // TRANSLATORS: Log message. In BassWrapper.
     Logger.Log(T._("- get sound device ..."));
     SoundDeviceId = GetDeviceId(config);
     if (SoundDeviceId < 0)
     {
         return;
     }
     // get record device
     // TRANSLATORS: Log message. In BassWrapper.
     Logger.Log(T._("- get record device ..."));
     RecordDeviceId = GetRecordDeviceId(config);
     if (RecordDeviceId < 0)
     {
         return;
     }
     // init sound device
     // TRANSLATORS: Log message. In BassWrapper.
     Logger.Log(T._("- initialize sound device ..."));
     if (!Bass.BASS_Init(SoundDeviceId, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
     {
         // TRANSLATORS: Error message. In BassWrapper. {0} is error code.
         throw new Exception(T._("Failed to init sound device: {0}", Bass.BASS_ErrorGetCode()));
     }
     // init record device
     // TRANSLATORS: Log message. In BassWrapper.
     Logger.Log(T._("- initialize record device ..."));
     if (!Bass.BASS_RecordInit(RecordDeviceId))
     {
         // TRANSLATORS: Error message. In BassWrapper. {0} is error code.
         throw new Exception(T._("Failed to init recording device: {0}", Bass.BASS_ErrorGetCode()));
     }
     BassWrapper.IsInitialized = true;
 }
コード例 #3
0
ファイル: VoiceChat.cs プロジェクト: blackoutazrael/Nursery
 public VoiceChat(Options.MainConfig config)
 {
     this.deviceName   = config.DeviceRead;
     this.recordProc   = new RECORDPROC(recordDevice_audioReceived);
     this.recordHandle = Bass.BASS_RecordStart(SAMPLE_RATE, CHANNEL_COUNT, BASSFlag.BASS_RECORD_PAUSE, this.recordProc, IntPtr.Zero);
 }