Exemplo n.º 1
0
        public UserDefinedWriter(string path, Stream IO, AudioPCMConfig pcm, string encoder, string encoderParams, string encoderMode, int padding)
        {
            Path           = path;
            _encoder       = encoder;
            _encoderParams = encoderParams;
            _encoderMode   = encoderMode;
            useTempFile    = _encoderParams.Contains("%I");
            tempFile       = path + ".tmp.wav";

            _encoderProcess = new Process();
            _encoderProcess.StartInfo.FileName       = _encoder;
            _encoderProcess.StartInfo.Arguments      = _encoderParams.Replace("%O", "\"" + path + "\"").Replace("%M", encoderMode).Replace("%P", padding.ToString()).Replace("%I", "\"" + tempFile + "\"");
            _encoderProcess.StartInfo.CreateNoWindow = true;
            if (!useTempFile)
            {
                _encoderProcess.StartInfo.RedirectStandardInput = true;
            }
            _encoderProcess.StartInfo.UseShellExecute = false;
            if (!_encoderParams.Contains("%O"))
            {
                _encoderProcess.StartInfo.RedirectStandardOutput = true;
            }
            if (useTempFile)
            {
                wrt = new WAVWriter(tempFile, null, pcm);
                return;
            }
            bool      started = false;
            Exception ex      = null;

            try
            {
                started = _encoderProcess.Start();
                if (started)
                {
                    _encoderProcess.PriorityClass = Process.GetCurrentProcess().PriorityClass;
                }
            }
            catch (Exception _ex)
            {
                ex = _ex;
            }
            if (!started)
            {
                throw new Exception(_encoder + ": " + (ex == null ? "please check the path" : ex.Message));
            }
            if (_encoderProcess.StartInfo.RedirectStandardOutput)
            {
                Stream outputStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read);
                outputBuffer = new CyclicBuffer(2 * 1024 * 1024, _encoderProcess.StandardOutput.BaseStream, outputStream);
            }
            Stream inputStream = new CyclicBufferOutputStream(_encoderProcess.StandardInput.BaseStream, 128 * 1024);

            wrt = new WAVWriter(path, inputStream, pcm);
        }
        public UserDefinedWriter(string path, Stream IO, AudioPCMConfig pcm, string encoder, string encoderParams, string encoderMode, int padding)
        {
            _path = path;
            _encoder = encoder;
            _encoderParams = encoderParams;
            _encoderMode = encoderMode;
            useTempFile = _encoderParams.Contains("%I");
            tempFile = path + ".tmp.wav";

            _encoderProcess = new Process();
            _encoderProcess.StartInfo.FileName = _encoder;
            _encoderProcess.StartInfo.Arguments = _encoderParams.Replace("%O", "\"" + path + "\"").Replace("%M", encoderMode).Replace("%P", padding.ToString()).Replace("%I", "\"" + tempFile + "\"");
            _encoderProcess.StartInfo.CreateNoWindow = true;
            if (!useTempFile)
                _encoderProcess.StartInfo.RedirectStandardInput = true;
            _encoderProcess.StartInfo.UseShellExecute = false;
            if (!_encoderParams.Contains("%O"))
                _encoderProcess.StartInfo.RedirectStandardOutput = true;
            if (useTempFile)
            {
                wrt = new WAVWriter(tempFile, null, pcm);
                return;
            }
            bool started = false;
            Exception ex = null;
            try
            {
                started = _encoderProcess.Start();
                if (started)
                    _encoderProcess.PriorityClass = Process.GetCurrentProcess().PriorityClass;
            }
            catch (Exception _ex)
            {
                ex = _ex;
            }
            if (!started)
                throw new Exception(_encoder + ": " + (ex == null ? "please check the path" : ex.Message));
            if (_encoderProcess.StartInfo.RedirectStandardOutput)
            {
                Stream outputStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read);
                outputBuffer = new CyclicBuffer(2 * 1024 * 1024, _encoderProcess.StandardOutput.BaseStream, outputStream);
            }
            Stream inputStream = new CyclicBufferOutputStream(_encoderProcess.StandardInput.BaseStream, 128 * 1024);
            wrt = new WAVWriter(path, inputStream, pcm);
        }
 public CyclicBufferOutputStream(Stream output, int size)
 {
     _buffer = new CyclicBuffer(size);
     _buffer.WriteTo(output);
 }
 public CyclicBufferOutputStream(CyclicBuffer buffer)
 {
     _buffer = buffer;
 }
Exemplo n.º 5
0
 public CycilcBufferInputStream(CyclicBuffer buffer)
 {
     _buffer = buffer;
 }
 public CyclicBufferOutputStream(Stream output, int size)
 {
     _buffer = new CyclicBuffer(size);
     _buffer.WriteTo(output);
 }
 public CyclicBufferOutputStream(CyclicBuffer buffer)
 {
     _buffer = buffer;
 }