Пример #1
0
        private void GenerateLine(LrcModel model, int lineIndex, LrcLine line, Position endStamp)
        {
            if (line.Items.Count <= 0)
            {
                return;
            }
            int           i;
            StringBuilder sc = new StringBuilder();

            for (i = 0; i < line.Items.Count - 1; i++)
            {
                Position position = null;
                for (int delta = 1; delta < line.Items.Count - i - 1; delta++)
                {
                    LrcChar c = line.Items[i + delta];
                    if (c.Skip || c.Position.Time <= 0)
                    {
                        continue;
                    }
                    position = c.Position;
                    break;
                }

                if (position is null)
                {
                    for (int lineDelta = 1; lineDelta < model.Items.Count - lineIndex - 1; lineDelta++)
                    {
                        bool    founded    = false;
                        LrcLine searchLine = model.Items[lineIndex + lineDelta];
                        for (int d = 1; d < searchLine.Items.Count; d++)
                        {
                            LrcChar c = searchLine.Items[d];
                            if (c.Skip || c.Position.Time <= 0)
                            {
                                continue;
                            }
                            position = c.Position;
                            founded  = true;
                            break;
                        }

                        if (founded)
                        {
                            break;
                        }
                    }
                }

                if (position is null)
                {
                    position = new Position(line.Items[i].Position.Time + 20);
                }
                sc.Append(GenerateChar(line.Items[i], position).generated);
            }
            (Position e, string generated) = GenerateChar(line.Items[i], endStamp);
            _sb.AppendLine(
                $"Dialogue: 0,{line.Items[0].Position.ConvertToSubtitleTimestamp()},{e.ConvertToSubtitleTimestamp()},Default,,0,0,0,,{sc}{generated}");
        }
Пример #2
0
        private string Generate(LrcModel model)
        {
            int i;

            for (i = 0; i < model.Items.Count - 1; i++)
            {
                GenerateLine(model, i, model.Items[i], model.Items[i + 1].Items[0].Position);
            }
            GenerateLine(model, model.Items.Count - 1, model.Items[i], null);
            return(_sb.ToString());
        }