Пример #1
0
        /// <inheritdoc/>
        public void Play(AudioSampleType type, AudioPriorityBracket priority)
        {
            // Play audio if it is in the correct priority bracket...
            if (priority == AudioPriorityBracket.Pack && !mAudioPlayer.IsPlaying)
            {
                var audioFile = GetAudioSampleFile(type);
                if (audioFile != null)
                {
                    // Play the pack manager audio
                    mAudioPlayer.Play(audioFile.URI);
                }
            }
            // Force.
            else if (priority == AudioPriorityBracket.PackForce)
            {
                // Stop all playing the current audio first...
                foreach (KeyValuePair <AudioSampleType, AudioSample> audio in mAudioSamples)
                {
                    audio.Value.Stop();
                }

                var audioFile = GetAudioSampleFile(type);
                if (audioFile != null)
                {
                    // Play the pack manager priority audio
                    mAudioPlayer.Play(audioFile.URI);
                }
            }
            // Otherwise play lower bracket audio, if the pack manager is not playing atm...
            else if (!mAudioPlayer.IsPlaying)
            {
                // Play on sample bracket
                GetAudioSample(type)?.Play();
            }
        }
Пример #2
0
 public AviSynthClip(IntPtr avs)
 {
     _vi = new AVSDLLVideoInfo();
     this._avs = avs;
     _colorSpace = AviSynthColorspace.RGB32;
     _sampleType = AudioSampleType.INT8;
 }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the AsyncAudioCapture class with the specified sample rate, channel and sampleType.
        /// </summary>
        /// <param name="sampleRate">The audio sample rate (8000 ~ 192000Hz).</param>
        /// <param name="channel">The audio channel type.</param>
        /// <param name="sampleType">The audio sample type.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <paramref name="sampleRate"/> is less than <see cref="AudioCaptureBase.MinSampleRate"/>.<br/>
        ///     -or-<br/>
        ///     <paramref name="sampleRate"/> is greater than <see cref="AudioCaptureBase.MaxSampleRate"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="channel"/> is invalid.<br/>
        ///     -or-<br/>
        ///     <paramref name="sampleType"/> is invalid.
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">The required privilege is not specified.</exception>
        /// <exception cref="NotSupportedException">The system does not support microphone.</exception>
        /// <since_tizen> 3 </since_tizen>
        public AsyncAudioCapture(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
            : base(sampleRate, channel, sampleType)
        {
            _streamCallback = (IntPtr handle, uint length, IntPtr _) => { OnInputDataAvailable(handle, length); };

            AudioInput.SetStreamCallback(_handle, _streamCallback, IntPtr.Zero)
            .ThrowIfFailed("Failed to create instance.");
        }
 internal AudioStreamStoringEventArgs(IMediaBuffer stream, AudioSampleType type, int channel,
                                      uint recordingTime)
 {
     Stream    = stream;
     Type      = type;
     Channels  = channel;
     Timestamp = recordingTime;
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the AsyncAudioCapture class with the specified sample rate, channel and sampleType.
        /// </summary>
        /// <param name="sampleRate">The audio sample rate (8000 ~ 48000Hz).</param>
        /// <param name="channel">The audio channel type.</param>
        /// <param name="sampleType">The audio sample type.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <paramref name="sampleRate"/> is less than <see cref="AudioCaptureBase.MinSampleRate"/>.<br/>
        ///     -or-<br/>
        ///     <paramref name="sampleRate"/> is greater than <see cref="AudioCaptureBase.MaxSampleRate"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="channel"/> is invalid.<br/>
        ///     -or-<br/>
        ///     <paramref name="sampleType"/> is invalid.
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">The required privilege is not specified.</exception>
        /// <exception cref="NotSupportedException">The system does not support microphone.</exception>
        /// <since_tizen> 3 </since_tizen>
        public AsyncAudioCapture(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
            : base(sampleRate, channel, sampleType)
        {
            _streamCallback = (IntPtr handle, uint length, IntPtr _) => { OnInputDataAvailable(handle, length); };

            AudioIOUtil.ThrowIfError(
                AudioInput.SetStreamCallback(_handle, _streamCallback, IntPtr.Zero),
                $"Failed to initialize a { nameof(AsyncAudioCapture) }");
        }
Пример #6
0
        public AviSynthClip(string func, string arg, bool bRequireRGB24, bool bRunInThread)
        {
            _vi         = new AVSDLLVideoInfo();
            _avs        = IntPtr.Zero;
            _colorSpace = AviSynthColorspace.Unknown;
            _sampleType = AudioSampleType.Unknown;
            bool   bOpenSuccess    = false;
            string strErrorMessage = string.Empty;

            lock (_locker)
            {
                Random rnd = new Random();
                _random = rnd.Next(1, 1000000);

                if (MainForm.Instance.Settings.ShowDebugInformation)
                {
                    HandleAviSynthWrapperDLL(false, arg);
                }

                System.Windows.Forms.Application.UseWaitCursor = true;
                if (bRunInThread)
                {
                    Thread t = new Thread(new ThreadStart(delegate
                    {
                        bOpenSuccess = OpenAVSScript(func, arg, bRequireRGB24, out strErrorMessage);
                    }));
                    t.Start();
                    while (t.ThreadState == ThreadState.Running)
                    {
                        MeGUI.core.util.Util.Wait(1000);
                    }
                }
                else
                {
                    bOpenSuccess = OpenAVSScript(func, arg, bRequireRGB24, out strErrorMessage);
                }
                System.Windows.Forms.Application.UseWaitCursor = false;
            }

            if (bOpenSuccess == false)
            {
                string err = string.Empty;
                if (_avs != IntPtr.Zero)
                {
                    err = getLastError();
                }
                else
                {
                    err = strErrorMessage;
                }
                Dispose(false);
                throw new AviSynthException(err);
            }
        }
Пример #7
0
        /// <summary>
        /// Get <see cref="AudioSample"/> from <see cref="mAudioSamples"/> by <see cref="AudioSampleType"/>
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>Audio sample or null</returns>
        protected AudioSample GetAudioSample(AudioSampleType type)
        {
            if (mAudioSamples.ContainsKey(type))
            {
                return(mAudioSamples[type]);
            }

            // Log it.
            IoC.Logger.Log($"Audio sample '{type}' does not exist!", LogLevel.Error);
            return(null);
        }
Пример #8
0
 public AviSynthClip(string func, string arg, AviSynthColorspace colorSpace)
 {
     _vi         = new AVSDLLVideoInfo();
     _avs        = new IntPtr(0);
     _colorSpace = AviSynthColorspace.Unknown;
     _sampleType = AudioSampleType.Unknown;
     if (0 != dimzon_avs_init(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, colorSpace.ToString()))
     {
         var err = GetLastError();
         throw new ApplicationException(err);
     }
 }
Пример #9
0
 public AviSynthClip(string func, string arg, AviSynthColorspace forceColorspace, AviSynthScriptEnvironment env)
 {
     _vi         = new AVSDLLVideoInfo();
     _avs        = new IntPtr(0);
     _colorSpace = AviSynthColorspace.Unknown;
     _sampleType = AudioSampleType.Unknown;
     if (0 != dimzon_avs_init(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
     {
         string err = getLastError();
         cleanup(false);
         throw new AviSynthException(err);
     }
 }
Пример #10
0
 public AviSynthClip(string func, string arg , AviSynthColorspace forceColorspace, AviSynthScriptEnvironment env)
 {
     _vi = new AVSDLLVideoInfo();
     _avs =  new IntPtr(0);
     _colorSpace = AviSynthColorspace.Unknown;
     _sampleType = AudioSampleType.Unknown;
     if(0!=dimzon_avs_init_2(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
     {
         string err = getLastError();
         cleanup(false);
         throw new AviSynthException(err);
     }
 }
Пример #11
0
        public AviSynthClip(string func, string arg, AviSynthColorspace forceColorspace, AviSynthScriptEnvironment env)
        {
            _vi         = new AVSDLLVideoInfo();
            _avs        = new IntPtr(0);
            _colorSpace = AviSynthColorspace.Unknown;
            _sampleType = AudioSampleType.Unknown;
            bool bOpenSuccess = false;

            if (MainForm.Instance.Settings.OpenAVSInThreadDuringSession)
            {
                MainForm.Instance.AvsLock++;

                Thread t = new Thread(new ThreadStart(delegate
                {
                    System.Windows.Forms.Application.UseWaitCursor = true;
                    if (0 == dimzon_avs_init_2(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
                    {
                        bOpenSuccess = true;
                    }
                    MainForm.Instance.AvsLock--;
                    if (MainForm.Instance.AvsLock == 0)
                    {
                        System.Windows.Forms.Application.UseWaitCursor = false;
                    }
                }));
                t.Start();

                while (t.ThreadState == ThreadState.Running)
                {
                    System.Windows.Forms.Application.DoEvents();
                    Thread.Sleep(100);
                }
            }
            else
            {
                if (0 == dimzon_avs_init_2(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
                {
                    bOpenSuccess = true;
                }
            }

            if (bOpenSuccess == false)
            {
                string err = getLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
Пример #12
0
        /// <summary>
        /// Get the desired audio from the pack by the type
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>Audio file or null if it does not exist</returns>
        protected AudioFile GetAudioSampleFile(AudioSampleType type)
        {
            var audioSample = GetAudioSample(type);

            if (audioSample == null)
            {
                return(null);
            }

            var audioFile = audioSample.GetAudioFile();

            if (audioFile == null)
            {
                return(null);
            }

            return(audioFile);
        }
Пример #13
0
        internal AudioCaptureBase(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
        {
            if (sampleRate < MinSampleRate || MaxSampleRate < sampleRate)
            {
                throw new ArgumentOutOfRangeException(nameof(sampleRate), sampleRate,
                                                      $"Valid sampleRate range is { MinSampleRate } <= x <= { MaxSampleRate }.");
            }

            ValidationUtil.ValidateEnum(typeof(AudioChannel), channel, nameof(channel));
            ValidationUtil.ValidateEnum(typeof(AudioSampleType), sampleType, nameof(sampleType));

            SampleRate = sampleRate;
            Channel    = channel;
            SampleType = sampleType;

            AudioIOUtil.ThrowIfError(
                AudioInput.Create(SampleRate, (int)Channel, (int)SampleType, out _handle));

            RegisterStateChangedCallback();
        }
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the AudioPlayback class with the specified sample rate, channel, and sample type.
        /// </summary>
        /// <param name="sampleRate">The audio sample rate (8000 ~ 192000Hz).</param>
        /// <param name="channel">The audio channel type.</param>
        /// <param name="sampleType">The audio sample type.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <paramref name="sampleRate"/> is less than <see cref="MinSampleRate"/>.<br/>
        ///     -or-<br/>
        ///     <paramref name="sampleRate"/> is greater than <see cref="MaxSampleRate"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="channel"/> is invalid.<br/>
        ///     -or-<br/>
        ///     <paramref name="sampleType"/> is invalid.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public AudioPlayback(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
        {
            if (sampleRate < MinSampleRate || MaxSampleRate < sampleRate)
            {
                throw new ArgumentOutOfRangeException(nameof(sampleRate), sampleRate,
                                                      $"Valid sampleRate range is { MinSampleRate } <= x <= { MaxSampleRate }.");
            }

            ValidationUtil.ValidateEnum(typeof(AudioChannel), channel, nameof(channel));
            ValidationUtil.ValidateEnum(typeof(AudioSampleType), sampleType, nameof(sampleType));

            SampleRate = sampleRate;
            Channel    = channel;
            SampleType = sampleType;

            AudioOutput.Create(SampleRate, (int)Channel, (int)SampleType, out _handle)
            .ThrowIfFailed("Failed to create instance.");

            RegisterStreamCallback();
            RegisterStateChangedCallback();
        }
Пример #15
0
        /// <inheritdoc/>
        public void Play(AudioSampleType type, AudioPriorityBracket priority = AudioPriorityBracket.Sample)
        {
            // We do not want to play any audio.
            if (IoC.DataContent.PreferencesData.AudioAlertType == AudioAlertType.None)
            {
                return;
            }

            switch (IoC.DataContent.PreferencesData.AudioAlertType)
            {
            // Standard.
            case AudioAlertType.Standard:
                mAudioPacks[AudioAlertType.Standard].Play(type, priority);
                break;

            default:
                // Log it.
                IoC.Logger.Log("A selected audio alert level value is out of box!", LogLevel.Error);
                Debugger.Break();
                break;
            }
        }
Пример #16
0
        //, AviSynthScriptEnvironment env)
        //Полноценное открытие: инициализация + Invoke + GetVideoInfo (func обязательно должна возвращать Clip с видео!)
        public AviSynthClip(string func, string arg, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
        {
            _avs = new IntPtr(0);
            _vi = new AVSDLLVideoInfo();
            _vi.mt_import = (SysInfo.AVSIsMT) ? Settings.MTMode_Internal : MTMode.Undefined;

            //Эти два поля работают и на вход, и на выход. Для "dimzon_avs_init" через них можно задать требуемые на выходе PixelType и SampleType.
            //При нуле (Undefined) никаких преобразований не будет. На выходе из "dimzon_avs_init" поля будут содержать то, что получилось в итоге.
            //В "dimzon_avs_invoke" работают только на выход.
            _vi.pixel_type = forceColorSpace;
            _vi.sample_type = forceSampleType;

            //Эти поля содержат инфу об исходных PixelType и SampleType, т.е. до того, как они были изменены в "dimzon_avs_init".
            //В "dimzon_avs_invoke" обновляются только в случае их равенства нулю.
            _vi.pixel_type_orig = AviSynthColorspace.Undefined;
            _vi.sample_type_orig = AudioSampleType.Undefined;

            if (0 != dimzon_avs_init(ref _avs, func, arg, ref _vi))
            {
                string err = GetLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
Пример #17
0
 private static extern int dimzon_avs_init(ref IntPtr avs, string func, string arg, ref AVSDLLVideoInfo vi, ref AviSynthColorspace originalColorspace, ref AudioSampleType originalSampleType, string cs);
Пример #18
0
 public AviSynthReader(AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
 {
     //Если надо - меняем форматы
     forced_colorspace = forceColorSpace;
     forced_sampletype = forceSampleType;
 }
Пример #19
0
 public AviSynthReader()
 {
     //По умолчанию форматы не меняются
     forced_colorspace = AviSynthColorspace.Undefined;
     forced_sampletype = AudioSampleType.Undefined;
 }
Пример #20
0
 public AviSynthClip ParseScript(string script, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
 {
     return(new AviSynthClip("Eval", script, forceColorSpace, forceSampleType)); //, this);
 }
Пример #21
0
 public AviSynthClip OpenScriptFile(string filePath, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
 {
     return new AviSynthClip("Import", filePath, forceColorSpace, forceSampleType); //, this);
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the AudioCapture class with the specified sample rate, channel, and sampleType.
 /// </summary>
 /// <param name="sampleRate">The audio sample rate (8000 ~ 48000Hz).</param>
 /// <param name="channel">The audio channel type.</param>
 /// <param name="sampleType">The audio sample type.</param>
 /// <exception cref="ArgumentOutOfRangeException">
 ///     <paramref name="sampleRate"/> is less than <see cref="AudioCaptureBase.MinSampleRate"/>.<br/>
 ///     -or-<br/>
 ///     <paramref name="sampleRate"/> is greater than <see cref="AudioCaptureBase.MaxSampleRate"/>.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///     <paramref name="channel"/> is invalid.<br/>
 ///     -or-<br/>
 ///     <paramref name="sampleType"/> is invalid.
 /// </exception>
 /// <exception cref="UnauthorizedAccessException">The required privilege is not specified.</exception>
 /// <exception cref="NotSupportedException">The system does not support microphone.</exception>
 /// <since_tizen> 3 </since_tizen>
 public AudioCapture(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
     : base(sampleRate, channel, sampleType)
 {
 }
Пример #23
0
 public AviSynthReader(AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
 {
     //Если надо - меняем форматы
     forced_colorspace = forceColorSpace;
     forced_sampletype = forceSampleType;
 }
Пример #24
0
        /// <summary>
        /// Creates outgoing audio stream of type automatically assigned and adds procedures (callback or serviceable) for consuming given audio source data.
        /// Adds audio specific features (e.g. resampling, level meter) to processing pipeline and to returning stream handler.
        /// </summary>
        /// <param name="voiceInfo">Outgoing audio stream parameters. Set applicable fields to read them by encoder and by receiving client when voice created.</param>
        /// <param name="source">Streaming audio source.</param>
        /// <param name="sampleType">Voice's audio sample type. If does not match source audio sample type, conversion will occur.</param>
        /// <param name="channelId">Transport channel specific to transport.</param>
        /// <param name="encoder">Audio encoder. Set to null to use default Opus encoder.</param>
        /// <returns>Outgoing stream handler.</returns>
        /// <remarks>
        /// audioSourceDesc.SamplingRate and voiceInfo.SamplingRate may do not match. Automatic resampling will occur in this case.
        /// </remarks>
        public LocalVoice CreateLocalVoiceAudioFromSource(VoiceInfo voiceInfo, IAudioDesc source, AudioSampleType sampleType, IEncoder encoder = null, int channelId = 0)
        {
            // resolve AudioSampleType.Source to concrete type for encoder creation
            if (sampleType == AudioSampleType.Source)
            {
                if (source is IAudioPusher <float> || source is IAudioReader <float> )
                {
                    sampleType = AudioSampleType.Float;
                }
                else if (source is IAudioPusher <short> || source is IAudioReader <short> )
                {
                    sampleType = AudioSampleType.Short;
                }
            }

            if (encoder == null)
            {
                switch (sampleType)
                {
                case AudioSampleType.Float:
                    encoder = Platform.CreateDefaultAudioEncoder <float>(transport, voiceInfo);
                    break;

                case AudioSampleType.Short:
                    encoder = Platform.CreateDefaultAudioEncoder <short>(transport, voiceInfo);
                    break;
                }
            }

            if (source is IAudioPusher <float> )
            {
                if (sampleType == AudioSampleType.Short)
                {
                    transport.LogInfo("[PV] Creating local voice with source samples type conversion from IAudioPusher float to short.");
                    var localVoice = CreateLocalVoiceAudio <short>(voiceInfo, source, encoder, channelId);
                    // we can safely reuse the same buffer in callbacks from native code
                    //
                    var bufferFactory = new FactoryReusableArray <float>(0);
                    ((IAudioPusher <float>)source).SetCallback(buf => {
                        var shortBuf = localVoice.BufferFactory.New(buf.Length);
                        AudioUtil.Convert(buf, shortBuf, buf.Length);
                        localVoice.PushDataAsync(shortBuf);
                    }, bufferFactory);
                    return(localVoice);
                }
                else
                {
                    var localVoice = CreateLocalVoiceAudio <float>(voiceInfo, source, encoder, channelId);
                    ((IAudioPusher <float>)source).SetCallback(buf => localVoice.PushDataAsync(buf), localVoice.BufferFactory);
                    return(localVoice);
                }
            }
            else if (source is IAudioPusher <short> )
            {
                if (sampleType == AudioSampleType.Float)
                {
                    transport.LogInfo("[PV] Creating local voice with source samples type conversion from IAudioPusher short to float.");
                    var localVoice = CreateLocalVoiceAudio <float>(voiceInfo, source, encoder, channelId);
                    // we can safely reuse the same buffer in callbacks from native code
                    //
                    var bufferFactory = new FactoryReusableArray <short>(0);
                    ((IAudioPusher <short>)source).SetCallback(buf =>
                    {
                        var floatBuf = localVoice.BufferFactory.New(buf.Length);
                        AudioUtil.Convert(buf, floatBuf, buf.Length);
                        localVoice.PushDataAsync(floatBuf);
                    }, bufferFactory);
                    return(localVoice);
                }
                else
                {
                    var localVoice = CreateLocalVoiceAudio <short>(voiceInfo, source, encoder, channelId);
                    ((IAudioPusher <short>)source).SetCallback(buf => localVoice.PushDataAsync(buf), localVoice.BufferFactory);
                    return(localVoice);
                }
            }
            else if (source is IAudioReader <float> )
            {
                if (sampleType == AudioSampleType.Short)
                {
                    transport.LogInfo("[PV] Creating local voice with source samples type conversion from IAudioReader float to short.");
                    var localVoice = CreateLocalVoiceAudio <short>(voiceInfo, source, encoder, channelId);
                    localVoice.LocalUserServiceable = new BufferReaderPushAdapterAsyncPoolFloatToShort(localVoice, source as IAudioReader <float>);
                    return(localVoice);
                }
                else
                {
                    var localVoice = CreateLocalVoiceAudio <float>(voiceInfo, source, encoder, channelId);
                    localVoice.LocalUserServiceable = new BufferReaderPushAdapterAsyncPool <float>(localVoice, source as IAudioReader <float>);
                    return(localVoice);
                }
            }
            else if (source is IAudioReader <short> )
            {
                if (sampleType == AudioSampleType.Float)
                {
                    transport.LogInfo("[PV] Creating local voice with source samples type conversion from IAudioReader short to float.");
                    var localVoice = CreateLocalVoiceAudio <float>(voiceInfo, source, encoder, channelId);
                    localVoice.LocalUserServiceable = new BufferReaderPushAdapterAsyncPoolShortToFloat(localVoice, source as IAudioReader <short>);
                    return(localVoice);
                }
                else
                {
                    var localVoice = CreateLocalVoiceAudio <short>(voiceInfo, source, encoder, channelId);
                    localVoice.LocalUserServiceable = new BufferReaderPushAdapterAsyncPool <short>(localVoice, source as IAudioReader <short>);
                    return(localVoice);
                }
            }
            else
            {
                transport.LogError("[PV] CreateLocalVoiceAudioFromSource does not support Voice.IAudioDesc of type {0}", source.GetType());
                return(LocalVoiceAudioDummy.Dummy);
            }
        }
Пример #25
0
 public AviSynthClip ParseScript(string script, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
 {
     return new AviSynthClip("Eval", script, forceColorSpace, forceSampleType); //, this);
 }
Пример #26
0
 public AviSynthClip OpenScriptFile(string filePath, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
 {
     return(new AviSynthClip("Import", filePath, forceColorSpace, forceSampleType)); //, this);
 }
Пример #27
0
 /// <summary>
 /// Add new audio sample to the list with possibility to add it with initial configuration.
 /// <see cref="AudioSample"/>.
 /// </summary>
 /// <param name="type">The type of the new sample</param>
 /// <param name="item">The func to create audio sample</param>
 protected void AddAudioSample(AudioSampleType type, Func <AudioSample, AudioSample> item)
 {
     AddAudioSample(item(new AudioSample(type)));
 }
Пример #28
0
 public AviSynthReader()
 {
     //По умолчанию форматы не меняются
     forced_colorspace = AviSynthColorspace.Undefined;
     forced_sampletype = AudioSampleType.Undefined;
 }
Пример #29
0
        //Полноценное открытие: инициализация + Invoke + GetVideoInfo (func обязательно должна возвращать Clip с видео!)
        public AviSynthClip(string func, string arg, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType) //, AviSynthScriptEnvironment env)
        {
            _avs          = new IntPtr(0);
            _vi           = new AVSDLLVideoInfo();
            _vi.mt_import = (SysInfo.AVSIsMT) ? Settings.MTMode_Internal : MTMode.Undefined;

            //Эти два поля работают и на вход, и на выход. Для "dimzon_avs_init" через них можно задать требуемые на выходе PixelType и SampleType.
            //При нуле (Undefined) никаких преобразований не будет. На выходе из "dimzon_avs_init" поля будут содержать то, что получилось в итоге.
            //В "dimzon_avs_invoke" работают только на выход.
            _vi.pixel_type  = forceColorSpace;
            _vi.sample_type = forceSampleType;

            //Эти поля содержат инфу об исходных PixelType и SampleType, т.е. до того, как они были изменены в "dimzon_avs_init".
            //В "dimzon_avs_invoke" обновляются только в случае их равенства нулю.
            _vi.pixel_type_orig  = AviSynthColorspace.Undefined;
            _vi.sample_type_orig = AudioSampleType.Undefined;

            if (0 != dimzon_avs_init(ref _avs, func, arg, ref _vi))
            {
                string err = GetLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
Пример #30
0
        /// <summary>
        /// Detects if the AviSynth version can be used
        /// </summary>
        /// <returns>0 if everything is fine, 3 if the version is outdated or a different value for other errors</param>
        public static int CheckAvisynthInstallation(out string strVersion, out bool bIsAVS26, out bool bIsAVSPlus, out bool bIsMT, out string strAviSynthDLL, ref core.util.LogItem oLog)
        {
            strVersion     = "";
            bIsAVS26       = false;
            bIsAVSPlus     = false;
            bIsMT          = false;
            strAviSynthDLL = string.Empty;

            IntPtr             _avs        = new IntPtr(0);
            AVSDLLVideoInfo    _vi         = new AVSDLLVideoInfo();
            AviSynthColorspace _colorSpace = AviSynthColorspace.Unknown;
            AudioSampleType    _sampleType = AudioSampleType.Unknown;

            int iStartResult = -1;

            try
            {
                iStartResult = dimzon_avs_init_2(ref _avs, "Eval", "Version()", ref _vi, ref _colorSpace, ref _sampleType, AviSynthColorspace.RGB24.ToString());

                foreach (System.Diagnostics.ProcessModule module in System.Diagnostics.Process.GetCurrentProcess().Modules)
                {
                    if (module.FileName.ToLowerInvariant().EndsWith("avisynth.dll"))
                    {
                        strAviSynthDLL = module.FileName.ToLowerInvariant();
                    }
                }

                if (iStartResult == 0)
                {
                    int iWrapperVersion = GetAvisynthWrapperInterfaceVersion();
                    try
                    {
                        const int     errlen = 1024;
                        StringBuilder sb     = new StringBuilder(errlen);
                        sb.Length  = dimzon_avs_getstrfunction(_avs, "VersionString", sb, errlen);
                        strVersion = sb.ToString();

                        bool bResult = false;
                        int  iResult = dimzon_avs_functionexists(_avs, "AutoloadPlugins", ref bResult);
                        bIsAVSPlus = false;
                        if (iResult == 0)
                        {
                            bIsAVSPlus = bResult;
                        }

                        if (iWrapperVersion < 5)
                        {
                            bResult  = false;
                            iResult  = dimzon_avs_functionexists(_avs, "ConvertToYV16", ref bResult);
                            bIsAVS26 = false;
                            if (iResult == 0)
                            {
                                bIsAVS26 = bResult;
                            }
                        }
                        else
                        {
                            bIsAVS26 = true;
                        }

                        string strMTFunction = "Prefetch";
                        if (!bIsAVSPlus)
                        {
                            strMTFunction = "SetMTMode";
                        }
                        bResult = false;
                        iResult = dimzon_avs_functionexists(_avs, strMTFunction, ref bResult);
                        bIsMT   = false;
                        if (iResult == 0)
                        {
                            bIsMT = bResult;
                        }
                    }
                    catch (Exception ex)
                    {
                        oLog.LogValue("Error", ex.Message, core.util.ImageType.Error, false);
                    }
                }

                int iCloseResult = dimzon_avs_destroy(ref _avs);
                if (_avs != IntPtr.Zero)
                {
                    CloseHandle(_avs);
                }
                _avs = IntPtr.Zero;
            }
            catch (Exception ex)
            {
                oLog.LogValue("Error", ex.Message, core.util.ImageType.Error, false);
            }

            return(iStartResult);
        }
Пример #31
0
 private static extern int dimzon_avs_init_2(ref IntPtr avs, string func, string arg, ref AVSDLLVideoInfo vi, ref AviSynthColorspace originalColorspace, ref AudioSampleType originalSampleType, string cs);
Пример #32
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public AudioSample(AudioSampleType type)
 {
     Type        = type;
     mAudioFiles = new List <AudioFile>();
 }