コード例 #1
0
        void UpdateSettings()
        {
            if (string.IsNullOrEmpty(_camID))
            {
                _camID = AudioDeviceManager.ALTNAMEFORNULL;
            }

            MixCastData.CameraCalibrationData curCam = MixCast.Settings.GetCameraByID(_camID);
            if (curCam == null || curCam.audioData == null)
            {
                return; // shouldn't happen, but just in case.
            }
            var device = AudioDeviceManager.GetAudioDeviceByAltName(curCam.audioData.audioAltName);

            if (device != null)
            {
                _adeviceAltName       = device.audioDeviceAltName;
                _adeviceBitsPerSample = (int)device.bitsPerSample;
                _adeviceChannels      = (int)device.channel;
                _adeviceConfiguration = device.defaultSettings.audioConfig;
                _adeviceSamplingRate  = (int)device.samplingRate;
                _adeviceDelayMs       = (int)device.desktopDelayMs;
                // deviceName            = device.audioDeviceName; // commenting out so no import warning in SDK
            }
        }
コード例 #2
0
        //private bool waitPreselectDesktopCnt = false;

        // Use this for initialization
        protected override void OnEnable()
        {
            base.OnEnable();

            if (context != null && context.Data != null && context.Data.audioData != null)
            {
                if (AudioAsyncFeed.Instance(context.Data.id).audAsyncDec == IntPtr.Zero)
                {
                    audioConfig = context.Data.audioData.audioConfig;
                }
            }
        }
コード例 #3
0
        public void SetAudioConfiguration(MixCastAV.AUDIOCONFIG cfgType)
        {
            if (audAsyncDec != IntPtr.Zero)
            {
                //useful for debugging
                //if (cfgType == MixCastAV.AUDIOCONFIG.MICROPHONE_AND_DESKTOP)
                //	Debug.Log("The audio mode is set to : MICROPHONE_AND_DESKTOP");
                //if (cfgType == MixCastAV.AUDIOCONFIG.DESKTOP_ONLY)
                //	Debug.Log("The audio mode is set to : DESKTOP_ONLY");
                //if (cfgType == MixCastAV.AUDIOCONFIG.MICROPHONE_ONLY)
                //	Debug.Log("The audio mode is set to : MICROPHONE_ONLY");
                //if (cfgType == MixCastAV.AUDIOCONFIG.NO_AUDIO)
                //	Debug.Log("The audio mode is set to : NO_AUDIO");

                MixCastAV.setCfgAudioDecodeAsync(audAsyncDec, cfgType);
                _adeviceConfiguration = cfgType;                 // save the configuration change
            }
            //Debug.LogWarning( "Setting audio config to " + cfgType.ToString() );
        }
コード例 #4
0
        //multi tool function
        public RETURNCHANGETYPE SetPlay(string altName, int numChannels, int samplingRate, int bitsPerSample,
                                        MixCastAV.AUDIOCONFIG audioConfig, float micVolume, float desktopVolume, int delayMs)
        {
            if (_suppressingPlayback)
            {
                return(RETURNCHANGETYPE.NothingNewDoNothing);
            }
            //Debug.Log( "SetPlay()" );
            if (delayMs > 1000)
            {
                Debug.LogWarning("Delay is too high for the audio, " + delayMs + "ms, setting it to 1000ms.");
                delayMs = 1000;
            }

            //create the audio asynchronous interface
            string DeviceNameSwitch    = altName;
            int    nChannelsSwitch     = numChannels;
            int    samplingRateSwitch  = samplingRate;
            int    bitsPerSampleSwitch = bitsPerSample;

            MixCastAV.AUDIOCONFIG configSwitch = audioConfig;

            //when the string is null, we want to use some defaults for a null audio track still
            if (string.IsNullOrEmpty(altName) == true || altName.Contains(AudioDeviceManager.ALTNAMEFORNULL))
            {
                //dummy info for null track when no data found
                DeviceNameSwitch    = AudioDeviceManager.ALTNAMEFORNULL;
                nChannelsSwitch     = MixCastAV.DEFAUDIO_CHANNELS;
                samplingRateSwitch  = MixCastAV.DEFAUDIO_SAMPLING;
                bitsPerSampleSwitch = MixCastAV.DEFAUDIO_BITDEPTH;
            }


            //if it is exactly the same as last configuration
            if (audAsyncDec != IntPtr.Zero)
            {
                if (_adeviceAltName == altName &&
                    _adeviceBitsPerSample == bitsPerSample &&
                    _adeviceChannels == numChannels &&
                    _adeviceSamplingRate == samplingRate &&
                    _adeviceDelayMs == delayMs)
                {
                    if (_adeviceConfiguration == audioConfig)
                    {
                        //Debug.LogWarning( "No audio change for " + altName );
                        return(RETURNCHANGETYPE.NothingNewDoNothing); //nothing to do since it is the same as last time
                    }
                    else
                    {
                        // only audioConfig changed
                        SetAudioConfiguration(audioConfig);
                        //Debug.LogWarning( "Audio Config: " + audioConfig.ToString() );
                        return(RETURNCHANGETYPE.ConfigurationChangeOnly);
                    }
                }
                else
                {
                    Stop();
                }
            }

            //Debug.LogError("devicename: " + deviceName + ", nCh: " + numChannels + ", sampling: " + samplingRate + ", bitsPer: " + bitsPerSample + ", cfg: " + audioConfig);
            audAsyncDec = MixCastAV.createAudioDecodeAsync(DeviceNameSwitch, nChannelsSwitch,
                                                           samplingRateSwitch, bitsPerSampleSwitch, delayMs, MixCastAV.AUDIOCONFIG.MICROPHONE_AND_DESKTOP, MixCastAV.chunksPerSec);

            //Debug.Log("delay is set to : " + delayMs);

            if (audAsyncDec == IntPtr.Zero)
            {
                //Debug.LogError("Error creating Audio Device Async Interface." + audAsyncDec);
                Debug.LogWarning("Error creating decoder");
                return(RETURNCHANGETYPE.ErrorCreating);
            }
            else             //audAsyncDec is already ready
            {
                //successfully created, so save the variables
                _adeviceAltName       = DeviceNameSwitch;
                _adeviceChannels      = nChannelsSwitch;
                _adeviceSamplingRate  = samplingRateSwitch;
                _adeviceBitsPerSample = bitsPerSampleSwitch;
                _adeviceConfiguration = configSwitch;
                _adeviceDelayMs       = delayMs;

                MixCastAV.setMicVolume(audAsyncDec, micVolume);
                MixCastAV.setDesktopVolume(audAsyncDec, desktopVolume);
                Play();
                SetAudioConfiguration(audioConfig);
                //set intended configuration
                //if (LibAvStuff.checkStartedAudioDecodeAsync(audAsyncDec) == 0)

                // deviceName = _adeviceAltName; // commenting out so no import warning in SDK

                return(RETURNCHANGETYPE.MadeNewDevice);
            }
        }