Пример #1
0
        /// <summary>
        /// このトラックのメタテキストを,指定されたファイルに出力します.
        /// </summary>
        /// <param name="file"></param>
        public void printMetaText(string file, string encoding = "Shift_JIS")
        {
            TextStream tms    = new TextStream();
            int        count  = MetaText.getEventList().getCount();
            int        clLast = MetaText.getEventList().getElement(count - 1).Clock + 480;

            MetaText.print(tms, clLast, 0);
            InternalStreamWriter sw = null;

            try {
                sw = new InternalStreamWriter(file, encoding);
                tms.setPointer(-1);
                while (tms.ready())
                {
                    string line = tms.readLine().ToString();
                    sw.write(line);
                    sw.newLine();
                }
            } catch (Exception ex) {
                serr.println("VsqTrack#printMetaText; ex=" + ex);
            } finally {
                if (sw != null)
                {
                    try {
                        sw.close();
                    } catch (Exception ex2) {
                        serr.println("VsqTrack#printMetaText; ex2=" + ex2);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// テキストファイルからデータ点を読込み、現在のリストに追加します
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public string appendFromText(TextStream reader)
        {
#if DEBUG
            sout.println("VsqBPList#appendFromText; start");
            double started = PortUtil.getCurrentTime();
            int    count   = 0;
#endif
            int clock = 0;
            int value = 0;
            int minus = 1;
            int mode  = 0; // 0: clockを読んでいる, 1: valueを読んでいる
            while (reader.ready())
            {
                char ch = reader.get();
                if (ch == '\n')
                {
                    if (mode == 1)
                    {
                        addWithoutSort(clock, value * minus);
                        mode  = 0;
                        clock = 0;
                        value = 0;
                        minus = 1;
                    }
                    continue;
                }
                if (ch == '[')
                {
                    if (mode == 1)
                    {
                        addWithoutSort(clock, value * minus);
                        mode  = 0;
                        clock = 0;
                        value = 0;
                        minus = 1;
                    }
                    reader.setPointer(reader.getPointer() - 1);
                    break;
                }
                if (ch == '=')
                {
                    mode = 1;
                    continue;
                }
                if (ch == '-')
                {
                    minus = -1;
                    continue;
                }
                if (Char.IsNumber(ch))
                {
                    int num = 0;
                    if (ch == '1')
                    {
                        num = 1;
                    }
                    else if (ch == '2')
                    {
                        num = 2;
                    }
                    else if (ch == '3')
                    {
                        num = 3;
                    }
                    else if (ch == '4')
                    {
                        num = 4;
                    }
                    else if (ch == '5')
                    {
                        num = 5;
                    }
                    else if (ch == '6')
                    {
                        num = 6;
                    }
                    else if (ch == '7')
                    {
                        num = 7;
                    }
                    else if (ch == '8')
                    {
                        num = 8;
                    }
                    else if (ch == '9')
                    {
                        num = 9;
                    }
                    if (mode == 0)
                    {
                        clock = clock * 10 + num;
                    }
                    else
                    {
                        value = value * 10 + num;
                    }
                }
            }
            return(reader.readLine());
        }