• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1974 (tree)
日時2012-01-26 06:14:19
作者haruneko24

ログメッセージ

[stand2.0/StandConverter] TranscriberWindow::表示を適正なものに変更.

変更サマリ

差分

--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWidget.cpp (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWidget.cpp (revision 1974)
@@ -38,6 +38,11 @@
3838 delete ui;
3939 }
4040
41+void TranscriberWidget::settingChanged()
42+{
43+ emit changed(this);
44+}
45+
4146 QString TranscriberWidget::dir()
4247 {
4348 return ui->DirectoryName->text();
@@ -67,3 +72,8 @@
6772 {
6873 return QTextCodec::codecForName(ui->EncodeComboBox->currentText().toLocal8Bit().data());
6974 }
75+
76+QString TranscriberWidget::colorName()
77+{
78+ return ui->ColorSelector->currentText();
79+}
--- vConnect/trunk/stand2.0/StandConverter/gui/MappingView.cpp (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/gui/MappingView.cpp (revision 1974)
@@ -3,10 +3,20 @@
33 #include <QPaintEvent>
44 #include <QPainter>
55
6+#include <math.h>
7+
68 using namespace stand::gui;
79
810 const int MappingView::_MAPPING_SIZE = 128;
911
12+// min, max macro
13+#ifndef min
14+#define min(a,b) (((a)<(b))?(a):(b))
15+#endif
16+#ifndef max
17+#define max(a,b) (((a)<(b))?(b):(a))
18+#endif
19+
1020 MappingView::MappingView(QWidget *parent) :
1121 QWidget(parent)
1222 {
@@ -54,17 +64,111 @@
5464 p.drawLine(x, y, x + w, y);
5565 }
5666 }
67+ for(int i = 0; i < _data.size(); i++)
68+ {
69+ int x = _data.at(i).note / (double)_MAPPING_SIZE * width();
70+ int w = (1 + _data.at(i).note) / (double)_MAPPING_SIZE * width() - x;
71+ int y = (_MAPPING_SIZE - 1 - _data.at(i).brightness) / (double)_MAPPING_SIZE * height();
72+ int h = (1 + _MAPPING_SIZE - 1 - _data.at(i).brightness) / (double)_MAPPING_SIZE * height() - y;
73+ p.setPen(Qt::white);
74+ p.drawLine(x, y, x, y + h);
75+ p.drawLine(x, y, x + w, y);
76+ p.drawLine(x, y + h, x + w, y + h);
77+ p.drawLine(x + w, y, x + w, y + h);
78+ }
5779 }
5880
59-void MappingView::setMapping(QVector<Map> &mapping)
81+void MappingView::setMapping(QVector<stand::gui::MappingView::Map> &mapping)
6082 {
6183 _data = mapping;
62- for(unsigned int i = 0; i < mapping.size(); i++)
84+ unsigned int i;
85+ for(i = 0; i < _data.size(); i++)
6386 {
87+ Map m = _data.at(i), tmp;
88+ int index = i;
89+ for(int j = i + 1; j < _data.size(); j++)
90+ {
91+ if(m.brightness > _data.at(j).brightness)
92+ {
93+ m = _data.at(j);
94+ index = j;
95+ }
96+ }
97+ tmp = _data.at(i);
98+ _data.replace(i, m);
99+ _data.replace(index, tmp);
100+ }
101+
102+ int r = _data.at(0).color.red();
103+ int g = _data.at(0).color.green();
104+ int b = _data.at(0).color.blue();
105+ for(i = 0; i <= _data.at(0).brightness; i++)
106+ {
107+ int y = 127 - i;
108+
109+ for(int j = 0; j < _MAPPING_SIZE; j++)
110+ {
111+ _map[j][y].r = r;
112+ _map[j][y].g = g;
113+ _map[j][y].b = b;
114+ }
115+ }
116+ for(int index = 1; index < _data.size(); index++)
117+ {
118+ int pbri = _data.at(index - 1).brightness;
119+ int bri = _data.at(index).brightness;
120+ for(; i <= (bri + pbri) / 2 && i < _MAPPING_SIZE; i++)
121+ {
122+ int y = 127 - i;
123+ int c = (1 + i - pbri) * 2;
124+ int d = bri - pbri;
125+ int cr = r + _data.at(index).color.red() * log((double)c) / log((double)d);
126+ int cg = g + _data.at(index).color.green() * log((double)c) / log((double)d);
127+ int cb = b + _data.at(index).color.blue() * log((double)c) / log((double)d);
128+ for(int j = 0; j < _MAPPING_SIZE; j++)
129+ {
130+ _map[j][y].r = min(255, cr);
131+ _map[j][y].g = min(255, cg);
132+ _map[j][y].b = min(255, cb);
133+ }
134+ }
135+ for(; i < bri && i < _MAPPING_SIZE; i++)
136+ {
137+ int y = 127 - i;
138+ int c = (bri - i) * 2;
139+ int d = bri - pbri;
140+ int cr = r * log((double)c) / log((double)d) + _data.at(index).color.red();
141+ int cg = g * log((double)c) / log((double)d) + _data.at(index).color.green();
142+ int cb = b * log((double)c) / log((double)d) + _data.at(index).color.blue();
143+ for(int j = 0; j < _MAPPING_SIZE; j++)
144+ {
145+ _map[j][y].r = min(255, cr);
146+ _map[j][y].g = min(255, cg);
147+ _map[j][y].b = min(255, cb);
148+ }
149+ }
150+ r = _data.at(index).color.red();
151+ g = _data.at(index).color.green();
152+ b = _data.at(index).color.blue();
153+ }
154+ for(; i < _MAPPING_SIZE; i++)
155+ {
156+ int y = 127 - i;
157+ for(int j = 0; j < _MAPPING_SIZE; j++)
158+ {
159+ _map[j][y].r = _data.last().color.red();
160+ _map[j][y].g = _data.last().color.green();
161+ _map[j][y].b = _data.last().color.blue();
162+ }
163+ }
164+
165+ for(int i = 0; i < _data.size(); i++)
166+ {
64167 int x = mapping.at(i).note;
65- int y = 127 - mapping.at(i).brightness;
66- _map[x][y].r = mapping.at(i).color.red();
67- _map[x][y].g = mapping.at(i).color.green();
68- _map[x][y].b = mapping.at(i).color.blue();
168+ int y = 127 - _data.at(i).brightness;
169+ _map[x][y].r = _data.at(i).color.red();
170+ _map[x][y].g = _data.at(i).color.green();
171+ _map[x][y].b = _data.at(i).color.blue();
69172 }
173+ update();
70174 }
--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.cpp (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.cpp (revision 1974)
@@ -23,18 +23,39 @@
2323 ui->SettingTabs->removeTab(0);
2424 delete p;
2525 }
26- ui->SettingTabs->addTab(new TranscriberWidget(this), tr("Base"));
26+ TranscriberWidget *w = new TranscriberWidget(ui->SettingTabs);
27+ ui->SettingTabs->addTab(w, tr("Base"));
2728
29+ 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>&)));
31+
2832 isAnalyzing = false;
2933 current = NULL;
34+ settingChanged();
3035 _setItemEnabled();
3136 }
3237
3338 TranscriberWindow::~TranscriberWindow()
3439 {
40+ disconnect();
3541 delete ui;
3642 }
3743
44+void TranscriberWindow::settingChanged()
45+{
46+ QVector<stand::gui::MappingView::Map> mapping;
47+ stand::gui::MappingView::Map m;
48+ for(int i = 0; i < ui->SettingTabs->count(); i++)
49+ {
50+ TranscriberWidget *w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(i));
51+ m.brightness = w->bri();
52+ m.note = w->note();
53+ m.color = QColor(w->colorName());
54+ mapping.push_back(m);
55+ }
56+ emit mappingChanged(mapping);
57+}
58+
3859 void TranscriberWindow::closeEvent(QCloseEvent *e)
3960 {
4061 QMessageBox::StandardButton val = QMessageBox::Yes;
@@ -67,7 +88,11 @@
6788 QString num;
6889 num.setNum(index);
6990
70- ui->SettingTabs->addTab(new TranscriberWidget(this, index), tr("Opt. ") + num);
91+ TranscriberWidget *w = new TranscriberWidget(ui->SettingTabs, index);
92+ ui->SettingTabs->addTab(w, tr("Opt. ") + num);
93+ 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>&)));
95+ settingChanged();
7196 }
7297
7398 void TranscriberWindow::removeTab()
@@ -88,6 +113,7 @@
88113 }
89114 QWidget *p = ui->SettingTabs->widget(index);
90115 ui->SettingTabs->removeTab(index);
116+ settingChanged();
91117 delete p;
92118 }
93119
@@ -129,8 +155,10 @@
129155 QMessageBox::critical(this, tr("Error"), tr("Some settings are invalid."));
130156 return;
131157 }
132- current = new stand::synthesis::Transcriber(s, this);
158+ ui->ProgressBar->setMaximum(s.base.lib->size());
159+ current = new stand::synthesis::Transcriber(&s, this);
133160 connect(this, SIGNAL(sendCancelToTranscriber()), current, SLOT(cancel()));
161+ connect(current, SIGNAL(progressChanged(int)), ui->ProgressBar, SLOT(setValue(int)));
134162 connect(current, SIGNAL(finish(bool)), SLOT(transcriptionFinished(bool)));
135163
136164 current->start();
@@ -157,40 +185,63 @@
157185 bool TranscriberWindow::_createSetting(stand::synthesis::TranscriberSetting &s)
158186 {
159187 s.numThreads = ui->NumThreads->value();
160- s.base = new stand::io::UtauLibrary();
188+ s.base.lib = new stand::io::UtauLibrary();
161189
162190 TranscriberWidget *w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(0));
163191 QString filename = w->dir() + QDir::separator() + "oto.ini";
164- if(!s.base->readFromOtoIni(filename, w->codec()))
192+ if(!s.base.lib->readFromOtoIni(filename, w->codec()))
165193 {
166194 QMessageBox::critical(this, tr("Error"), tr("Base file path is invalid\n") + filename);
167- delete s.base;
195+ delete s.base.lib;
168196 return false;
169197 }
170- s.optionals.clear();
198+ s.base.brightness = w->bri();
199+ s.base.note = w->note();
171200
172201 for(int i = 0; i < ui->SettingTabs->count() - 1; i++)
173202 {
203+ stand::synthesis::Transcriber::TranscriberItem item;
174204 w = dynamic_cast<TranscriberWidget *>(ui->SettingTabs->widget(i + 1));
175205 QString filename = w->dir() + QDir::separator() + "oto.ini";
176206 stand::io::UtauLibrary *lib = new stand::io::UtauLibrary();
177207 if(lib->readFromOtoIni(filename, w->codec()))
178208 {
179- s.optionals.push_back(lib);
209+ item.lib = lib;
210+ item.brightness = w->bri();
211+ item.note = w->note();
212+ s.optionals.push_back(item);
180213 }
181214 else
182215 {
183216 QMessageBox::critical(this, tr("Error"), tr("Invalid file path\n") + filename);
184217 delete lib;
185- delete s.base;
218+ delete s.base.lib;
186219 for(int i = 0; i < s.optionals.size(); i++)
187220 {
188- delete s.optionals.at(i);
221+ delete s.optionals.at(i).lib;
189222 }
190223 return false;
191224 }
192225 }
193- // ToDo::ばぶるそーーーーと!!
226+ // ToDo::そーーーーと!!
227+ for(int i = 0; i < s.optionals.size(); i++)
228+ {
229+ int minimum = s.optionals.at(i).brightness;
230+ int index = i;
231+ for(int j = i + 1; j < s.optionals.size(); j++)
232+ {
233+ if(minimum < s.optionals.at(j).brightness)
234+ {
235+ minimum = s.optionals.at(j).brightness;
236+ index = j;
237+ }
238+ }
239+ 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);
244+ }
194245
195246 return true;
196247 }
--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWidget.h (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWidget.h (revision 1974)
@@ -19,12 +19,17 @@
1919 Q_OBJECT
2020 public slots:
2121 void openDirDialog();
22+ void settingChanged();
2223
24+signals:
25+ void changed(QWidget *);
26+
2327 public:
2428 explicit TranscriberWidget(QWidget *parent = 0, int index = 0ULL);
2529 ~TranscriberWidget();
2630
2731 QString dir();
32+ QString colorName();
2833 int bri();
2934 int note();
3035 QTextCodec *codec();
--- vConnect/trunk/stand2.0/StandConverter/gui/MappingView.h (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/gui/MappingView.h (revision 1974)
@@ -27,7 +27,7 @@
2727 void paintEvent(QPaintEvent *e);
2828
2929 public slots:
30- void setMapping(QVector<Map> &mapping);
30+ void setMapping(QVector<stand::gui::MappingView::Map> &mapping);
3131
3232 signals:
3333
--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.h (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.h (revision 1974)
@@ -2,7 +2,10 @@
22 #define TRANSCRIBERWINDOW_H
33
44 #include <QMainWindow>
5+#include <QVector>
56
7+#include "MappingView.h"
8+
69 namespace Ui {
710 class TranscriberWindow;
811 }
@@ -22,11 +25,13 @@
2225 Q_OBJECT
2326 signals:
2427 void sendCancelToTranscriber();
28+ void mappingChanged(QVector<stand::gui::MappingView::Map> &mapping);
2529 public slots:
2630 void addTab();
2731 void removeTab();
2832
2933 void pushAnalyze();
34+ void settingChanged();
3035 void transcriptionFinished(bool);
3136 public:
3237 explicit TranscriberWindow(QWidget *parent = 0);
--- vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.cpp (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.cpp (revision 1974)
@@ -1,10 +1,11 @@
11 #include "Transcriber.h"
2+#include "TranscriberSetting.h"
23 #include "TranscriberElement.h"
34 #include "../io/UtauLibrary.h"
45
56 using namespace stand::synthesis;
67
7-Transcriber::Transcriber(const TranscriberSetting &s, QObject *parent) :
8+Transcriber::Transcriber(const TranscriberSetting *s, QObject *parent) :
89 QThread(parent)
910 {
1011 setting = s;
@@ -12,10 +13,10 @@
1213
1314 Transcriber::~Transcriber()
1415 {
15- delete setting.base;
16- for(int i = 0; i < setting.optionals.size();i ++)
16+ delete setting->base.lib;
17+ for(int i = 0; i < setting->optionals.size();i ++)
1718 {
18- delete setting.optionals.at(i);
19+ delete setting->optionals.at(i).lib;
1920 }
2021 for(int i = 0; i < elements.size(); i++)
2122 {
@@ -33,9 +34,9 @@
3334 QMutex mutex;
3435 mutex.lock();
3536 elements.clear();
36- for(int i = 0; i < setting.numThreads && i < setting.base->size(); i++)
37+ for(int i = 0; i < setting->numThreads && i < setting->base.lib->size(); i++)
3738 {
38- TranscriberElement *e = new TranscriberElement(i, &setting, &mutex, this);
39+ TranscriberElement *e = new TranscriberElement(i, setting, &mutex, this);
3940 elements.push_back(e);
4041 e->start();
4142 currentIndex = i;
@@ -54,7 +55,7 @@
5455 void Transcriber::elementFinished(TranscriberElement *e)
5556 {
5657 currentFinished++;
57- if(currentIndex < setting.base->size())
58+ if(currentIndex < setting->base.lib->size())
5859 {
5960 e->setIndex(currentIndex);
6061 currentIndex++;
@@ -64,13 +65,14 @@
6465 e->finishTranscription();
6566 }
6667 // SafeGuard (要るかな?)
67- if(currentFinished == setting.base->size() - 1)
68+ if(currentFinished == setting->base.lib->size() - 1)
6869 {
69- for(int i = 0; i < setting.numThreads; i++)
70+ for(int i = 0; i < setting->numThreads; i++)
7071 {
7172
7273 }
7374 }
75+ emit progressChanged(currentFinished);
7476 }
7577
7678 void Transcriber::cancel()
--- vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberSetting.h (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberSetting.h (revision 1974)
@@ -2,6 +2,7 @@
22 #define TRANSCRIBERSETTING_H
33
44 #include <QVector>
5+#include "Transcriber.h"
56
67 namespace stand
78 {
@@ -15,12 +16,9 @@
1516 class TranscriberSetting
1617 {
1718 public:
18- stand::io::UtauLibrary *base;
19- QVector<stand::io::UtauLibrary *> optionals;
19+ Transcriber::TranscriberItem base;
20+ QVector<Transcriber::TranscriberItem> optionals;
2021
21- int note;
22- int brightness;
23-
2422 unsigned int numThreads;
2523 };
2624
--- vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.h (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.h (revision 1974)
@@ -6,14 +6,17 @@
66 #include <QWaitCondition>
77 #include <QVector>
88
9-#include "TranscriberSetting.h"
10-
119 namespace stand
1210 {
11+namespace io
12+{
13+class UtauLibrary;
14+}
1315 namespace synthesis
1416 {
1517
1618 class TranscriberElement;
19+class TranscriberSetting;
1720
1821 class Transcriber : public QThread
1922 {
@@ -27,13 +30,20 @@
2730 void elementFinished(stand::synthesis::TranscriberElement *e);
2831
2932 public:
30- explicit Transcriber(const TranscriberSetting &s, QObject *parent = 0);
33+ struct TranscriberItem
34+ {
35+ stand::io::UtauLibrary *lib;
36+ int note;
37+ int brightness;
38+ };
39+
40+ explicit Transcriber(const TranscriberSetting *s, QObject *parent = 0);
3141 ~Transcriber();
3242
3343 void run();
3444
3545 private:
36- TranscriberSetting setting;
46+ const TranscriberSetting *setting;
3747 int currentFinished;
3848 int currentIndex;
3949 QVector<TranscriberElement *> elements;
--- vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.cpp (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.cpp (revision 1974)
@@ -18,10 +18,10 @@
1818 this->mutex = m;
1919 this->transcriber = t;
2020
21- libs.push_back(s->base);
21+ items.push_back(s->base);
2222 for(int i = 0; i < s->optionals.size(); i++)
2323 {
24- libs.push_back(s->optionals.at(i));
24+ items.push_back(s->optionals.at(i));
2525 }
2626 isFinished = false;
2727 }
@@ -44,7 +44,7 @@
4444 {
4545 stand::io::StandFile *prev, *current = NULL;
4646 prev = new stand::io::StandFile();
47- QString filename = libs.at(0)->directory().absolutePath() + QDir::separator() + libs.at(0)->at(index)->filename;
47+ QString filename = items.at(0).lib->directory().absolutePath() + QDir::separator() + items.at(0).lib->at(index)->filename;
4848 // 簡単だけど拡張子チェック
4949 if(filename.contains(".vvd") && !prev->read(QDir::toNativeSeparators(filename).toLocal8Bit().data()))
5050 {
@@ -52,12 +52,12 @@
5252 delete prev;
5353 prev = NULL;
5454 }
55- for(int i = 1; i < libs.size(); i++)
55+ for(int i = 1; i < items.size(); i++)
5656 {
57- const stand::io::UtauPhoneme *phoneme = libs.at(i)->find(libs.at(0)->at(index)->pronounce);
57+ const stand::io::UtauPhoneme *phoneme = items.at(i).lib->find(items.at(0).lib->at(index)->pronounce);
5858 if(phoneme)
5959 {
60- filename = libs.at(i)->directory().absolutePath() + QDir::separator() + phoneme->filename;
60+ filename = items.at(i).lib->directory().absolutePath() + QDir::separator() + phoneme->filename;
6161 current = new stand::io::StandFile();
6262 // 現在のファイルを読み込む→現在のファイルがよめていて,前回もファイルが読めていた場合だけ分析を行う.
6363 if(filename.contains(".vvd") && current->read(QDir::toNativeSeparators(filename).toLocal8Bit().data()) && prev)
@@ -64,6 +64,8 @@
6464 {
6565 // ToDo:: 写像関数の計算と保存
6666 stand::io::StandFile::matching(prev, current);
67+ // ファイルへ保存.
68+ current->write(QDir::toNativeSeparators(filename).toLocal8Bit().data());
6769 }
6870 else
6971 {
--- vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.h (revision 1973)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberElement.h (revision 1974)
@@ -4,6 +4,8 @@
44 #include <QThread>
55 #include <QVector>
66
7+#include "Transcriber.h"
8+
79 class QMutex;
810
911 namespace stand
@@ -15,7 +17,6 @@
1517 namespace synthesis
1618 {
1719
18-class Transcriber;
1920 class TranscriberSetting;
2021
2122 class TranscriberElement : public QThread
@@ -34,7 +35,7 @@
3435 QMutex *mutex;
3536 Transcriber *transcriber;
3637
37- QVector<stand::io::UtauLibrary *> libs;
38+ QVector<Transcriber::TranscriberItem> items;
3839
3940 bool isFinished;
4041 };
旧リポジトリブラウザで表示