• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1756 (tree)
日時2011-11-06 19:55:50
作者kbinani

ログメッセージ

[luavsq] Handleのparse処理まわりを実装

変更サマリ

差分

--- luavsq/trunk/VsqPhoneticSymbol.lua (revision 1755)
+++ luavsq/trunk/VsqPhoneticSymbol.lua (nonexistent)
@@ -1,101 +0,0 @@
1---[[
2- VsqPhoneticSymbol.lua
3- Copyright © 2011 kbinani
4-
5- This file is part of luavsq.
6-
7- luavsq is free software; you can redistribute it and/or
8- modify it under the terms of the BSD License.
9-
10- luavsq is distributed in the hope that it will be useful,
11- but WITHOUT ANY WARRANTY; without even the implied warranty of
12- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13-]]
14-
15-if( nil == luavsq )then
16- luavsq = {};
17-end
18-
19-if( nil == luavsq.VsqPhoneticSymbol )then
20-
21- ---
22- -- VSQで使用される発音記号の種類や有効性を判定するユーティリティ群です。
23- luavsq.VsqPhoneticSymbol = {};
24-
25- ---
26- -- 日本語の母音発音記号
27- luavsq.VsqPhoneticSymbol._SYMBOL_VOWEL_JP = "\ta\ti\tM\te\to\t";
28-
29- ---
30- -- 日本語の子音発音記号
31- luavsq.VsqPhoneticSymbol._SYMBOL_CONSONANT_JP = "\tk\tk'\tg\tg'\tN\tN'\ts\tS\tz\tZ\tdz\tdZ\tt\tt'\tts\ttS\td\td'\tn\tJ\th\th\\\tC\tp\\\tp\\'\tb\tb'\tp\tp'\tm\tm'\tj\t4\t4'\tw\tN\\\t";
32-
33- ---
34- -- 英語の母音発音記号
35- luavsq.VsqPhoneticSymbol._SYMBOL_VOWEL_EN = "\t@\tV\te\te\tI\ti:\t{\tO:\tQ\tU\tu:\t@r\teI\taI\tOI\t@U\taU\tI@\te@\tU@\tO@\tQ@\t";
36-
37- ---
38- -- 英語の子音発音記号
39- luavsq.VsqPhoneticSymbol._SYMBOL_CONSONANT_EN = "\tw\tj\tb\td\tg\tbh\tdh\tgh\tdZ\tv\tD\tz\tZ\tm\tn\tN\tr\tl\tl0\tp\tt\tk\tph\tth\tkh\ttS\tf\tT\ts\tS\th\tSil\tAsp\t";
40-
41- ---
42- -- 指定した文字列が子音を表す発音記号かどうかを判定します。
43- -- @param symbol String
44- -- @return boolean
45- function luavsq.VsqPhoneticSymbol.isConsonant( symbol )
46- local search = "\t" .. symbol .. "\t";
47- local startIndex, endIndex = luavsq.VsqPhoneticSymbol._SYMBOL_CONSONANT_JP:find( search );
48- if( startIndex ~= nil )then
49- return true;
50- else
51- startIndex, endIndex = luavsq.VsqPhoneticSymbol._SYMBOL_CONSONANT_EN:find( search );
52- if( startIndex ~= nil )then
53- return true;
54- end
55- end
56- return false;
57- end
58-
59- ---
60- -- 指定した文字列が母音を表す発音記号かどうかを判定します。
61- -- @param symbol String
62- -- @return boolean
63- function luavsq.VsqPhoneticSymbol.isVowel( symbol )
64- local search = "\t" .. symbol .. "\t";
65- local startIndex, endIndex = luavsq.VsqPhoneticSymbol._SYMBOL_VOWEL_JP:find( search );
66- if( startIndex ~= nil )then
67- return true;
68- else
69- startIndex, endIndex = luavsq.VsqPhoneticSymbol._SYMBOL_VOWEL_EN:find( search );
70- if( startIndex ~= nil )then
71- return true;
72- end
73- end
74- return false;
75- end
76-
77- ---
78- -- 指定した文字列が発音記号として有効かどうかを判定します。
79- -- @param symbol String
80- -- @return boolean
81- function luavsq.VsqPhoneticSymbol.isValidSymbol( symbol )
82- local isVowel = luavsq.VsqPhoneticSymbol.isVowel( symbol );
83- local isConsonant = luavsq.VsqPhoneticSymbol.isConsonant( symbol );
84- if( isVowel or isConsonant )then
85- return true;
86- end
87-
88- -- ブレスの判定
89- local symbolCharacterCount = symbol:len();
90- if( symbol:find( "br" ) == 1 and symbolCharacterCount > 2 )then
91- local s = symbol:sub( 3, symbolCharacterCount );
92- -- br001とかをfalseにするためのチェック
93- if( nil == tonumber( s ) )then
94- return false;
95- else
96- return true;
97- end
98- end
99- return false;
100- end
101-end
--- luavsq/trunk/test/VsqPhoneticSymbolTest.lua (revision 1755)
+++ luavsq/trunk/test/VsqPhoneticSymbolTest.lua (nonexistent)
@@ -1,21 +0,0 @@
1-require( "lunit" );
2-dofile( "../Util.lua" );
3-dofile( "../VsqPhoneticSymbol.lua" );
4-module( "enhanced", package.seeall, lunit.testcase );
5-
6-function testIsConsonant()
7- assert_true( luavsq.VsqPhoneticSymbol.isConsonant( "k'" ) );
8- assert_false( luavsq.VsqPhoneticSymbol.isConsonant( "a" ) );
9-end
10-
11-function testIsVowel()
12- assert_true( luavsq.VsqPhoneticSymbol.isVowel( "@" ) );
13- assert_false( luavsq.VsqPhoneticSymbol.isVowel( "b" ) );
14-end
15-
16-function testIsValidSymbol()
17- assert_true( luavsq.VsqPhoneticSymbol.isValidSymbol( "a" ) );
18- assert_true( luavsq.VsqPhoneticSymbol.isValidSymbol( "br1" ) );
19- assert_false( luavsq.VsqPhoneticSymbol.isValidSymbol( "__INVALID_SYMBOL__" ) );
20- assert_false( luavsq.VsqPhoneticSymbol.isValidSymbol( "br_" ) );
21-end
--- luavsq/trunk/test/PhoneticSymbolTest.lua (nonexistent)
+++ luavsq/trunk/test/PhoneticSymbolTest.lua (revision 1756)
@@ -0,0 +1,21 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../PhoneticSymbol.lua" );
4+module( "enhanced", package.seeall, lunit.testcase );
5+
6+function testIsConsonant()
7+ assert_true( luavsq.PhoneticSymbol.isConsonant( "k'" ) );
8+ assert_false( luavsq.PhoneticSymbol.isConsonant( "a" ) );
9+end
10+
11+function testIsVowel()
12+ assert_true( luavsq.PhoneticSymbol.isVowel( "@" ) );
13+ assert_false( luavsq.PhoneticSymbol.isVowel( "b" ) );
14+end
15+
16+function testIsValidSymbol()
17+ assert_true( luavsq.PhoneticSymbol.isValidSymbol( "a" ) );
18+ assert_true( luavsq.PhoneticSymbol.isValidSymbol( "br1" ) );
19+ assert_false( luavsq.PhoneticSymbol.isValidSymbol( "__INVALID_SYMBOL__" ) );
20+ assert_false( luavsq.PhoneticSymbol.isValidSymbol( "br_" ) );
21+end
--- luavsq/trunk/test/TextStreamTest.lua (nonexistent)
+++ luavsq/trunk/test/TextStreamTest.lua (revision 1756)
@@ -0,0 +1,51 @@
1+require( "lunit" );
2+dofile( "../TextStream.lua" );
3+module( "enhanced", package.seeall, lunit.testcase );
4+
5+function testConstruct()
6+ local stream = luavsq.TextStream.new();
7+ assert_false( stream:ready() );
8+ assert_equal( "", stream:toString() );
9+ assert_true( 0 > stream:getPointer() );
10+end
11+
12+function testReadLine()
13+ local stream = luavsq.TextStream.new();
14+ stream.array = { "h", "e", "l", "\n", "l", "o" };
15+ stream.length = 6;
16+ assert_true( stream:ready() );
17+ assert_equal( "hel", stream:readLine() );
18+ assert_true( stream:ready() );
19+ assert_equal( "lo", stream:readLine() );
20+ assert_false( stream:ready() );
21+end
22+
23+function testWrite()
24+ local stream = luavsq.TextStream.new();
25+ stream:write( "foo" );
26+ assert_equal( 2, stream:getPointer() );
27+ stream:setPointer( -1 );
28+ assert_equal( "foo", stream:readLine() );
29+end
30+
31+function testWriteLine()
32+ local stream = luavsq.TextStream.new();
33+ stream:writeLine( "foo" );
34+ assert_equal( 3, stream:getPointer() );
35+ stream:setPointer( -1 );
36+ assert_equal( "foo", stream:readLine() );
37+end
38+
39+function testClose()
40+ local stream = luavsq.TextStream.new();
41+ stream:writeLine( "foo" );
42+ -- エラーが起きなければ良しとする
43+ stream:close();
44+end
45+
46+function testToString()
47+ local stream = luavsq.TextStream.new();
48+ stream:writeLine( "foo" );
49+ stream:writeLine( "bar" );
50+ assert_equal( "foo\nbar\n", stream:toString() );
51+end
--- luavsq/trunk/test/LyricTest.lua (revision 1755)
+++ luavsq/trunk/test/LyricTest.lua (revision 1756)
@@ -1,6 +1,6 @@
11 require( "lunit" );
22 dofile( "../Util.lua" );
3-dofile( "../VsqPhoneticSymbol.lua" );
3+dofile( "../PhoneticSymbol.lua" );
44 dofile( "../Lyric.lua" );
55 module( "enhanced", package.seeall, lunit.testcase );
66
--- luavsq/trunk/test/VibratoHandleTest.lua (nonexistent)
+++ luavsq/trunk/test/VibratoHandleTest.lua (revision 1756)
@@ -0,0 +1,122 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../ArticulationType.lua" );
4+dofile( "../IconParameter.lua" );
5+dofile( "../VibratoBPPair.lua" );
6+dofile( "../VibratoBPList.lua" );
7+dofile( "../VibratoHandle.lua" );
8+dofile( "../Handle.lua" );
9+dofile( "../HandleType.lua" );
10+module( "enhanced", package.seeall, lunit.testcase );
11+
12+function testToString()
13+ local handle = luavsq.VibratoHandle.new();
14+ handle:setCaption( "foo" );
15+ assert_equal( "foo", handle:toString() );
16+end
17+
18+function testGetterAndSetterRateBP()
19+ local handle = luavsq.VibratoHandle.new();
20+ local rateBP = luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 1, 128 } );
21+ assert_not_equal( "0=1,1=128", handle:getRateBP():getData() );
22+ handle:setRateBP( rateBP );
23+ assert_equal( "0=1,1=128", handle:getRateBP():getData() );
24+end
25+
26+function testGetterAndSetterDepthBP()
27+ local handle = luavsq.VibratoHandle.new();
28+ local depthBP = luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 1, 128 } );
29+ assert_not_equal( "0=1,1=128", handle:getDepthBP():getData() );
30+ handle:setDepthBP( depthBP );
31+ assert_equal( "0=1,1=128", handle:getDepthBP():getData() );
32+end
33+
34+function testGetterAndSetterCaption()
35+ local handle = luavsq.VibratoHandle.new();
36+ local expected = "asdf";
37+ assert_not_equal( expected, handle:getCaption() );
38+ handle:setCaption( expected );
39+ assert_equal( expected, handle:getCaption() );
40+end
41+
42+function testGetterAndSetterStartRate()
43+ local handle = luavsq.VibratoHandle.new();
44+ local expected = 12345;
45+ assert_not_equal( expected, handle:getStartRate() );
46+ handle:setStartRate( expected );
47+ assert_equal( expected, handle:getStartRate() );
48+end
49+
50+function testGetterAndSetterStartDepth()
51+ local handle = luavsq.VibratoHandle.new();
52+ local expected = 12345;
53+ assert_not_equal( expected, handle:getStartDepth() );
54+ handle:setStartDepth( expected );
55+ assert_equal( expected, handle:getStartDepth() );
56+end
57+
58+function testGetterAndSetterLength()
59+ local handle = luavsq.VibratoHandle.new();
60+ local expected = 9999;
61+ assert_not_equal( handle:getLength() );
62+ handle:setLength( expected );
63+ assert_equal( expected, handle:getLength() );
64+end
65+
66+function testGetDisplayString()
67+ local handle = luavsq.VibratoHandle.new();
68+ handle:setCaption( "yahoo" );
69+ assert_equal( "yahoo", handle:getDisplayString() );
70+end
71+
72+function testClone()
73+ local handle = luavsq.VibratoHandle.new();
74+ handle.index = 1;
75+ handle.iconID = "hahaha";
76+ handle.ids = "baka";
77+ handle.original = 2;
78+ handle:setCaption( "aho" );
79+ handle:setLength( 3 );
80+ handle:setStartDepth( 4 );
81+ handle:setDepthBP( luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 32, 56 } ) );
82+ handle:setStartRate( 5 );
83+ handle:setRateBP( luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 64, 128 } ) );
84+ local copy = handle:clone();
85+ assert_equal( 1, copy.index );
86+ assert_equal( "hahaha", copy.iconID );
87+ assert_equal( "baka", copy.ids );
88+ assert_equal( 2, copy.original );
89+ assert_equal( "aho", copy:getCaption() );
90+ assert_equal( 3, copy:getLength() );
91+ assert_equal( 4, copy:getStartDepth() );
92+ assert_equal( "0=32,1=56", copy:getDepthBP():getData() );
93+ assert_equal( 5, copy:getStartRate() );
94+ assert_equal( "0=64,1=128", copy:getRateBP():getData() );
95+end
96+
97+function testCastToHandle()
98+ local vibratoHandle = luavsq.VibratoHandle.new();
99+ vibratoHandle.index = 1;
100+ vibratoHandle.iconID = "hahaha";
101+ vibratoHandle.ids = "baka";
102+ vibratoHandle.original = 2;
103+ vibratoHandle:setCaption( "aho" );
104+ vibratoHandle:setLength( 3 );
105+ vibratoHandle:setStartDepth( 4 );
106+ vibratoHandle:setDepthBP( luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 32, 56 } ) );
107+ vibratoHandle:setStartRate( 5 );
108+ vibratoHandle:setRateBP( luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 64, 128 } ) );
109+
110+ local handle = vibratoHandle:castToHandle();
111+ assert_equal( luavsq.HandleType.Vibrato, handle._type );
112+ assert_equal( 1, handle.index );
113+ assert_equal( "hahaha", handle.iconID );
114+ assert_equal( "baka", handle.ids );
115+ assert_equal( 2, handle.original );
116+ assert_equal( "aho", handle.caption );
117+ assert_equal( 3, handle:getLength() );
118+ assert_equal( 4, handle.startDepth );
119+ assert_equal( "0=32,1=56", handle.depthBP:getData() );
120+ assert_equal( 5, handle.startRate );
121+ assert_equal( "0=64,1=128", handle.rateBP:getData() );
122+end
--- luavsq/trunk/test/NoteHeadHandleTest.lua (nonexistent)
+++ luavsq/trunk/test/NoteHeadHandleTest.lua (revision 1756)
@@ -0,0 +1,115 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../ArticulationType.lua" );
4+dofile( "../NoteHeadHandle.lua" );
5+dofile( "../IconParameter.lua" );
6+dofile( "../Handle.lua" );
7+dofile( "../HandleType.lua" );
8+module( "enhanced", package.seeall, lunit.testcase );
9+
10+function testConstruct()
11+ local handle = luavsq.NoteHeadHandle.new();
12+ assert_equal( luavsq.ArticulationType.NoteAttack, handle.articulation );
13+end
14+
15+function testConstructWithArguments()
16+ local ids = "foo";
17+ local iconID = "$05030000";
18+ local index = 1000;
19+ local handle = luavsq.NoteHeadHandle.new( ids, iconID, index );
20+ assert_equal( luavsq.ArticulationType.NoteAttack, handle.articulation );
21+ assert_equal( ids, handle.ids );
22+ assert_equal( iconID, handle.iconID );
23+ assert_equal( index, handle.index );
24+end
25+
26+function testToString()
27+ local handle = luavsq.NoteHeadHandle.new();
28+ handle.ids = "foo";
29+ handle.caption = "bar";
30+ assert_equal( "foobar", handle:toString() );
31+end
32+
33+function testGetterAndSetterDepth()
34+ local handle = luavsq.NoteHeadHandle.new();
35+ local expected = 1234;
36+ assert_not_equal( expected, handle:getDepth() );
37+ handle:setDepth( expected );
38+ assert_equal( expected, handle:getDepth() );
39+end
40+
41+function testGetterAndSetterDuration()
42+ local handle = luavsq.NoteHeadHandle.new();
43+ local expected = 947;
44+ assert_not_equal( expected, handle:getDuration() );
45+ handle:setDuration( expected );
46+ assert_equal( expected, handle:getDuration() );
47+end
48+
49+function testGetterAndSetterCaption()
50+ local handle = luavsq.NoteHeadHandle.new();
51+ local expected = "aho";
52+ assert_not_equal( expected, handle:getCaption() );
53+ handle:setCaption( expected );
54+ assert_equal( expected, handle:getCaption() );
55+end
56+
57+function testGetterAndSetterLength()
58+ local handle = luavsq.NoteHeadHandle.new();
59+ local expected = 31347;
60+ assert_not_equal( expected, handle:getLength() );
61+ handle:setLength( expected );
62+ assert_equal( expected, handle:getLength() );
63+end
64+
65+function testGetDisplayString()
66+ local handle = luavsq.NoteHeadHandle.new();
67+ handle.ids = "goo";
68+ handle.caption = "gle";
69+ assert_equal( "google", handle:getDisplayString() );
70+end
71+
72+function testClone()
73+ local handle = luavsq.NoteHeadHandle.new();
74+ handle.index = 1;
75+ handle.iconID = "$05010000";
76+ handle.ids = "dwango";
77+ handle.original = 2;
78+ handle.caption = "niwango";
79+ handle:setLength( 3 );
80+ handle:setDuration( 4 );
81+ handle:setDepth( 5 );
82+
83+ local copy = handle:clone();
84+ assert_equal( 1, copy.index );
85+ assert_equal( "$05010000", copy.iconID );
86+ assert_equal( "dwango", copy.ids );
87+ assert_equal( 2, copy.original );
88+ assert_equal( "niwango", copy.caption );
89+ assert_equal( 3, copy:getLength() );
90+ assert_equal( 4, copy:getDuration() );
91+ assert_equal( 5, copy:getDepth() );
92+end
93+
94+function testCastToHandle()
95+ local handle = luavsq.NoteHeadHandle.new();
96+ handle.index = 1;
97+ handle.iconID = "$05010000";
98+ handle.ids = "dwango";
99+ handle.original = 2;
100+ handle.caption = "niwango";
101+ handle:setLength( 3 );
102+ handle:setDuration( 4 );
103+ handle:setDepth( 5 );
104+
105+ local casted = handle:castToHandle();
106+ assert_equal( luavsq.HandleType.NoteHeadHandle, casted._type );
107+ assert_equal( 1, casted.index );
108+ assert_equal( "$05010000", casted.iconID );
109+ assert_equal( "dwango", casted.ids );
110+ assert_equal( 2, casted.original );
111+ assert_equal( "niwango", casted.caption );
112+ assert_equal( 3, casted.length );
113+ assert_equal( 4, casted.duration );
114+ assert_equal( 5, casted.depth );
115+end
--- luavsq/trunk/test/IconHandleTest.lua (nonexistent)
+++ luavsq/trunk/test/IconHandleTest.lua (revision 1756)
@@ -0,0 +1,62 @@
1+require( "lunit" );
2+dofile( "../IconHandle.lua" );
3+dofile( "../Handle.lua" );
4+dofile( "../HandleType.lua" );
5+module( "enhanced", package.seeall, lunit.testcase );
6+
7+function getIconHandle()
8+ local handle = luavsq.IconHandle.new();
9+ handle.caption = "bar";
10+ handle.iconID = "$07010001";
11+ handle.ids = "foo";
12+ handle.index = 1;
13+ handle.length = 2;
14+ handle.original = 3;
15+ handle.program = 4;
16+ handle.language= 5;
17+ return handle;
18+end
19+
20+function testGetterAndSetterLength()
21+ local handle = getIconHandle();
22+ local expected = 12084;
23+ assert_not_equal( expected, handle:getLength() );
24+ handle:setLength( expected );
25+ assert_equal( expected, handle:getLength() );
26+end
27+
28+function testEqual()
29+ local a = getIconHandle();
30+ local b = getIconHandle();
31+ assert_true( a:equals( b ) );
32+ a.iconID = "$07010001";
33+ b.iconID = "$07010002";
34+ assert_false( a:equals( b ) );
35+end
36+
37+function testClone()
38+ local handle = getIconHandle();
39+ local copy = handle:clone();
40+ assert_equal( handle.caption, copy.caption );
41+ assert_equal( handle.iconID, copy.iconID );
42+ assert_equal( handle.ids, copy.ids );
43+ assert_equal( handle.index, copy.index );
44+ assert_equal( handle.language, copy.language );
45+ assert_equal( handle:getLength(), copy:getLength() );
46+ assert_equal( handle.original, copy.original );
47+ assert_equal( handle.program, copy.program );
48+end
49+
50+function testCastToHandle()
51+ local handle = getIconHandle();
52+ local casted = handle:castToHandle();
53+ assert_equal( luavsq.HandleType.Singer, casted._type );
54+ assert_equal( "bar", casted.caption );
55+ assert_equal( "$07010001", casted.iconID );
56+ assert_equal( "foo", casted.ids );
57+ assert_equal( 1, casted.index );
58+ assert_equal( 5, casted.language );
59+ assert_equal( 2, casted:getLength() );
60+ assert_equal( 4, casted.program );
61+ assert_equal( 3, casted.original );
62+end
--- luavsq/trunk/test/VibratoBPListTest.lua (nonexistent)
+++ luavsq/trunk/test/VibratoBPListTest.lua (revision 1756)
@@ -0,0 +1,72 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../VibratoBPPair.lua" );
4+dofile( "../VibratoBPList.lua" );
5+module( "enhanced", package.seeall, lunit.testcase );
6+
7+function testConstructWithString()
8+ local list = luavsq.VibratoBPList.new( "2", "1.0,0.0", "128,1" );
9+ assert_equal( 2, list:getCount() );
10+ assert_equal( "0=1,1=128", list:getData() );
11+end
12+
13+function testConstructWithArray()
14+ local list = luavsq.VibratoBPList.new( { 1.0, 0.0 }, { 128, 1 } );
15+ assert_equal( 2, list:getCount() );
16+ assert_equal( "0=1,1=128", list:getData() );
17+end
18+
19+function testGetValue()
20+ local list = luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 1, 128 } );
21+ assert_equal( 1, list:getValue( 0.0 ) );
22+ assert_equal( 1, list:getValue( 0.99999 ) );
23+ assert_equal( 128, list:getValue( 1.0 ) );
24+ assert_equal( 64, list:getValue( -0.0000001, 64 ) );
25+end
26+
27+function testClone()
28+ local list = luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 1, 128 } );
29+ local copy = list:clone();
30+ assert_equal( "0=1,1=128", copy:getData() );
31+end
32+
33+function testGetCount()
34+ local list = luavsq.VibratoBPList.new( { 0.0, 0.4, 1.0 }, { 1, 64, 128 } );
35+ assert_equal( 3, list:getCount() );
36+end
37+
38+function testGetElement()
39+ local list = luavsq.VibratoBPList.new( { 0.4, 0.0, 1.0 }, { 64, 1, 128 } );
40+ assert_equal( 0, list:getElement( 0 ).x );
41+ assert_equal( 1, list:getElement( 0 ).y );
42+ assert_equal( 0.4, list:getElement( 1 ).x );
43+ assert_equal( 64, list:getElement( 1 ).y );
44+ assert_equal( 1, list:getElement( 2 ).x );
45+ assert_equal( 128, list:getElement( 2 ).y );
46+end
47+
48+function testSetElement()
49+ local list = luavsq.VibratoBPList.new( { 0.0, 0.4, 1.0 }, { 1, 64, 128 } );
50+ list:setElement( 1, luavsq.VibratoBPPair.new( 0.2, 32 ) );
51+ assert_equal( 0.2, list:getElement( 1 ).x );
52+ assert_equal( 32, list:getElement( 1 ).y );
53+end
54+
55+function testGetData()
56+ local list = luavsq.VibratoBPList.new( { 0.0, 0.4, 1.0 }, { 1, 64, 128 } );
57+ assert_equal( "0=1,0.4=64,1=128", list:getData() );
58+ list = luavsq.VibratoBPList.new( {}, {} );
59+ assert_equal( "", list:getData() );
60+end
61+
62+function testSetData()
63+ local list = luavsq.VibratoBPList.new( {}, {} );
64+ list:setData( "0.4=64,0=1,1=128" );
65+ assert_equal( 3, list:getCount() );
66+ assert_equal( 0, list:getElement( 0 ).x );
67+ assert_equal( 1, list:getElement( 0 ).y );
68+ assert_equal( 0.4, list:getElement( 1 ).x );
69+ assert_equal( 64, list:getElement( 1 ).y );
70+ assert_equal( 1, list:getElement( 2 ).x );
71+ assert_equal( 128, list:getElement( 2 ).y );
72+end
--- luavsq/trunk/test/VibratoBPPairTest.lua (nonexistent)
+++ luavsq/trunk/test/VibratoBPPairTest.lua (revision 1756)
@@ -0,0 +1,36 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../VibratoBPPair.lua" );
4+module( "enhanced", package.seeall, lunit.testcase );
5+
6+function testConstruct()
7+ local point = luavsq.VibratoBPPair.new();
8+ assert_equal( 0.0, point.x );
9+ assert_equal( 0, point.y );
10+end
11+
12+function testConstructWithCoordinate()
13+ local point = luavsq.VibratoBPPair.new( 2.0, 3 );
14+ assert_equal( 2, point.x );
15+ assert_equal( 3, point.y );
16+end
17+
18+function testCompareTo()
19+ local a = luavsq.VibratoBPPair.new( 2.0, 3 );
20+ local b = luavsq.VibratoBPPair.new( 2.0, 10 );
21+ assert_equal( 0, a:compareTo( b ) );
22+
23+ local c = luavsq.VibratoBPPair.new( 1.0, 3 );
24+ assert_equal( 1, b:compareTo( c ) );
25+ assert_equal( -1, c:compareTo( b ) );
26+end
27+
28+function testCompare()
29+ local a = luavsq.VibratoBPPair.new( 2.0, 3 );
30+ local b = luavsq.VibratoBPPair.new( 2.0, 10 );
31+ assert_equal( 0, luavsq.VibratoBPPair.compare( a, b ) );
32+
33+ local c = luavsq.VibratoBPPair.new( 1.0, 3 );
34+ assert_equal( 1, luavsq.VibratoBPPair.compare( b, c ) );
35+ assert_equal( -1, luavsq.VibratoBPPair.compare( c, b ) );
36+end
--- luavsq/trunk/test/HandleTest.lua (nonexistent)
+++ luavsq/trunk/test/HandleTest.lua (revision 1756)
@@ -0,0 +1,472 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../Handle.lua" );
4+dofile( "../TextStream.lua" );
5+dofile( "../HandleType.lua" );
6+dofile( "../Lyric.lua" );
7+dofile( "../VibratoBPList.lua" );
8+dofile( "../VibratoBPPair.lua" );
9+dofile( "../LyricHandle.lua" );
10+dofile( "../ArticulationType.lua" );
11+dofile( "../VibratoHandle.lua" );
12+dofile( "../IconParameter.lua" );
13+dofile( "../IconHandle.lua" );
14+dofile( "../NoteHeadHandle.lua" );
15+dofile( "../IconDynamicsHandle.lua" );
16+module( "enhanced", package.seeall, lunit.testcase );
17+
18+function getLyricStream()
19+ local stream = luavsq.TextStream.new();
20+ stream:writeLine( "L0=あ,a,0.4,0,1" );
21+ stream:writeLine( "L1=は,h a,0.6,64,0,0" );
22+ stream:setPointer( -1 );
23+ return stream;
24+end
25+
26+function getVibratoStream()
27+ local stream = luavsq.TextStream.new();
28+ stream:writeLine( "IconID=$04040004" );
29+ stream:writeLine( "IDS=normal-da-yo" );
30+ stream:writeLine( "Caption=キャプションです=あ" );
31+ stream:writeLine( "Original=5" );
32+ stream:writeLine( "Length=120" );
33+ stream:writeLine( "StartDepth=64" );
34+ stream:writeLine( "DepthBPNum=3" );
35+ stream:writeLine( "DepthBPX=0.500000,0.750000,1.000000" );
36+ stream:writeLine( "DepthBPY=64,32,0" );
37+ stream:writeLine( "StartRate=64" );
38+ stream:writeLine( "RateBPNum=3" );
39+ stream:writeLine( "RateBPX=0.500000,0.750000,1.000000" );
40+ stream:writeLine( "RateBPY=64,32,0" );
41+ stream:writeLine( "[h#0002]" );
42+ stream:setPointer( -1 );
43+ return stream;
44+end
45+
46+function getSingerStream()
47+ local stream = luavsq.TextStream.new();
48+ stream:writeLine( "IconID=$07010002" );
49+ stream:writeLine( "IDS=Miku3" );
50+ stream:writeLine( "Original=2" );
51+ stream:writeLine( "Caption=" );
52+ stream:writeLine( "Length=1" );
53+ stream:writeLine( "Language=1" );
54+ stream:writeLine( "Program=2" );
55+ stream:setPointer( -1 );
56+ return stream;
57+end
58+
59+function getAttackStream()
60+ local stream = luavsq.TextStream.new();
61+ stream:writeLine( "IconID=$01010002" );
62+ stream:writeLine( "IDS=accent" );
63+ stream:writeLine( "Original=2" );
64+ stream:writeLine( "Caption=Accent" );
65+ stream:writeLine( "Length=120" );
66+ stream:writeLine( "Duration=64" );
67+ stream:writeLine( "Depth=63" );
68+ stream:setPointer( -1 );
69+ return stream;
70+end
71+
72+function getCrescendoStream()
73+ local stream = luavsq.TextStream.new();
74+ stream:writeLine( "IconID=$05020001" );
75+ stream:writeLine( "IDS=Crescendo" );
76+ stream:writeLine( "Original=4" );
77+ stream:writeLine( "Caption=Zero Crescendo Curve" );
78+ stream:writeLine( "Length=960" );
79+ stream:writeLine( "StartDyn=2" );
80+ stream:writeLine( "EndDyn=38" );
81+ stream:writeLine( "DynBPNum=1" );
82+ stream:writeLine( "DynBPX=0.5" );
83+ stream:writeLine( "DynBPY=11" );
84+ stream:setPointer( -1 );
85+ return stream;
86+end
87+
88+---
89+-- 歌詞ハンドルの読み込みテスト
90+-- EOFで読み込みが終了する場合
91+function testConstructLyricFromTextStreamStopWithEOF()
92+ local stream = getLyricStream();
93+ local lastLine = {};
94+ lastLine.value = "";
95+ local index = 100;
96+
97+ local handle = luavsq.Handle.new( stream, index, lastLine );
98+ assert_equal( luavsq.HandleType.Lyric, handle._type );
99+ assert_equal( index, handle.index );
100+ assert_equal( 2, #handle.lyrics );
101+
102+ local lyric1 = handle.lyrics[1];
103+ assert_equal( "あ", lyric1.phrase );
104+ assert_equal( "a", lyric1:getPhoneticSymbol() );
105+ assert_equal( 0.4, lyric1.lengthRatio );
106+ assert_equal( "0", lyric1:getConsonantAdjustment() );
107+ assert_true( lyric1.isProtected );
108+
109+ local lyric2 = handle.lyrics[2];
110+ assert_equal( "は", lyric2.phrase );
111+ assert_equal( "h a", lyric2:getPhoneticSymbol() );
112+ assert_equal( 0.6, lyric2.lengthRatio );
113+ assert_equal( "64 0", lyric2:getConsonantAdjustment() );
114+ assert_false( lyric2.isProtected );
115+end
116+
117+---
118+-- 歌詞ハンドルの読み込みテスト
119+-- 次の歌詞ハンドルの先頭に到達して読み込みが終了する場合
120+function testConstructLyricFromTextStreamStopWithNextHandle()
121+ local stream = luavsq.TextStream.new();
122+ stream:writeLine( "L0=あ,a,0.4,0,1" );
123+ stream:writeLine( "[h#0002]" );
124+ stream:setPointer( -1 );
125+ local lastLine = {};
126+ lastLine.value = "";
127+ local index = 100;
128+
129+ local handle = luavsq.Handle.new( stream, index, lastLine );
130+ assert_equal( luavsq.HandleType.Lyric, handle._type );
131+ assert_equal( index, handle.index );
132+ assert_equal( 1, #handle.lyrics );
133+
134+ assert_not_nil( handle.rateBP );
135+ assert_equal( 0, handle.rateBP:getCount() );
136+ assert_not_nil( handle.depthBP );
137+ assert_equal( 0, handle.depthBP:getCount() );
138+ assert_not_nil( handle.dynBP );
139+ assert_equal( 0, handle.dynBP:getCount() );
140+
141+ local lyric = handle.lyrics[1];
142+ assert_equal( "あ", lyric.phrase );
143+ assert_equal( "a", lyric:getPhoneticSymbol() );
144+ assert_equal( 0.4, lyric.lengthRatio );
145+ assert_equal( "0", lyric:getConsonantAdjustment() );
146+ assert_true( lyric.isProtected );
147+
148+ assert_equal( "[h#0002]", lastLine.value );
149+end
150+
151+function testConstructVibratoFromTextStream()
152+ local stream = getVibratoStream();
153+ local lastLine = { ["value"] = "" };
154+ local index = 101;
155+ local handle = luavsq.Handle.new( stream, index, lastLine );
156+
157+ assert_equal( luavsq.HandleType.Vibrato, handle._type );
158+ assert_equal( "$04040004", handle.iconID );
159+ assert_equal( "normal-da-yo", handle.ids );
160+ assert_equal( "キャプションです=あ", handle.caption );
161+ assert_equal( 5, handle.original );
162+ assert_equal( 120, handle:getLength() );
163+ assert_equal( 64, handle.startDepth );
164+ assert_equal( "0.5=64,0.75=32,1=0", handle.depthBP:getData() );
165+ assert_equal( 64, handle.startRate );
166+ assert_equal( "0.5=64,0.75=32,1=0", handle.rateBP:getData() );
167+
168+ assert_equal( "[h#0002]", lastLine.value );
169+end
170+
171+function testConstructVibratoFromTextStreamWithoutBP()
172+ local stream = luavsq.TextStream.new();
173+ stream:writeLine( "IconID=$04040004" );
174+ stream:writeLine( "IDS=normal-da-yo" );
175+ stream:writeLine( "Caption=キャプションです=あ" );
176+ stream:writeLine( "Original=5" );
177+ stream:writeLine( "Length=120" );
178+ stream:writeLine( "StartDepth=64" );
179+ stream:writeLine( "StartRate=64" );
180+ stream:writeLine( "[h#0002]" );
181+ stream:setPointer( -1 );
182+
183+ local lastLine = { ["value"] = "" };
184+ local index = 101;
185+ local handle = luavsq.Handle.new( stream, index, lastLine );
186+
187+ assert_not_nil( handle.rateBP );
188+ assert_equal( 0, handle.rateBP:getCount() );
189+ assert_not_nil( handle.depthBP );
190+ assert_equal( 0, handle.depthBP:getCount() );
191+end
192+
193+function testConstructSingerFromTextStream()
194+ local stream = getSingerStream();
195+ local index = 101;
196+ local lastLine = { ["value"] = "" };
197+ local handle = luavsq.Handle.new( stream, index, lastLine );
198+ assert_equal( index, handle.index );
199+ assert_equal( luavsq.HandleType.Singer, handle._type );
200+ assert_equal( "$07010002", handle.iconID );
201+ assert_equal( "Miku3", handle.ids );
202+ assert_equal( 2, handle.original );
203+ assert_equal( "", handle.caption );
204+ assert_equal( 1, handle:getLength() );
205+ assert_equal( 1, handle.language );
206+ assert_equal( 2, handle.program );
207+end
208+
209+function testConstructAttackFromTextStream()
210+ local stream = getAttackStream();
211+ local lastLine = { ["value"] = "" };
212+ local index = 204;
213+ local handle = luavsq.Handle.new( stream, index, lastLine );
214+ assert_equal( luavsq.HandleType.NoteHead, handle._type );
215+ assert_equal( index, handle.index );
216+ assert_equal( "$01010002", handle.iconID );
217+ assert_equal( "accent", handle.ids );
218+ assert_equal( 2, handle.original );
219+ assert_equal( "Accent", handle.caption );
220+ assert_equal( 120, handle:getLength() );
221+ assert_equal( 64, handle.duration );
222+ assert_equal( 63, handle.depth );
223+end
224+
225+function testConstructCrescendFromTextStream()
226+ local stream = getCrescendoStream();
227+ local lastLine = { ["value"] = "" };
228+ local index = 204;
229+ local handle = luavsq.Handle.new( stream, index, lastLine );
230+ assert_equal( index, handle.index );
231+ assert_equal( luavsq.HandleType.Dynamics, handle._type );
232+ assert_equal( "$05020001", handle.iconID );
233+ assert_equal( "Crescendo", handle.ids );
234+ assert_equal( 4, handle.original );
235+ assert_equal( "Zero Crescendo Curve", handle.caption );
236+ assert_equal( 960, handle:getLength() );
237+ assert_equal( 2, handle.startDyn );
238+ assert_equal( 38, handle.endDyn );
239+ assert_equal( "0.5=11", handle.dynBP:getData() );
240+end
241+
242+function testGetterAndSetterLength()
243+ local handle = luavsq.Handle.new();
244+ local expected = 847;
245+ assert_not_equal( expected, handle:getLength() );
246+ handle:setLength( expected );
247+ assert_equal( expected, handle:getLength() );
248+end
249+
250+function testCastToLyricHandle()
251+ local stream = getLyricStream();
252+ local lastLine = { ["value"] = "" };
253+ local index = 3847;
254+ local handle = luavsq.Handle.new( stream, index, lastLine );
255+ local casted = handle:castToLyricHandle();
256+ assert_equal( index, casted.index );
257+ assert_equal( #handle.lyrics, #casted.lyrics );
258+ local i;
259+ for i = 1, #handle.lyrics, 1 do
260+ assert_equal( handle.lyrics[i]:toString(), casted.lyrics[i]:toString() );
261+ end
262+end
263+
264+function testCastToVibratoHandle()
265+ local stream = getVibratoStream();
266+ local lastLine = { ["value"] = "" };
267+ local index = 347;
268+ local handle = luavsq.Handle.new( stream, index, lastLine );
269+
270+ local casted = handle:castToVibratoHandle();
271+ assert_equal( index, casted.index );
272+ assert_equal( "キャプションです=あ", casted:getCaption() );
273+ assert_equal( "0.5=64,0.75=32,1=0", casted:getDepthBP():getData() );
274+ assert_equal( "$04040004", casted.iconID );
275+ assert_equal( "normal-da-yo", casted.ids );
276+ assert_equal( 120, casted:getLength() );
277+ assert_equal( 5, casted.original );
278+ assert_equal( "0.5=64,0.75=32,1=0", casted:getRateBP():getData() );
279+ assert_equal( 64, casted:getStartDepth() );
280+ assert_equal( 64, casted:getStartRate() );
281+end
282+
283+function testCastToIconHandle()
284+ local stream = getSingerStream();
285+ local lastLine = { ["value"] = "" };
286+ local index = 9476;
287+ local handle = luavsq.Handle.new( stream, index, lastLine );
288+
289+ local casted = handle:castToIconHandle();
290+ assert_equal( index, casted.index );
291+ assert_equal( "", casted.caption );
292+ assert_equal( "$07010002", casted.iconID );
293+ assert_equal( "Miku3", casted.ids );
294+ assert_equal( 1, casted.language );
295+ assert_equal( 1, casted:getLength() );
296+ assert_equal( 2, casted.original );
297+ assert_equal( 2, casted.program );
298+end
299+
300+function testCastToNoteHeadHandle()
301+ local stream = getAttackStream();
302+ local lastLine = { ["value"] = "" };
303+ local index = 70375;
304+ local handle = luavsq.Handle.new( stream, index, lastLine );
305+ local casted = handle:castToNoteHeadHandle();
306+ assert_equal( "Accent", casted:getCaption() );
307+ assert_equal( 63, casted:getDepth() );
308+ assert_equal( 64, casted:getDuration() );
309+ assert_equal( "$01010002", casted.iconID );
310+ assert_equal( "accent", casted.ids );
311+ assert_equal( 120, casted:getLength() );
312+ assert_equal( 2, casted.original );
313+end
314+
315+function testCastToIconDynamicsHandle()
316+ local stream = getCrescendoStream();
317+ local lastLine = { ["value"] = "" };
318+ local index = 1548;
319+ local handle = luavsq.Handle.new( stream, index, lastLine );
320+ local casted = handle:castToIconDynamicsHandle();
321+ assert_equal( "Crescendo", casted.ids );
322+ assert_equal( "$05020001", casted.iconID );
323+ assert_equal( 4, casted.original );
324+ assert_equal( "Zero Crescendo Curve", casted:getCaption() );
325+ assert_equal( "0.5=11", casted.dynBP:getData() );
326+ assert_equal( 38, casted.endDyn );
327+ assert_equal( 960, casted:getLength() );
328+ assert_equal( 2, casted.startDyn );
329+end
330+
331+function testWrite()
332+ local stream = getLyricStream();
333+ local handle = luavsq.Handle.new( stream, 1, {} );
334+ local dest = luavsq.TextStream.new();
335+ handle:write( dest );
336+ dest:setPointer( -1 );
337+ assert_equal( "[h#0001]", dest:readLine() );
338+ assert_equal( "L0=\"あ\",\"a\",0.4,0,1", dest:readLine() );
339+ assert_equal( "L1=\"は\",\"h a\",0.6,64,0,0", dest:readLine() );
340+end
341+
342+function testLyricToString()
343+ local stream = getLyricStream();
344+ local handle = luavsq.Handle.new( stream, 1, {} );
345+ local expected =
346+ "[h#0001]\n" ..
347+ "L0=\"あ\",\"a\",0.4,0,1\n" ..
348+ "L1=\"は\",\"h a\",0.6,64,0,0";
349+ assert_equal( expected, handle:toString() );
350+end
351+
352+function testVibratoToString()
353+ local stream = getVibratoStream();
354+ local handle = luavsq.Handle.new( stream, 1, {} );
355+ local expected =
356+ "[h#0001]\n" ..
357+ "IconID=$04040004\n" ..
358+ "IDS=normal-da-yo\n" ..
359+ "Original=5\n" ..
360+ "Caption=キャプションです=あ\n" ..
361+ "Length=120\n" ..
362+ "StartDepth=64\n" ..
363+ "DepthBPNum=3\n" ..
364+ "DepthBPX=0.500000,0.750000,1.000000\n" ..
365+ "DepthBPY=64,32,0\n" ..
366+ "StartRate=64\n" ..
367+ "RateBPNum=3\n" ..
368+ "RateBPX=0.500000,0.750000,1.000000\n" ..
369+ "RateBPY=64,32,0";
370+ assert_equal( expected, handle:toString() );
371+
372+ handle.rateBP = luavsq.VibratoBPList.new( {}, {} );
373+ handle.depthBP = luavsq.VibratoBPList.new( {}, {} );
374+ expected =
375+ "[h#0001]\n" ..
376+ "IconID=$04040004\n" ..
377+ "IDS=normal-da-yo\n" ..
378+ "Original=5\n" ..
379+ "Caption=キャプションです=あ\n" ..
380+ "Length=120\n" ..
381+ "StartDepth=64\n" ..
382+ "DepthBPNum=0\n" ..
383+ "StartRate=64\n" ..
384+ "RateBPNum=0";
385+ assert_equal( expected, handle:toString() );
386+end
387+
388+function testSingerToString()
389+ local stream = getSingerStream();
390+ local handle = luavsq.Handle.new( stream, 2, {} );
391+ local expected =
392+ "[h#0002]\n" ..
393+ "IconID=$07010002\n" ..
394+ "IDS=Miku3\n" ..
395+ "Original=2\n" ..
396+ "Caption=\n" ..
397+ "Length=1\n" ..
398+ "Language=1\n" ..
399+ "Program=2";
400+ assert_equal( expected, handle:toString() );
401+end
402+
403+function testAttackToString()
404+ local stream = getAttackStream();
405+ local handle = luavsq.Handle.new( stream, 3, {} );
406+ local expected =
407+ "[h#0003]\n" ..
408+ "IconID=$01010002\n" ..
409+ "IDS=accent\n" ..
410+ "Original=2\n" ..
411+ "Caption=Accent\n" ..
412+ "Length=120\n" ..
413+ "Duration=64\n" ..
414+ "Depth=63";
415+ assert_equal( expected, handle:toString() );
416+end
417+
418+function testCrescendoToString()
419+ local stream = getCrescendoStream();
420+ local handle = luavsq.Handle.new( stream, 4, {} );
421+ local expected =
422+ "[h#0004]\n" ..
423+ "IconID=$05020001\n" ..
424+ "IDS=Crescendo\n" ..
425+ "Original=4\n" ..
426+ "Caption=Zero Crescendo Curve\n" ..
427+ "StartDyn=2\n" ..
428+ "EndDyn=38\n" ..
429+ "Length=960\n" ..
430+ "DynBPNum=1\n" ..
431+ "DynBPX=0.500000\n" ..
432+ "DynBPY=11";
433+ assert_equal( expected, handle:toString() );
434+
435+ -- dynBPのデータ点が複数
436+ handle.dynBP = luavsq.VibratoBPList.new( { 0.4, 0.8 }, { 1, 2 } );
437+ expected =
438+ "[h#0004]\n" ..
439+ "IconID=$05020001\n" ..
440+ "IDS=Crescendo\n" ..
441+ "Original=4\n" ..
442+ "Caption=Zero Crescendo Curve\n" ..
443+ "StartDyn=2\n" ..
444+ "EndDyn=38\n" ..
445+ "Length=960\n" ..
446+ "DynBPNum=2\n" ..
447+ "DynBPX=0.400000,0.800000\n" ..
448+ "DynBPY=1,2";
449+ assert_equal( expected, handle:toString() );
450+
451+ -- dynBPのデータ点が 0 個
452+ handle.dynBP = luavsq.VibratoBPList.new( {}, {} );
453+ expected =
454+ "[h#0004]\n" ..
455+ "IconID=$05020001\n" ..
456+ "IDS=Crescendo\n" ..
457+ "Original=4\n" ..
458+ "Caption=Zero Crescendo Curve\n" ..
459+ "StartDyn=2\n" ..
460+ "EndDyn=38\n" ..
461+ "Length=960\n" ..
462+ "DynBPNum=0";
463+ assert_equal( expected, handle:toString() );
464+
465+ -- dynBPがnil
466+ handle.dynBP = nil;
467+ assert_equal( expected, handle:toString() );
468+end
469+
470+function testGetHandleIndexFromString()
471+ assert_equal( 2, luavsq.Handle.getHandleIndexFromString( "h#0002" ) );
472+end
--- luavsq/trunk/test/IconDynamicsHandleTest.lua (nonexistent)
+++ luavsq/trunk/test/IconDynamicsHandleTest.lua (revision 1756)
@@ -0,0 +1,131 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../Handle.lua" );
4+dofile( "../IconDynamicsHandle.lua" );
5+dofile( "../ArticulationType.lua" );
6+dofile( "../IconParameter.lua" );
7+dofile( "../VibratoBPList.lua" );
8+dofile( "../VibratoBPPair.lua" );
9+dofile( "../HandleType.lua" );
10+module( "enhanced", package.seeall, lunit.testcase );
11+
12+function testConstruct()
13+ local handle = luavsq.IconDynamicsHandle.new();
14+ assert_equal( luavsq.ArticulationType.Dynaff, handle.articulation );
15+end
16+
17+function testIsDynaffType()
18+ local handle = luavsq.IconDynamicsHandle.new();
19+ handle.iconID = nil;
20+ assert_false( handle:isDynaffType() );
21+ handle.iconID = "$05000000";
22+ assert_false( handle:isDynaffType() );
23+ handle.iconID = "$05010000";
24+ assert_true( handle:isDynaffType() );
25+end
26+
27+function testIsCrescendType()
28+ local handle = luavsq.IconDynamicsHandle.new();
29+ handle.iconID = nil;
30+ assert_false( handle:isCrescendType() );
31+ handle.iconID = "$05000000";
32+ assert_false( handle:isCrescendType() );
33+ handle.iconID = "$05020000";
34+ assert_true( handle:isCrescendType() );
35+end
36+
37+function testIsDecrescendType()
38+ local handle = luavsq.IconDynamicsHandle.new();
39+ handle.iconID = nil;
40+ assert_false( handle:isDecrescendType() );
41+ handle.iconID = "$05000000";
42+ assert_false( handle:isDecrescendType() );
43+ handle.iconID = "$05030000";
44+ assert_true( handle:isDecrescendType() );
45+end
46+
47+function testClone()
48+ local handle = luavsq.IconDynamicsHandle.new();
49+ handle.iconID = "$05010000";
50+ handle.ids = "foo";
51+ handle.original = 1;
52+ handle.caption = "bar";
53+ handle.startDyn = 2;
54+ handle.endDyn = 3;
55+ handle.length = 4;
56+ handle.dynBP = nil;
57+ local copy = handle:clone();
58+ assert_equal( "$05010000", copy.iconID );
59+ assert_equal( "foo", copy.ids );
60+ assert_equal( 1, copy.original );
61+ assert_equal( "bar", copy.caption );
62+ assert_equal( 2, copy:getStartDyn() );
63+ assert_equal( 3, copy:getEndDyn() );
64+ assert_equal( 4, copy:getLength() );
65+ assert_nil( copy:getDynBP() );
66+
67+ local dynBP = luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 1, 64 } );
68+ handle:setDynBP( dynBP );
69+ copy = handle:clone();
70+ assert_equal( "0=1,1=64", copy:getDynBP():getData() );
71+end
72+
73+function testCastToHandle()
74+ local handle = luavsq.IconDynamicsHandle.new();
75+ handle.iconID = "$05010000";
76+ handle.ids = "foo";
77+ handle.original = 1;
78+ handle.caption = "bar";
79+ handle.dynBP = nil;
80+ handle.startDyn = 2;
81+ handle.endDyn = 3;
82+ handle.length = 4;
83+ local casted = handle:castToHandle();
84+ assert_equal( "$05010000", casted.iconID );
85+ assert_equal( "foo", casted.ids );
86+ assert_equal( 1, casted.original );
87+ assert_equal( "bar", casted.caption );
88+ assert_equal( nil, casted.dynBP );
89+ assert_equal( 2, casted.startDyn );
90+ assert_equal( 3, casted.endDyn );
91+ assert_equal( 4, casted.length );
92+end
93+
94+function testGetterAndSetterCaption()
95+ local handle = luavsq.IconDynamicsHandle.new();
96+ handle:setCaption( "foo" );
97+ assert_equal( "foo", handle:getCaption() );
98+end
99+
100+function testGetterAndSetterLength()
101+ local handle = luavsq.IconDynamicsHandle.new();
102+ local expected = 100;
103+ assert_not_equal( expected, handle:getLength() );
104+ handle:setLength( expected );
105+ assert_equal( expected, handle:getLength() );
106+end
107+
108+function testGetterAndSetterStartDyn()
109+ local handle = luavsq.IconDynamicsHandle.new();
110+ local expected = 100;
111+ assert_not_equal( expected, handle:getStartDyn() );
112+ handle:setStartDyn( expected );
113+ assert_equal( expected, handle:getStartDyn() );
114+end
115+
116+function testGetterAndSetterEndDyn()
117+ local handle = luavsq.IconDynamicsHandle.new();
118+ local expected = 100;
119+ assert_not_equal( expected, handle:getEndDyn() );
120+ handle:setEndDyn( expected );
121+ assert_equal( expected, handle:getEndDyn() );
122+end
123+
124+function testGetterAndSetterDynBP()
125+ local handle = luavsq.IconDynamicsHandle.new();
126+ local dynBP = luavsq.VibratoBPList.new( { 0.0, 1.0 }, { 1, 2 } );
127+ handle:setDynBP( nil );
128+ assert_nil( handle:getDynBP() );
129+ handle:setDynBP( dynBP );
130+ assert_equal( "0=1,1=2", handle:getDynBP():getData() );
131+end
--- luavsq/trunk/test/LyricHandleTest.lua (nonexistent)
+++ luavsq/trunk/test/LyricHandleTest.lua (revision 1756)
@@ -0,0 +1,52 @@
1+require( "lunit" );
2+dofile( "../Util.lua" );
3+dofile( "../HandleType.lua" );
4+dofile( "../Handle.lua" );
5+dofile( "../ArticulationType.lua" );
6+dofile( "../Lyric.lua" );
7+dofile( "../LyricHandle.lua" );
8+dofile( "../PhoneticSymbol.lua" );
9+module( "enhanced", package.seeall, lunit.testcase );
10+
11+function testConstruct()
12+ local handle = luavsq.LyricHandle.new();
13+ assert_equal( 0, handle.index );
14+ assert_equal( 1, handle:getCount() );
15+ assert_equal( "a", handle:getLyricAt( 0 ).phrase );
16+ assert_equal( "a", handle:getLyricAt( 0 ):getPhoneticSymbol() );
17+end
18+
19+function testConstructWithPhrase()
20+ local handle = luavsq.LyricHandle.new( "は", "h a" );
21+ assert_equal( 0, handle.index );
22+ assert_equal( 1, handle:getCount() );
23+ assert_equal( "は", handle:getLyricAt( 0 ).phrase );
24+ assert_equal( "h a", handle:getLyricAt( 0 ):getPhoneticSymbol() );
25+end
26+
27+function testGetterAndSetterLyric()
28+ local handle = luavsq.LyricHandle.new( "は", "h a" );
29+ local lyric = luavsq.Lyric.new( "ら", "4 a" );
30+ handle:setLyricAt( 1, lyric );
31+ assert_equal( 2, handle:getCount() );
32+ assert_true( handle:getLyricAt( 1 ):equals( lyric ) );
33+end
34+
35+function testClone()
36+ local handle = luavsq.LyricHandle.new( "ら", "4 a" );
37+ handle.index = 10;
38+ local copy = handle:clone();
39+ assert_equal( handle.index, copy.index );
40+ assert_true( handle:getLyricAt( 0 ):equals( copy:getLyricAt( 0 ) ) );
41+end
42+
43+function testCastToHandle()
44+ local lyricHandle = luavsq.LyricHandle.new( "ら", "4 a" );
45+ lyricHandle.index = 10;
46+ local handle = lyricHandle:castToHandle();
47+ assert_equal( luavsq.HandleType.Lyric, handle._type );
48+ assert_equal( 1, #handle.lyrics );
49+ assert_equal( "ら", handle.lyrics[1].phrase );
50+ assert_equal( "4 a", handle.lyrics[1]:getPhoneticSymbol() );
51+ assert_equal( 10, handle.index );
52+end
--- luavsq/trunk/PhoneticSymbol.lua (nonexistent)
+++ luavsq/trunk/PhoneticSymbol.lua (revision 1756)
@@ -0,0 +1,101 @@
1+--[[
2+ PhoneticSymbol.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.PhoneticSymbol )then
20+
21+ ---
22+ -- VSQで使用される発音記号の種類や有効性を判定するユーティリティ群です。
23+ luavsq.PhoneticSymbol = {};
24+
25+ ---
26+ -- 日本語の母音発音記号
27+ luavsq.PhoneticSymbol._SYMBOL_VOWEL_JP = "\ta\ti\tM\te\to\t";
28+
29+ ---
30+ -- 日本語の子音発音記号
31+ luavsq.PhoneticSymbol._SYMBOL_CONSONANT_JP = "\tk\tk'\tg\tg'\tN\tN'\ts\tS\tz\tZ\tdz\tdZ\tt\tt'\tts\ttS\td\td'\tn\tJ\th\th\\\tC\tp\\\tp\\'\tb\tb'\tp\tp'\tm\tm'\tj\t4\t4'\tw\tN\\\t";
32+
33+ ---
34+ -- 英語の母音発音記号
35+ luavsq.PhoneticSymbol._SYMBOL_VOWEL_EN = "\t@\tV\te\te\tI\ti:\t{\tO:\tQ\tU\tu:\t@r\teI\taI\tOI\t@U\taU\tI@\te@\tU@\tO@\tQ@\t";
36+
37+ ---
38+ -- 英語の子音発音記号
39+ luavsq.PhoneticSymbol._SYMBOL_CONSONANT_EN = "\tw\tj\tb\td\tg\tbh\tdh\tgh\tdZ\tv\tD\tz\tZ\tm\tn\tN\tr\tl\tl0\tp\tt\tk\tph\tth\tkh\ttS\tf\tT\ts\tS\th\tSil\tAsp\t";
40+
41+ ---
42+ -- 指定した文字列が子音を表す発音記号かどうかを判定します。
43+ -- @param symbol String
44+ -- @return boolean
45+ function luavsq.PhoneticSymbol.isConsonant( symbol )
46+ local search = "\t" .. symbol .. "\t";
47+ local startIndex, endIndex = luavsq.PhoneticSymbol._SYMBOL_CONSONANT_JP:find( search );
48+ if( startIndex ~= nil )then
49+ return true;
50+ else
51+ startIndex, endIndex = luavsq.PhoneticSymbol._SYMBOL_CONSONANT_EN:find( search );
52+ if( startIndex ~= nil )then
53+ return true;
54+ end
55+ end
56+ return false;
57+ end
58+
59+ ---
60+ -- 指定した文字列が母音を表す発音記号かどうかを判定します。
61+ -- @param symbol String
62+ -- @return boolean
63+ function luavsq.PhoneticSymbol.isVowel( symbol )
64+ local search = "\t" .. symbol .. "\t";
65+ local startIndex, endIndex = luavsq.PhoneticSymbol._SYMBOL_VOWEL_JP:find( search );
66+ if( startIndex ~= nil )then
67+ return true;
68+ else
69+ startIndex, endIndex = luavsq.PhoneticSymbol._SYMBOL_VOWEL_EN:find( search );
70+ if( startIndex ~= nil )then
71+ return true;
72+ end
73+ end
74+ return false;
75+ end
76+
77+ ---
78+ -- 指定した文字列が発音記号として有効かどうかを判定します。
79+ -- @param symbol String
80+ -- @return boolean
81+ function luavsq.PhoneticSymbol.isValidSymbol( symbol )
82+ local isVowel = luavsq.PhoneticSymbol.isVowel( symbol );
83+ local isConsonant = luavsq.PhoneticSymbol.isConsonant( symbol );
84+ if( isVowel or isConsonant )then
85+ return true;
86+ end
87+
88+ -- ブレスの判定
89+ local symbolCharacterCount = symbol:len();
90+ if( symbol:find( "br" ) == 1 and symbolCharacterCount > 2 )then
91+ local s = symbol:sub( 3, symbolCharacterCount );
92+ -- br001とかをfalseにするためのチェック
93+ if( nil == tonumber( s ) )then
94+ return false;
95+ else
96+ return true;
97+ end
98+ end
99+ return false;
100+ end
101+end
--- luavsq/trunk/ArticulationType.lua (nonexistent)
+++ luavsq/trunk/ArticulationType.lua (revision 1756)
@@ -0,0 +1,44 @@
1+--[[
2+ IconParameter.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.ArticulationType )then
20+ ---
21+ -- アイコン設定の種類を表します。
22+ luavsq.ArticulationType = {};
23+
24+ ---
25+ -- ビブラート
26+ luavsq.ArticulationType.Vibrato = 0;
27+
28+ ---
29+ -- クレッシェンド、またはデクレッシェンド
30+ luavsq.ArticulationType.Crescendo = 1;
31+
32+ ---
33+ -- ピアノ、フォルテ等の強弱記号
34+ luavsq.ArticulationType.Dynaff = 2;
35+
36+ ---
37+ -- アタック
38+ luavsq.ArticulationType.NoteAttack = 3;
39+
40+ ---
41+ -- NoteTransition(詳細不明)
42+ luavsq.ArticulationType.NoteTransition = 4;
43+
44+end
--- luavsq/trunk/TextStream.lua (nonexistent)
+++ luavsq/trunk/TextStream.lua (revision 1756)
@@ -0,0 +1,138 @@
1+--[[
2+ TextStream.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.TextStream )then
20+
21+ luavsq.TextStream = {};
22+
23+ function luavsq.TextStream.new()
24+ local this = {};
25+ this.array = {};
26+ this.length = 0;
27+ this.position = -1;
28+
29+ ---
30+ -- @return [int]
31+ function this:getPointer()
32+ return self.position;
33+ end
34+
35+ ---
36+ -- @param value [int]
37+ -- @return [void]
38+ function this:setPointer( value )
39+ self.position = value;
40+ end
41+
42+ ---
43+ -- @return [char]
44+ function this:get()
45+ self.position = self.position + 1;
46+ return self.array[self.position + 1];
47+ end
48+
49+ ---
50+ -- @return [string]
51+ function this:readLine()
52+ local sb = "";
53+ -- '\n'が来るまで読み込み
54+ while( self.position + 1 < self.length )do
55+ self.position = self.position + 1;
56+ local c = self.array[self.position + 1];
57+ if( c == "\n" )then
58+ break;
59+ end
60+ sb = sb .. c;
61+ end
62+ return sb;
63+ end
64+
65+ ---
66+ -- @return [bool]
67+ function this:ready()
68+ if( 0 <= self.position + 1 and self.position + 1 < self.length )then
69+ return true;
70+ else
71+ return false;
72+ end
73+ end
74+
75+ ---
76+ -- @param length [int]
77+ -- @return [void]
78+ function this:_ensureCapacity( _length )
79+ if( _length > #self.array )then
80+ local add = _length - #self.array;
81+ for i = 1, add, 1 do
82+ table.insert( self.array, " " );
83+ end
84+ end
85+ end
86+
87+ ---
88+ -- @param str [string]
89+ -- @return [void]
90+ function this:write( str )
91+ local len = str:len();
92+ local newSize = self.position + 1 + len;
93+ local offset = self.position + 1;
94+ self:_ensureCapacity( newSize );
95+ for i = 1, len, 1 do
96+ self.array[offset + i] = str:sub( i, i );
97+ end
98+ self.position = self.position + len;
99+ self.length = math.max( self.length, newSize );
100+ end
101+
102+ ---
103+ -- @param str [string]
104+ -- @return [void]
105+ function this:writeLine( str )
106+ local len = str:len();
107+ local offset = self.position + 1;
108+ local newSize = offset + len + 1;
109+ self:_ensureCapacity( newSize );
110+ for i = 1, len, 1 do
111+ self.array[offset + i] = str:sub( i, i );
112+ end
113+ self.array[offset + len + 1] = "\n";
114+ self.position = self.position + len + 1;
115+ self.length = math.max( self.length, newSize );
116+ end
117+
118+ ---
119+ -- @return [void]
120+ function this:close()
121+ self.array = nil;
122+ self.length = 0;
123+ end
124+
125+ ---
126+ --
127+ function this:toString()
128+ local ret = "";
129+ for i = 1, self.length, 1 do
130+ ret = ret .. self.array[i];
131+ end
132+ return ret;
133+ end
134+
135+ return this;
136+ end
137+
138+end
--- luavsq/trunk/NoteHeadHandle.lua (nonexistent)
+++ luavsq/trunk/NoteHeadHandle.lua (revision 1756)
@@ -0,0 +1,137 @@
1+--[[
2+ NoteHeadHandle.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.NoteHeadHandle )then
20+
21+ luavsq.NoteHeadHandle = {};
22+
23+ function luavsq.NoteHeadHandle.new( ... )
24+ local arguments = { ... };
25+ local this = luavsq.IconParameter.new();
26+
27+ this.articulation = luavsq.ArticulationType.NoteAttack;
28+ this.index = 0;
29+ this.iconID = "";
30+ this.ids = "";
31+ this.original = 0;
32+
33+ ---
34+ -- @return [String]
35+ function this:toString()
36+ return self:getDisplayString();
37+ end
38+
39+ ---
40+ -- @return [int]
41+ function this:getDepth()
42+ return self.depth;
43+ end
44+
45+ ---
46+ -- @param value [int]
47+ -- @return [void]
48+ function this:setDepth( value )
49+ self.depth = value;
50+ end
51+
52+ ---
53+ -- @return [int]
54+ function this:getDuration()
55+ return self.duration;
56+ end
57+
58+ ---
59+ -- @param value [int]
60+ -- @return [void]
61+ function this:setDuration( value )
62+ self.duration = value;
63+ end
64+
65+ ---
66+ -- @return [String]
67+ function this:getCaption()
68+ return self.caption;
69+ end
70+
71+ ---
72+ -- @param value [String]
73+ -- @return [void]
74+ function this:setCaption( value )
75+ self.caption = value;
76+ end
77+
78+ ---
79+ -- @return [int]
80+ function this:getLength()
81+ return self.length;
82+ end
83+
84+ ---
85+ -- @param value [int]
86+ -- @return [void]
87+ function this:setLength( value )
88+ self.length = value;
89+ end
90+
91+ ---
92+ -- @return [String]
93+ function this:getDisplayString()
94+ return self.ids .. self.caption;
95+ end
96+
97+ ---
98+ -- @return [object]
99+ function this:clone()
100+ local result = luavsq.NoteHeadHandle.new();
101+ result.index = self.index;
102+ result.iconID = self.iconID;
103+ result.ids = self.ids;
104+ result.original = self.original;
105+ result:setCaption( self:getCaption() );
106+ result:setLength( self:getLength() );
107+ result:setDuration( self:getDuration() );
108+ result:setDepth( self:getDepth() );
109+ return result;
110+ end
111+
112+ ---
113+ -- @return [VsqHandle]
114+ function this:castToHandle()
115+ local ret = luavsq.Handle.new();
116+ ret._type = luavsq.HandleType.NoteHeadHandle;
117+ ret.index = self.index;
118+ ret.iconID = self.iconID;
119+ ret.ids = self.ids;
120+ ret.original = self.original;
121+ ret.caption = self:getCaption();
122+ ret:setLength( self:getLength() );
123+ ret.duration = self:getDuration();
124+ ret.depth = self:getDepth();
125+ return ret;
126+ end
127+
128+ if( #arguments == 3 )then
129+ this.ids = arguments[1];
130+ this.iconID = arguments[2];
131+ this.index = arguments[3];
132+ end
133+
134+ return this;
135+ end
136+
137+end
--- luavsq/trunk/IconHandle.lua (nonexistent)
+++ luavsq/trunk/IconHandle.lua (revision 1756)
@@ -0,0 +1,116 @@
1+--[[
2+ IconHandle.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.IconHandle )then
20+
21+ ---
22+ -- 歌手設定を表します。
23+ luavsq.IconHandle = {};
24+
25+ ---
26+ -- 新しい歌手設定のインスタンスを初期化します。
27+ function luavsq.IconHandle.new()
28+ local this = {};
29+
30+ ---
31+ -- キャプション。
32+ this.caption = "";
33+
34+ ---
35+ -- この歌手設定を一意に識別するためのIDです。
36+ this.iconID = "";
37+
38+ ---
39+ -- ユーザ・フレンドリー名。
40+ -- このフィールドの値は、他の歌手設定のユーザ・フレンドリー名と重複する場合があります。
41+ this.ids = "";
42+
43+ this.index = 0;
44+
45+ ---
46+ -- ゲートタイム長さ。
47+ this.length = 0;
48+
49+ this.original = 0;
50+ this.program = 0;
51+ this.language = 0;
52+
53+ ---
54+ -- ゲートタイム長さを取得します。
55+ -- @return [int]
56+ function this:getLength()
57+ return self.length;
58+ end
59+
60+ ---
61+ -- ゲートタイム長さを設定します。
62+ -- @param value [int]
63+ -- @return [void]
64+ function this:setLength( value )
65+ self.length = value;
66+ end
67+
68+ ---
69+ -- このインスタンスと、指定された歌手変更のインスタンスが等しいかどうかを判定します。
70+ -- @param item [IconHandle] 比較対象の歌手変更。
71+ -- @returns [bool] このインスタンスと、比較対象の歌手変更が等しければtrue、そうでなければfalseを返します。
72+ function this:equals( item )
73+ if( nil == item )then
74+ return false;
75+ else
76+ return self.iconID == item.iconID;
77+ end
78+ end
79+
80+ ---
81+ -- このインスタンスのコピーを作成します。
82+ -- @return [object]
83+ function this:clone()
84+ local ret = luavsq.IconHandle.new();
85+ ret.caption = self.caption;
86+ ret.iconID = self.iconID;
87+ ret.ids = self.ids;
88+ ret.index = self.index;
89+ ret.language = self.language;
90+ ret:setLength( self.length );
91+ ret.original = self.original;
92+ ret.program = self.program;
93+ return ret;
94+ end
95+
96+ ---
97+ -- この歌手設定のインスタンスを、Handleに型キャストします。
98+ -- @return (luavsq.Handle)
99+ function this:castToHandle()
100+ local ret = luavsq.Handle.new();
101+ ret._type = luavsq.HandleType.Singer;
102+ ret.caption = self.caption;
103+ ret.iconID = self.iconID;
104+ ret.ids = self.ids;
105+ ret.index = self.index;
106+ ret.language = self.language;
107+ ret:setLength( self.length );
108+ ret.program = self.program;
109+ ret.original = self.original;
110+ return ret;
111+ end
112+
113+ return this;
114+ end
115+
116+end
--- luavsq/trunk/VibratoBPPair.lua (nonexistent)
+++ luavsq/trunk/VibratoBPPair.lua (revision 1756)
@@ -0,0 +1,60 @@
1+--[[
2+ VibratoBPPair.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.VibratoBPPair )then
20+
21+ luavsq.VibratoBPPair = {};
22+
23+ function luavsq.VibratoBPPair.new( ... )
24+ local arguments = { ... };
25+ local this = {};
26+ this.x = 0.0;
27+ this.y = 0;
28+ if( #arguments == 2 )then
29+ this.x = arguments[1];
30+ this.y = arguments[2];
31+ end
32+
33+ ---
34+ -- この VibratoBPPair のインスタンスと、引数で指定されたインスタンスを比較する
35+ -- @param item (luavsq.VibratoBPPair)
36+ -- @return (integer)
37+ function this:compareTo( item )
38+ local v = self.x - item.x;
39+ if( v > 0.0 )then
40+ return 1;
41+ elseif( v < 0.0 )then
42+ return -1;
43+ end
44+ return 0;
45+ end
46+
47+ return this;
48+ end
49+
50+ ---
51+ -- 引数で与えられた 2 つのインスタンスの順序比較し、第 1 引数のものが第 2 引数のものより大きければ 1 を返す。
52+ -- 小さければ -1 を返す。同順であれば 0 を返す。
53+ -- @param a (luavsq.VibratoBPPair)
54+ -- @param b (luavsq.VibratoBPPair)
55+ -- @return (integer)
56+ function luavsq.VibratoBPPair.compare( a, b )
57+ return a:compareTo( b );
58+ end
59+
60+end
--- luavsq/trunk/Lyric.lua (revision 1755)
+++ luavsq/trunk/Lyric.lua (revision 1756)
@@ -36,8 +36,8 @@
3636 this.phrase = "a";
3737 this.lengthRatio = 1.0;
3838 this.isProtected = false;
39- this._phoneticSymbol = {};
40- this._consonantAdjustment = {};
39+ this._phoneticSymbol = { "a" };
40+ this._consonantAdjustment = { 0 };
4141
4242 ---
4343 -- @param line String
@@ -185,7 +185,7 @@
185185 for i = 2, #arr, 1 do
186186 ret = ret .. " " .. arr[i];
187187 end
188- return ret;
188+ return "" .. ret;
189189 end
190190
191191 ---
@@ -212,7 +212,7 @@
212212 self._consonantAdjustment = luavsq.Util.array( #self._phoneticSymbol );
213213 for i = 1, #self._phoneticSymbol, 1 do
214214 local consonantAdjustment;
215- if( luavsq.VsqPhoneticSymbol.isConsonant( self._phoneticSymbol[i] ) )then
215+ if( luavsq.PhoneticSymbol.isConsonant( self._phoneticSymbol[i] ) )then
216216 consonantAdjustment = 64;
217217 else
218218 consonantAdjustment = 0;
@@ -248,7 +248,9 @@
248248 result._phoneticSymbol[i] = self._phoneticSymbol[i];
249249 end
250250 result.lengthRatio = self.lengthRatio;
251- if( self._consonantAdjustment ~= nil )then
251+ if( nil == self._consonantAdjustment )then
252+ result._consonantAdjustment = nil;
253+ else
252254 result._consonantAdjustment = luavsq.Util.array( #self._consonantAdjustment );
253255 for i = 1, #self._consonantAdjustment, 1 do
254256 result._consonantAdjustment[i] = self._consonantAdjustment[i];
@@ -275,8 +277,7 @@
275277
276278 ---
277279 -- この歌詞の発音記号を設定します。
278- -- @param value [String]
279- -- @return [void]
280+ -- @param value (string)
280281 function this:setPhoneticSymbol( value )
281282 local s = value:gsub( " ", " " );
282283 self._phoneticSymbol = luavsq.Util.split( s, " " );
@@ -322,7 +323,7 @@
322323 self._consonantAdjustment = luavsq.Util.array( #symbol );
323324 for i = 1, #symbol, 1 do
324325 local consonantAdjustment;
325- if( luavsq.VsqPhoneticSymbol.isConsonant( symbol[i] ) )then
326+ if( luavsq.PhoneticSymbol.isConsonant( symbol[i] ) )then
326327 consonantAdjustment = 64;
327328 else
328329 consonantAdjustment = 0;
--- luavsq/trunk/VibratoHandle.lua (nonexistent)
+++ luavsq/trunk/VibratoHandle.lua (revision 1756)
@@ -0,0 +1,167 @@
1+--[[
2+ VibratoHandle.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+-- requires( IconParameter.lua )
16+-- requires( ArticulationType.lua )
17+-- requires( VibratoBPList.lua )
18+
19+if( nil == luavsq )then
20+ luavsq = {};
21+end
22+
23+if( nil == luavsq.VibratoHandle )then
24+
25+ luavsq.VibratoHandle = {};
26+
27+ function luavsq.VibratoHandle.new()
28+ local this = luavsq.IconParameter.new();
29+ this.articulation = luavsq.ArticulationType.Vibrato;
30+ this.startRate = 64;
31+ this.startDepth = 64;
32+ this.rateBP = luavsq.VibratoBPList.new();
33+ this.depthBP = luavsq.VibratoBPList.new();
34+
35+ ---
36+ -- @return [string]
37+ function this:toString()
38+ return self:getDisplayString();
39+ end
40+
41+ ---
42+ -- @return [VibratoBPList]
43+ function this:getRateBP()
44+ return self.rateBP;
45+ end
46+
47+ ---
48+ -- @param value [VibratoBPList]
49+ -- @return [void]
50+ function this:setRateBP( value )
51+ self.rateBP = value;
52+ end
53+
54+ ---
55+ -- @return [string]
56+ function this:getCaption()
57+ return self.caption;
58+ end
59+
60+ ---
61+ -- @param value [string]
62+ -- @return [void]
63+ function this:setCaption( value )
64+ self.caption = value;
65+ end
66+
67+ ---
68+ -- @return [int]
69+ function this:getStartRate()
70+ return self.startRate;
71+ end
72+
73+ ---
74+ -- @param value [int]
75+ -- @return [void]
76+ function this:setStartRate( value )
77+ self.startRate = value;
78+ end
79+
80+ ---
81+ -- @return [VibratoBPList]
82+ function this:getDepthBP()
83+ return self.depthBP;
84+ end
85+
86+ ---
87+ -- @param value [VibratoBPList]
88+ -- @return [void]
89+ function this:setDepthBP( value )
90+ self.depthBP = value;
91+ end
92+
93+ ---
94+ -- @return [int]
95+ function this:getStartDepth()
96+ return self.startDepth;
97+ end
98+
99+ ---
100+ -- @param value [int]
101+ -- @return [void]
102+ function this:setStartDepth( value )
103+ self.startDepth = value;
104+ end
105+
106+ ---
107+ -- @return [int]
108+ function this:getLength()
109+ return self.length;
110+ end
111+
112+ ---
113+ -- @param value [int]
114+ -- @return [void]
115+ function this:setLength( value )
116+ self.length = value;
117+ end
118+
119+ ---
120+ -- @return [string]
121+ function this:getDisplayString()
122+ return self.caption;
123+ end
124+
125+ ---
126+ -- @return [object]
127+ function this:clone()
128+ local result = luavsq.VibratoHandle.new();
129+ result.index = self.index;
130+ result.iconID = self.iconID;
131+ result.ids = self.ids;
132+ result.original = self.original;
133+ result:setCaption( self.caption );
134+ result:setLength( self:getLength() );
135+ result:setStartDepth( self.startDepth );
136+ if( nil ~= self.depthBP )then
137+ result:setDepthBP( self.depthBP:clone() );
138+ end
139+ result:setStartRate( self.startRate );
140+ if( nil ~= self.rateBP )then
141+ result:setRateBP( self.rateBP:clone() );
142+ end
143+ return result;
144+ end
145+
146+ ---
147+ -- @return [VsqHandle]
148+ function this:castToHandle()
149+ local ret = luavsq.Handle.new();
150+ ret._type = luavsq.HandleType.Vibrato;
151+ ret.index = self.index;
152+ ret.iconID = self.iconID;
153+ ret.ids = self.ids;
154+ ret.original = self.original;
155+ ret.caption = self.caption;
156+ ret:setLength( self:getLength() );
157+ ret.startDepth = self.startDepth;
158+ ret.startRate = self.startRate;
159+ ret.depthBP = self.depthBP:clone();
160+ ret.rateBP = self.rateBP:clone();
161+ return ret;
162+ end
163+
164+ return this;
165+ end
166+
167+end
--- luavsq/trunk/VibratoBPList.lua (nonexistent)
+++ luavsq/trunk/VibratoBPList.lua (revision 1756)
@@ -0,0 +1,178 @@
1+--[[
2+ VibratoBPList.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+-- requires( Util.lua )
16+-- requires( VibratoBPPair.lua )
17+
18+if( nil == luavsq )then
19+ luavsq = {};
20+end
21+
22+if( nil == luavsq.VibratoBPList )then
23+
24+ luavsq.VibratoBPList = {};
25+
26+ function luavsq.VibratoBPList.new( ... )
27+ local arguments = { ... };
28+ local this = {};
29+ this._list = {};
30+
31+ ---
32+ -- @param strNum (string)
33+ -- @param strBPX (string)
34+ -- @param strBPY (string)
35+ function this:_init_3( strNum, strBPX, strBPY )
36+ local num = tonumber( strNum );
37+ if( nil == num )then
38+ num = 0;
39+ end
40+ local bpx = luavsq.Util.split( strBPX, ',' );
41+ local bpy = luavsq.Util.split( strBPY, ',' );
42+ local actNum = math.min( num, math.min( #bpx, #bpy ) );
43+ if( actNum > 0 )then
44+ local x = luavsq.Util.array( actNum );
45+ local y = luavsq.Util.array( actNum );
46+ for i = 1, actNum, 1 do
47+ x[i] = tonumber( bpx[i] );
48+ y[i] = tonumber( bpy[i] );
49+ end
50+
51+ local len = math.min( #x, #y );
52+ for i = 1, len, 1 do
53+ self._list[i] = luavsq.VibratoBPPair.new( x[i], y[i] );
54+ end
55+ table.sort( self._list, luavsq.VibratoBPList._comparator );
56+ end
57+ end
58+
59+ ---
60+ -- @param x (table<float>)
61+ -- @param y (table<integer>)
62+ function this:_init_2( x, y )
63+ local len = math.min( #x, #y );
64+ for i = 1, len, 1 do
65+ self._list[i] = luavsq.VibratoBPPair.new( x[i], y[i] );
66+ end
67+ local comparator = function( a, b )
68+ if( a:compareTo( b ) < 0 )then
69+ return true;
70+ else
71+ return false;
72+ end
73+ end
74+ table.sort( self._list, luavsq.VibratoBPList._comparator );
75+ end
76+
77+ ---
78+ -- @param x [float]
79+ -- @param defaultValue [int]
80+ -- @return [int]
81+ function this:getValue( x, defaultValue )
82+ if( #self._list <= 0 )then
83+ return defaultValue;
84+ end
85+ local index = -1;
86+ for i = 1, #self._list, 1 do
87+ if( x < self._list[i].x )then
88+ break;
89+ end
90+ index = i;
91+ end
92+ if( index == -1 )then
93+ return defaultValue;
94+ else
95+ return self._list[index].y;
96+ end
97+ end
98+
99+ ---
100+ -- @return [object]
101+ function this:clone()
102+ local ret = luavsq.VibratoBPList.new();
103+ for i = 1, #self._list, 1 do
104+ ret._list[i] = luavsq.VibratoBPPair.new( self._list[i].x, self._list[i].y );
105+ end
106+ return ret;
107+ end
108+
109+ ---
110+ -- @return (integer)
111+ function this:getCount()
112+ return #self._list;
113+ end
114+
115+ ---
116+ -- @param index (integer) 0から始まるインデックス
117+ -- @return (luavsq.VibratoBPPair)
118+ function this:getElement( index )
119+ return self._list[index + 1];
120+ end
121+
122+ ---
123+ -- @param index (integer) 0から始まるインデックス
124+ -- @param value (luavsq.VibratoBPPair)
125+ function this:setElement( index, value )
126+ self._list[index + 1] = value;
127+ end
128+
129+ ---
130+ -- @return (string)
131+ function this:getData()
132+ local ret = "";
133+ for i = 1, #self._list, 1 do
134+ if( i > 1 )then
135+ ret = ret .. ",";
136+ end
137+ ret = ret .. self._list[i].x .. "=" .. self._list[i].y;
138+ end
139+ return ret;
140+ end
141+
142+ ---
143+ -- @param value [String]
144+ -- @return [void]
145+ function this:setData( value )
146+ self._list = {};
147+ local spl = luavsq.Util.split( value, ',' );
148+ local j = 1
149+ for i = 1, #spl, 1 do
150+ local spl2 = luavsq.Util.split( spl[i], '=' );
151+ if( #spl2 >= 2 )then
152+ self._list[j] = luavsq.VibratoBPPair.new( tonumber( spl2[1] ), tonumber( spl2[2] ) );
153+ j = j + 1
154+ end
155+ end
156+ table.sort( self._list, luavsq.VibratoBPList._comparator );
157+ end
158+
159+ if( #arguments == 3 )then
160+ this:_init_3( arguments[1], arguments[2], arguments[3] );
161+ elseif( #arguments == 2 )then
162+ this:_init_2( arguments[1], arguments[2] );
163+ end
164+
165+ return this;
166+ end
167+
168+ ---
169+ -- @param a (luavsq.VibratoBPPair)
170+ -- @param b (luavsq.VibratoBPPair)
171+ function luavsq.VibratoBPList._comparator( a, b )
172+ if( a:compareTo( b ) < 0 )then
173+ return true;
174+ else
175+ return false;
176+ end
177+ end
178+end
--- luavsq/trunk/IconParameter.lua (nonexistent)
+++ luavsq/trunk/IconParameter.lua (revision 1756)
@@ -0,0 +1,97 @@
1+--[[
2+ IconParameter.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+-- requires( ArticulationType.lua )
16+
17+if( nil == luavsq )then
18+ luavsq = {};
19+end
20+
21+if( nil == luavsq.IconParameter )then
22+
23+ ---
24+ -- アイコン設定ファイルである*.AICファイルを読み取ることで作成されるアイコン設定を表します。
25+ -- アイコン設定ファイルを使用するIconDynamicsHandle、NoteHeadHandle、およびVibratoHandleの基底クラスとなっています。
26+ luavsq.IconParameter = {};
27+
28+ function luavsq.IconParameter.new()
29+ local this = {};
30+
31+ ---
32+ -- アイコン設定の種類
33+ -- @var (luavsq.ArticulationType)
34+ this.articulation = luavsq.ArticulationType.Dynaff;
35+
36+ ---
37+ -- アイコンのボタンに使用される画像ファイルへの相対パス
38+ this.button = "";
39+
40+ ---
41+ -- キャプション
42+ this.caption = "";
43+
44+ ---
45+ -- ゲートタイム長さ
46+ this.length = 0;
47+
48+ ---
49+ -- ビブラート深さの開始値
50+ this.startDepth = 64;
51+
52+ ---
53+ -- ビブラート深さの終了値
54+ this.endDepth = 64;
55+
56+ ---
57+ -- ビブラート速さの開始値
58+ this.startRate = 64;
59+
60+ ---
61+ -- ビブラート速さの終了値
62+ this.endRate = 64;
63+
64+ this.startDyn = 64;
65+ this.endDyn = 64;
66+ this.duration = 1;
67+ this.depth = 64;
68+ this.dynBP = nil;
69+ this.depthBP = nil;
70+ this.rateBP = nil;
71+ this.buttonImageFullPath = "";
72+
73+ --TODO: AIC ファイルからのコンストラクタを追加する
74+
75+ ---
76+ -- @return [String]
77+ function this:getButton()
78+ return self.button;
79+ end
80+
81+ ---
82+ -- @return [String]
83+ function this:getButtonImageFullPath()
84+ return self.buttonImageFullPath;
85+ end
86+
87+ ---
88+ -- @param value [String]
89+ -- @return [void]
90+ function this:setButtonImageFullPath( value )
91+ self.buttonImageFullPath = value;
92+ end
93+
94+ return this;
95+ end
96+
97+end
--- luavsq/trunk/Handle.lua (nonexistent)
+++ luavsq/trunk/Handle.lua (revision 1756)
@@ -0,0 +1,383 @@
1+--[[
2+ Handle.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.Handle )then
20+
21+ ---
22+ -- ハンドルを取り扱います。ハンドルにはLyricHandle、VibratoHandle、IconHandleおよびNoteHeadHandleがある
23+ luavsq.Handle = {};
24+
25+ function luavsq.Handle.new( ... )
26+ local arguments = { ... };
27+ local this = {};
28+ this._type = luavsq.HandleType.Lyric;
29+ this.index = 0;
30+ this.iconID = "";
31+ this.ids = "";
32+ this.lyrics = {};
33+ this.original = 0;
34+ this.caption = "";
35+ this.length = 0;
36+ this.startDepth = 0;
37+ this.depthBP = nil;
38+ this.startRate = 0;
39+ this.rateBP = nil;
40+ this.language = 0;
41+ this.program = 0;
42+ this.duration = 0;
43+ this.depth = 0;
44+ this.startDyn = 0;
45+ this.endDyn = 0;
46+ this.dynBP = nil;
47+
48+ ---
49+ -- 歌詞・発音記号列の前後にクォーテーションマークを付けるかどうか
50+ this.addQuotationMark = true;
51+
52+ ---
53+ -- @return [int]
54+ function this:getLength()
55+ return self.length;
56+ end
57+
58+ ---
59+ -- @param value [int]
60+ -- @return [void]
61+ function this:setLength( value )
62+ self.length = value;
63+ end
64+
65+ ---
66+ -- @return (luavsq.LyricHandle)
67+ function this:castToLyricHandle()
68+ local ret = luavsq.LyricHandle.new();
69+ ret.index = self.index;
70+ ret.lyrics = self.lyrics;
71+ return ret;
72+ end
73+
74+ ---
75+ -- @return (luavsq.VibratoHandle)
76+ function this:castToVibratoHandle()
77+ local ret = luavsq.VibratoHandle.new();
78+ ret.index = self.index;
79+ ret:setCaption( self.caption );
80+ ret:setDepthBP( self.depthBP );
81+ ret.iconID = self.iconID;
82+ ret.ids = self.ids;
83+ ret:setLength( self.length );
84+ ret.original = self.original;
85+ ret:setRateBP( self.rateBP );
86+ ret:setStartDepth( self.startDepth );
87+ ret:setStartRate( self.startRate );
88+ return ret;
89+ end
90+
91+ ---
92+ -- @return [IconHandle]
93+ function this:castToIconHandle()
94+ local ret = luavsq.IconHandle.new();
95+ ret.index = self.index;
96+ ret.caption = self.caption;
97+ ret.iconID = self.iconID;
98+ ret.ids = self.ids;
99+ ret.language = self.language;
100+ ret:setLength( self.length );
101+ ret.original = self.original;
102+ ret.program = self.program;
103+ return ret;
104+ end
105+
106+ ---
107+ -- @return [NoteHeadHandle]
108+ function this:castToNoteHeadHandle()
109+ local ret = luavsq.NoteHeadHandle.new();
110+ ret:setCaption( self.caption );
111+ ret:setDepth( self.depth );
112+ ret:setDuration( self.duration );
113+ ret.iconID = self.iconID;
114+ ret.ids = self.ids;
115+ ret:setLength( self:getLength() );
116+ ret.original = self.original;
117+ return ret;
118+ end
119+
120+ ---
121+ -- @return [IconDynamicsHandle]
122+ function this:castToIconDynamicsHandle()
123+ local ret = luavsq.IconDynamicsHandle.new();
124+ ret.ids = self.ids;
125+ ret.iconID = self.iconID;
126+ ret.original = self.original;
127+ ret:setCaption( self.caption );
128+ ret:setDynBP( self.dynBP );
129+ ret:setEndDyn( self.endDyn );
130+ ret:setLength( self:getLength() );
131+ ret:setStartDyn( self.startDyn );
132+ return ret;
133+ end
134+
135+ ---
136+ -- インスタンスをストリームに書き込みます。
137+ -- encode=trueの場合、2バイト文字をエンコードして出力します。
138+ -- @param sw [ITextWriter] 書き込み対象
139+ function this:write( sw )
140+ sw:writeLine( self:toString() );
141+ end
142+
143+ ---
144+ -- FileStreamから読み込みながらコンストラクト
145+ -- @param sr [TextStream]読み込み対象
146+ -- @param index [int]
147+ -- @param last_line [ByRef<string>]
148+ function this:_init_3( sr, index, last_line )
149+ self.index = index;
150+ local spl;
151+ local spl2;
152+
153+ -- default値で埋める
154+ self._type = luavsq.HandleType.Vibrato;
155+ self.iconID = "";
156+ self.ids = "normal";
157+ self.lyrics = { luavsq.Lyric.new( "" ) };
158+ self.original = 0;
159+ self.caption = "";
160+ self.length = 0;
161+ self.startDepth = 0;
162+ self.depthBP = null;
163+ self.startRate = 0;
164+ self.rateBP = null;
165+ self.language = 0;
166+ self.program = 0;
167+ self.duration = 0;
168+ self.depth = 64;
169+
170+ local tmpDepthBPX = "";
171+ local tmpDepthBPY = "";
172+ local tmpDepthBPNum = "";
173+
174+ local tmpRateBPX = "";
175+ local tmpRateBPY = "";
176+ local tmpRateBPNum = "";
177+
178+ local tmpDynBPX = "";
179+ local tmpDynBPY = "";
180+ local tmpDynBPNum = "";
181+
182+ -- "["にぶち当たるまで読込む
183+ last_line.value = sr:readLine();
184+ while( last_line.value:find( "[", 1, true ) ~= 1 )do
185+ spl = luavsq.Util.split( last_line.value, '=' );
186+ local search = spl[1];
187+ if( search == "Language" )then
188+ self._type = luavsq.HandleType.Singer;
189+ self.language = tonumber( spl[2], 10 );
190+ elseif( search == "Program" )then
191+ self.program = tonumber( spl[2], 10 );
192+ elseif( search == "IconID" )then
193+ self.iconID = spl[2];
194+ elseif( search == "IDS" )then
195+ self.ids = spl[2];
196+ elseif( search == "Original" )then
197+ self.original = tonumber( spl[2], 10 );
198+ elseif( search == "Caption" )then
199+ self.caption = spl[2];
200+ for i = 3, #spl, 1 do
201+ self.caption = self.caption .. "=" .. spl[i];
202+ end
203+ elseif( search == "Length" )then
204+ self.length = tonumber( spl[2], 10 );
205+ elseif( search == "StartDepth" )then
206+ self.startDepth = tonumber( spl[2], 10 );
207+ elseif( search == "DepthBPNum" )then
208+ tmpDepthBPNum = spl[2];
209+ elseif( search == "DepthBPX" )then
210+ tmpDepthBPX = spl[2];
211+ elseif( search == "DepthBPY" )then
212+ tmpDepthBPY = spl[2];
213+ elseif( search == "StartRate" )then
214+ self._type = luavsq.HandleType.Vibrato;
215+ self.startRate = tonumber( spl[2], 10 );
216+ elseif( search == "RateBPNum" )then
217+ tmpRateBPNum = spl[2];
218+ elseif( search == "RateBPX" )then
219+ tmpRateBPX = spl[2];
220+ elseif( search == "RateBPY" )then
221+ tmpRateBPY = spl[2];
222+ elseif( search == "Duration" )then
223+ self._type = luavsq.HandleType.NoteHead;
224+ self.duration = tonumber( spl[2], 10 );
225+ elseif( search == "Depth" )then
226+ self.depth = tonumber( spl[2], 10 );
227+ elseif( search == "StartDyn" )then
228+ self._type = luavsq.HandleType.Dynamics;
229+ self.startDyn = tonumber( spl[2], 10 );
230+ elseif( search == "EndDyn" )then
231+ self._type = luavsq.HandleType.Dynamics;
232+ self.endDyn = tonumber( spl[2], 10 );
233+ elseif( search == "DynBPNum" )then
234+ tmpDynBPNum = spl[2];
235+ elseif( search == "DynBPX" )then
236+ tmpDynBPX = spl[2];
237+ elseif( search == "DynBPY" )then
238+ tmpDynBPY = spl[2];
239+ elseif( search:find( "L" ) == 1 and search:len() >= 2 )then
240+ local num = search:sub( 2, 2 );
241+ if( nil ~= tonumber( num ) )then
242+ local lyric = luavsq.Lyric.new( spl[2] );
243+ self._type = luavsq.HandleType.Lyric;
244+ local index = tonumber( num );
245+ self.lyrics[index + 1] = lyric;
246+ end
247+ end
248+ if( not sr:ready() )then
249+ break;
250+ end
251+ last_line.value = sr:readLine();
252+ end
253+
254+ -- RateBPX, RateBPYの設定
255+ if( self._type == luavsq.HandleType.Vibrato )then
256+ if( tmpRateBPNum ~= "" )then
257+ self.rateBP = luavsq.VibratoBPList.new( tmpRateBPNum, tmpRateBPX, tmpRateBPY );
258+ else
259+ self.rateBP = luavsq.VibratoBPList.new();
260+ end
261+
262+ -- DepthBPX, DepthBPYの設定
263+ if( tmpDepthBPNum ~= "" )then
264+ self.depthBP = luavsq.VibratoBPList.new( tmpDepthBPNum, tmpDepthBPX, tmpDepthBPY );
265+ else
266+ self.depthBP = luavsq.VibratoBPList.new();
267+ end
268+ else
269+ self.depthBP = luavsq.VibratoBPList.new();
270+ self.rateBP = luavsq.VibratoBPList.new();
271+ end
272+
273+ if( tmpDynBPNum ~= "" )then
274+ self.dynBP = luavsq.VibratoBPList.new( tmpDynBPNum, tmpDynBPX, tmpDynBPY );
275+ else
276+ self.dynBP = luavsq.VibratoBPList.new();
277+ end
278+ end
279+
280+ ---
281+ -- インスタンスを文字列に変換します
282+ -- @return [string] インスタンスを変換した文字列
283+ function this:toString()
284+ local result = "";
285+ result = result .. "[h#" .. string.format( "%04d", self.index ) .. "]";
286+ if( self._type == luavsq.HandleType.Lyric )then
287+ for i = 1, #self.lyrics, 1 do
288+ result = result .. "\n" .. "L" .. (i - 1) .. "=" .. self.lyrics[i]:toString( self.addQuotationMark );
289+ end
290+ elseif( self._type == luavsq.HandleType.Vibrato )then
291+ result = result .. "\n" .. "IconID=" .. self.iconID .. "\n";
292+ result = result .. "IDS=" .. self.ids .. "\n";
293+ result = result .. "Original=" .. self.original .. "\n";
294+ result = result .. "Caption=" .. self.caption .. "\n";
295+ result = result .. "Length=" .. self.length .. "\n";
296+ result = result .. "StartDepth=" .. self.startDepth .. "\n";
297+ result = result .. "DepthBPNum=" .. self.depthBP:getCount() .. "\n";
298+ if( self.depthBP:getCount() > 0 )then
299+ result = result .. "DepthBPX=" .. string.format( "%.6f", self.depthBP:getElement( 0 ).x );
300+ for i = 1, self.depthBP:getCount() - 1, 1 do
301+ result = result .. "," .. string.format( "%.6f", self.depthBP:getElement( i ).x );
302+ end
303+ result = result .. "\n" .. "DepthBPY=" .. self.depthBP:getElement( 0 ).y;
304+ for i = 1, self.depthBP:getCount() - 1, 1 do
305+ result = result .. "," .. self.depthBP:getElement( i ).y;
306+ end
307+ result = result .. "\n";
308+ end
309+ result = result .. "StartRate=" .. self.startRate .. "\n";
310+ result = result .. "RateBPNum=" .. self.rateBP:getCount();
311+ if( self.rateBP:getCount() > 0 )then
312+ result = result .. "\n" .. "RateBPX=" .. string.format( "%.6f", self.rateBP:getElement( 0 ).x );
313+ for i = 1, self.rateBP:getCount() - 1, 1 do
314+ result = result .. "," .. string.format( "%.6f", self.rateBP:getElement( i ).x );
315+ end
316+ result = result .. "\n" .. "RateBPY=" .. self.rateBP:getElement( 0 ).y;
317+ for i = 1, self.rateBP:getCount() - 1, 1 do
318+ result = result .. "," .. self.rateBP:getElement( i ).y;
319+ end
320+ end
321+ elseif( self._type == luavsq.HandleType.Singer )then
322+ result = result .. "\n" .. "IconID=" .. self.iconID .. "\n";
323+ result = result .. "IDS=" .. self.ids .. "\n";
324+ result = result .. "Original=" .. self.original .. "\n";
325+ result = result .. "Caption=" .. self.caption .. "\n";
326+ result = result .. "Length=" .. self.length .. "\n";
327+ result = result .. "Language=" .. self.language .. "\n";
328+ result = result .. "Program=" .. self.program;
329+ elseif( self._type == luavsq.HandleType.NoteHead )then
330+ result = result .. "\n" .. "IconID=" .. self.iconID .. "\n";
331+ result = result .. "IDS=" .. self.ids .. "\n";
332+ result = result .. "Original=" .. self.original .. "\n";
333+ result = result .. "Caption=" .. self.caption .. "\n";
334+ result = result .. "Length=" .. self.length .. "\n";
335+ result = result .. "Duration=" .. self.duration .. "\n";
336+ result = result .. "Depth=" .. self.depth;
337+ elseif( self._type == luavsq.HandleType.Dynamics )then
338+ result = result .. "\n" .. "IconID=" .. self.iconID .. "\n";
339+ result = result .. "IDS=" .. self.ids .. "\n";
340+ result = result .. "Original=" .. self.original .. "\n";
341+ result = result .. "Caption=" .. self.caption .. "\n";
342+ result = result .. "StartDyn=" .. self.startDyn .. "\n";
343+ result = result .. "EndDyn=" .. self.endDyn .. "\n";
344+ result = result .. "Length=" .. self.length .. "\n";
345+ if( nil ~= self.dynBP )then
346+ if( self.dynBP:getCount() <= 0 )then
347+ result = result .. "DynBPNum=0";
348+ else
349+ local c = self.dynBP:getCount();
350+ result = result .. "DynBPNum=" .. c .. "\n";
351+ result = result .. "DynBPX=" .. string.format( "%.6f", self.dynBP:getElement( 0 ).x );
352+ for i = 1, c - 1, 1 do
353+ result = result .. "," .. string.format( "%.6f", self.dynBP:getElement( i ).x );
354+ end
355+ result = result .. "\n" .. "DynBPY=" .. self.dynBP:getElement( 0 ).y;
356+ for i = 1, c - 1, 1 do
357+ result = result .. "," .. self.dynBP:getElement( i ).y;
358+ end
359+ end
360+ else
361+ result = result .. "DynBPNum=0";
362+ end
363+ end
364+ return result;
365+ end
366+
367+ if( #arguments == 3 )then
368+ this:_init_3( arguments[1], arguments[2], arguments[3] );
369+ end
370+
371+ return this;
372+ end
373+
374+ ---
375+ -- ハンドル指定子(例えば"h#0123"という文字列)からハンドル番号を取得します
376+ -- @param _string [string] ハンドル指定子
377+ -- @return [int] ハンドル番号
378+ function luavsq.Handle.getHandleIndexFromString( _string )
379+ local spl = luavsq.Util.split( _string, "#" );
380+ return tonumber( spl[2], 10 );
381+ end
382+
383+end
--- luavsq/trunk/IconDynamicsHandle.lua (nonexistent)
+++ luavsq/trunk/IconDynamicsHandle.lua (revision 1756)
@@ -0,0 +1,185 @@
1+--[[
2+ IconDynamicsHandle.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.IconDynamicsHandle )then
20+
21+ luavsq.IconDynamicsHandle = {};
22+
23+ ---
24+ -- 強弱記号の場合の、IconIDの最初の5文字。
25+ luavsq.IconDynamicsHandle.ICONID_HEAD_DYNAFF = "$0501";
26+
27+ ---
28+ -- クレッシェンドの場合の、IconIDの最初の5文字。
29+ luavsq.IconDynamicsHandle.ICONID_HEAD_CRESCEND = "$0502";
30+
31+ ---
32+ -- デクレッシェンドの場合の、IconIDの最初の5文字。
33+ luavsq.IconDynamicsHandle.ICONID_HEAD_DECRESCEND = "$0503";
34+
35+ function luavsq.IconDynamicsHandle.new()
36+ local this = luavsq.IconParameter.new();
37+
38+ this.articulation = luavsq.ArticulationType.Dynaff;
39+
40+ ---
41+ -- このハンドルが強弱記号を表すものかどうかを表すブール値を取得します。
42+ -- @return [bool]
43+ function this:isDynaffType()
44+ if( nil ~= self.iconID )then
45+ return self.iconID:find( luavsq.IconDynamicsHandle.ICONID_HEAD_DYNAFF ) == 1;
46+ else
47+ return false;
48+ end
49+ end
50+
51+ ---
52+ -- このハンドルがクレッシェンドを表すものかどうかを表すブール値を取得します。
53+ -- @return [bool]
54+ function this:isCrescendType()
55+ if( nil ~= self.iconID )then
56+ return self.iconID:find( luavsq.IconDynamicsHandle.ICONID_HEAD_CRESCEND ) == 1;
57+ else
58+ return false;
59+ end
60+ end
61+
62+ ---
63+ -- このハンドルがデクレッシェンドを表すものかどうかを表すブール値を取得します。
64+ -- @return [bool]
65+ function this:isDecrescendType()
66+ if( nil ~= self.iconID )then
67+ return self.iconID:find( luavsq.IconDynamicsHandle.ICONID_HEAD_DECRESCEND ) == 1;
68+ else
69+ return false;
70+ end
71+ end
72+
73+ ---
74+ -- このインスタンスのコピーを作成します。
75+ -- @return [object]
76+ function this:clone()
77+ local ret = luavsq.IconDynamicsHandle.new();
78+ ret.iconID = self.iconID;
79+ ret.ids = self.ids;
80+ ret.original = self.original;
81+ ret:setCaption( self:getCaption() );
82+ ret:setStartDyn( self:getStartDyn() );
83+ ret:setEndDyn( self:getEndDyn() );
84+ if( nil ~= self.dynBP )then
85+ ret:setDynBP( self.dynBP:clone() );
86+ end
87+ ret:setLength( self:getLength() );
88+ return ret;
89+ end
90+
91+ ---
92+ -- この強弱記号設定のインスタンスを、Handleに型キャストします。
93+ -- @return [VsqHandle]
94+ function this:castToHandle()
95+ local ret = luavsq.Handle.new();
96+ ret._type = luavsq.HandleType.DynamicsHandle;
97+ ret.iconID = self.iconID;
98+ ret.ids = self.ids;
99+ ret.original = self.original;
100+ ret.caption = self:getCaption();
101+ ret.dynBP = self:getDynBP();
102+ ret.endDyn = self:getEndDyn();
103+ ret:setLength( self:getLength() );
104+ ret.startDyn = self:getStartDyn();
105+ return ret;
106+ end
107+
108+ ---
109+ -- キャプションを取得します。
110+ -- @return [string]
111+ function this:getCaption()
112+ return self.caption;
113+ end
114+
115+ ---
116+ -- キャプションを設定します。
117+ -- @param value [string]
118+ -- @return [void]
119+ function this:setCaption( value )
120+ self.caption = value;
121+ end
122+
123+ ---
124+ -- ゲートタイム長さを取得します。
125+ -- @return [int]
126+ function this:getLength()
127+ return self.length;
128+ end
129+
130+ ---
131+ -- ゲートタイム長さを設定します。
132+ -- @param value [int]
133+ -- @return [void]
134+ function this:setLength( value )
135+ self.length = value;
136+ end
137+
138+ ---
139+ -- DYNの開始値を取得します。
140+ -- @return [int]
141+ function this:getStartDyn()
142+ return self.startDyn;
143+ end
144+
145+ ---
146+ -- DYNの開始値を設定します。
147+ -- @param value [int]
148+ function this:setStartDyn( value )
149+ self.startDyn = value;
150+ end
151+
152+ ---
153+ -- DYNの終了値を取得します。
154+ -- @return [int]
155+ function this:getEndDyn()
156+ return self.endDyn;
157+ end
158+
159+ ---
160+ -- DYNの終了値を設定します。
161+ -- @param value [int]
162+ -- @return [void]
163+ function this:setEndDyn( value )
164+ self.endDyn = value;
165+ end
166+
167+ ---
168+ -- DYNカーブを表すリストを取得します。
169+ -- @return [VibratoBPList]
170+ function this:getDynBP()
171+ return self.dynBP;
172+ end
173+
174+ ---
175+ -- DYNカーブを表すリストを設定します。
176+ -- @param value [VibratoBPList]
177+ -- @return [void]
178+ function this:setDynBP( value )
179+ self.dynBP = value;
180+ end
181+
182+ return this;
183+ end
184+
185+end
--- luavsq/trunk/HandleType.lua (nonexistent)
+++ luavsq/trunk/HandleType.lua (revision 1756)
@@ -0,0 +1,29 @@
1+--[[
2+ HandleType.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+if( nil == luavsq )then
16+ luavsq = {};
17+end
18+
19+if( nil == luavsq.HandleType )then
20+
21+ luavsq.HandleType = {};
22+
23+ luavsq.HandleType.Lyric = 0;
24+ luavsq.HandleType.Vibrato = 1;
25+ luavsq.HandleType.Singer = 2;
26+ luavsq.HandleType.NoteHead = 3;
27+ luavsq.HandleType.Dynamics = 4;
28+
29+end
--- luavsq/trunk/LyricHandle.lua (nonexistent)
+++ luavsq/trunk/LyricHandle.lua (revision 1756)
@@ -0,0 +1,98 @@
1+--[[
2+ LyricHandle.lua
3+ Copyright © 2011 kbinani
4+
5+ This file is part of luavsq.
6+
7+ luavsq is free software; you can redistribute it and/or
8+ modify it under the terms of the BSD License.
9+
10+ luavsq is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+]]
14+
15+-- requires( VsqHandleType.lua )
16+-- requires( VsqHandle.lua )
17+-- requires( Lyric.lua )
18+
19+if( nil == luavsq )then
20+ luavsq = {};
21+end
22+
23+if( nil == luavsq.LyricHandle )then
24+
25+ luavsq.LyricHandle = {};
26+
27+ ---
28+ -- type = Lyric用のhandleのコンストラクタ
29+ -- @param phrase (string) 歌詞
30+ -- @param phoneticSymbol (string) 発音記号
31+ function luavsq.LyricHandle.new( ... )
32+ local arguments = { ... };
33+ local this = {};
34+ this.articulation = luavsq.ArticulationType.Vibrato;
35+
36+ ---
37+ -- @var index (integer)
38+ this.index = 0;
39+
40+ ---
41+ -- @var lyrics (table<luavsq.Lyric>)
42+ this.lyrics = {};
43+
44+ if( #arguments >= 2 )then
45+ local phrase = arguments[1];
46+ local phoneticSymbol = arguments[2];
47+ this.lyrics[1] = luavsq.Lyric.new( phrase, phoneticSymbol );
48+ else
49+ this.lyrics[1] = luavsq.Lyric.new();
50+ end
51+
52+ ---
53+ -- @param index (integer) 0 から始まるインデックス
54+ -- @return (luavsq.Lyric)
55+ function this:getLyricAt( index )
56+ return self.lyrics[index + 1];
57+ end
58+
59+ ---
60+ -- @param index (integer) 0 から始まるインデックス
61+ -- @param value (luavsq.Lyric)
62+ function this:setLyricAt( index, value )
63+ self.lyrics[index + 1] = value;
64+ end
65+
66+ ---
67+ -- @return (integer)
68+ function this:getCount()
69+ return #self.lyrics;
70+ end
71+
72+ ---
73+ -- @return (luavsq.LyricHandle)
74+ function this:clone()
75+ local result = luavsq.LyricHandle.new();
76+ result.index = self.index;
77+ result.lyrics = {};
78+ for i = 1, #self.lyrics, 1 do
79+ local buf = self.lyrics[i]:clone();
80+ table.insert( result.lyrics, buf );
81+ end
82+ return result;
83+ end
84+
85+ ---
86+ -- @return (luavsq.Handle)
87+ function this:castToHandle()
88+ local result = luavsq.Handle.new();
89+ result._type = luavsq.HandleType.Lyric;
90+ result.lyrics = self.lyrics;
91+ result.index = self.index;
92+ return result;
93+ end
94+
95+ return this;
96+ end
97+
98+end
旧リポジトリブラウザで表示