コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
2baedff12c
|
||
|
|
9e114cc414
|
||
|
|
316b4fe1b6
|
||
|
|
0a2a9a2bf6
|
||
|
|
fa1758de0d
|
||
|
|
fe5801cefe
|
||
|
|
63198039dc
|
||
|
|
ba001e1d23
|
||
|
|
26d3f2007e
|
||
|
|
5328d1efe3
|
||
|
|
6dc3b7f4f7
|
||
|
|
36169bc285
|
||
|
|
b997849ece
|
||
|
|
fbf5745ff7 |
検索条件に一致するファイルはありません
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
UTAU for YMM4 v1.4.1
|
||||
UTAU for YMM4 v1.5.0
|
||||
========================================
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合成する
|
||||
音声合成プラグインです。
|
||||
|
||||
@@ -122,7 +122,7 @@ jobs:
|
||||
git add -A
|
||||
$pending = git diff --cached --name-only
|
||||
if ($pending) {
|
||||
git commit -m "バージョンを$tagへ合わせる" --quiet
|
||||
git commit -m "バージョンを${tag}へ合わせる" --quiet
|
||||
git push origin HEAD:main
|
||||
Write-Host "main へ訂正を反映しました"
|
||||
} else {
|
||||
|
||||
@@ -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. [ノートの項目一覧](#ノートの項目一覧)
|
||||
@@ -135,7 +137,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合
|
||||
|
||||
出力は 16 ビットのモノラル WAV です。ノートの母音から口パクに使う情報も作ります。
|
||||
|
||||
### 6. 解析キャッシュ
|
||||
### 6. 解析と合成の再利用
|
||||
|
||||
分析結果は、音声ファイルの場所と更新日時と読み込む範囲と推定方法を鍵にしてメモリへ保持します。2 回目以降の合成では分析をやり直しません。上限は既定で 512MB で、64MB から 4096MB まで設定できます。上限を超えると古い物から捨てます。設定画面から破棄することもできます。複数の音声ファイルの分析は複数のコアで並列に行います。
|
||||
|
||||
|
||||
@@ -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([]));
|
||||
|
||||
@@ -124,6 +124,28 @@ public sealed class UtauRendererTests : IDisposable
|
||||
|
||||
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();
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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,7 +37,9 @@ 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
|
||||
{
|
||||
@@ -73,6 +76,10 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
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);
|
||||
|
||||
@@ -224,6 +231,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
|
||||
timing.RenderLengthMilliseconds,
|
||||
timing.FadeInMilliseconds,
|
||||
timing.FadeOutMilliseconds,
|
||||
timing.SkipMilliseconds,
|
||||
unit.NoteStartMilliseconds - origin,
|
||||
unit.NoteLengthMilliseconds,
|
||||
unit.Tone,
|
||||
@@ -369,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++)
|
||||
@@ -384,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);
|
||||
|
||||
@@ -404,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;
|
||||
@@ -455,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);
|
||||
}
|
||||
|
||||
@@ -534,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)
|
||||
@@ -582,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)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.4.1</Version>
|
||||
<Version>1.5.0</Version>
|
||||
<Platforms>AnyCPU;x64;x64</Platforms>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
||||
バイナリ
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 650 KiB |
新しいイシューから参照
ユーザーをブロックする