Пример #1
0
        /// <summary>
        /// Retrieve the length of the audio file
        /// sox file.wav 2>&1 -n stat | grep Length | cut -d : -f 2 | cut -f 1 </summary>
        /// <returns> the length in seconds or null </returns>
        public double GetLength(string path)
        {
            List<string> cmd = new List<string>();

            cmd.Add(soxBin);
            cmd.Add(path);
            cmd.Add("-n");
            cmd.Add("stat");

            LengthParser sc = new LengthParser (this, _globalCallback);

            try
            {
                ExecSox(cmd, sc);
            }
            catch (System.Exception)
            {
                return -1;
            }

            return sc.length;
        }
Пример #2
0
        public static bool Parse(SyntaxContext context, int position)
        {
            var list     = context.list;
            var offset   = 0;
            var index    = position;
            var count    = 0;
            var isMissed = false;

            while (ParenParser.Parse(context, index))
            {
                ;
            }
            while (TableIParser.Parse(context, index))
            {
                ;
            }
            while (TableSParser.Parse(context, index))
            {
                ;
            }
            while (ListParser.Parse(context, index))
            {
                ;
            }
            while (PropertyParser.Parse(context, index))
            {
                ;
            }
            while (IndexParser.Parse(context, index))
            {
                ;
            }
            while (CallParser.Parse(context, index))
            {
                ;
            }
            while (NotParser.Parse(context, index))
            {
                ;
            }
            while (LengthParser.Parse(context, index))
            {
                ;
            }
            while (NegateParser.Parse(context, index))
            {
                ;
            }
            while (PowerParser.Parse(context, index))
            {
                ;
            }
            while (MultiplyParser.Parse(context, index))
            {
                ;
            }
            while (DivisionParser.Parse(context, index))
            {
                ;
            }
            while (ModParser.Parse(context, index))
            {
                ;
            }
            while (AddParser.Parse(context, index))
            {
                ;
            }
            while (SubtractParser.Parse(context, index))
            {
                ;
            }
            if (!list[index].isRightValue)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            if (!ParserHelper.IsOperator(list[index], "<"))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            while (ParenParser.Parse(context, index))
            {
                ;
            }
            while (TableIParser.Parse(context, index))
            {
                ;
            }
            while (TableSParser.Parse(context, index))
            {
                ;
            }
            while (ListParser.Parse(context, index))
            {
                ;
            }
            while (PropertyParser.Parse(context, index))
            {
                ;
            }
            while (IndexParser.Parse(context, index))
            {
                ;
            }
            while (CallParser.Parse(context, index))
            {
                ;
            }
            while (NotParser.Parse(context, index))
            {
                ;
            }
            while (LengthParser.Parse(context, index))
            {
                ;
            }
            while (NegateParser.Parse(context, index))
            {
                ;
            }
            while (PowerParser.Parse(context, index))
            {
                ;
            }
            while (MultiplyParser.Parse(context, index))
            {
                ;
            }
            while (DivisionParser.Parse(context, index))
            {
                ;
            }
            while (ModParser.Parse(context, index))
            {
                ;
            }
            while (AddParser.Parse(context, index))
            {
                ;
            }
            while (SubtractParser.Parse(context, index))
            {
                ;
            }
            if (!list[index].isRightValue)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            context.Insert(position, ExpressionCreator.CreateLess(list, position, offset));
            context.Remove(position + 1, offset);
            return(true);
        }
Пример #3
0
        public static bool Parse(SyntaxContext context, int position)
        {
            var list     = context.list;
            var offset   = 0;
            var index    = position;
            var count    = 0;
            var isMissed = false;

            if (!ParserHelper.IsKeyword(list[index], "for"))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            if (list[index].type != Expression.Type.Word)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            if (!ParserHelper.IsOperator(list[index], "="))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            while (FunctionAParser.Parse(context, index))
            {
                ;
            }
            while (ParenParser.Parse(context, index))
            {
                ;
            }
            while (TableIParser.Parse(context, index))
            {
                ;
            }
            while (TableSParser.Parse(context, index))
            {
                ;
            }
            while (ListParser.Parse(context, index))
            {
                ;
            }
            while (PropertyParser.Parse(context, index))
            {
                ;
            }
            while (IndexParser.Parse(context, index))
            {
                ;
            }
            while (CallParser.Parse(context, index))
            {
                ;
            }
            while (NotParser.Parse(context, index))
            {
                ;
            }
            while (LengthParser.Parse(context, index))
            {
                ;
            }
            while (NegateParser.Parse(context, index))
            {
                ;
            }
            while (PowerParser.Parse(context, index))
            {
                ;
            }
            while (MultiplyParser.Parse(context, index))
            {
                ;
            }
            while (DivisionParser.Parse(context, index))
            {
                ;
            }
            while (ModParser.Parse(context, index))
            {
                ;
            }
            while (AddParser.Parse(context, index))
            {
                ;
            }
            while (SubtractParser.Parse(context, index))
            {
                ;
            }
            while (ConcatParser.Parse(context, index))
            {
                ;
            }
            while (LessParser.Parse(context, index))
            {
                ;
            }
            while (GreaterParser.Parse(context, index))
            {
                ;
            }
            while (LessEqualParser.Parse(context, index))
            {
                ;
            }
            while (GreaterEqualParser.Parse(context, index))
            {
                ;
            }
            while (EqualParser.Parse(context, index))
            {
                ;
            }
            while (NotEqualParser.Parse(context, index))
            {
                ;
            }
            while (AndParser.Parse(context, index))
            {
                ;
            }
            while (OrParser.Parse(context, index))
            {
                ;
            }
            if (!list[index].isRightValue)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            if (!ParserHelper.IsOperator(list[index], ","))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            while (FunctionAParser.Parse(context, index))
            {
                ;
            }
            while (ParenParser.Parse(context, index))
            {
                ;
            }
            while (TableIParser.Parse(context, index))
            {
                ;
            }
            while (TableSParser.Parse(context, index))
            {
                ;
            }
            while (ListParser.Parse(context, index))
            {
                ;
            }
            while (PropertyParser.Parse(context, index))
            {
                ;
            }
            while (IndexParser.Parse(context, index))
            {
                ;
            }
            while (CallParser.Parse(context, index))
            {
                ;
            }
            while (NotParser.Parse(context, index))
            {
                ;
            }
            while (LengthParser.Parse(context, index))
            {
                ;
            }
            while (NegateParser.Parse(context, index))
            {
                ;
            }
            while (PowerParser.Parse(context, index))
            {
                ;
            }
            while (MultiplyParser.Parse(context, index))
            {
                ;
            }
            while (DivisionParser.Parse(context, index))
            {
                ;
            }
            while (ModParser.Parse(context, index))
            {
                ;
            }
            while (AddParser.Parse(context, index))
            {
                ;
            }
            while (SubtractParser.Parse(context, index))
            {
                ;
            }
            while (ConcatParser.Parse(context, index))
            {
                ;
            }
            while (LessParser.Parse(context, index))
            {
                ;
            }
            while (GreaterParser.Parse(context, index))
            {
                ;
            }
            while (LessEqualParser.Parse(context, index))
            {
                ;
            }
            while (GreaterEqualParser.Parse(context, index))
            {
                ;
            }
            while (EqualParser.Parse(context, index))
            {
                ;
            }
            while (NotEqualParser.Parse(context, index))
            {
                ;
            }
            while (AndParser.Parse(context, index))
            {
                ;
            }
            while (OrParser.Parse(context, index))
            {
                ;
            }
            if (!list[index].isRightValue)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            if (!ParserHelper.IsKeyword(list[index], "do"))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            while (ModuleParser.Parse(context, index))
            {
                ;
            }
            if (list[index].type != Expression.Type.Module)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            if (!ParserHelper.IsKeyword(list[index], "end"))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            context.Insert(position, ExpressionCreator.CreateFor(list, position, offset));
            context.Remove(position + 1, offset);
            return(true);
        }
Пример #4
0
 public static void Register(Type type, LengthParser parse)
 {
     _lenParseList[type] = parse;
 }