• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1967 (tree)
日時2012-01-15 06:42:59
作者kbinani

ログメッセージ

[vConnect/trunk/stand2.0] added: CurveTypeEnum

変更サマリ

差分

--- vConnect/trunk/stand2.0/stand/vsqMetaText/BPList.h (revision 1966)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/BPList.h (revision 1967)
@@ -34,6 +34,13 @@
3434
3535 void setParameter( string left, string right );
3636
37+ /**
38+ * 指定したインデックスにおけるカーブの値を取得する
39+ * @param index インデックス
40+ * @return カーブの値
41+ */
42+ BP get( int index );
43+
3744 private:
3845 vector<BP> data;
3946 };
--- vConnect/trunk/stand2.0/stand/vsqMetaText/Sequence.cpp (revision 1966)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/Sequence.cpp (revision 1967)
@@ -77,13 +77,14 @@
7777
7878 Sequence::Sequence()
7979 {
80- string temp;
81-
82- this->controlCurves.resize( CONTROL_CURVE_NUM );
83-
84- for( vector<BPList>::size_type i = 0; i < this->controlCurves.size(); i++ ){
85- this->controlCurves[i].setParameter( -10000, controlCurveDefaultValue[i] );
86- this->mMapCurves.insert( make_pair( controlCurveName[i], &this->controlCurves[i] ) );
80+ vector<CurveTypeEnum::CurveType> values = CurveTypeEnum::values();
81+ int size = values.size();
82+ this->controlCurves.resize( size );
83+ for( int i = 0; i < size; i++ ){
84+ int defaultValue = CurveTypeEnum::getDefault( values[i] );
85+ string name = CurveTypeEnum::getName( values[i] );
86+ this->controlCurves[i].setParameter( -10000, defaultValue );
87+ this->mMapCurves.insert( make_pair( name, &this->controlCurves[i] ) );
8788 }
8889 }
8990
--- vConnect/trunk/stand2.0/stand/vsqMetaText/vsqBase.h (revision 1966)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/vsqBase.h (revision 1967)
@@ -27,34 +27,6 @@
2727 /* by the value in phoneme DataBase. */
2828 //#define __UTAU_OFFSET__
2929
30-const string controlCurveName[]={
31- "[PitchBendBPList]",
32- "[PitchBendSensBPList]",
33- "[DynamicsBPList]",
34- "[EpRResidualBPList]", /* BRE Curve */
35- "[EpRESlopeBPList]", /* BRI Curve */
36- "[EpRESlopeDepthBPList]", /* CLE Curve */
37- "[GenderFactorBPList]" /* GEN Curve */
38-};
39-const int controlCurveDefaultValue[] = {
40- 0,
41- 2,
42- 64,
43- 0,
44- 64,
45- 0,
46- 64
47-};
48-enum{
49- PITCH_BEND=0,
50- PITCH_BEND_SENS,
51- DYNAMICS,
52- BRETHINESS,
53- BRIGHTNESS,
54- CLEARNESS,
55- GENDER
56-};
57-
5830 const string OBJ_NAME_OTOINI = "[oto.ini]";
5931 const string OBJ_NAME_EVENT_LIST = "[EventList]";
6032 const string OBJ_NAME_TEMPO = "[Tempo]";
--- vConnect/trunk/stand2.0/stand/vsqMetaText/Sequence.h (revision 1966)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/Sequence.h (revision 1967)
@@ -11,6 +11,7 @@
1111 #include "EventList.h"
1212 #include "BPList.h"
1313 #include "vsqTempo.h"
14+#include "CurveTypeEnum.h"
1415 #include "../RuntimeOption.h"
1516 #include "../Socket.h"
1617 #include "../Path.h"
--- vConnect/trunk/stand2.0/stand/vsqMetaText/CurveTypeEnum.h (nonexistent)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/CurveTypeEnum.h (revision 1967)
@@ -0,0 +1,118 @@
1+/**
2+ * CurveTypeEnum.h
3+ * Copyright (C) 2012 kbinani
4+ *
5+ * This file is part of vConnect-STAND.
6+ *
7+ * vConnect-STAND is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU GPL Lisence.
9+ *
10+ * v.Connect 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+#ifndef __CurveTypeEnum_h__
15+#define __CurveTypeEnum_h__
16+
17+namespace vconnect
18+{
19+ /**
20+ * コントロールカーブの種類を表す
21+ */
22+ class CurveTypeEnum
23+ {
24+ public:
25+ enum CurveType
26+ {
27+ PITCH_BEND = 0,
28+ PITCH_BEND_SENS,
29+ DYNAMICS,
30+ BRETHINESS,
31+ BRIGHTNESS,
32+ CLEARNESS,
33+ GENDER,
34+ };
35+
36+ /**
37+ * カーブの種類から、そのカーブのデフォルト値を取得する
38+ * @param curveType カーブの種類
39+ * @return デフォルト値
40+ */
41+ static int getDefault( CurveType curveType )
42+ {
43+ switch( curveType ){
44+ case PITCH_BEND:{
45+ return 0;
46+ }
47+ case PITCH_BEND_SENS:{
48+ return 2;
49+ }
50+ case DYNAMICS:{
51+ return 64;
52+ }
53+ case BRETHINESS:{
54+ return 0;
55+ }
56+ case BRIGHTNESS:{
57+ return 64;
58+ }
59+ case CLEARNESS:{
60+ return 0;
61+ }
62+ case GENDER:{
63+ return 64;
64+ }
65+ }
66+ }
67+
68+ /**
69+ * カーブの種類から、そのカーブの名前を取得する
70+ * @param curveType カーブの種類
71+ * @return 名前
72+ */
73+ static string getName( CurveType curveType )
74+ {
75+ switch( curveType ){
76+ case PITCH_BEND:{
77+ return "[PitchBendBPList]";
78+ }
79+ case PITCH_BEND_SENS:{
80+ return "[PitchBendSensBPList]";
81+ }
82+ case DYNAMICS:{
83+ return "[DynamicsBPList]";
84+ }
85+ case BRETHINESS:{
86+ return "[EpRResidualBPList]";
87+ }
88+ case BRIGHTNESS:{
89+ return "[EpRESlopeBPList]";
90+ }
91+ case CLEARNESS:{
92+ return "[EpRESlopeDepthBPList]";
93+ }
94+ case GENDER:{
95+ return "[GenderFactorBPList]";
96+ }
97+ }
98+ }
99+
100+ /**
101+ * カーブの種類の一覧を取得する
102+ * @return カーブ種類のリスト
103+ */
104+ static vector<CurveType> values()
105+ {
106+ vector<CurveType> result;
107+ result.push_back( PITCH_BEND );
108+ result.push_back( PITCH_BEND_SENS );
109+ result.push_back( DYNAMICS );
110+ result.push_back( BRETHINESS );
111+ result.push_back( BRIGHTNESS );
112+ result.push_back( CLEARNESS );
113+ result.push_back( GENDER );
114+ return result;
115+ }
116+ };
117+}
118+#endif
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- vConnect/trunk/stand2.0/stand/vsqMetaText/BPList.cpp (revision 1966)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/BPList.cpp (revision 1967)
@@ -47,4 +47,9 @@
4747 }
4848 }
4949 }
50+
51+ BP BPList::get( int index )
52+ {
53+ return this->data[index];
54+ }
5055 }
--- vConnect/trunk/stand2.0/stand/StringUtil.h (revision 1966)
+++ vConnect/trunk/stand2.0/stand/StringUtil.h (revision 1967)
@@ -35,7 +35,7 @@
3535 * @param limit 区切る回数の最大値
3636 * @return 区切られた文字列のリスト
3737 */
38- static vector<string> explode( string delimiter, string text, int limit = string::npos )
38+ static vector<string> explode( string delimiter, string text, string::size_type limit = string::npos )
3939 {
4040 vector<string> result;
4141 string::size_type searchFrom = 0;
@@ -66,9 +66,10 @@
6666 return text;
6767 }
6868 string result = text;
69- int index = result.find( search, 0 );
69+ string::size_type index = result.find( search, 0 );
7070 int searchLength = search.length();
7171 int replaceLength = replace.length();
72+
7273 while( string::npos != index ){
7374 result.replace( index, searchLength, replace );
7475 index = result.find( search, index - searchLength + replaceLength + 1 );
--- vConnect/trunk/stand2.0/stand/tests/vsq/SequenceTest.cpp (nonexistent)
+++ vConnect/trunk/stand2.0/stand/tests/vsq/SequenceTest.cpp (revision 1967)
@@ -0,0 +1,84 @@
1+#ifndef TEST_SequenceTest
2+#define TEST_SequenceTest
3+#include "../AllTests.h"
4+#include "../../vsqMetaText/Sequence.h"
5+
6+using namespace std;
7+using namespace vconnect;
8+
9+class SequenceTest : public CppUnit::TestFixture
10+{
11+public:
12+ void testConstruct()
13+ {
14+ Sequence sequence;
15+ // PITCH_BEND
16+ BP point = sequence.controlCurves[0].get( 0 );
17+ CPPUNIT_ASSERT_EQUAL( (long int)-10000, point.tick );
18+ CPPUNIT_ASSERT_EQUAL( 0, point.value );
19+ CPPUNIT_ASSERT(
20+ sequence.mMapCurves[CurveTypeEnum::getName( CurveTypeEnum::PITCH_BEND )]
21+ == &sequence.controlCurves[0]
22+ );
23+
24+ // PITCH_BEND_SENS
25+ point = sequence.controlCurves[1].get( 0 );
26+ CPPUNIT_ASSERT_EQUAL( (long int)-10000, point.tick );
27+ CPPUNIT_ASSERT_EQUAL( 2, point.value );
28+ CPPUNIT_ASSERT(
29+ sequence.mMapCurves[CurveTypeEnum::getName( CurveTypeEnum::PITCH_BEND_SENS )]
30+ == &sequence.controlCurves[1]
31+ );
32+
33+ // DYNAMICS
34+ point = sequence.controlCurves[2].get( 0 );
35+ CPPUNIT_ASSERT_EQUAL( (long int)-10000, point.tick );
36+ CPPUNIT_ASSERT_EQUAL( 64, point.value );
37+ CPPUNIT_ASSERT(
38+ sequence.mMapCurves[CurveTypeEnum::getName( CurveTypeEnum::DYNAMICS )]
39+ == &sequence.controlCurves[2]
40+ );
41+
42+ // BRETHINESS
43+ point = sequence.controlCurves[3].get( 0 );
44+ CPPUNIT_ASSERT_EQUAL( (long int)-10000, point.tick );
45+ CPPUNIT_ASSERT_EQUAL( 0, point.value );
46+ CPPUNIT_ASSERT(
47+ sequence.mMapCurves[CurveTypeEnum::getName( CurveTypeEnum::BRETHINESS )]
48+ == &sequence.controlCurves[3]
49+ );
50+
51+ // BRIGHTNESS
52+ point = sequence.controlCurves[4].get( 0 );
53+ CPPUNIT_ASSERT_EQUAL( (long int)-10000, point.tick );
54+ CPPUNIT_ASSERT_EQUAL( 64, point.value );
55+ CPPUNIT_ASSERT(
56+ sequence.mMapCurves[CurveTypeEnum::getName( CurveTypeEnum::BRIGHTNESS )]
57+ == &sequence.controlCurves[4]
58+ );
59+
60+ // CLEARNESS
61+ point = sequence.controlCurves[5].get( 0 );
62+ CPPUNIT_ASSERT_EQUAL( (long int)-10000, point.tick );
63+ CPPUNIT_ASSERT_EQUAL( 0, point.value );
64+ CPPUNIT_ASSERT(
65+ sequence.mMapCurves[CurveTypeEnum::getName( CurveTypeEnum::CLEARNESS )]
66+ == &sequence.controlCurves[5]
67+ );
68+
69+ // GENDER
70+ point = sequence.controlCurves[6].get( 0 );
71+ CPPUNIT_ASSERT_EQUAL( (long int)-10000, point.tick );
72+ CPPUNIT_ASSERT_EQUAL( 64, point.value );
73+ CPPUNIT_ASSERT(
74+ sequence.mMapCurves[CurveTypeEnum::getName( CurveTypeEnum::GENDER )]
75+ == &sequence.controlCurves[6]
76+ );
77+ }
78+
79+ CPPUNIT_TEST_SUITE( SequenceTest );
80+ CPPUNIT_TEST( testConstruct );
81+ CPPUNIT_TEST_SUITE_END();
82+};
83+REGISTER_TEST_SUITE( SequenceTest );
84+#endif
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- vConnect/trunk/stand2.0/stand/tests/Makefile (revision 1966)
+++ vConnect/trunk/stand2.0/stand/tests/Makefile (revision 1967)
@@ -1,6 +1,7 @@
11 SOURCE=./*.cpp ./*/*.cpp \
2- ../Thread.cpp ../Mutex.cpp ../vsqMetaText/Lyric.cpp \
3- ../utau/UtauDB.cpp
2+ ../Thread.cpp ../Mutex.cpp ../vsqMetaText/*.cpp \
3+ ../utau/*.cpp
4+
45 all: *.cpp *.h
56 g++ -finput-charset=UTF-8 $(SOURCE) ../../libiconv-1.13/lib/*.o -lcppunit -o run
67 ./run
--- vConnect/trunk/stand2.0/stand/Synthesizer.cpp (revision 1966)
+++ vConnect/trunk/stand2.0/stand/Synthesizer.cpp (revision 1967)
@@ -20,6 +20,7 @@
2020 #include "vsqMetaText/EventList.h"
2121 #include "Thread.h"
2222 #include "utau/UtauDBManager.h"
23+#include "vsqMetaText/CurveTypeEnum.h"
2324
2425 #define TRANS_MAX 4096
2526 double temporary1[TRANS_MAX];
@@ -358,8 +359,9 @@
358359 // 準備4.合成時刻に必要な情報を整理.
359360 vConnectFrame *frames = new vConnectFrame[frameLength];
360361 vector<vConnectPhoneme *> phonemes;
361- calculateFrameData(frames, frameLength, phonemes, mVsq, mManagerList, mControlCurves[BRIGHTNESS], beginFrame);
362+ calculateFrameData(frames, frameLength, phonemes, mVsq, mManagerList, mControlCurves[CurveTypeEnum::BRIGHTNESS], beginFrame);
362363
364+
363365 // 実際の合成.
364366 vConnectArg arg1, arg2;
365367 arg1.frames = frames;
@@ -700,9 +702,12 @@
700702 }
701703 //================================================================================================= ↑前処理
702704
703- int currentPosition, currentFrame = p->beginFrame;
704- double currentTime = 0.0, T;
705- int genIndex = 0, breIndex = 0;
705+ int currentPosition;
706+ int currentFrame = p->beginFrame;
707+ double currentTime = 0.0;
708+ double T;
709+ int genIndex = 0;
710+ int breIndex = 0;
706711 int noiseCount = 0;
707712
708713 // 合成処理
@@ -719,11 +724,11 @@
719724 T = 1.0 / currentF0;
720725
721726 // コントロールトラックのインデックスを該当箇所まで進める.
722- while( currentFrame + p->frameOffset > (*(p->controlCurves))[GENDER][genIndex].frameTime )
727+ while( currentFrame + p->frameOffset > (*(p->controlCurves))[CurveTypeEnum::GENDER][genIndex].frameTime )
723728 {
724729 genIndex++;
725730 }
726- while( currentFrame + p->frameOffset > (*(p->controlCurves))[BRETHINESS][breIndex].frameTime )
731+ while( currentFrame + p->frameOffset > (*(p->controlCurves))[CurveTypeEnum::BRETHINESS][breIndex].frameTime )
727732 {
728733 breIndex++;
729734 }
@@ -759,7 +764,7 @@
759764 }
760765 }
761766 // BRE の値によりノイズを励起信号に加算する.
762- appendNoise( starSpec, (int)min( p->fftLength, T * fs ), (*(p->controlCurves))[BRETHINESS][breIndex].value / 128.0, &noiseCount );
767+ appendNoise( starSpec, (int)min( p->fftLength, T * fs ), (*(p->controlCurves))[CurveTypeEnum::BRETHINESS][breIndex].value / 128.0, &noiseCount );
763768
764769 // starSpec -> residual DFT を実行する.
765770 fftw_execute(forward_r2c);
@@ -768,7 +773,7 @@
768773 calculateRawWave(impulse, residual, p->fftLength, *frames, waveform, spectrum, cepstrum, forward_r2c_raw, forward, inverse);
769774
770775 // Gender Factor を適用したスペクトルを starSpec に書き込む.
771- double stretchRatio = pow(2.0 , (double)((*(p->controlCurves))[GENDER][genIndex].value - 64) / 64.0);
776+ double stretchRatio = pow(2.0 , (double)((*(p->controlCurves))[CurveTypeEnum::GENDER][genIndex].value - 64) / 64.0);
772777 vConnectUtility::linearStretch(starSpec, impulse, stretchRatio, p->fftLength / 2 + 1);
773778
774779 // 合成パワースペクトルから最小位相応答を計算.
@@ -1038,21 +1043,21 @@
10381043 for( ; index < itemi->endFrame - beginFrame && index < frameLength; index++ )
10391044 {
10401045 // ピッチetcカーブに格納されている値の内どれを使うか?
1041- while( index + beginFrame > mControlCurves[PITCH_BEND][pitIndex].frameTime )
1046+ while( index + beginFrame > mControlCurves[CurveTypeEnum::PITCH_BEND][pitIndex].frameTime )
10421047 {
10431048 pitIndex++;
10441049 }
1045- while( index + beginFrame > mControlCurves[PITCH_BEND_SENS][pbsIndex].frameTime )
1050+ while( index + beginFrame > mControlCurves[CurveTypeEnum::PITCH_BEND_SENS][pbsIndex].frameTime )
10461051 {
10471052 pbsIndex++;
10481053 }
1049- while( index + beginFrame > mControlCurves[DYNAMICS][dynIndex].frameTime )
1054+ while( index + beginFrame > mControlCurves[CurveTypeEnum::DYNAMICS][dynIndex].frameTime )
10501055 {
10511056 dynIndex++;
10521057 }
1053- pitch_change = pow( 2, (double)mControlCurves[PITCH_BEND][pitIndex].value / 8192.0 * (double)mControlCurves[PITCH_BEND_SENS][pbsIndex].value / 12.0 );
1058+ pitch_change = pow( 2, (double)mControlCurves[CurveTypeEnum::PITCH_BEND][pitIndex].value / 8192.0 * (double)mControlCurves[CurveTypeEnum::PITCH_BEND_SENS][pbsIndex].value / 12.0 );
10541059 f0[index] = mNoteFrequency[itemi->note] * pitch_change * getPitchFluctuation( (double)index * framePeriod / 1000.0 );
1055- dynamics[index] = (double)mControlCurves[DYNAMICS][dynIndex].value / 64.0;
1060+ dynamics[index] = (double)mControlCurves[CurveTypeEnum::DYNAMICS][dynIndex].value / 64.0;
10561061 if( index > portamentoBegin )
10571062 {
10581063 dynamics[index] *= 1.0 - (double)( index - portamentoBegin ) / 50.0;
旧リポジトリブラウザで表示