コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
eb90cfd9c6
|
||
|
|
eaaebb43fe | ||
|
|
2baedff12c
|
||
|
|
9e114cc414
|
||
|
|
316b4fe1b6
|
||
|
|
0a2a9a2bf6
|
||
|
|
fa1758de0d
|
||
|
|
fe5801cefe
|
||
|
|
63198039dc
|
||
|
|
ba001e1d23
|
||
|
|
26d3f2007e
|
||
|
|
5328d1efe3
|
||
|
|
6dc3b7f4f7
|
||
|
|
36169bc285
|
||
|
|
b997849ece
|
||
|
|
fbf5745ff7 | ||
|
|
9b9b922164
|
||
|
|
703bb6b3a4
|
||
|
|
5b599a7f25
|
||
|
|
b4455e3252
|
||
|
|
aca86e31b7
|
||
|
|
8aa4a6f64b
|
検索条件に一致するファイルはありません
+12
-5
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
UTAU for YMM4 v1.2.0
|
||||
UTAU for YMM4 v1.6.1
|
||||
========================================
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合成する
|
||||
音声合成プラグインです。
|
||||
@@ -40,8 +40,12 @@ WorldNet で分析して合成し直します。
|
||||
複数のアイテムへ分けて並べられます。分けて置くと、編集のたびに合成し直す
|
||||
範囲が狭くなります。フレーズの中の音は分ける前と変わりません。
|
||||
|
||||
- 合成した音は区間ごとに覚えておき、直したノートを含む区間だけを合成し直します。
|
||||
区間は休符で切れる塊です。表現の帯で曲線を引いているときは行いません。
|
||||
- 合成は休符で切れる区間ごとに複数のコアで並列に行います。区間は互いに独立して
|
||||
いるため、並列にしても結果は変わりません。
|
||||
|
||||
- 合成した音は区間ごとに覚えておきます。音程や音量のように位置が動かない編集
|
||||
では、直したノートを含む区間だけを合成し直します。区間は休符で切れる塊です。
|
||||
表現の帯で曲線を引いているときは行いません。
|
||||
|
||||
- 歌詞は、かなのほか a か のような連続音の形とローマ字でも書けます。歌詞の
|
||||
最後の空白より後ろをかなへ戻して照合するため、連続音の譜面を単独音の音源で
|
||||
@@ -52,6 +56,9 @@ WorldNet で分析して合成し直します。
|
||||
|
||||
- アイテムの編集画面の「ノートを編集」から、音程・長さ・ビブラート・
|
||||
ポルタメント・表現曲線を編集できます。
|
||||
|
||||
- ノートエディターの工具列に出る文言が幅に収まらないときは、2 秒おいてから
|
||||
端まで送り、2 秒おいて戻ります。収まっているときは動きません。
|
||||
--------------------------------------------------------------------------------
|
||||
■ 対応フォーマット
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -78,8 +85,8 @@ WorldNet で分析して合成し直します。
|
||||
キャッシュするため、2 回目以降は速くなります。上限は既定で 512MB で、
|
||||
64MB から 4096MB まで設定画面から変更できます。
|
||||
|
||||
- 合成は 1 件ずつ順に行います。休符を挟まずに続く区間が長すぎると
|
||||
合成できません。文を分けてください。
|
||||
- 合成の要求は 1 件ずつ順に処理します。1 件の中では区間ごとに並列に合成します。
|
||||
休符を挟まずに続く区間が長すぎると合成できません。文を分けてください。
|
||||
|
||||
- UST の Flags と旧式の音程には対応していません。UST の書き出しにも
|
||||
対応していません。
|
||||
|
||||
@@ -50,6 +50,88 @@ jobs:
|
||||
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
|
||||
echo "VERSION=$($tag.TrimStart('v'))" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: バージョン記載の照合と訂正
|
||||
shell: pwsh
|
||||
run: |
|
||||
function Read-TextKeepingBom {
|
||||
param([string]$Path)
|
||||
$bytes = [System.IO.File]::ReadAllBytes($Path)
|
||||
$hasBom = $bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF
|
||||
$offset = 0
|
||||
if ($hasBom) { $offset = 3 }
|
||||
return @{
|
||||
Text = [System.Text.Encoding]::UTF8.GetString($bytes, $offset, $bytes.Length - $offset)
|
||||
HasBom = $hasBom
|
||||
}
|
||||
}
|
||||
|
||||
function Write-TextKeepingBom {
|
||||
param([string]$Path, [string]$Text, [bool]$HasBom)
|
||||
$body = [System.Text.Encoding]::UTF8.GetBytes($Text)
|
||||
if ($HasBom) { $body = [byte[]](0xEF, 0xBB, 0xBF) + $body }
|
||||
[System.IO.File]::WriteAllBytes($Path, $body)
|
||||
}
|
||||
|
||||
function Repair-VersionFiles {
|
||||
param([string]$Root, [string]$Version, [string]$Tag)
|
||||
$changed = @()
|
||||
|
||||
$csprojPath = Join-Path $Root "UTAU/UTAU.csproj"
|
||||
$csproj = Read-TextKeepingBom -Path $csprojPath
|
||||
$wantedCsproj = "<Version>$Version</Version>"
|
||||
if (-not $csproj.Text.Contains($wantedCsproj)) {
|
||||
$updated = $csproj.Text -replace '<Version>[^<]*</Version>', $wantedCsproj
|
||||
if (-not $updated.Contains($wantedCsproj)) { throw "UTAU.csproj に <Version> が見つかりませんでした" }
|
||||
Write-TextKeepingBom -Path $csprojPath -Text $updated -HasBom $csproj.HasBom
|
||||
$changed += "UTAU/UTAU.csproj"
|
||||
}
|
||||
|
||||
$readmePath = Join-Path $Root ".github/Plugin_Readme.txt"
|
||||
$readme = Read-TextKeepingBom -Path $readmePath
|
||||
$wantedHeading = " UTAU for YMM4 $Tag"
|
||||
if (-not $readme.Text.Contains($wantedHeading)) {
|
||||
$updated = $readme.Text -replace '(?m)^( UTAU for YMM4 )v[0-9][^\r\n]*', "`${1}$Tag"
|
||||
if (-not $updated.Contains($wantedHeading)) { throw "Plugin_Readme.txt の見出しが見つかりませんでした" }
|
||||
Write-TextKeepingBom -Path $readmePath -Text $updated -HasBom $readme.HasBom
|
||||
$changed += ".github/Plugin_Readme.txt"
|
||||
}
|
||||
|
||||
return $changed
|
||||
}
|
||||
|
||||
$tag = "${{ steps.version.outputs.TAG }}"
|
||||
$version = "${{ steps.version.outputs.VERSION }}"
|
||||
$changed = Repair-VersionFiles -Root "." -Version $version -Tag $tag
|
||||
|
||||
if ($changed.Count -eq 0) {
|
||||
Write-Host "バージョン記載は $tag と一致しています"
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host "タグと合わない記載を訂正しました: $($changed -join ', ')"
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git fetch origin main --quiet
|
||||
|
||||
$sync = Join-Path $env:RUNNER_TEMP "version-sync"
|
||||
git worktree add $sync origin/main --quiet
|
||||
Repair-VersionFiles -Root $sync -Version $version -Tag $tag | Out-Null
|
||||
|
||||
Push-Location $sync
|
||||
git add -A
|
||||
$pending = git diff --cached --name-only
|
||||
if ($pending) {
|
||||
git commit -m "バージョンを${tag}へ合わせる" --quiet
|
||||
git push origin HEAD:main
|
||||
Write-Host "main へ訂正を反映しました"
|
||||
} else {
|
||||
Write-Host "main は既に $tag と一致しています"
|
||||
}
|
||||
Pop-Location
|
||||
|
||||
git worktree remove $sync --force
|
||||
|
||||
- name: resx ファイルの生成(初回ビルド)
|
||||
shell: pwsh
|
||||
run: |
|
||||
@@ -100,6 +182,12 @@ jobs:
|
||||
Copy-Item ".github/LICENSE/*.txt" "$stageRoot/LICENSE/"
|
||||
Copy-Item ".github/Plugin_Readme.txt" "$stageRoot/Readme.txt"
|
||||
|
||||
$readme = Get-Content "$stageRoot/Readme.txt" -Raw
|
||||
if (-not $readme.Contains(" UTAU for YMM4 $version")) {
|
||||
Write-Error "同梱する Readme.txt の見出しが $version と一致しません"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Compress-Archive -Path "stage/*" -DestinationPath $pkgName -CompressionLevel Optimal
|
||||
echo "PKG_NAME=$pkgName" >> $env:GITHUB_OUTPUT
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合
|
||||
単独音・連続音・CVVC のいずれの音源にも対応し、UST ファイルの読み込みにも対応します。
|
||||
セリフのかなから組み立てたノートは、ピアノロールのノートエディターで編集できます。
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## 目次
|
||||
@@ -24,7 +26,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合
|
||||
- [3. UST ファイルの読み込み](#3-ust-ファイルの読み込み)
|
||||
- [4. ノートエディター](#4-ノートエディター)
|
||||
- [5. WORLD による合成](#5-world-による合成)
|
||||
- [6. 解析キャッシュ](#6-解析キャッシュ)
|
||||
- [6. 解析と合成の再利用](#6-解析と合成の再利用)
|
||||
5. [音程記法](#音程記法)
|
||||
6. [パラメータ一覧](#パラメータ一覧)
|
||||
7. [ノートの項目一覧](#ノートの項目一覧)
|
||||
@@ -46,7 +48,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合
|
||||
|
||||
セリフに書いたかなからノート列を組み立てるほか、UST ファイルのパスを書くとその譜面をそのまま読み込みます。組み立てたノートはノートエディターで編集でき、音程・長さ・ビブラート・ポルタメント・表現曲線を調整できます。
|
||||
|
||||
音声ファイルの分析結果と、合成した音を区間ごとにメモリへ保持するため、2 回目以降の合成が速くなります。1 つのノートを直したときは、そのノートを含む区間だけを合成し直します。
|
||||
音声ファイルの分析結果と、合成した音を区間ごとにメモリへ保持するため、2 回目以降の合成が速くなります。1 つのノートを直したときは、その周りの区間だけを合成し直します。
|
||||
|
||||
画面の表示は日本語のほか、英語、簡体字と繁体字の中国語、韓国語、スペイン語、アラビア語、インドネシア語に対応します。
|
||||
|
||||
@@ -122,6 +124,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合
|
||||
- 休符の挿入、ノートの削除、すべてのノートの選択、表示範囲に合わせる操作をボタンから行えます。
|
||||
- ノートは隙間なく並びます。間を空けるときは休符を挿入します。
|
||||
- 原音設定に見つからなかった歌詞があるときは、工具列の右端に警告として並びます。ノートエディターを開いたままでも、合成をやり直すたびに書き換わります。
|
||||
- 工具列の文言が幅に収まらないときは、2 秒おいてから端まで送り、2 秒おいて戻ります。収まっているときは動きません。
|
||||
- 編集内容は YMM4 の取り消しとやり直しに対応します。合成の結果として作られる情報は取り消しの対象になりません。
|
||||
|
||||
### 5. WORLD による合成
|
||||
@@ -134,11 +137,13 @@ YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合
|
||||
|
||||
出力は 16 ビットのモノラル WAV です。ノートの母音から口パクに使う情報も作ります。
|
||||
|
||||
### 6. 解析キャッシュ
|
||||
### 6. 解析と合成の再利用
|
||||
|
||||
分析結果は、音声ファイルの場所と更新日時と読み込む範囲と推定方法を鍵にしてメモリへ保持します。2 回目以降の合成では分析をやり直しません。上限は既定で 512MB で、64MB から 4096MB まで設定できます。上限を超えると古い物から捨てます。設定画面から破棄することもできます。複数の音声ファイルの分析は複数のコアで並列に行います。
|
||||
|
||||
合成した音そのものも区間ごとに保持します。区間は休符で切れる塊で、50 ミリ秒より離れたノートの間で分かれます。鍵には、その区間の合成に使う値をすべて入れます。原音の場所と切り出す範囲、ノートの音程・長さ・子音速度・音量・モジュレーション・ビブラート・音程曲線、合成の設定、区間の位置と長さです。1 つのノートを直すと、そのノートを含む区間だけを合成し直し、残りはそのまま使います。上限は既定で 256MB で、64MB から 4096MB まで設定できます。超えると古い物から捨てます。設定画面の破棄は分析と区間の両方を消します。表現の帯でフォルマントか息の量の曲線を引いているときは、曲線が時刻ごとに変わるため区間の再利用を行いません。
|
||||
区間ごとの合成は複数のコアで並列に行います。区間は互いに独立しているため、並列にしても結果は変わりません。同時に使うコアの数は、区間の大きさから必要な作業領域を見積もり、合計が 768MB に収まる範囲で決めます。
|
||||
|
||||
合成した音そのものも区間ごとに保持します。区間は休符で切れる塊で、50 ミリ秒より離れたノートの間で分かれます。鍵には、その区間の合成に使う値をすべて入れます。原音の場所と切り出す範囲、ノートの音程・長さ・子音速度・音量・モジュレーション・ビブラート・音程曲線、合成の設定、区間の位置と長さです。鍵は区間の中での相対的な位置で作るため、後ろのノートが前後へ動いただけの区間はそのまま使います。音程や音量のように位置が動かない編集では、直したノートを含む区間だけを合成し直します。ノートの長さを変えたときは、区間の切れ目がフレームの丸めでずれる分だけ、いくつかの区間を合成し直します。上限は既定で 256MB で、64MB から 4096MB まで設定できます。超えると古い物から捨てます。設定画面の破棄は分析と区間の両方を消します。表現の帯でフォルマントか息の量の曲線を引いているときは、曲線が時刻ごとに変わるため区間の再利用を行いません。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using UTAU.Notes;
|
||||
using UTAU.Phonemes;
|
||||
using UTAU.Synthesis;
|
||||
using UTAU.ViewModels;
|
||||
using WorldNet;
|
||||
|
||||
namespace UTAU.Tests;
|
||||
|
||||
@@ -457,9 +456,8 @@ public sealed class CurveRenderingTests : IDisposable
|
||||
{
|
||||
var notes = NoteSequenceBuilder.Build("<!C4:1/4>あ", NoteBuildOptions.Create(60));
|
||||
var units = Phonemizer.Phonemize(bank, TempoMap.Create(notes, TimeBase.Default), null, PhonemizeOptions.Default);
|
||||
using var arena = new WorldArena();
|
||||
var settings = RenderSettings.Default with { Estimator = F0Estimator.Dio };
|
||||
return new UtauRenderer(settings, curves, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render(units, arena).Samples;
|
||||
return new UtauRenderer(settings, curves, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render(units).Samples;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
using UTAU.Models;
|
||||
using UTAU.Notes;
|
||||
using UTAU.Phonemes;
|
||||
using UTAU.Synthesis;
|
||||
|
||||
namespace UTAU.Tests;
|
||||
|
||||
public sealed class ParallelRenderTests : IDisposable
|
||||
{
|
||||
const double SampleMilliseconds = 300.0;
|
||||
|
||||
readonly string directory = TestVoiceBank.CreateTemporaryDirectory();
|
||||
readonly AnalysisCache analysis = new(AnalysisCache.DefaultBudgetBytes);
|
||||
|
||||
public void Dispose() => TestVoiceBank.DeleteDirectory(directory);
|
||||
|
||||
VoiceBank Bank()
|
||||
{
|
||||
TestVoiceBank.WriteText(directory, VoiceBankLoader.CharacterFileName, "name=parallel\r\n");
|
||||
TestVoiceBank.WriteText(
|
||||
directory,
|
||||
VoiceBankLoader.OtoFileName,
|
||||
string.Join("\r\n",
|
||||
[
|
||||
"a.wav=あ,50,80,-200,100,40",
|
||||
"ka.wav=か,50,120,-200,140,50",
|
||||
"sa.wav=さ,50,120,-200,140,50",
|
||||
]));
|
||||
var index = 0;
|
||||
foreach (var name in new[] { "a.wav", "ka.wav", "sa.wav" })
|
||||
TestVoiceBank.WriteSample(directory, name, TestVoiceBank.CreateVowel(180.0 + index++ * 40.0, SampleMilliseconds));
|
||||
return VoiceBankLoader.Load("parallel", directory);
|
||||
}
|
||||
|
||||
static UTAUNote[] Score(int phrases)
|
||||
{
|
||||
var notes = new List<UTAUNote>();
|
||||
string[] lyrics = ["あ", "か", "さ"];
|
||||
for (var phrase = 0; phrase < phrases; phrase++)
|
||||
{
|
||||
if (phrase > 0)
|
||||
notes.Add(new UTAUNote { Lyric = UTAUNote.RestLyric, LengthTicks = 240, Tone = 60 });
|
||||
for (var index = 0; index < 4; index++)
|
||||
notes.Add(new UTAUNote { Lyric = lyrics[index % 3], LengthTicks = 240, Tone = 60 + index % 5 });
|
||||
}
|
||||
return [.. notes];
|
||||
}
|
||||
|
||||
double[] Render(VoiceBank bank, UTAUNote[] notes, SegmentCache cache)
|
||||
{
|
||||
var units = Phonemizer.Phonemize(bank, TempoMap.Create(notes, TimeBase.Default), null, PhonemizeOptions.Default);
|
||||
var renderer = new UtauRenderer(
|
||||
RenderSettings.Default with { Estimator = F0Estimator.Dio },
|
||||
RenderCurves.Empty,
|
||||
analysis,
|
||||
cache);
|
||||
return renderer.Render(units).Samples;
|
||||
}
|
||||
|
||||
static SegmentCache Fresh() => new(SegmentCache.DefaultBudgetBytes);
|
||||
|
||||
[Theory]
|
||||
[InlineData(1)]
|
||||
[InlineData(2)]
|
||||
[InlineData(8)]
|
||||
[InlineData(20)]
|
||||
public void RenderingTheSameScoreTwiceGivesTheSameAudio(int phrases)
|
||||
{
|
||||
var bank = Bank();
|
||||
var notes = Score(phrases);
|
||||
|
||||
var first = Render(bank, notes, Fresh());
|
||||
var second = Render(bank, notes, Fresh());
|
||||
|
||||
Assert.Equal(first, second);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RepeatedRendersStayIdentical()
|
||||
{
|
||||
var bank = Bank();
|
||||
var notes = Score(12);
|
||||
var expected = Render(bank, notes, Fresh());
|
||||
|
||||
for (var pass = 0; pass < 5; pass++)
|
||||
Assert.Equal(expected, Render(bank, notes, Fresh()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EverySegmentWritesADistinctStretchOfTheOutput()
|
||||
{
|
||||
var bank = Bank();
|
||||
var notes = Score(20);
|
||||
var samples = Render(bank, notes, Fresh());
|
||||
|
||||
var silent = 0;
|
||||
foreach (var value in samples)
|
||||
{
|
||||
if (value == 0.0)
|
||||
silent++;
|
||||
}
|
||||
|
||||
Assert.True(samples.Length > 0);
|
||||
Assert.True(silent < samples.Length, "the render produced only silence");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ACachedParallelRenderMatchesAFreshOne()
|
||||
{
|
||||
var bank = Bank();
|
||||
var notes = Score(20);
|
||||
var shared = Fresh();
|
||||
|
||||
var warm = Render(bank, notes, shared);
|
||||
notes[5].Tone = 68;
|
||||
|
||||
var cached = Render(bank, notes, shared);
|
||||
var fresh = Render(bank, notes, Fresh());
|
||||
|
||||
Assert.Equal(fresh, cached);
|
||||
Assert.False(warm.AsSpan().SequenceEqual(cached));
|
||||
}
|
||||
}
|
||||
@@ -475,10 +475,66 @@ public sealed class UnitTimingBuilderTests
|
||||
public void PreutteranceIsScaledDownWhenThePreviousNoteIsTooShort()
|
||||
{
|
||||
var timings = UnitTimingBuilder.Build([CreateUnit(0.0, 20.0, 0.0, 0.0), CreateUnit(20.0, 200.0, 80.0, 40.0)]);
|
||||
Assert.Equal(-20.0, timings[1].AudioStartMilliseconds, 9);
|
||||
Assert.Equal(20.0, timings[1].FadeInMilliseconds, 9);
|
||||
Assert.Equal(5.0, timings[1].AudioStartMilliseconds, 9);
|
||||
Assert.Equal(7.5, timings[1].FadeInMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void APlosiveKeepsOneTenthOfThePreviousNote()
|
||||
{
|
||||
var timings = UnitTimingBuilder.Build([CreateUnit(0.0, 100.0, 0.0, 0.0), CreateUnit(100.0, 200.0, 200.0, -10.0)]);
|
||||
Assert.Equal(10.0, timings[1].AudioStartMilliseconds, 9);
|
||||
Assert.Equal(UTAUNote.DefaultFadeInMilliseconds, timings[1].FadeInMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ARestLimitsThePreutteranceToTheGap()
|
||||
{
|
||||
var rest = new PhonemeUnit(new UTAUNote { Lyric = UTAUNote.RestLyric }, null, "R", 100.0, 30.0, 100.0, 30.0, 60);
|
||||
var timings = UnitTimingBuilder.Build([CreateUnit(0.0, 100.0, 0.0, 0.0), rest, CreateUnit(130.0, 200.0, 80.0, 40.0)]);
|
||||
Assert.Equal(100.0, timings[1].AudioStartMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ANegativeOverlapLeavesAGapBeforeTheNextUnit()
|
||||
{
|
||||
var timings = UnitTimingBuilder.Build([CreateUnit(0.0, 200.0, 0.0, 0.0), CreateUnit(200.0, 200.0, 60.0, -10.0)]);
|
||||
Assert.Equal(130.0, timings[0].AudioEndMilliseconds, 9);
|
||||
Assert.Equal(140.0, timings[1].AudioStartMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ANegativeOverlapIsLimitedByTheDefaultRelease()
|
||||
{
|
||||
var timings = UnitTimingBuilder.Build([CreateUnit(0.0, 100.0, 0.0, 0.0), CreateUnit(100.0, 200.0, 20.0, -60.0)]);
|
||||
Assert.Equal(35.0, timings[0].AudioEndMilliseconds, 9);
|
||||
Assert.Equal(80.0, timings[1].AudioStartMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThePreutteranceNeverExceedsThePreviousNote()
|
||||
{
|
||||
var timings = UnitTimingBuilder.Build([CreateUnit(0.0, 30.0, 10.0, 0.0), CreateUnit(30.0, 200.0, 100.0, 80.0)]);
|
||||
Assert.Equal(0.0, timings[1].AudioStartMilliseconds, 9);
|
||||
Assert.Equal(24.0, timings[1].FadeInMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ALimitedPreutteranceSkipsIntoTheSample()
|
||||
{
|
||||
var timings = UnitTimingBuilder.Build([CreateUnit(0.0, 20.0, 0.0, 0.0), CreateUnit(20.0, 200.0, 80.0, 40.0)]);
|
||||
var timing = timings[1];
|
||||
var map = TimeMap.Create(0.0, 200.0, 400.0, timing.RenderLengthMilliseconds + timing.SkipMilliseconds, 100.0, StretchMode.Stretch);
|
||||
var atNoteStart = timing.Unit.StartMilliseconds - timing.AudioStartMilliseconds + timing.SkipMilliseconds;
|
||||
|
||||
Assert.Equal(65.0, timing.SkipMilliseconds, 9);
|
||||
Assert.Equal(80.0, map.Map(atNoteStart), 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnUnlimitedPreutteranceSkipsNothing()
|
||||
=> Assert.Equal(0.0, Assert.Single(UnitTimingBuilder.Build([CreateUnit(100.0, 200.0, 40.0, 20.0)])).SkipMilliseconds, 9);
|
||||
|
||||
[Fact]
|
||||
public void SilentUnitsAreNotRendered()
|
||||
{
|
||||
@@ -537,6 +593,27 @@ public sealed class UnitTimingBuilderTests
|
||||
Assert.Equal(60.0, Assert.Single(UnitTimingBuilder.Build([unit])).AudioStartMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheConsonantVelocityScalesThePreutterance()
|
||||
{
|
||||
var unit = CreateUnit(100.0, 200.0, 40.0, 20.0);
|
||||
unit.Note.Velocity = 200.0;
|
||||
var timing = Assert.Single(UnitTimingBuilder.Build([unit]));
|
||||
|
||||
Assert.Equal(80.0, timing.AudioStartMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnOverriddenPreutteranceIgnoresTheConsonantVelocity()
|
||||
{
|
||||
var unit = CreateUnit(100.0, 200.0, 40.0, 20.0);
|
||||
unit.Note.PreutteranceOverride = 10.0;
|
||||
unit.Note.Velocity = 200.0;
|
||||
var timing = Assert.Single(UnitTimingBuilder.Build([unit]));
|
||||
|
||||
Assert.Equal(90.0, timing.AudioStartMilliseconds, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyInputProducesNoTimings()
|
||||
=> Assert.Empty(UnitTimingBuilder.Build([]));
|
||||
|
||||
@@ -68,10 +68,10 @@ public sealed class RenderMessageDisplayTests
|
||||
return host;
|
||||
}
|
||||
|
||||
static TextBlock WarningBlock(Border host)
|
||||
static ScrollingText WarningBlock(Border host)
|
||||
=> Descend(host)
|
||||
.OfType<DockPanel>()
|
||||
.SelectMany(x => x.Children.OfType<TextBlock>())
|
||||
.SelectMany(x => x.Children.OfType<ScrollingText>())
|
||||
.First(x => DockPanel.GetDock(x) == Dock.Right);
|
||||
|
||||
[Fact]
|
||||
|
||||
+25
-5
@@ -119,12 +119,33 @@ public sealed class UtauRendererTests : IDisposable
|
||||
{
|
||||
var notes = NoteSequenceBuilder.Build(text, NoteBuildOptions.Create(60));
|
||||
var units = Phonemizer.Phonemize(bank, TempoMap.Create(notes, new TimeBase(tempo, speed)), null, PhonemizeOptions.Default);
|
||||
using var arena = new WorldArena();
|
||||
return new UtauRenderer(settings ?? RenderSettings.Default with { Estimator = F0Estimator.Dio }, curves ?? RenderCurves.Empty, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render(units, arena);
|
||||
return new UtauRenderer(settings ?? RenderSettings.Default with { Estimator = F0Estimator.Dio }, curves ?? RenderCurves.Empty, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render(units);
|
||||
}
|
||||
|
||||
static double Peak(double[] samples) => samples.Length == 0 ? 0.0 : samples.Max(Math.Abs);
|
||||
|
||||
VoiceBank BankAtLevel(string name, double level)
|
||||
{
|
||||
var path = Path.Combine(directory, name);
|
||||
Directory.CreateDirectory(path);
|
||||
TestVoiceBank.WriteText(path, VoiceBankLoader.CharacterFileName, "name=試験音源\r\n");
|
||||
TestVoiceBank.WriteText(path, VoiceBankLoader.OtoFileName, "a.wav=あ,50,80,-500,100,40");
|
||||
TestVoiceBank.WriteSample(path, "a.wav", [.. TestVoiceBank.CreateVowel().Select(x => x * level)]);
|
||||
return VoiceBankLoader.Load(name, path);
|
||||
}
|
||||
|
||||
const double QuietLevel = 0.25;
|
||||
const double PeakCompression = 0.86;
|
||||
|
||||
[Fact]
|
||||
public void AQuietSampleIsLiftedTowardTheSamePeak()
|
||||
{
|
||||
var loud = Peak(Render(BankAtLevel("loud", 1.0), "<!C4:1/4>あ").Samples);
|
||||
var quiet = Peak(Render(BankAtLevel("quiet", QuietLevel), "<!C4:1/4>あ").Samples);
|
||||
|
||||
Assert.Equal(Math.Pow(QuietLevel, 1.0 - PeakCompression), quiet / loud, 2);
|
||||
}
|
||||
|
||||
static double MeasureFundamental(RenderResult result)
|
||||
{
|
||||
using var arena = new WorldArena();
|
||||
@@ -294,8 +315,7 @@ public sealed class UtauRendererTests : IDisposable
|
||||
[Fact]
|
||||
public void UnitsWithoutAnyRenderableEntryProduceAnEmptyResult()
|
||||
{
|
||||
using var arena = new WorldArena();
|
||||
var result = new UtauRenderer(RenderSettings.Default with { Estimator = F0Estimator.Dio }, RenderCurves.Empty, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render([], arena);
|
||||
var result = new UtauRenderer(RenderSettings.Default with { Estimator = F0Estimator.Dio }, RenderCurves.Empty, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render([]);
|
||||
|
||||
Assert.Empty(result.Samples);
|
||||
Assert.Empty(result.Timings);
|
||||
@@ -341,7 +361,7 @@ public sealed class SegmentedRenderTests : IDisposable
|
||||
var units = Phonemizer.Phonemize(bank, TempoMap.Create(notes, TimeBase.Default), null, PhonemizeOptions.Default);
|
||||
using var arena = new WorldArena();
|
||||
var settings = RenderSettings.Default with { Estimator = F0Estimator.Dio };
|
||||
return new UtauRenderer(settings, RenderCurves.Empty, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render(units, arena).Samples;
|
||||
return new UtauRenderer(settings, RenderCurves.Empty, cache, new SegmentCache(SegmentCache.DefaultBudgetBytes)).Render(units).Samples;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using UTAU.Notes;
|
||||
using UTAU.ViewModels;
|
||||
using UTAU.Views;
|
||||
using YukkuriMovieMaker.Controls;
|
||||
|
||||
namespace UTAU.Tests;
|
||||
|
||||
[Collection("Wpf")]
|
||||
public sealed class ScrollingTextTests
|
||||
{
|
||||
const string Long = "697 個のノートを読み込みました 全 88 フレーズ 前後の休符 1200 ティックを除きました";
|
||||
const string Short = "12 個のノート";
|
||||
|
||||
static T RunSta<T>(Func<T> action)
|
||||
{
|
||||
var result = default(T)!;
|
||||
Exception? error = null;
|
||||
var thread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
result = action();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
error = exception;
|
||||
}
|
||||
});
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
thread.Join();
|
||||
if (error is not null)
|
||||
throw new InvalidOperationException(error.Message, error);
|
||||
return result;
|
||||
}
|
||||
|
||||
static IEnumerable<DependencyObject> Descend(DependencyObject root)
|
||||
{
|
||||
var count = VisualTreeHelper.GetChildrenCount(root);
|
||||
for (var index = 0; index < count; index++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(root, index);
|
||||
yield return child;
|
||||
foreach (var descendant in Descend(child))
|
||||
yield return descendant;
|
||||
}
|
||||
}
|
||||
|
||||
static (bool Scrolling, double Hidden, double Width) Measure(string text, double available)
|
||||
{
|
||||
var control = new ScrollingText { Text = text, FontSize = 12.0 };
|
||||
var host = new Border { Width = available, Height = 26.0, Child = control };
|
||||
host.Measure(new Size(available, 26.0));
|
||||
host.Arrange(new Rect(0.0, 0.0, available, 26.0));
|
||||
host.UpdateLayout();
|
||||
return (control.IsScrolling, control.HiddenWidth, control.ActualWidth);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShortTextDoesNotScroll()
|
||||
{
|
||||
var result = RunSta(() => Measure(Short, 400.0));
|
||||
|
||||
Assert.False(result.Scrolling);
|
||||
Assert.Equal(0.0, result.Hidden);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OverflowingTextScrolls()
|
||||
{
|
||||
var result = RunSta(() => Measure(Long, 200.0));
|
||||
|
||||
Assert.True(result.Scrolling);
|
||||
Assert.True(result.Hidden > 0.0, $"hidden={result.Hidden}");
|
||||
Assert.Equal(200.0, result.Width, 1);
|
||||
}
|
||||
|
||||
static double NaturalWidth(string text)
|
||||
{
|
||||
var control = new ScrollingText { Text = text, FontSize = 12.0 };
|
||||
control.Measure(new Size(double.PositiveInfinity, 26.0));
|
||||
return control.DesiredSize.Width;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TextThatFitsDoesNotScroll()
|
||||
{
|
||||
var result = RunSta(() =>
|
||||
{
|
||||
var natural = NaturalWidth(Long);
|
||||
return (natural, Measure(Long, natural + 8.0));
|
||||
});
|
||||
|
||||
Assert.True(result.natural > 0.0);
|
||||
Assert.False(result.Item2.Scrolling);
|
||||
Assert.Equal(0.0, result.Item2.Hidden);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheToolbarUsesScrollingTextForBothMessages()
|
||||
{
|
||||
var found = RunSta(() =>
|
||||
{
|
||||
var editor = new NoteEditor();
|
||||
var button = (PopupButton)editor.Content;
|
||||
var root = (Grid)button.PopupContent!;
|
||||
button.PopupContent = null;
|
||||
|
||||
var pronounce = new UTAUVoicePronounce { ImportMessage = Long, RenderMessage = Long };
|
||||
pronounce.Notes.Add(new UTAUNote { Lyric = "あ" });
|
||||
using var viewModel = new NoteEditorViewModel(pronounce);
|
||||
root.DataContext = viewModel;
|
||||
|
||||
var host = new Border { Width = 980.0, Height = 480.0, Child = root };
|
||||
host.Measure(new Size(980.0, 480.0));
|
||||
host.Arrange(new Rect(0.0, 0.0, 980.0, 480.0));
|
||||
host.UpdateLayout();
|
||||
|
||||
return Descend(host)
|
||||
.OfType<DockPanel>()
|
||||
.SelectMany(x => x.Children.OfType<ScrollingText>())
|
||||
.Select(x => x.Text)
|
||||
.ToArray();
|
||||
});
|
||||
|
||||
Assert.Equal(2, found.Length);
|
||||
Assert.All(found, x => Assert.Equal(Long, x));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using UTAU.Models;
|
||||
using UTAU.Notes;
|
||||
using UTAU.Phonemes;
|
||||
using UTAU.Synthesis;
|
||||
using WorldNet;
|
||||
|
||||
namespace UTAU.Tests;
|
||||
|
||||
@@ -51,13 +50,12 @@ public sealed class SegmentCacheTests : IDisposable
|
||||
double[] Render(VoiceBank bank, UTAUNote[] notes, RenderSettings? settings = null)
|
||||
{
|
||||
var units = Phonemizer.Phonemize(bank, TempoMap.Create(notes, TimeBase.Default), null, PhonemizeOptions.Default);
|
||||
using var arena = new WorldArena();
|
||||
var renderer = new UtauRenderer(
|
||||
settings ?? RenderSettings.Default with { Estimator = F0Estimator.Dio },
|
||||
RenderCurves.Empty,
|
||||
analysis,
|
||||
segments);
|
||||
return renderer.Render(units, arena).Samples;
|
||||
return renderer.Render(units).Samples;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -87,10 +85,52 @@ public sealed class SegmentCacheTests : IDisposable
|
||||
RenderCurves.Empty,
|
||||
analysis,
|
||||
new SegmentCache(SegmentCache.DefaultBudgetBytes));
|
||||
using var arena = new WorldArena();
|
||||
var units = Phonemizer.Phonemize(bank, TempoMap.Create(notes, TimeBase.Default), null, PhonemizeOptions.Default);
|
||||
|
||||
Assert.Equal(fresh.Render(units, arena).Samples, cached);
|
||||
Assert.Equal(fresh.Render(units).Samples, cached);
|
||||
}
|
||||
|
||||
static UTAUNote[] LongScore(int phrases)
|
||||
{
|
||||
var notes = new List<UTAUNote>();
|
||||
for (var phrase = 0; phrase < phrases; phrase++)
|
||||
{
|
||||
if (phrase > 0)
|
||||
notes.Add(new UTAUNote { Lyric = UTAUNote.RestLyric, LengthTicks = 240, Tone = 60 });
|
||||
notes.Add(new UTAUNote { Lyric = "あ", LengthTicks = 240, Tone = 60 });
|
||||
notes.Add(new UTAUNote { Lyric = "か", LengthTicks = 240, Tone = 62 });
|
||||
}
|
||||
return [.. notes];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShiftingTheWholeScoreReusesEveryLaterSegment()
|
||||
{
|
||||
var bank = Bank();
|
||||
var notes = LongScore(8);
|
||||
|
||||
Render(bank, notes);
|
||||
var before = segments.Count;
|
||||
|
||||
notes[0].PreutteranceOverride = 200.0;
|
||||
Render(bank, notes);
|
||||
|
||||
Assert.Equal(before + 1, segments.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnEditThatMovesLaterNotesRebuildsFewerThanEverySegment()
|
||||
{
|
||||
var bank = Bank();
|
||||
var notes = LongScore(8);
|
||||
|
||||
Render(bank, notes);
|
||||
var before = segments.Count;
|
||||
|
||||
notes[0].LengthTicks = 480;
|
||||
Render(bank, notes);
|
||||
|
||||
Assert.True(segments.Count - before < before, $"rebuilt={segments.Count - before} of {before}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -159,13 +199,12 @@ public sealed class SegmentCacheTests : IDisposable
|
||||
double[] RenderFresh(VoiceBank bank, UTAUNote[] notes, RenderSettings? settings = null)
|
||||
{
|
||||
var units = Phonemizer.Phonemize(bank, TempoMap.Create(notes, TimeBase.Default), null, PhonemizeOptions.Default);
|
||||
using var arena = new WorldArena();
|
||||
var renderer = new UtauRenderer(
|
||||
settings ?? RenderSettings.Default with { Estimator = F0Estimator.Dio },
|
||||
RenderCurves.Empty,
|
||||
analysis,
|
||||
new SegmentCache(SegmentCache.DefaultBudgetBytes));
|
||||
return renderer.Render(units, arena).Samples;
|
||||
return renderer.Render(units).Samples;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
@@ -60,19 +60,26 @@ public sealed class TimeMapTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StretchModeAlsoCompresses()
|
||||
public void StretchModeNeverRunsFasterThanTheSource()
|
||||
{
|
||||
var map = TimeMap.Create(0.0, 0.0, 400.0, 100.0, 100.0, StretchMode.Stretch);
|
||||
Assert.Equal(200.0, map.Map(50.0), 9);
|
||||
Assert.Equal(400.0, map.Map(100.0), 9);
|
||||
Assert.Equal(50.0, map.Map(50.0), 9);
|
||||
Assert.Equal(100.0, map.Map(100.0), 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConsonantIsCompressedWhenTheOutputIsShorterThanTheConsonant()
|
||||
public void ConsonantKeepsItsSpeedWhenTheOutputIsShorter()
|
||||
{
|
||||
var map = TimeMap.Create(0.0, 200.0, 400.0, 50.0, 100.0, StretchMode.Loop);
|
||||
Assert.Equal(50.0, map.ConsonantOutputLength, 9);
|
||||
Assert.Equal(200.0, map.Map(50.0), 9);
|
||||
Assert.Equal(200.0, map.ConsonantOutputLength, 9);
|
||||
Assert.Equal(50.0, map.Map(50.0), 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheConsonantVelocityScalesTheConsonantOutput()
|
||||
{
|
||||
Assert.Equal(100.0, TimeMap.Create(0.0, 200.0, 400.0, 1000.0, 200.0, StretchMode.Loop).ConsonantOutputLength, 9);
|
||||
Assert.Equal(400.0, TimeMap.Create(0.0, 200.0, 400.0, 1000.0, 0.0, StretchMode.Loop).ConsonantOutputLength, 9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -89,6 +96,24 @@ public sealed class TimeMapTests
|
||||
|
||||
public sealed class SpectrumTransformTests
|
||||
{
|
||||
[Fact]
|
||||
public void AMixingWeightAndAGainScaleThePowerAlike()
|
||||
{
|
||||
var scaled = SpectrumTransform.ToPower(0.25 * SpectrumTransform.ToAmplitude(4.0));
|
||||
var gained = new[] { 4.0 };
|
||||
SpectrumTransform.ApplyGain(gained, 0.25);
|
||||
|
||||
Assert.Equal(gained[0], scaled, 12);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MixingWeightsThatSumToOneKeepTheLevel()
|
||||
{
|
||||
var sum = 0.4 * SpectrumTransform.ToAmplitude(9.0) + 0.6 * SpectrumTransform.ToAmplitude(9.0);
|
||||
|
||||
Assert.Equal(9.0, SpectrumTransform.ToPower(sum), 12);
|
||||
}
|
||||
|
||||
static double[] CreatePeak(int size, int index)
|
||||
{
|
||||
var spectrum = new double[size];
|
||||
|
||||
@@ -150,7 +150,8 @@ public sealed class UstPhraseRangeTests : IDisposable
|
||||
Assert.Equal(["か", "あ"], second.Notes.Select(x => x.Lyric));
|
||||
Assert.Equal(UstPhraseRange.All, whole.ImportedRange);
|
||||
Assert.Equal(new UstPhraseRange(2, 1), second.ImportedRange);
|
||||
Assert.Contains(string.Format(Texts.UstPhraseTotalFormat, Phrases.Length), second.ImportMessage);
|
||||
Assert.Contains(string.Format(Texts.UstPhraseRangeFormat, 2, 1, Phrases.Length), second.ImportMessage);
|
||||
Assert.Contains(string.Format(Texts.UstPhraseTotalFormat, Phrases.Length), whole.ImportMessage);
|
||||
Assert.Contains(string.Format(Texts.UstPhraseOffsetFormat, 2160), second.ImportMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -388,6 +388,53 @@ public sealed class UstTests
|
||||
Assert.Equal(79520, rests.Sum(x => x.LengthTicks));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ANoteLongerThanTheNoteLimitKeepsTheTimeline()
|
||||
{
|
||||
var result = Import(Document(
|
||||
"Tempo=120.00",
|
||||
["Length=32640", "Lyric=a", "NoteNum=60"],
|
||||
["Length=480", "Lyric=i", "NoteNum=62"]));
|
||||
|
||||
Assert.Equal([30720, 1920, 480], result.Notes.Select(x => x.LengthTicks).ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ARestLongerThanTheNoteLimitKeepsTheTimeline()
|
||||
{
|
||||
var result = Import(Document(
|
||||
"Tempo=120.00",
|
||||
Sung(),
|
||||
["Length=32640", "Lyric=R", "NoteNum=60"],
|
||||
Sung("Lyric=i")));
|
||||
|
||||
Assert.Equal([480, 30720, 1920, 480], result.Notes.Select(x => x.LengthTicks).ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ARestShorterThanTheNoteLimitDoesNotPileUpDelay()
|
||||
{
|
||||
var result = Import(Document(
|
||||
"Tempo=120.00",
|
||||
Sung(),
|
||||
["Length=10", "Lyric=R", "NoteNum=60"],
|
||||
Sung("Lyric=i"),
|
||||
["Length=10", "Lyric=R", "NoteNum=60"],
|
||||
Sung("Lyric=u")));
|
||||
|
||||
Assert.Equal([480, 15, 475, 15, 475], result.Notes.Select(x => x.LengthTicks).ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ADurationWithoutADeltaFollowsTheScoreLength()
|
||||
{
|
||||
var text = "[#SETTING]\r\nTempo=120.00\r\n"
|
||||
+ "[#0000]\r\nDuration=240\r\nLength=480\r\nLyric=a\r\nNoteNum=60\r\n";
|
||||
var result = Import(text);
|
||||
|
||||
Assert.Equal(480, Assert.Single(result.Notes).LengthTicks);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheSettingTempoIsUsed()
|
||||
{
|
||||
|
||||
+25
-8
@@ -36,6 +36,7 @@ internal sealed record UstImportResult(
|
||||
internal static class UstImporter
|
||||
{
|
||||
public const double MaximumDeclaredTempo = 1000.0;
|
||||
public const int MaximumSectionTicks = TimeBase.TicksPerWholeNote * 1024;
|
||||
public const double CentsPerPitchUnit = 10.0;
|
||||
public const int EnvelopeFieldCount = 7;
|
||||
const double TempoEpsilon = 1e-9;
|
||||
@@ -52,6 +53,7 @@ internal static class UstImporter
|
||||
var legacyPitchNoteCount = 0;
|
||||
var position = 0;
|
||||
var end = 0;
|
||||
var emitted = 0;
|
||||
|
||||
foreach (var section in document.NoteSections)
|
||||
{
|
||||
@@ -59,16 +61,15 @@ internal static class UstImporter
|
||||
var duration = ParseInteger(section.Find(UstKeys.Duration));
|
||||
var delta = ParseInteger(section.Find(UstKeys.Delta));
|
||||
|
||||
var noteLength = duration ?? length ?? 0;
|
||||
var hasSpacing = delta is not null && duration is not null && length is not null;
|
||||
var noteLength = Math.Min((hasSpacing ? duration : length) ?? 0, MaximumSectionTicks);
|
||||
if (noteLength <= 0)
|
||||
continue;
|
||||
|
||||
var start = delta is not null && duration is not null && length is not null
|
||||
? Math.Max(position + delta.Value, end)
|
||||
: end;
|
||||
var start = hasSpacing ? Math.Max(position + delta!.Value, end) : end;
|
||||
|
||||
var previousTone = notes.Count == 0 ? MusicalTone.MiddleC.NoteNumber : notes[^1].Tone;
|
||||
AddRest(notes, start - end, previousTone);
|
||||
emitted += AddRest(notes, start - emitted, previousTone);
|
||||
|
||||
var sectionTempo = ParseNumber(section.Find(UstKeys.Tempo));
|
||||
var isTempoChange = IsUsableTempo(sectionTempo)
|
||||
@@ -76,12 +77,14 @@ internal static class UstImporter
|
||||
if (isTempoChange)
|
||||
currentTempo = ClampTempo(sectionTempo!.Value);
|
||||
|
||||
var note = CreateNote(section, noteLength, new TimeBase(currentTempo, 1.0));
|
||||
var note = CreateNote(section, HeadLengthTicks(start + noteLength - emitted), new TimeBase(currentTempo, 1.0));
|
||||
if (isTempoChange)
|
||||
note.TempoOverride = currentTempo;
|
||||
if (note.PitchPoints.Count == 0 && HasLegacyPitch(section))
|
||||
legacyPitchNoteCount++;
|
||||
notes.Add(note);
|
||||
emitted += note.LengthTicks;
|
||||
emitted += AddRest(notes, start + noteLength - emitted, note.Tone);
|
||||
|
||||
position = start;
|
||||
end = start + noteLength;
|
||||
@@ -245,11 +248,12 @@ internal static class UstImporter
|
||||
|| section.Find(UstKeys.LegacyPitches) is not null
|
||||
|| section.Find(UstKeys.LegacyPitchesTypo) is not null;
|
||||
|
||||
static void AddRest(List<UTAUNote> notes, int lengthTicks, int tone)
|
||||
static int AddRest(List<UTAUNote> notes, int lengthTicks, int tone)
|
||||
{
|
||||
var emitted = 0;
|
||||
while (lengthTicks >= UTAUNote.MinimumLengthTicks)
|
||||
{
|
||||
var chunk = Math.Min(lengthTicks, UTAUNote.MaximumLengthTicks);
|
||||
var chunk = HeadLengthTicks(lengthTicks);
|
||||
notes.Add(new UTAUNote
|
||||
{
|
||||
Lyric = UTAUNote.RestLyric,
|
||||
@@ -257,7 +261,20 @@ internal static class UstImporter
|
||||
LengthTicks = chunk,
|
||||
});
|
||||
lengthTicks -= chunk;
|
||||
emitted += chunk;
|
||||
}
|
||||
return emitted;
|
||||
}
|
||||
|
||||
static int HeadLengthTicks(int lengthTicks)
|
||||
{
|
||||
if (lengthTicks <= UTAUNote.MaximumLengthTicks)
|
||||
return lengthTicks;
|
||||
|
||||
var remainder = lengthTicks - UTAUNote.MaximumLengthTicks;
|
||||
return remainder >= UTAUNote.MinimumLengthTicks
|
||||
? UTAUNote.MaximumLengthTicks
|
||||
: UTAUNote.MaximumLengthTicks - (UTAUNote.MinimumLengthTicks - remainder);
|
||||
}
|
||||
|
||||
static (int Leading, int Total) TrimSurroundingRests(List<UTAUNote> notes)
|
||||
|
||||
@@ -19,11 +19,15 @@ internal sealed record PhonemeUnit(
|
||||
|
||||
public double EndMilliseconds => StartMilliseconds + LengthMilliseconds;
|
||||
|
||||
public double Preutterance => Note.PreutteranceOverride > UTAUNote.FollowOtoValue
|
||||
public bool HasPreutteranceOverride => Note.PreutteranceOverride > UTAUNote.FollowOtoValue;
|
||||
|
||||
public bool HasOverlapOverride => Note.OverlapOverride > UTAUNote.FollowOtoValue;
|
||||
|
||||
public double Preutterance => HasPreutteranceOverride
|
||||
? Note.PreutteranceOverride
|
||||
: Entry?.Preutterance ?? 0.0;
|
||||
|
||||
public double Overlap => Note.OverlapOverride > UTAUNote.FollowOtoValue
|
||||
public double Overlap => HasOverlapOverride
|
||||
? Note.OverlapOverride
|
||||
: Entry?.Overlap ?? 0.0;
|
||||
}
|
||||
@@ -37,12 +37,12 @@ internal sealed class SegmentCache(long budgetBytes)
|
||||
{
|
||||
if (!entries.TryGetValue(key, out var node))
|
||||
return false;
|
||||
if (node.Value.Samples.Length != destination.Length)
|
||||
if (node.Value.Samples.Length < destination.Length)
|
||||
return false;
|
||||
|
||||
order.Remove(node);
|
||||
order.AddFirst(node);
|
||||
node.Value.Samples.CopyTo(destination);
|
||||
node.Value.Samples.AsSpan(0, destination.Length).CopyTo(destination);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ internal readonly record struct UnitKey(
|
||||
double RenderLengthMilliseconds,
|
||||
double FadeInMilliseconds,
|
||||
double FadeOutMilliseconds,
|
||||
double SkipMilliseconds,
|
||||
double NoteStartMilliseconds,
|
||||
double NoteLengthMilliseconds,
|
||||
int Tone,
|
||||
@@ -54,6 +55,7 @@ internal readonly record struct UnitKey(
|
||||
&& RenderLengthMilliseconds.Equals(other.RenderLengthMilliseconds)
|
||||
&& FadeInMilliseconds.Equals(other.FadeInMilliseconds)
|
||||
&& FadeOutMilliseconds.Equals(other.FadeOutMilliseconds)
|
||||
&& SkipMilliseconds.Equals(other.SkipMilliseconds)
|
||||
&& NoteStartMilliseconds.Equals(other.NoteStartMilliseconds)
|
||||
&& NoteLengthMilliseconds.Equals(other.NoteLengthMilliseconds)
|
||||
&& Tone == other.Tone
|
||||
@@ -72,6 +74,7 @@ internal readonly record struct UnitKey(
|
||||
hash.Add(RenderLengthMilliseconds);
|
||||
hash.Add(FadeInMilliseconds);
|
||||
hash.Add(FadeOutMilliseconds);
|
||||
hash.Add(SkipMilliseconds);
|
||||
hash.Add(NoteStartMilliseconds);
|
||||
hash.Add(NoteLengthMilliseconds);
|
||||
hash.Add(Tone);
|
||||
@@ -93,27 +96,21 @@ internal sealed class SegmentKey : IEquatable<SegmentKey>
|
||||
|
||||
public SegmentKey(
|
||||
RenderSettings settings,
|
||||
int startFrame,
|
||||
int frameCount,
|
||||
int sampleRate,
|
||||
double offset,
|
||||
double framePeriod,
|
||||
UnitKey[] units)
|
||||
{
|
||||
Settings = settings;
|
||||
StartFrame = startFrame;
|
||||
FrameCount = frameCount;
|
||||
SampleRate = sampleRate;
|
||||
Offset = offset;
|
||||
FramePeriod = framePeriod;
|
||||
this.units = units;
|
||||
|
||||
var code = new HashCode();
|
||||
code.Add(settings);
|
||||
code.Add(startFrame);
|
||||
code.Add(frameCount);
|
||||
code.Add(sampleRate);
|
||||
code.Add(offset);
|
||||
code.Add(framePeriod);
|
||||
foreach (var unit in units)
|
||||
code.Add(unit);
|
||||
@@ -122,24 +119,18 @@ internal sealed class SegmentKey : IEquatable<SegmentKey>
|
||||
|
||||
public RenderSettings Settings { get; }
|
||||
|
||||
public int StartFrame { get; }
|
||||
|
||||
public int FrameCount { get; }
|
||||
|
||||
public int SampleRate { get; }
|
||||
|
||||
public double Offset { get; }
|
||||
|
||||
public double FramePeriod { get; }
|
||||
|
||||
public bool Equals(SegmentKey? other)
|
||||
=> other is not null
|
||||
&& hash == other.hash
|
||||
&& Settings == other.Settings
|
||||
&& StartFrame == other.StartFrame
|
||||
&& FrameCount == other.FrameCount
|
||||
&& SampleRate == other.SampleRate
|
||||
&& Offset.Equals(other.Offset)
|
||||
&& FramePeriod.Equals(other.FramePeriod)
|
||||
&& units.AsSpan().SequenceEqual(other.units.AsSpan());
|
||||
|
||||
|
||||
@@ -68,6 +68,10 @@ internal static class SpectrumTransform
|
||||
}
|
||||
}
|
||||
|
||||
public static double ToAmplitude(double power) => Math.Sqrt(power);
|
||||
|
||||
public static double ToPower(double amplitude) => amplitude * amplitude;
|
||||
|
||||
public static double Clamp(double aperiodicity)
|
||||
=> double.IsNaN(aperiodicity)
|
||||
? MaximumAperiodicity
|
||||
|
||||
@@ -21,17 +21,14 @@ internal readonly record struct TimeMap(
|
||||
StretchMode stretchMode)
|
||||
{
|
||||
var scale = VelocityToConsonantScale(velocity);
|
||||
var consonantSourceLength = Math.Max(consonantEnd - regionStart, 0.0);
|
||||
var consonantOutputLength = Math.Min(consonantSourceLength * scale, Math.Max(outputLength, 0.0));
|
||||
if (consonantSourceLength > 0.0 && consonantOutputLength > 0.0)
|
||||
scale = consonantOutputLength / consonantSourceLength;
|
||||
var consonantOutputLength = Math.Max(consonantEnd - regionStart, 0.0) * scale;
|
||||
|
||||
return new TimeMap(
|
||||
regionStart,
|
||||
consonantEnd,
|
||||
regionEnd,
|
||||
consonantOutputLength,
|
||||
Math.Max(outputLength - consonantOutputLength, 0.0),
|
||||
Math.Max(Math.Max(outputLength, 0.0) - consonantOutputLength, 0.0),
|
||||
scale,
|
||||
stretchMode);
|
||||
}
|
||||
@@ -53,8 +50,10 @@ internal readonly record struct TimeMap(
|
||||
var elapsed = outputMilliseconds - ConsonantOutputLength;
|
||||
if (StretchMode == StretchMode.Stretch)
|
||||
{
|
||||
var progress = SustainOutputLength > 0.0 ? Math.Clamp(elapsed / SustainOutputLength, 0.0, 1.0) : 0.0;
|
||||
return ConsonantEnd + sustainSourceLength * progress;
|
||||
var speed = SustainOutputLength > 0.0
|
||||
? Math.Clamp(sustainSourceLength / SustainOutputLength, 0.0, 1.0)
|
||||
: 0.0;
|
||||
return Math.Min(ConsonantEnd + elapsed * speed, RegionEnd);
|
||||
}
|
||||
|
||||
var period = sustainSourceLength * 2.0;
|
||||
|
||||
+58
-22
@@ -1,3 +1,4 @@
|
||||
using UTAU.Notes;
|
||||
using UTAU.Phonemes;
|
||||
|
||||
namespace UTAU.Synthesis;
|
||||
@@ -7,7 +8,8 @@ internal readonly record struct UnitTiming(
|
||||
double AudioStartMilliseconds,
|
||||
double RenderLengthMilliseconds,
|
||||
double FadeInMilliseconds,
|
||||
double FadeOutMilliseconds)
|
||||
double FadeOutMilliseconds,
|
||||
double SkipMilliseconds)
|
||||
{
|
||||
public double AudioEndMilliseconds => AudioStartMilliseconds + RenderLengthMilliseconds;
|
||||
|
||||
@@ -33,32 +35,63 @@ internal readonly record struct UnitTiming(
|
||||
|
||||
internal static class UnitTimingBuilder
|
||||
{
|
||||
const double AdjacentHeadShare = 0.5;
|
||||
const double PlosiveHeadShare = 0.9;
|
||||
|
||||
public static IReadOnlyList<UnitTiming> Build(IReadOnlyList<PhonemeUnit> units)
|
||||
{
|
||||
var timings = new List<UnitTiming>(units.Count);
|
||||
var preutterances = new double[units.Count];
|
||||
var overlaps = new double[units.Count];
|
||||
var adjacent = new bool[units.Count];
|
||||
var skips = new double[units.Count];
|
||||
|
||||
for (var i = 0; i < units.Count; i++)
|
||||
{
|
||||
var preutterance = units[i].Preutterance;
|
||||
var overlap = units[i].Overlap;
|
||||
var head = preutterance - overlap;
|
||||
var available = i == 0 ? 0.0 : units[i - 1].LengthMilliseconds;
|
||||
var consonantScale = TimeMap.VelocityToConsonantScale(units[i].Note.Velocity);
|
||||
var preutterance = units[i].HasPreutteranceOverride ? units[i].Preutterance : units[i].Preutterance * consonantScale;
|
||||
var overlap = units[i].HasOverlapOverride ? units[i].Overlap : units[i].Overlap * consonantScale;
|
||||
var requested = preutterance;
|
||||
var preceding = FindPrecedingVoiced(units, i);
|
||||
|
||||
if (i > 0 && head > available && head > 0.0)
|
||||
if (preceding >= 0)
|
||||
{
|
||||
var ratio = available / head;
|
||||
preutterance *= ratio;
|
||||
overlap *= ratio;
|
||||
}
|
||||
else if (i == 0 && head < 0.0)
|
||||
{
|
||||
overlap = preutterance;
|
||||
var precedingLength = units[preceding].LengthMilliseconds;
|
||||
var gap = units[i].StartMilliseconds - units[preceding].EndMilliseconds;
|
||||
var limit = preutterance;
|
||||
adjacent[i] = gap <= 0.0;
|
||||
|
||||
if (adjacent[i])
|
||||
{
|
||||
var head = preutterance - overlap;
|
||||
if (overlap > 0.0)
|
||||
{
|
||||
if (head > precedingLength * AdjacentHeadShare)
|
||||
limit = precedingLength * AdjacentHeadShare / head * preutterance;
|
||||
}
|
||||
else
|
||||
limit = Math.Min(limit, precedingLength * PlosiveHeadShare);
|
||||
|
||||
limit = Math.Min(limit, precedingLength);
|
||||
if (preutterances[preceding] < UTAUNote.DefaultFadeInMilliseconds)
|
||||
limit = Math.Min(limit, precedingLength + preutterances[preceding] - UTAUNote.DefaultFadeInMilliseconds);
|
||||
}
|
||||
else if (gap < preutterance)
|
||||
limit = gap;
|
||||
|
||||
if (preutterance > limit)
|
||||
{
|
||||
overlap *= preutterance > 0.0 ? limit / preutterance : 0.0;
|
||||
preutterance = limit;
|
||||
}
|
||||
|
||||
if (overlap < 0.0)
|
||||
overlap = Math.Max(overlap, Math.Min(0.0, UTAUNote.DefaultFadeOutMilliseconds - precedingLength + preutterance));
|
||||
}
|
||||
|
||||
preutterances[i] = preutterance;
|
||||
overlaps[i] = Math.Max(overlap, 0.0);
|
||||
preutterances[i] = Math.Max(preutterance, 0.0);
|
||||
overlaps[i] = overlap;
|
||||
skips[i] = Math.Max(requested - preutterances[i], 0.0);
|
||||
}
|
||||
|
||||
for (var i = 0; i < units.Count; i++)
|
||||
@@ -74,12 +107,11 @@ internal static class UnitTimingBuilder
|
||||
: units[next].StartMilliseconds - preutterances[next] + overlaps[next] - audioStart;
|
||||
renderLength = Math.Max(renderLength, RenderSettings.MinimumUnitLengthMilliseconds);
|
||||
|
||||
var previous = FindPreviousVoiced(units, i);
|
||||
var fadeIn = previous >= 0 && overlaps[i] > 0.0 ? overlaps[i] : unit.Note.FadeInMilliseconds;
|
||||
var fadeOut = next >= 0 && overlaps[next] > 0.0 ? overlaps[next] : unit.Note.FadeOutMilliseconds;
|
||||
var fadeIn = adjacent[i] && overlaps[i] > 0.0 ? overlaps[i] : unit.Note.FadeInMilliseconds;
|
||||
var fadeOut = next >= 0 && adjacent[next] && overlaps[next] > 0.0 ? overlaps[next] : unit.Note.FadeOutMilliseconds;
|
||||
(fadeIn, fadeOut) = LimitFades(fadeIn, fadeOut, renderLength);
|
||||
|
||||
timings.Add(new UnitTiming(unit, audioStart, renderLength, fadeIn, fadeOut));
|
||||
timings.Add(new UnitTiming(unit, audioStart, renderLength, fadeIn, fadeOut, skips[i]));
|
||||
}
|
||||
|
||||
return timings;
|
||||
@@ -103,9 +135,13 @@ internal static class UnitTimingBuilder
|
||||
return next < units.Count && !units[next].IsSilent ? next : -1;
|
||||
}
|
||||
|
||||
static int FindPreviousVoiced(IReadOnlyList<PhonemeUnit> units, int index)
|
||||
static int FindPrecedingVoiced(IReadOnlyList<PhonemeUnit> units, int index)
|
||||
{
|
||||
var previous = index - 1;
|
||||
return previous >= 0 && !units[previous].IsSilent ? previous : -1;
|
||||
for (var preceding = index - 1; preceding >= 0; preceding--)
|
||||
{
|
||||
if (!units[preceding].IsSilent)
|
||||
return preceding;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+171
-65
@@ -15,7 +15,8 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
double RegionStart,
|
||||
double RegionEnd,
|
||||
double ConsonantEnd,
|
||||
double MeanF0);
|
||||
double MeanF0,
|
||||
double AutoGain);
|
||||
|
||||
sealed record Segment(int StartFrame, int FrameCount, IReadOnlyList<int> TimingIndices);
|
||||
|
||||
@@ -36,18 +37,55 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
int EndSample,
|
||||
double RegionStart,
|
||||
double RegionEnd,
|
||||
double ConsonantEnd);
|
||||
double ConsonantEnd,
|
||||
double SourcePeak,
|
||||
double RegionPeak);
|
||||
|
||||
sealed class RenderState : IDisposable
|
||||
{
|
||||
public required WorldArena Arena { get; init; }
|
||||
|
||||
public required SegmentBuffers Buffers { get; init; }
|
||||
|
||||
public required double[] FrameSpectrum { get; init; }
|
||||
|
||||
public required double[] WarpedSpectrum { get; init; }
|
||||
|
||||
public required double[] FrameAperiodicity { get; init; }
|
||||
|
||||
public static RenderState Create(int widest, int spectrumSize, int outputSamples) => new()
|
||||
{
|
||||
Arena = new WorldArena(),
|
||||
Buffers = new SegmentBuffers(
|
||||
new double[widest],
|
||||
new double[(long)widest * spectrumSize],
|
||||
new double[(long)widest * spectrumSize],
|
||||
new double[widest],
|
||||
new double[widest],
|
||||
new double[widest],
|
||||
new double[outputSamples]),
|
||||
FrameSpectrum = new double[spectrumSize],
|
||||
WarpedSpectrum = new double[spectrumSize],
|
||||
FrameAperiodicity = new double[spectrumSize],
|
||||
};
|
||||
|
||||
public void Dispose() => Arena.Dispose();
|
||||
}
|
||||
|
||||
const long RenderBufferBudgetBytes = 768L * 1024 * 1024;
|
||||
const long MaximumFrameElements = 1L << 24;
|
||||
const double FrameCountEpsilon = 1e-9;
|
||||
const int SegmentGapFrames = 10;
|
||||
const double PeakCompressionPercent = 86.0;
|
||||
const double PeakTarget = 0.5;
|
||||
const double VoicedRatioBias = 5.0;
|
||||
const double VoicedRatioSlope = 10.0;
|
||||
|
||||
readonly Dictionary<string, AudioSample> loadedSamples = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public RenderResult Render(IReadOnlyList<PhonemeUnit> units, WorldArena arena)
|
||||
public RenderResult Render(IReadOnlyList<PhonemeUnit> units)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(units);
|
||||
ArgumentNullException.ThrowIfNull(arena);
|
||||
|
||||
var timings = UnitTimingBuilder.Build(units);
|
||||
if (timings.Count == 0)
|
||||
@@ -76,60 +114,87 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
|
||||
var outputLength = ToSampleIndex(frameCount - 1, framePeriod, sampleRate) + 1;
|
||||
var samples = new double[outputLength];
|
||||
var frameSpectrum = new double[spectrumSize];
|
||||
var warpedSpectrum = new double[spectrumSize];
|
||||
var frameAperiodicity = new double[spectrumSize];
|
||||
|
||||
var widest = segments.Max(x => x.FrameCount);
|
||||
var buffers = new SegmentBuffers(
|
||||
new double[widest],
|
||||
new double[widest * spectrumSize],
|
||||
new double[widest * spectrumSize],
|
||||
new double[widest],
|
||||
new double[widest],
|
||||
new double[widest],
|
||||
new double[ToSampleIndex(widest - 1, framePeriod, sampleRate) + 1]);
|
||||
|
||||
var cacheable = ReferenceEquals(curves, RenderCurves.Empty);
|
||||
var outputSamples = ToSampleIndex(widest - 1, framePeriod, sampleRate) + 1;
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
var produced = ToSampleIndex(segment.FrameCount - 1, framePeriod, sampleRate) + 1;
|
||||
var start = ToSampleIndex(segment.StartFrame, framePeriod, sampleRate);
|
||||
var length = Math.Min(produced, samples.Length - start);
|
||||
if (length <= 0)
|
||||
continue;
|
||||
|
||||
var key = cacheable
|
||||
? BuildSegmentKey(segment, timings, requests, offset, framePeriod, sampleRate)
|
||||
: null;
|
||||
|
||||
if (key is not null && segmentCache.TryCopyInto(key, samples.AsSpan(start, length)))
|
||||
continue;
|
||||
|
||||
RenderSegment(
|
||||
segment,
|
||||
timings,
|
||||
requests,
|
||||
arena,
|
||||
offset,
|
||||
framePeriod,
|
||||
sampleRate,
|
||||
fftSize,
|
||||
spectrumSize,
|
||||
frameSpectrum,
|
||||
warpedSpectrum,
|
||||
frameAperiodicity,
|
||||
buffers,
|
||||
samples);
|
||||
|
||||
if (key is not null)
|
||||
segmentCache.Store(key, samples.AsSpan(start, length));
|
||||
}
|
||||
Parallel.For(
|
||||
0,
|
||||
segments.Count,
|
||||
new ParallelOptions { MaxDegreeOfParallelism = DetermineParallelism(widest, spectrumSize, segments.Count) },
|
||||
() => RenderState.Create(widest, spectrumSize, outputSamples),
|
||||
(index, _, state) =>
|
||||
{
|
||||
var limit = index + 1 < segments.Count
|
||||
? ToSampleIndex(segments[index + 1].StartFrame, framePeriod, sampleRate)
|
||||
: samples.Length;
|
||||
RenderOne(segments[index], limit, timings, requests, state, offset, framePeriod, sampleRate, fftSize, spectrumSize, samples, cacheable);
|
||||
return state;
|
||||
},
|
||||
state => state.Dispose());
|
||||
|
||||
return new RenderResult(samples, sampleRate, timings, offset);
|
||||
}
|
||||
|
||||
static int DetermineParallelism(int widest, int spectrumSize, int segmentCount)
|
||||
{
|
||||
var perWorker = (long)widest * spectrumSize * sizeof(double) * 2;
|
||||
if (perWorker <= 0)
|
||||
return 1;
|
||||
|
||||
var affordable = (int)Math.Clamp(RenderBufferBudgetBytes / perWorker, 1, Environment.ProcessorCount);
|
||||
return Math.Min(affordable, Math.Max(segmentCount, 1));
|
||||
}
|
||||
|
||||
void RenderOne(
|
||||
Segment segment,
|
||||
int outputLimit,
|
||||
IReadOnlyList<UnitTiming> timings,
|
||||
IReadOnlyList<AnalysisRequest?> requests,
|
||||
RenderState state,
|
||||
double offset,
|
||||
double framePeriod,
|
||||
int sampleRate,
|
||||
int fftSize,
|
||||
int spectrumSize,
|
||||
double[] samples,
|
||||
bool cacheable)
|
||||
{
|
||||
var produced = ToSampleIndex(segment.FrameCount - 1, framePeriod, sampleRate) + 1;
|
||||
var start = ToSampleIndex(segment.StartFrame, framePeriod, sampleRate);
|
||||
var length = Math.Min(Math.Min(produced, samples.Length - start), outputLimit - start);
|
||||
if (length <= 0)
|
||||
return;
|
||||
|
||||
var key = cacheable
|
||||
? BuildSegmentKey(segment, timings, requests, offset, framePeriod, sampleRate)
|
||||
: null;
|
||||
|
||||
if (key is not null && segmentCache.TryCopyInto(key, samples.AsSpan(start, length)))
|
||||
return;
|
||||
|
||||
RenderSegment(
|
||||
segment,
|
||||
start,
|
||||
length,
|
||||
timings,
|
||||
requests,
|
||||
state.Arena,
|
||||
offset,
|
||||
framePeriod,
|
||||
sampleRate,
|
||||
fftSize,
|
||||
spectrumSize,
|
||||
state.FrameSpectrum,
|
||||
state.WarpedSpectrum,
|
||||
state.FrameAperiodicity,
|
||||
state.Buffers,
|
||||
samples);
|
||||
|
||||
if (key is not null)
|
||||
segmentCache.Store(key, state.Buffers.Output.AsSpan(0, produced));
|
||||
}
|
||||
|
||||
static int ToSampleIndex(int frame, double framePeriod, int sampleRate)
|
||||
=> (int)(frame * framePeriod / 1000.0 * sampleRate);
|
||||
|
||||
@@ -141,6 +206,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
double framePeriod,
|
||||
int sampleRate)
|
||||
{
|
||||
var origin = offset + segment.StartFrame * framePeriod;
|
||||
var units = new UnitKey[segment.TimingIndices.Count];
|
||||
|
||||
for (var i = 0; i < units.Length; i++)
|
||||
@@ -161,11 +227,12 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
request.RegionEnd,
|
||||
request.ConsonantEnd)
|
||||
: null,
|
||||
timing.AudioStartMilliseconds,
|
||||
timing.AudioStartMilliseconds - origin,
|
||||
timing.RenderLengthMilliseconds,
|
||||
timing.FadeInMilliseconds,
|
||||
timing.FadeOutMilliseconds,
|
||||
unit.NoteStartMilliseconds,
|
||||
timing.SkipMilliseconds,
|
||||
unit.NoteStartMilliseconds - origin,
|
||||
unit.NoteLengthMilliseconds,
|
||||
unit.Tone,
|
||||
note.LengthTicks,
|
||||
@@ -176,7 +243,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
[.. note.PitchPoints]);
|
||||
}
|
||||
|
||||
return new SegmentKey(settings, segment.StartFrame, segment.FrameCount, sampleRate, offset, framePeriod, units);
|
||||
return new SegmentKey(settings, segment.FrameCount, sampleRate, framePeriod, units);
|
||||
}
|
||||
|
||||
static IReadOnlyList<Segment> BuildSegments(
|
||||
@@ -215,6 +282,8 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
|
||||
void RenderSegment(
|
||||
Segment segment,
|
||||
int outputStart,
|
||||
int outputLength,
|
||||
IReadOnlyList<UnitTiming> timings,
|
||||
IReadOnlyList<AnalysisRequest?> requests,
|
||||
WorldArena arena,
|
||||
@@ -284,10 +353,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
output,
|
||||
arena);
|
||||
|
||||
var start = ToSampleIndex(segment.StartFrame, framePeriod, sampleRate);
|
||||
var length = Math.Min(produced, samples.Length - start);
|
||||
if (length > 0)
|
||||
Array.Copy(buffers.Output, 0, samples, start, length);
|
||||
Array.Copy(buffers.Output, 0, samples, outputStart, outputLength);
|
||||
}
|
||||
|
||||
void AccumulateUnit(
|
||||
@@ -311,11 +377,11 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
var note = unit.Note;
|
||||
var startFrame = Math.Max((int)Math.Floor((timing.AudioStartMilliseconds - offset) / framePeriod) - segmentStartFrame, 0);
|
||||
var endFrame = Math.Min((int)Math.Ceiling((timing.AudioEndMilliseconds - offset) / framePeriod) - segmentStartFrame, frameCount - 1);
|
||||
var gain = settings.Gain * Math.Clamp(note.Intensity, 0.0, 200.0) / 100.0;
|
||||
var gain = settings.Gain * Math.Clamp(note.Intensity, 0.0, 200.0) / 100.0 * source.AutoGain;
|
||||
var baseFormantRatio = settings.FormantRatio;
|
||||
var hasFormantCurve = curves.HasFormant;
|
||||
var hasBreathinessCurve = curves.HasBreathiness;
|
||||
var map = TimeMap.Create(source.RegionStart, source.ConsonantEnd, source.RegionEnd, timing.RenderLengthMilliseconds, note.Velocity, settings.StretchMode);
|
||||
var map = TimeMap.Create(source.RegionStart, source.ConsonantEnd, source.RegionEnd, timing.RenderLengthMilliseconds + timing.SkipMilliseconds, note.Velocity, settings.StretchMode);
|
||||
var modulation = Math.Clamp(note.Modulation, -200.0, 200.0) / 100.0;
|
||||
|
||||
for (var frame = startFrame; frame <= endFrame; frame++)
|
||||
@@ -326,7 +392,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
if (weight <= 0.0)
|
||||
continue;
|
||||
|
||||
var sourceMilliseconds = map.Map(elapsed);
|
||||
var sourceMilliseconds = map.Map(elapsed + timing.SkipMilliseconds);
|
||||
var frameIndex = source.Features.GetFrameIndex(sourceMilliseconds);
|
||||
SampleFeatures(source.Features, frameIndex, frameSpectrum, frameAperiodicity, out var sourceF0);
|
||||
|
||||
@@ -346,7 +412,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
var baseIndex = (long)frame * spectrumSize;
|
||||
for (var k = 0; k < spectrumSize; k++)
|
||||
{
|
||||
spectrogram[baseIndex + k] += weight * warpedSpectrum[k];
|
||||
spectrogram[baseIndex + k] += weight * SpectrumTransform.ToAmplitude(warpedSpectrum[k]);
|
||||
aperiodicity[baseIndex + k] += weight * frameAperiodicity[k];
|
||||
}
|
||||
weightSum[frame] += weight;
|
||||
@@ -397,7 +463,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
|
||||
for (var k = 0; k < spectrumSize; k++)
|
||||
{
|
||||
spectrogram[baseIndex + k] = Math.Max(spectrogram[baseIndex + k], SpectrumTransform.MinimumPower);
|
||||
spectrogram[baseIndex + k] = Math.Max(SpectrumTransform.ToPower(spectrogram[baseIndex + k]), SpectrumTransform.MinimumPower);
|
||||
aperiodicity[baseIndex + k] = SpectrumTransform.Clamp(aperiodicity[baseIndex + k] / total);
|
||||
}
|
||||
|
||||
@@ -476,7 +542,19 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
endSample,
|
||||
regionStart,
|
||||
regionEnd,
|
||||
consonantEnd);
|
||||
consonantEnd,
|
||||
Peak(sample.Samples, 0, sample.Samples.Length),
|
||||
Peak(sample.Samples, sample.MillisecondsToSamples(regionStart), sample.MillisecondsToSamples(regionEnd)));
|
||||
}
|
||||
|
||||
static double Peak(ReadOnlySpan<double> samples, int from, int to)
|
||||
{
|
||||
from = Math.Clamp(from, 0, samples.Length);
|
||||
to = Math.Clamp(to, from, samples.Length);
|
||||
var peak = 0.0;
|
||||
for (var i = from; i < to; i++)
|
||||
peak = Math.Max(peak, Math.Abs(samples[i]));
|
||||
return peak;
|
||||
}
|
||||
|
||||
void AnalyzeInParallel(IReadOnlyList<AnalysisRequest?> requests)
|
||||
@@ -524,7 +602,35 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
value.RegionStart,
|
||||
value.RegionEnd,
|
||||
value.ConsonantEnd,
|
||||
ComputeMeanF0(features, value.RegionStart, value.RegionEnd));
|
||||
ComputeMeanF0(features, value.RegionStart, value.RegionEnd),
|
||||
ComputeAutoGain(
|
||||
value.SourcePeak,
|
||||
value.RegionPeak,
|
||||
ComputeVoicedRatio(features, value.RegionStart, value.RegionEnd)));
|
||||
}
|
||||
|
||||
static double ComputeVoicedRatio(WorldFeatures features, double regionStart, double regionEnd)
|
||||
{
|
||||
var voiced = 0;
|
||||
var count = 0;
|
||||
var first = Math.Max((int)Math.Floor(features.GetFrameIndex(regionStart)), 0);
|
||||
var last = Math.Min((int)Math.Ceiling(features.GetFrameIndex(regionEnd)), features.FrameCount - 1);
|
||||
|
||||
for (var i = first; i <= last; i++)
|
||||
{
|
||||
count++;
|
||||
if (features.F0[i] > 0.0)
|
||||
voiced++;
|
||||
}
|
||||
|
||||
return count == 0 ? 0.0 : (double)voiced / count;
|
||||
}
|
||||
|
||||
static double ComputeAutoGain(double sourcePeak, double regionPeak, double voicedRatio)
|
||||
{
|
||||
var weight = 1.0 / (1.0 + Math.Exp(VoicedRatioBias - VoicedRatioSlope * voicedRatio));
|
||||
var peak = regionPeak * weight + sourcePeak * (1.0 - weight);
|
||||
return peak <= 0.0 ? 1.0 : Math.Pow(PeakTarget / peak, PeakCompressionPercent / 100.0);
|
||||
}
|
||||
|
||||
static double ComputeMeanF0(WorldFeatures features, double regionStart, double regionEnd)
|
||||
|
||||
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>لم يتم استيراد بيانات الدرجة القديمة</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>تمت إزالة {0} تِك من السكتات في البداية والنهاية</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>{0} عبارة إجمالاً</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>تم تحميل {1} عبارة بدءاً من العبارة {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>يبدأ عند التِك {0} من الأصل</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>{1} من {2} عبارة بدءاً من {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>من التِك {0} في الأصل</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>الإيقاع</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>القيمة 0 تتبع إيقاع النوتة الموسيقية. وإدخال قيمة يغيّر الإيقاع بدءاً من هذه النوتة.</value></data>
|
||||
</root>
|
||||
+2
-2
@@ -144,7 +144,7 @@ UstImportEmpty,,読み込めるノートがありません,The file has no notes
|
||||
UstLegacyPitchIgnored,,旧式の音程は取り込めません,The legacy pitch data was not imported,未导入旧式音高数据,未匯入舊式音高資料,구형 음정 자료는 가져오지 않았습니다,Los datos de tono heredados no se importaron,لم يتم استيراد بيانات الدرجة القديمة,Data nada lawas tidak diimpor
|
||||
UstRestTrimmedFormat,,前後の休符 {0} ティックを除きました,Trimmed {0} ticks of leading and trailing rests,已去除首尾休止符 {0} 刻,已去除首尾休止符 {0} 刻,앞뒤 쉼표 {0}틱을 제거했습니다,Se recortaron {0} tics de silencios inicial y final,تمت إزالة {0} تِك من السكتات في البداية والنهاية,Memangkas {0} tik istirahat di awal dan akhir
|
||||
UstPhraseTotalFormat,,全 {0} フレーズ,{0} phrases in total,共 {0} 个乐句,共 {0} 個樂句,전체 {0} 프레이즈,{0} frases en total,{0} عبارة إجمالاً,Total {0} frasa
|
||||
UstPhraseRangeFormat,,フレーズ {0} から {1} 個を読み込みました,Loaded {1} phrases starting at phrase {0},从第 {0} 个乐句起载入了 {1} 个,從第 {0} 個樂句起載入了 {1} 個,프레이즈 {0}부터 {1}개를 불러왔습니다,Se cargaron {1} frases desde la frase {0},تم تحميل {1} عبارة بدءاً من العبارة {0},Memuat {1} frasa mulai dari frasa {0}
|
||||
UstPhraseOffsetFormat,,元の {0} ティック目から始まります,Starts {0} ticks into the original,从原曲第 {0} 刻开始,從原曲第 {0} 刻開始,원곡의 {0}틱부터 시작합니다,Empieza en el tic {0} del original,يبدأ عند التِك {0} من الأصل,Dimulai pada tik {0} dari aslinya
|
||||
UstPhraseRangeFormat,,全 {2} フレーズ中 {0} から {1} 個,{1} of {2} phrases from {0},共 {2} 个乐句中自第 {0} 个起 {1} 个,共 {2} 個樂句中自第 {0} 個起 {1} 個,전체 {2} 프레이즈 중 {0}부터 {1}개,{1} de {2} frases desde la {0},{1} من {2} عبارة بدءاً من {0},{1} dari {2} frasa mulai {0}
|
||||
UstPhraseOffsetFormat,,元の {0} ティック目から,from tick {0} of the original,自原曲第 {0} 刻,自原曲第 {0} 刻,원곡 {0}틱부터,desde el tic {0} del original,من التِك {0} في الأصل,dari tik {0} aslinya
|
||||
NoteTempo,,テンポ,Tempo,速度,速度,템포,Tempo,الإيقاع,Tempo
|
||||
NoteTempoDescription,,0でこの譜面のテンポに従います。値を入れるとこのノートから先のテンポが変わります。,0 follows the tempo of the score. A value changes the tempo from this note onward.,0 表示沿用乐谱的速度。填入数值则从该音符起改变速度。,0 表示沿用樂譜的速度。填入數值則從該音符起改變速度。,0이면 악보의 템포를 따릅니다. 값을 넣으면 이 노트부터 템포가 바뀝니다.,0 sigue el tempo de la partitura. Un valor cambia el tempo a partir de esta nota.,القيمة 0 تتبع إيقاع النوتة الموسيقية. وإدخال قيمة يغيّر الإيقاع بدءاً من هذه النوتة.,0 mengikuti tempo partitur. Sebuah nilai mengubah tempo mulai dari not ini.
|
||||
|
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>The legacy pitch data was not imported</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>Trimmed {0} ticks of leading and trailing rests</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>{0} phrases in total</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>Loaded {1} phrases starting at phrase {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>Starts {0} ticks into the original</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>{1} of {2} phrases from {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>from tick {0} of the original</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>Tempo</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>0 follows the tempo of the score. A value changes the tempo from this note onward.</value></data>
|
||||
</root>
|
||||
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>Los datos de tono heredados no se importaron</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>Se recortaron {0} tics de silencios inicial y final</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>{0} frases en total</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>Se cargaron {1} frases desde la frase {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>Empieza en el tic {0} del original</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>{1} de {2} frases desde la {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>desde el tic {0} del original</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>Tempo</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>0 sigue el tempo de la partitura. Un valor cambia el tempo a partir de esta nota.</value></data>
|
||||
</root>
|
||||
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>Data nada lawas tidak diimpor</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>Memangkas {0} tik istirahat di awal dan akhir</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>Total {0} frasa</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>Memuat {1} frasa mulai dari frasa {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>Dimulai pada tik {0} dari aslinya</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>{1} dari {2} frasa mulai {0}</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>dari tik {0} aslinya</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>Tempo</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>0 mengikuti tempo partitur. Sebuah nilai mengubah tempo mulai dari not ini.</value></data>
|
||||
</root>
|
||||
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>구형 음정 자료는 가져오지 않았습니다</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>앞뒤 쉼표 {0}틱을 제거했습니다</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>전체 {0} 프레이즈</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>프레이즈 {0}부터 {1}개를 불러왔습니다</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>원곡의 {0}틱부터 시작합니다</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>전체 {2} 프레이즈 중 {0}부터 {1}개</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>원곡 {0}틱부터</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>템포</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>0이면 악보의 템포를 따릅니다. 값을 넣으면 이 노트부터 템포가 바뀝니다.</value></data>
|
||||
</root>
|
||||
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>旧式の音程は取り込めません</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>前後の休符 {0} ティックを除きました</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>全 {0} フレーズ</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>フレーズ {0} から {1} 個を読み込みました</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>元の {0} ティック目から始まります</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>全 {2} フレーズ中 {0} から {1} 個</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>元の {0} ティック目から</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>テンポ</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>0でこの譜面のテンポに従います。値を入れるとこのノートから先のテンポが変わります。</value></data>
|
||||
</root>
|
||||
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>未导入旧式音高数据</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>已去除首尾休止符 {0} 刻</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>共 {0} 个乐句</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>从第 {0} 个乐句起载入了 {1} 个</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>从原曲第 {0} 刻开始</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>共 {2} 个乐句中自第 {0} 个起 {1} 个</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>自原曲第 {0} 刻</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>速度</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>0 表示沿用乐谱的速度。填入数值则从该音符起改变速度。</value></data>
|
||||
</root>
|
||||
+2
-2
@@ -204,8 +204,8 @@
|
||||
<data name="UstLegacyPitchIgnored" xml:space="preserve"><value>未匯入舊式音高資料</value></data>
|
||||
<data name="UstRestTrimmedFormat" xml:space="preserve"><value>已去除首尾休止符 {0} 刻</value></data>
|
||||
<data name="UstPhraseTotalFormat" xml:space="preserve"><value>共 {0} 個樂句</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>從第 {0} 個樂句起載入了 {1} 個</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>從原曲第 {0} 刻開始</value></data>
|
||||
<data name="UstPhraseRangeFormat" xml:space="preserve"><value>共 {2} 個樂句中自第 {0} 個起 {1} 個</value></data>
|
||||
<data name="UstPhraseOffsetFormat" xml:space="preserve"><value>自原曲第 {0} 刻</value></data>
|
||||
<data name="NoteTempo" xml:space="preserve"><value>速度</value></data>
|
||||
<data name="NoteTempoDescription" xml:space="preserve"><value>0 表示沿用樂譜的速度。填入數值則從該音符起改變速度。</value></data>
|
||||
</root>
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.2.0</Version>
|
||||
<Version>1.6.1</Version>
|
||||
<Platforms>AnyCPU;x64;x64</Platforms>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
||||
@@ -135,19 +135,17 @@ internal sealed class UTAUVoicePronounce : UndoRedoable, IVoicePronounce
|
||||
|
||||
static string BuildImportMessage(UstImportResult imported, UstPhraseRange range)
|
||||
{
|
||||
var parts = new List<string>
|
||||
{
|
||||
string.Format(Texts.UstImportedFormat, imported.Notes.Count),
|
||||
string.Format(Texts.UstPhraseTotalFormat, imported.TotalPhrases),
|
||||
};
|
||||
var parts = new List<string> { string.Format(Texts.UstImportedFormat, imported.Notes.Count) };
|
||||
|
||||
if (!range.CoversEverything)
|
||||
if (range.CoversEverything)
|
||||
parts.Add(string.Format(Texts.UstPhraseTotalFormat, imported.TotalPhrases));
|
||||
else
|
||||
{
|
||||
var taken = range.Count > 0 ? range.Count : imported.TotalPhrases - range.Start + 1;
|
||||
parts.Add(string.Format(Texts.UstPhraseRangeFormat, range.Start, Math.Max(taken, 0)));
|
||||
parts.Add(string.Format(Texts.UstPhraseRangeFormat, range.Start, Math.Max(taken, 0), imported.TotalPhrases));
|
||||
}
|
||||
|
||||
if (imported.StartTicks > 0)
|
||||
if (!range.CoversEverything && imported.StartTicks > 0)
|
||||
parts.Add(string.Format(Texts.UstPhraseOffsetFormat, imported.StartTicks));
|
||||
if (imported.TrimmedRestTicks > 0)
|
||||
parts.Add(string.Format(Texts.UstRestTrimmedFormat, imported.TrimmedRestTicks));
|
||||
|
||||
@@ -2,7 +2,6 @@ using UTAU.Models;
|
||||
using UTAU.Notes;
|
||||
using UTAU.Phonemes;
|
||||
using UTAU.Synthesis;
|
||||
using WorldNet;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
using YukkuriMovieMaker.Plugin.Voice;
|
||||
|
||||
@@ -90,9 +89,8 @@ internal sealed class UTAUVoiceSpeaker(VoiceBank bank) : IVoiceSpeaker
|
||||
parameter.Breathiness,
|
||||
parameter.Brightness);
|
||||
|
||||
using var arena = new WorldArena();
|
||||
var renderer = new UtauRenderer(settings, BuildCurves(pronounce, tempoMap), AnalysisCache.Shared, SegmentCache.Shared);
|
||||
var result = renderer.Render(units, arena);
|
||||
var result = renderer.Render(units);
|
||||
if (result.Samples.Length == 0)
|
||||
throw new InvalidOperationException(unresolved.Length > 0 ? unresolved : Texts.NoRenderableNoteMessage);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:root="clr-namespace:UTAU"
|
||||
xmlns:vm="clr-namespace:UTAU.ViewModels"
|
||||
xmlns:v="clr-namespace:UTAU.Views"
|
||||
xmlns:c="clr-namespace:YukkuriMovieMaker.Controls;assembly=YukkuriMovieMaker.Controls"
|
||||
xmlns:icons="clr-namespace:YukkuriMovieMaker.Resources.Icons;assembly=YukkuriMovieMaker.Plugin"
|
||||
xmlns:theme="clr-namespace:YukkuriMovieMaker.Theme;assembly=YukkuriMovieMaker.Plugin"
|
||||
@@ -75,11 +76,9 @@
|
||||
</StackPanel>
|
||||
|
||||
<DockPanel Grid.Column="1">
|
||||
<TextBlock DockPanel.Dock="Right" Text="{Binding RenderMessage}" VerticalAlignment="Center" Margin="12,0,0,0"
|
||||
Foreground="{DynamicResource {x:Static theme:YMM4Colors.WarningBannerForegroundBrushKey}}"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
<TextBlock Text="{Binding ImportMessage}" VerticalAlignment="Center" Margin="12,0,0,0" Opacity="0.75"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
<v:ScrollingText DockPanel.Dock="Right" Text="{Binding RenderMessage}" VerticalAlignment="Center" Margin="12,0,0,0"
|
||||
Foreground="{DynamicResource {x:Static theme:YMM4Colors.WarningBannerForegroundBrushKey}}"/>
|
||||
<v:ScrollingText Text="{Binding ImportMessage}" VerticalAlignment="Center" Margin="12,0,0,0" Opacity="0.75"/>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace UTAU.Views;
|
||||
|
||||
internal sealed class ScrollingText : Control
|
||||
{
|
||||
public const double PixelsPerSecond = 40.0;
|
||||
public const double HoldSeconds = 2.0;
|
||||
|
||||
readonly TextBlock block = new();
|
||||
readonly TranslateTransform offset = new();
|
||||
|
||||
public ScrollingText()
|
||||
{
|
||||
block.RenderTransform = offset;
|
||||
AddVisualChild(block);
|
||||
AddLogicalChild(block);
|
||||
ClipToBounds = true;
|
||||
SizeChanged += (_, _) => Restart();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||
nameof(Text),
|
||||
typeof(string),
|
||||
typeof(ScrollingText),
|
||||
new PropertyMetadata(string.Empty, OnTextChanged));
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => (string)GetValue(TextProperty);
|
||||
set => SetValue(TextProperty, value);
|
||||
}
|
||||
|
||||
public double HiddenWidth => Math.Max(block.DesiredSize.Width - ActualWidth, 0.0);
|
||||
|
||||
public bool IsScrolling { get; private set; }
|
||||
|
||||
protected override int VisualChildrenCount => 1;
|
||||
|
||||
protected override Visual GetVisualChild(int index) => block;
|
||||
|
||||
static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is not ScrollingText control)
|
||||
return;
|
||||
|
||||
control.block.Text = e.NewValue as string ?? string.Empty;
|
||||
control.InvalidateMeasure();
|
||||
control.Restart();
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size constraint)
|
||||
{
|
||||
block.FontFamily = FontFamily;
|
||||
block.FontSize = FontSize;
|
||||
block.FontStyle = FontStyle;
|
||||
block.FontWeight = FontWeight;
|
||||
block.FontStretch = FontStretch;
|
||||
block.Foreground = Foreground;
|
||||
block.Measure(new Size(double.PositiveInfinity, constraint.Height));
|
||||
|
||||
return new Size(
|
||||
double.IsInfinity(constraint.Width) ? block.DesiredSize.Width : Math.Min(block.DesiredSize.Width, constraint.Width),
|
||||
block.DesiredSize.Height);
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size size)
|
||||
{
|
||||
block.Arrange(new Rect(0.0, 0.0, block.DesiredSize.Width, size.Height));
|
||||
return size;
|
||||
}
|
||||
|
||||
void Restart()
|
||||
{
|
||||
offset.BeginAnimation(TranslateTransform.XProperty, null);
|
||||
offset.X = 0.0;
|
||||
IsScrolling = false;
|
||||
|
||||
var hidden = HiddenWidth;
|
||||
if (hidden <= 1.0 || ActualWidth <= 0.0)
|
||||
return;
|
||||
|
||||
var travel = TimeSpan.FromSeconds(hidden / PixelsPerSecond);
|
||||
var hold = TimeSpan.FromSeconds(HoldSeconds);
|
||||
var frames = new DoubleAnimationUsingKeyFrames
|
||||
{
|
||||
RepeatBehavior = RepeatBehavior.Forever,
|
||||
KeyFrames =
|
||||
{
|
||||
new LinearDoubleKeyFrame(0.0, KeyTime.FromTimeSpan(hold)),
|
||||
new LinearDoubleKeyFrame(-hidden, KeyTime.FromTimeSpan(hold + travel)),
|
||||
new LinearDoubleKeyFrame(-hidden, KeyTime.FromTimeSpan(hold + travel + hold)),
|
||||
new LinearDoubleKeyFrame(0.0, KeyTime.FromTimeSpan(hold + travel + hold + travel)),
|
||||
},
|
||||
};
|
||||
|
||||
IsScrolling = true;
|
||||
offset.BeginAnimation(TranslateTransform.XProperty, frames);
|
||||
}
|
||||
}
|
||||
バイナリ
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 650 KiB |
新しいイシューから参照
ユーザーをブロックする