Skip to content

Commit

Permalink
Merge pull request #8 from traP-jp/game
Browse files Browse the repository at this point in the history
v0.2
  • Loading branch information
TwoSquirrels authored Sep 28, 2024
2 parents 29d8e58 + a7d7ae4 commit de1e6a8
Show file tree
Hide file tree
Showing 51 changed files with 804 additions and 220 deletions.
2 changes: 2 additions & 0 deletions ShoutWars.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<ClCompile Include="Source\Multiplay\RoomInfo.cpp" />
<ClCompile Include="Source\Result.cpp" />
<ClCompile Include="Source\Title.cpp" />
<ClCompile Include="Source\Voice\MFCC.cpp" />
<ClCompile Include="Source\Voice\MFCCAnalyzer.cpp" />
<ClCompile Include="Source\Voice\Phoneme.cpp" />
<ClCompile Include="Source\Voice\WordDetector.cpp" />
Expand Down Expand Up @@ -250,6 +251,7 @@
<ClInclude Include="Source\Multiplay\RoomInfo.hpp" />
<ClInclude Include="Source\Result.hpp" />
<ClInclude Include="Source\Title.hpp" />
<ClInclude Include="Source\Voice\MFCC.hpp" />
<ClInclude Include="Source\Voice\MFCCAnalyzer.hpp" />
<ClInclude Include="Source\Voice\Phoneme.hpp" />
<ClInclude Include="Source\Voice\WordDetector.hpp" />
Expand Down
6 changes: 6 additions & 0 deletions ShoutWars.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@
<ClCompile Include="Source\Voice\WordDetector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Source\Voice\MFCC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="App\icon.ico">
Expand Down Expand Up @@ -521,5 +524,8 @@
<ClInclude Include="Source\Voice\WordDetector.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Source\Voice\MFCC.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
14 changes: 7 additions & 7 deletions Source/Calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ void Calibration::update() {

// 音声解析
phoneme.mic.fft(fftResult, FFTSampleLength::SL2K);
phonemeId = phoneme.estimate(FFTSampleLength::SL2K);
phonemeScores = phoneme.estimate(FFTSampleLength::SL2K);

// 音素登録ボタン
for (size_t id : step(12)) {
if (phonemeRects[id].mouseOver()) {
Cursor::RequestStyle(CursorStyle::Hand);
if (MouseL.down()) isWaitingToSet = true;
if (isWaitingToSet && MouseL.pressedDuration() >= 0.4s) {
if (isWaitingToSet && MouseL.pressedDuration() >= 0.8s) {
isWaitingToSet = false;
phoneme.setMFCC(id);
}
Expand Down Expand Up @@ -74,7 +74,7 @@ void Calibration::draw() const {
RectF{
Arg::topLeft(1800.0 - 1680.0 * (nowUs - timeUs) / (phoneme.mfccHistoryLife / 1.1), 140.0 + i * 30.0),
1680.0 * 50'000 / (phoneme.mfccHistoryLife / 1.1), 30.0
}.draw(HSV{ 150 - mfcc[i] * 2, 0.6 });
}.draw(HSV{ 510.0 - mfcc.feature[i] * 2.0, 0.6 });
}
}
RectF{ Arg::rightCenter(120, 320), 200.0, 366.0 }.draw(Palette::Black);
Expand All @@ -88,19 +88,19 @@ void Calibration::draw() const {
for (size_t i : step(12)) {
RectF{
rect.x, rect.y + i * (rect.h / 12), rect.w, rect.h / 12
}.draw(HSV{ 150 - phoneme.mfccList[id][i] * 2, 0.6 });
}.draw(HSV{ 510.0 - phoneme.mfccList[id].feature[i] * 2.0, 0.6 });
}
if (!rect.mouseOver()) rect.drawFrame(4, Palette::White);
else if (!MouseL.pressed()) rect.drawFrame(12, Palette::White);
else if (MouseL.pressedDuration() < 0.5s) rect.drawFrame(12, Palette::Orange);
else if (MouseL.pressedDuration() < 1.0s) rect.drawFrame(12, Palette::Orange);
else rect.drawFrame(10, Palette::Limegreen);
font(phonemeNames[id]).draw(
30,
Arg::topCenter(rect.bottomCenter() + Vec2{ 0, 20 }),
id == phonemeId ? Palette::Limegreen : Palette::Orange
phonemeScores[id] >= 0.75 ? Palette::Limegreen : Palette::Orange
);
}
font(U"登録したい音素を発音しながら緑に光るまで長押ししてください").draw(40, 120, 540);
font(U"登録したい音素を雑音が入らないように気を付けて発音しながら緑に光るまで長押ししてください").draw(30, 120, 545);

// 入力感度
double rootThreshold = sqrt(phoneme.volumeThreshold);
Expand Down
4 changes: 2 additions & 2 deletions Source/Calibration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Calibration : public App::Scene {
FFTResult fftResult;
size_t phonemeId = 0;
Array<double> phonemeScores = Array<double>(12, 0.0);
bool isWaitingToSet = false;

Font font{ FontMethod::MSDF, 80 };
Expand All @@ -19,7 +19,7 @@ class Calibration : public App::Scene {

public:
Calibration(const InitData& init);
~Calibration();
~Calibration() override;

void update() override;
void draw() const override;
Expand Down
Loading

0 comments on commit de1e6a8

Please sign in to comment.