• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1975 (tree)
日時2012-01-29 05:16:36
作者haruneko24

ログメッセージ

[stand2.0/StandConverter] TranscriberをGUIへ移植(未完)

変更サマリ

差分

--- vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.cpp (revision 1975)
@@ -17,8 +17,8 @@
1717
1818 using namespace stand::gui;
1919
20-ConverterWindow::ConverterWindow(QWidget *parent) :
21- QMainWindow(parent),
20+ConverterWindow::ConverterWindow(QWidget *parent, Qt::WindowFlags f) :
21+ QMainWindow(parent, f),
2222 ui(new Ui::ConverterWindow())
2323 {
2424 ui->setupUi(this);
--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWidget.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWidget.cpp (revision 1975)
@@ -16,7 +16,7 @@
1616
1717 // Set ColorComboBox
1818 QStringList colorNames;
19- colorNames << tr("red") << tr("green") << tr("blue") << tr("cyan") << tr("magenta") << tr("yellow") << tr("white");
19+ colorNames << tr("red") << tr("lime") << tr("blue") << tr("cyan") << tr("magenta") << tr("yellow") << tr("white");
2020 QPalette pallete = ui->ColorSelector->palette();
2121 pallete.setColor(QPalette::Highlight, Qt::transparent);
2222
--- vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.h (revision 1975)
@@ -33,7 +33,7 @@
3333 void sendCancelToConverter();
3434
3535 public:
36- explicit ConverterWindow(QWidget *parent = 0);
36+ explicit ConverterWindow(QWidget *parent = 0, Qt::WindowFlags f = Qt::Window);
3737 ~ConverterWindow();
3838
3939 /// <summary> オーバーライドされた closeEvent .ユーザが Window を閉じようとしたときに呼ばれます. </summary>
--- vConnect/trunk/stand2.0/StandConverter/gui/MappingView.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/gui/MappingView.cpp (revision 1975)
@@ -78,13 +78,13 @@
7878 }
7979 }
8080
81-void MappingView::setMapping(QVector<stand::gui::MappingView::Map> &mapping)
81+void MappingView::setMapping(QVector<stand::gui::MappingView::Item> &mapping)
8282 {
8383 _data = mapping;
8484 unsigned int i;
8585 for(i = 0; i < _data.size(); i++)
8686 {
87- Map m = _data.at(i), tmp;
87+ Item m = _data.at(i), tmp;
8888 int index = i;
8989 for(int j = i + 1; j < _data.size(); j++)
9090 {
--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.cpp (revision 1975)
@@ -5,8 +5,11 @@
55 #include "../synthesis/Transcriber.h"
66 #include "../synthesis/TranscriberSetting.h"
77 #include "../io/UtauLibrary.h"
8+#include "../utility/Utility.h"
9+#include "ConverterWindow.h"
810
911 #include <QMessageBox>
12+#include <QFileDialog>
1013 #include <QCloseEvent>
1114
1215 using namespace stand::gui;
@@ -17,6 +20,8 @@
1720 {
1821 ui->setupUi(this);
1922
23+ // TabWidget の中身を空にする.
24+ // 今のとこ必要なんだけど, ui の設定でどうにかならないのかな?
2025 while(ui->SettingTabs->count() != 0)
2126 {
2227 QWidget *p = ui->SettingTabs->widget(0);
@@ -24,10 +29,10 @@
2429 delete p;
2530 }
2631 TranscriberWidget *w = new TranscriberWidget(ui->SettingTabs);
27- ui->SettingTabs->addTab(w, tr("Base"));
32+ ui->SettingTabs->addTab(w, tr("Lib. 1"));
2833
2934 connect(w, SIGNAL(changed(QWidget*)), this, SLOT(settingChanged()));
30- connect(this, SIGNAL(mappingChanged(QVector<stand::gui::MappingView::Map>&)), ui->MappingView, SLOT(setMapping(QVector<stand::gui::MappingView::Map>&)));
35+ connect(this, SIGNAL(mappingChanged(QVector<stand::gui::MappingView::Item>&)), ui->MappingView, SLOT(setMapping(QVector<stand::gui::MappingView::Item>&)));
3136
3237 isAnalyzing = false;
3338 current = NULL;
@@ -43,8 +48,8 @@
4348
4449 void TranscriberWindow::settingChanged()
4550 {
46- QVector<stand::gui::MappingView::Map> mapping;
47- stand::gui::MappingView::Map m;
51+ QVector<stand::gui::MappingView::Item> mapping;
52+ stand::gui::MappingView::Item m;
4853 for(int i = 0; i < ui->SettingTabs->count(); i++)
4954 {
5055 TranscriberWidget *w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(i));
@@ -86,12 +91,12 @@
8691 {
8792 int index = ui->SettingTabs->count();
8893 QString num;
89- num.setNum(index);
94+ num.setNum(index + 1);
9095
9196 TranscriberWidget *w = new TranscriberWidget(ui->SettingTabs, index);
92- ui->SettingTabs->addTab(w, tr("Opt. ") + num);
97+ ui->SettingTabs->addTab(w, tr("Lib. ") + num);
9398 connect(w, SIGNAL(changed(QWidget*)), this, SLOT(settingChanged()));
94- connect(this, SIGNAL(mappingChanged(QVector<stand::gui::MappingView::Map>&)), ui->MappingView, SLOT(setMapping(QVector<stand::gui::MappingView::Map>&)));
99+ connect(this, SIGNAL(mappingChanged(QVector<stand::gui::MappingView::Item>&)), ui->MappingView, SLOT(setMapping(QVector<stand::gui::MappingView::Item>&)));
95100 settingChanged();
96101 }
97102
@@ -98,10 +103,10 @@
98103 void TranscriberWindow::removeTab()
99104 {
100105 int index = ui->SettingTabs->currentIndex();
101- // Base tab cannot be removed.
102- if(index == 0)
106+ // 少なくとも一つのタブは必要である.
107+ if(ui->SettingTabs->count() == 1)
103108 {
104- QMessageBox::critical(this, tr("Error"), tr("You can not remove base tab."), QMessageBox::Ok);
109+ QMessageBox::critical(this, tr("Error"), tr("You need at least one lib."), QMessageBox::Ok);
105110 return;
106111 }
107112
@@ -131,6 +136,8 @@
131136 ui->ProgressBar->setEnabled(isAnalyzing);
132137 ui->RemoveButton->setEnabled(!isAnalyzing);
133138 ui->SettingTabs->setEnabled(!isAnalyzing);
139+ ui->RootDirectory->setEnabled(!isAnalyzing);
140+ ui->RootSelector->setEnabled(!isAnalyzing);
134141 }
135142
136143 void TranscriberWindow::pushAnalyze()
@@ -145,17 +152,36 @@
145152 }
146153 }
147154
155+void TranscriberWindow::pushRootDir()
156+{
157+ QString dirName = QFileDialog::getExistingDirectory(
158+ this,
159+ tr("Select connect root directory."),
160+ tr("")
161+ );
162+ ui->RootDirectory->setText(dirName);
163+}
164+
148165 void TranscriberWindow::_beginAnalyze()
149166 {
150167 stand::synthesis::TranscriberSetting s;
151- // ToDo::Create Setting
152-
168+ // Directory の存在チェック.なければ作成するなどの処理.
169+ if(!stand::utility::makeDirectory(this, ui->RootDirectory->text(), true))
170+ {
171+ return;
172+ }
173+ // 設定がおかしい.
174+ if(!_checkSettingAvailability())
175+ {
176+ return;
177+ }
178+ // コンバータが使える設定に変換する.できなければ帰る.
153179 if(!_createSetting(s))
154180 {
155181 QMessageBox::critical(this, tr("Error"), tr("Some settings are invalid."));
156182 return;
157183 }
158- ui->ProgressBar->setMaximum(s.base.lib->size());
184+ ui->ProgressBar->setMaximum(s.libraries.at(0).body->size());
159185 current = new stand::synthesis::Transcriber(&s, this);
160186 connect(this, SIGNAL(sendCancelToTranscriber()), current, SLOT(cancel()));
161187 connect(current, SIGNAL(progressChanged(int)), ui->ProgressBar, SLOT(setValue(int)));
@@ -185,62 +211,63 @@
185211 bool TranscriberWindow::_createSetting(stand::synthesis::TranscriberSetting &s)
186212 {
187213 s.numThreads = ui->NumThreads->value();
188- s.base.lib = new stand::io::UtauLibrary();
189214
190- TranscriberWidget *w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(0));
191- QString filename = w->dir() + QDir::separator() + "oto.ini";
192- if(!s.base.lib->readFromOtoIni(filename, w->codec()))
215+ // 指定されたライブラリを全部読み込む.
216+ for(int i = 0; i < ui->SettingTabs->count(); i++)
193217 {
194- QMessageBox::critical(this, tr("Error"), tr("Base file path is invalid\n") + filename);
195- delete s.base.lib;
196- return false;
197- }
198- s.base.brightness = w->bri();
199- s.base.note = w->note();
200-
201- for(int i = 0; i < ui->SettingTabs->count() - 1; i++)
202- {
203218 stand::synthesis::Transcriber::TranscriberItem item;
204- w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(i + 1));
219+ TranscriberWidget *w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(i));
205220 QString filename = w->dir() + QDir::separator() + "oto.ini";
206221 stand::io::UtauLibrary *lib = new stand::io::UtauLibrary();
207- if(lib->readFromOtoIni(filename, w->codec()))
222+ if(lib->readFromOtoIni(filename, w->codec()) && lib->size() != 0)
208223 {
209- item.lib = lib;
224+ item.body = lib;
210225 item.brightness = w->bri();
211226 item.note = w->note();
212- s.optionals.push_back(item);
227+ s.libraries.push_back(item);
228+ const stand::io::UtauPhoneme *p = lib->at(0);
229+ // 波形データの場合,とりあえずユーザに通知しておしまいにする.
230+ // ConverterDialogにしておけばよかったか…
231+ if(p->filename.contains(".wav"))
232+ {
233+ QMessageBox::critical(this, tr("Error"), tr("You must convert the library below.\n") + lib->directory().absolutePath());
234+ for(int i = 0; i < s.libraries.size(); i++)
235+ {
236+ delete s.libraries.at(i).body;
237+ }
238+ return false;
239+ }
213240 }
214241 else
215242 {
216- QMessageBox::critical(this, tr("Error"), tr("Invalid file path\n") + filename);
243+ // 読み込めなかった.
244+ QMessageBox::critical(this, tr("Error"), tr("Could not find the library below\n") + filename);
217245 delete lib;
218- delete s.base.lib;
219- for(int i = 0; i < s.optionals.size(); i++)
246+ for(int i = 0; i < s.libraries.size(); i++)
220247 {
221- delete s.optionals.at(i).lib;
248+ delete s.libraries.at(i).body;
222249 }
223250 return false;
224251 }
225252 }
226253 // ToDo::そーーーーと!!
227- for(int i = 0; i < s.optionals.size(); i++)
254+ for(int i = 0; i < s.libraries.size(); i++)
228255 {
229- int minimum = s.optionals.at(i).brightness;
256+ int minimum = s.libraries.at(i).brightness;
230257 int index = i;
231- for(int j = i + 1; j < s.optionals.size(); j++)
258+ for(int j = i + 1; j < s.libraries.size(); j++)
232259 {
233- if(minimum < s.optionals.at(j).brightness)
260+ if(minimum < s.libraries.at(j).brightness)
234261 {
235- minimum = s.optionals.at(j).brightness;
262+ minimum = s.libraries.at(j).brightness;
236263 index = j;
237264 }
238265 }
239266 stand::synthesis::Transcriber::TranscriberItem item, tmp;
240- item = s.optionals.at(index);
241- tmp = s.optionals.at(i);
242- s.optionals.replace(i, item);
243- s.optionals.replace(index, tmp);
267+ item = s.libraries.at(index);
268+ tmp = s.libraries.at(i);
269+ s.libraries.replace(i, item);
270+ s.libraries.replace(index, tmp);
244271 }
245272
246273 return true;
@@ -255,3 +282,21 @@
255282 isAnalyzing = false;
256283 _setItemEnabled();
257284 }
285+
286+bool TranscriberWindow::_checkSettingAvailability()
287+{
288+ QDir root(ui->RootDirectory->text());
289+ for(int i = 0; i < ui->SettingTabs->count(); i++)
290+ {
291+ TranscriberWidget *w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(i));
292+ QString relative = root.relativeFilePath(w->dir());
293+ QString absolute = QDir(relative).absolutePath();
294+ if(relative == absolute)
295+ {
296+ QMessageBox::critical(this, tr("Error"), tr("Could not create relative path of the library below;\n") + relative);
297+ return false;
298+ }
299+ }
300+ return true;
301+}
302+
--- vConnect/trunk/stand2.0/StandConverter/gui/MappingView.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/gui/MappingView.h (revision 1975)
@@ -14,7 +14,7 @@
1414 {
1515 Q_OBJECT
1616 public:
17- struct Map
17+ struct Item
1818 {
1919 int note;
2020 int brightness;
@@ -27,7 +27,7 @@
2727 void paintEvent(QPaintEvent *e);
2828
2929 public slots:
30- void setMapping(QVector<stand::gui::MappingView::Map> &mapping);
30+ void setMapping(QVector<stand::gui::MappingView::Item> &mapping);
3131
3232 signals:
3333
@@ -40,7 +40,7 @@
4040 };
4141
4242 _color **_map;
43- QVector<Map> _data;
43+ QVector<Item> _data;
4444 const static int _MAPPING_SIZE;
4545 };
4646
--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.h (revision 1975)
@@ -25,14 +25,16 @@
2525 Q_OBJECT
2626 signals:
2727 void sendCancelToTranscriber();
28- void mappingChanged(QVector<stand::gui::MappingView::Map> &mapping);
28+ void mappingChanged(QVector<stand::gui::MappingView::Item> &mapping);
2929 public slots:
3030 void addTab();
3131 void removeTab();
3232
3333 void pushAnalyze();
34+ void pushRootDir();
3435 void settingChanged();
3536 void transcriptionFinished(bool);
37+
3638 public:
3739 explicit TranscriberWindow(QWidget *parent = 0);
3840 ~TranscriberWindow();
@@ -45,6 +47,7 @@
4547 void _setItemEnabled();
4648
4749 bool _createSetting(stand::synthesis::TranscriberSetting &s);
50+ bool _checkSettingAvailability();
4851
4952 Ui::TranscriberWindow *ui;
5053 stand::synthesis::Transcriber *current;
--- vConnect/trunk/stand2.0/StandConverter/io/StandLibrary.cpp (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/io/StandLibrary.cpp (revision 1975)
@@ -0,0 +1,4 @@
1+#include "StandLibrary.h"
2+
3+using namespace stand::io;
4+
--- vConnect/trunk/stand2.0/StandConverter/io/WaveFile.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/io/WaveFile.cpp (revision 1975)
@@ -6,7 +6,7 @@
66
77 using namespace stand::io;
88
9-const WaveFile::WaveHeader WaveFile::DEFAULT_WAVE_FORMAT =
9+const WaveFile::Header WaveFile::DEFAULT_WAVE_FORMAT =
1010 {
1111 1,
1212 0,
--- vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.cpp (revision 1975)
@@ -20,7 +20,8 @@
2020
2121 bool UtauLibrary::readFromOtoIni(const QString &filename, QTextCodec *codec)
2222 {
23- _directory = QDir(filename);
23+ QFileInfo info(filename);
24+ _directory = info.absoluteDir().absolutePath();
2425 clear();
2526 return _readFromOtoIni(filename, codec);
2627 }
@@ -28,12 +29,12 @@
2829 bool UtauLibrary::_readFromOtoIni(const QString &filename, QTextCodec *codec)
2930 {
3031 QFile file(filename);
31- qDebug("UtauLibrary::readFromOtoIni(%s, %s)", filename, (codec)?(codec->name().data()):"\"\"");
32+ qDebug("UtauLibrary::readFromOtoIni(%s, %s)", filename.toLocal8Bit().data(), (codec)?(codec->name().data()):"\"\"");
3233
3334 // ファイルが存在しない.
3435 if(file.exists() == false)
3536 {
36- qDebug(" File Not Found :%s", filename);
37+ qDebug(" File Not Found :%s", filename.toLocal8Bit().data());
3738 return false;
3839 }
3940
@@ -40,7 +41,7 @@
4041 // 開けない.
4142 if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
4243 {
43- qDebug(" File Open Error :%s", filename);
44+ qDebug(" File Open Error :%s", filename.toLocal8Bit().data());
4445 return false;
4546 }
4647
@@ -51,7 +52,7 @@
5152 }
5253
5354 QFileInfo fileInfo(filename);
54- QString relative = _directory.relativeFilePath(fileInfo.absoluteDir().absolutePath()) + QDir::separator();
55+ QString relative = _directory.relativeFilePath(fileInfo.absoluteDir().absolutePath());
5556 if(relative == QDir::separator())
5657 {
5758 relative = "";
@@ -68,7 +69,7 @@
6869 c++;
6970 if(!_readOneLine(line, relative))
7071 {
71- qDebug(" Invalid args in l.%d\t: %s", c, line);
72+ qDebug(" Invalid args in l.%d\t: %s", c, line.toLocal8Bit().data());
7273 }
7374 }
7475
@@ -89,7 +90,7 @@
8990
9091 bool UtauLibrary::_readRecursive(const QString &filename, QTextCodec *codec, int maxDepth)
9192 {
92- qDebug("UtauLibrary::readRecursive(%s, %s, %d)", filename, (codec)?(codec->name().data()):"\"\"", maxDepth);
93+ qDebug("UtauLibrary::readRecursive(%s, %s, %d)", filename.toLocal8Bit().data(), (codec)?(codec->name().data()):"\"\"", maxDepth);
9394 bool ret = false;
9495 QDir dir(filename);
9596 QFileInfoList dirList = dir.entryInfoList(QDir::AllDirs);
@@ -174,11 +175,11 @@
174175
175176 const UtauPhoneme *UtauLibrary::find(const QString &pronounce)
176177 {
177- QHash<QString, UtauPhoneme *>::iterator it;
178+ QHash<QString, int>::iterator it;
178179 it = settingMap.find(pronounce);
179180 if(it != settingMap.end())
180181 {
181- return it.value();
182+ return at(it.value());
182183 }
183184 return NULL;
184185 }
--- vConnect/trunk/stand2.0/StandConverter/io/StandLibrary.h (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/io/StandLibrary.h (revision 1975)
@@ -0,0 +1,26 @@
1+#ifndef STANDLIBRARY_H
2+#define STANDLIBRARY_H
3+
4+#include <Qt>
5+#include <QDir>
6+#include <QVector>
7+
8+class QTextCodec;
9+
10+namespace stand
11+{
12+namespace io
13+{
14+
15+class UtauLibrary;
16+
17+class StandLibrary
18+{
19+public:
20+
21+};
22+
23+}
24+}
25+
26+#endif // STANDLIBRARY_H
--- vConnect/trunk/stand2.0/StandConverter/io/WaveFile.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/io/WaveFile.h (revision 1975)
@@ -11,7 +11,7 @@
1111 class WaveFile
1212 {
1313 public:
14- struct WaveHeader
14+ struct Header
1515 {
1616 qint16 formatID;
1717 qint32 chunksize;
@@ -31,7 +31,7 @@
3131 bool read(const char* filename);
3232 bool write(const char* filename);
3333
34- void setHeader(const WaveHeader &h)
34+ void setHeader(const Header &h)
3535 {
3636 _header = h;
3737 }
@@ -54,7 +54,7 @@
5454 return (!_data || _length == 0);
5555 }
5656
57- const WaveHeader *header() const
57+ const Header *header() const
5858 {
5959 return &_header;
6060 }
@@ -65,7 +65,7 @@
6565 }
6666
6767 double normalize();
68- const static WaveHeader DEFAULT_WAVE_FORMAT;
68+ const static Header DEFAULT_WAVE_FORMAT;
6969 private:
7070 void _createBuffer(unsigned int l);
7171 void _destroy();
@@ -82,7 +82,7 @@
8282 void _writeData24(qint8 *p);
8383 void _writeData32(qint8 *p);
8484
85- WaveHeader _header;
85+ Header _header;
8686 double *_data;
8787 unsigned int _length;
8888 };
--- vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.h (revision 1975)
@@ -76,9 +76,8 @@
7676 /// <param name = s> 追加したい原音設定 </parm>
7777 void push_back(const UtauPhoneme &s)
7878 {
79- UtauPhoneme u = s;
80- settingList.push_back(u);
81- settingMap.insert(u.pronounce, &(settingList.back()));
79+ settingMap[s.pronounce] = settingList.count();
80+ settingList.push_back(s);
8281 }
8382
8483 /// <summary> 指定発音の原音設定を返します. </summary>
@@ -92,7 +91,7 @@
9291 bool _readRecursive(const QString &filename, QTextCodec *codec = NULL, int maxDepth = 1);
9392
9493 QVector<UtauPhoneme> settingList;
95- QHash<QString, UtauPhoneme *> settingMap;
94+ QHash<QString, int> settingMap;
9695
9796 QDir _directory;
9897 };
--- vConnect/trunk/stand2.0/StandConverter/io/StandFile.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/io/StandFile.cpp (revision 1975)
@@ -72,6 +72,7 @@
7272
7373 bool StandFile::read(const char *path)
7474 {
75+ qDebug("StandFile::read(\"%s\");", path);
7576 FILE *fp = fopen(path, "rb");
7677 if(!fp)
7778 {
@@ -113,6 +114,7 @@
113114
114115 bool StandFile::write(const char *path)
115116 {
117+ qDebug("StandFile::write(\"%s\");", path);
116118 if(!_f0 || !_t || !_MFCC || !vorbis.data)
117119 {
118120 qDebug("StandFile::write(\"%s\"); // Empty Data.", path);
@@ -121,7 +123,7 @@
121123 FILE *fp = fopen(path, "wb");
122124 if(!fp)
123125 {
124- qDebug("StandFile::write(\"%s\"); // File could not be opened.", path);
126+ qDebug("StandFile::write(\"%s\"); // File open error.", path);
125127 return false;
126128 }
127129
@@ -289,17 +291,22 @@
289291 stand::math::smoothMatching(dst_to_src_stretched, src_to_dst, src_env, dst_to_src_stretched, src_len);
290292
291293 double framePeriod = src->framePeriod();
292- for( int i = 0; i < dst_len - 1; i++ ){
294+ for( int i = 0; i < dst_len - 1; i++ )
295+ {
293296 double tmp = (double)i / (double)dst_len * (double)src_len;
294- if( tmp >= src_len - 1 ){
295- dst_to_src[i] = dst_to_src_stretched[src_len-1];
296- }else{
297+ if( tmp >= src_len - 1 )
298+ {
299+ dst_to_src[i] = dst_to_src_stretched[src_len-1] * dst->framePeriod() / 1000.0 / (double)src_len * (double)dst_len;
300+ }
301+ else
302+ {
297303 dst_to_src[i] = stand::math::interpolateArray(tmp, dst_to_src_stretched) * dst->framePeriod() / 1000.0 / (double)src_len * (double)dst_len;
298304 }
299305 }
300- dst_to_src[dst_len-1] = dst_to_src_stretched[src_len-1] / (double)src_len * (double)dst_len;
306+ dst_to_src[dst_len-1] = dst_to_src_stretched[src_len-1] * dst->framePeriod() / 1000.0 / (double)src_len * (double)dst_len;
301307
302- for( int i = 0; i < src_len; i++ ){
308+ for( int i = 0; i < src_len; i++ )
309+ {
303310 dst_to_src_stretched[i] = src_to_dst[i] * framePeriod / 1000.0;
304311 }
305312 memcpy( src_to_dst, dst_to_src_stretched, sizeof( double ) * src_len );
--- vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.cpp (revision 1975)
@@ -8,15 +8,19 @@
88 Transcriber::Transcriber(const TranscriberSetting *s, QObject *parent) :
99 QThread(parent)
1010 {
11- setting = s;
11+ setting = new TranscriberSetting();
12+ setting->numThreads = s->numThreads;
13+ for(int i = 0; i < s->libraries.size(); i++)
14+ {
15+ setting->libraries.push_back(s->libraries.at(i));
16+ }
1217 }
1318
1419 Transcriber::~Transcriber()
1520 {
16- delete setting->base.lib;
17- for(int i = 0; i < setting->optionals.size();i ++)
21+ for(int i = 0; i < setting->libraries.size();i ++)
1822 {
19- delete setting->optionals.at(i).lib;
23+ delete setting->libraries.at(i).body;
2024 }
2125 for(int i = 0; i < elements.size(); i++)
2226 {
@@ -25,6 +29,7 @@
2529 elements.at(i)->disconnect();
2630 delete elements.at(i);
2731 }
32+ delete setting;
2833 }
2934
3035 void Transcriber::run()
@@ -34,7 +39,7 @@
3439 QMutex mutex;
3540 mutex.lock();
3641 elements.clear();
37- for(int i = 0; i < setting->numThreads && i < setting->base.lib->size(); i++)
42+ for(int i = 0; i < setting->numThreads && i < setting->libraries.at(0).body->size(); i++)
3843 {
3944 TranscriberElement *e = new TranscriberElement(i, setting, &mutex, this);
4045 elements.push_back(e);
@@ -41,9 +46,10 @@
4146 e->start();
4247 currentIndex = i;
4348 }
49+ currentIndex++;
4450 mutex.unlock();
4551
46- currentIndex = currentFinished = 0;
52+ currentFinished = 0;
4753 waitMutex.lock();
4854 condition.wait(&waitMutex);
4955 waitMutex.unlock();
@@ -55,7 +61,7 @@
5561 void Transcriber::elementFinished(TranscriberElement *e)
5662 {
5763 currentFinished++;
58- if(currentIndex < setting->base.lib->size())
64+ if(currentIndex < setting->libraries.at(0).body->size())
5965 {
6066 e->setIndex(currentIndex);
6167 currentIndex++;
@@ -64,14 +70,12 @@
6470 {
6571 e->finishTranscription();
6672 }
67- // SafeGuard (要るかな?)
68- if(currentFinished == setting->base.lib->size() - 1)
73+
74+ if(currentFinished == setting->libraries.at(0).body->size())
6975 {
70- for(int i = 0; i < setting->numThreads; i++)
71- {
76+ cancel();
77+ }
7278
73- }
74- }
7579 emit progressChanged(currentFinished);
7680 }
7781
--- vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberSetting.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberSetting.h (revision 1975)
@@ -16,8 +16,7 @@
1616 class TranscriberSetting
1717 {
1818 public:
19- Transcriber::TranscriberItem base;
20- QVector<Transcriber::TranscriberItem> optionals;
19+ QVector<Transcriber::TranscriberItem> libraries;
2120
2221 unsigned int numThreads;
2322 };
--- vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.h (revision 1975)
@@ -32,7 +32,7 @@
3232 public:
3333 struct TranscriberItem
3434 {
35- stand::io::UtauLibrary *lib;
35+ stand::io::UtauLibrary *body;
3636 int note;
3737 int brightness;
3838 };
@@ -43,7 +43,7 @@
4343 void run();
4444
4545 private:
46- const TranscriberSetting *setting;
46+ TranscriberSetting *setting;
4747 int currentFinished;
4848 int currentIndex;
4949 QVector<TranscriberElement *> elements;
--- vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.cpp (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.cpp (revision 1975)
@@ -10,8 +10,7 @@
1010
1111 using namespace stand::synthesis;
1212
13-TranscriberElement::TranscriberElement(unsigned int index, const TranscriberSetting *s, QMutex *m, Transcriber *t) :
14- QThread(t)
13+TranscriberElement::TranscriberElement(unsigned int index, const TranscriberSetting *s, QMutex *m, Transcriber *t)
1514 {
1615 this->index = index;
1716 this->setting = s;
@@ -18,10 +17,9 @@
1817 this->mutex = m;
1918 this->transcriber = t;
2019
21- items.push_back(s->base);
22- for(int i = 0; i < s->optionals.size(); i++)
20+ for(int i = 0; i < s->libraries.size(); i++)
2321 {
24- items.push_back(s->optionals.at(i));
22+ items.push_back(s->libraries.at(i));
2523 }
2624 isFinished = false;
2725 }
@@ -42,42 +40,7 @@
4240
4341 do
4442 {
45- stand::io::StandFile *prev, *current = NULL;
46- prev = new stand::io::StandFile();
47- QString filename = items.at(0).lib->directory().absolutePath() + QDir::separator() + items.at(0).lib->at(index)->filename;
48- // 簡単だけど拡張子チェック
49- if(filename.contains(".vvd") && !prev->read(QDir::toNativeSeparators(filename).toLocal8Bit().data()))
50- {
51- qDebug("%s is not vvd file!", filename);
52- delete prev;
53- prev = NULL;
54- }
55- for(int i = 1; i < items.size(); i++)
56- {
57- const stand::io::UtauPhoneme *phoneme = items.at(i).lib->find(items.at(0).lib->at(index)->pronounce);
58- if(phoneme)
59- {
60- filename = items.at(i).lib->directory().absolutePath() + QDir::separator() + phoneme->filename;
61- current = new stand::io::StandFile();
62- // 現在のファイルを読み込む→現在のファイルがよめていて,前回もファイルが読めていた場合だけ分析を行う.
63- if(filename.contains(".vvd") && current->read(QDir::toNativeSeparators(filename).toLocal8Bit().data()) && prev)
64- {
65- // ToDo:: 写像関数の計算と保存
66- stand::io::StandFile::matching(prev, current);
67- // ファイルへ保存.
68- current->write(QDir::toNativeSeparators(filename).toLocal8Bit().data());
69- }
70- else
71- {
72- qDebug("%s is not vvd file!", filename);
73- delete current;
74- current = NULL;
75- }
76- }
77- delete prev;
78- prev = current;
79- }
80- delete current;
43+ _analyze();
8144 mutex->lock();
8245 transcriber->elementFinished(this);
8346 mutex->unlock();
@@ -86,3 +49,40 @@
8649
8750 qDebug(" Done::TranscriberElement::run();");
8851 }
52+
53+void TranscriberElement::_analyze()
54+{
55+ stand::io::StandFile *prev, *current = NULL;
56+ prev = new stand::io::StandFile();
57+ QString filename = items.at(0).body->directory().absolutePath() + QDir::separator() + items.at(0).body->at(index)->filename;
58+ // 簡単だけど拡張子チェック
59+ if(filename.contains(".vvd") && !prev->read(QDir::toNativeSeparators(filename).toLocal8Bit().data()))
60+ {
61+ delete prev;
62+ prev = NULL;
63+ }
64+ for(int i = 1; i < items.size(); i++)
65+ {
66+ const stand::io::UtauPhoneme *phoneme = items.at(i).body->find(items.at(0).body->at(index)->pronounce);
67+ if(phoneme)
68+ {
69+ filename = items.at(i).body->directory().absolutePath() + QDir::separator() + phoneme->filename;
70+ current = new stand::io::StandFile();
71+ // 現在のファイルを読み込む→現在のファイルがよめていて,前回もファイルが読めていた場合だけ分析を行う.
72+ if(filename.contains(".vvd") && current->read(QDir::toNativeSeparators(filename).toLocal8Bit().data()) && prev)
73+ {
74+ // 写像関数の計算と保存
75+ stand::io::StandFile::matching(prev, current);
76+ current->write(QDir::toNativeSeparators(filename).toLocal8Bit().data());
77+ }
78+ else
79+ {
80+ delete current;
81+ current = NULL;
82+ }
83+ }
84+ delete prev;
85+ prev = current;
86+ }
87+ delete current;
88+}
--- vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.h (revision 1974)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.h (revision 1975)
@@ -30,6 +30,8 @@
3030 void setIndex(int index);
3131 void finishTranscription();
3232 private:
33+ void _analyze();
34+
3335 unsigned int index;
3436 const TranscriberSetting *setting;
3537 QMutex *mutex;
旧リポジトリブラウザで表示