4 コミット
作成者 SHA1 メッセージ 日付
routersys 1824f9faaf バージョンをv1.6.2へ合わせる
リリース / build-and-release (workflow_dispatch) Actions がタグ v1.6.2 のコミットから作成しました
2026-08-22 19:42:23 +09:00
routersys 41b813e2bb 音程の伸ばしを句の切れ目で決める 2026-08-22 19:29:49 +09:00
routersys e1fa384f83 音程曲線の先頭の伸ばしと1点の制御点を直す 2026-08-22 19:12:16 +09:00
routersys d455ed4659 音程を句全体の曲線として組み立てる 2026-08-22 18:37:08 +09:00
5個のファイルの変更、217行の追加、7行の削除

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
========================================
UTAU for YMM4 v1.6.1
UTAU for YMM4 v1.6.2
========================================
YukkuriMovieMaker4(YMM4)上で動作する、UTAU 音源から歌声を合成する
音声合成プラグインです。
+64
ファイルの表示
@@ -494,3 +494,67 @@ public sealed class AnalysisCacheTests
Assert.Equal(0, cache.UsedBytes);
}
}
public sealed class PitchTrackTests
{
static PhonemeUnit Unit(double start, double length, int tone, double preutterance, double overlap)
=> new(
new UTAUNote { Lyric = "a", Tone = tone },
new OtoEntry(@"C:ank", "a.wav", "a", 0.0, 0.0, 0.0, preutterance, overlap),
"a",
start,
length,
start,
length,
tone);
static PitchTrack Track(params PhonemeUnit[] units)
=> PitchTrack.Create(UnitTimingBuilder.Build(units), 0.0, 5.0, 80);
[Fact]
public void ThePitchStepsAtTheNoteBoundary()
{
var track = Track(Unit(0.0, 200.0, 60, 0.0, 0.0), Unit(200.0, 200.0, 72, 80.0, 40.0));
Assert.Equal(6000.0, track.CentsAt(39), 9);
Assert.Equal(7200.0, track.CentsAt(40), 9);
for (var frame = 0; frame < 80; frame++)
Assert.True(track.CentsAt(frame) is 6000.0 or 7200.0);
}
[Fact]
public void TheOverlapKeepsThePitchOfThePreviousNote()
{
var track = Track(Unit(0.0, 200.0, 60, 0.0, 0.0), Unit(200.0, 200.0, 72, 80.0, 40.0));
Assert.Equal(6000.0, track.CentsAt(24), 9);
}
[Fact]
public void APhraseOpeningNoteExtendsItsFirstPointBackToItsAudioStart()
{
var second = Unit(300.0, 200.0, 72, 80.0, 40.0);
second.Note.LengthTicks = 240;
second.Note.PitchPoints.Add(new PitchPoint(-50, 500.0));
second.Note.PitchPoints.Add(new PitchPoint(0, 0.0));
var track = Track(Unit(0.0, 200.0, 60, 0.0, 0.0), second);
Assert.Equal(7200.0, track.CentsAt(43), 9);
Assert.Equal(7700.0, track.CentsAt(44), 9);
Assert.Equal(7200.0, track.CentsAt(60), 9);
}
[Fact]
public void APortamentoReachesAcrossThePreviousNote()
{
var second = Unit(200.0, 200.0, 72, 80.0, 40.0);
second.Note.LengthTicks = 240;
second.Note.PitchPoints.Add(new PitchPoint(-120, -1200.0));
second.Note.PitchPoints.Add(new PitchPoint(0, 0.0));
var track = Track(Unit(0.0, 200.0, 60, 0.0, 0.0), second);
Assert.Equal(6000.0, track.CentsAt(20), 9);
Assert.Equal(6600.0, track.CentsAt(30), 9);
Assert.Equal(7200.0, track.CentsAt(40), 9);
}
}
+142
ファイルの表示
@@ -0,0 +1,142 @@
using UTAU.Notes;
namespace UTAU.Synthesis;
internal sealed class PitchTrack
{
readonly record struct TrackNote(UTAUNote Note, double StartMilliseconds, double LengthMilliseconds, int Tone, double AudioStartMilliseconds)
{
public double EndMilliseconds => StartMilliseconds + LengthMilliseconds;
public double Cents => Tone * 100.0;
}
readonly double[] cents;
PitchTrack(double[] cents) => this.cents = cents;
public static PitchTrack Create(IReadOnlyList<UnitTiming> timings, double startMilliseconds, double framePeriod, int frameCount)
{
ArgumentNullException.ThrowIfNull(timings);
var cents = new double[Math.Max(frameCount, 0)];
var notes = CollectNotes(timings);
if (cents.Length == 0 || notes.Count == 0)
return new PitchTrack(cents);
FillTones(cents, notes, startMilliseconds, framePeriod);
ApplyVibrato(cents, notes, startMilliseconds, framePeriod);
ApplyPortamento(cents, notes, startMilliseconds, framePeriod);
return new PitchTrack(cents);
}
public double CentsAt(int frame)
=> cents.Length == 0 ? 0.0 : cents[Math.Clamp(frame, 0, cents.Length - 1)];
static List<TrackNote> CollectNotes(IReadOnlyList<UnitTiming> timings)
{
var notes = new List<TrackNote>(timings.Count);
foreach (var timing in timings)
{
var unit = timing.Unit;
if (unit.Note.IsRest)
continue;
notes.Add(new TrackNote(unit.Note, unit.NoteStartMilliseconds, unit.NoteLengthMilliseconds, unit.Tone, timing.AudioStartMilliseconds));
}
notes.Sort((left, right) => left.StartMilliseconds.CompareTo(right.StartMilliseconds));
var distinct = new List<TrackNote>(notes.Count);
foreach (var note in notes)
{
if (distinct.Count > 0 && distinct[^1].StartMilliseconds == note.StartMilliseconds && ReferenceEquals(distinct[^1].Note, note.Note))
{
distinct[^1] = distinct[^1] with
{
AudioStartMilliseconds = Math.Min(distinct[^1].AudioStartMilliseconds, note.AudioStartMilliseconds),
};
continue;
}
distinct.Add(note);
}
return distinct;
}
static void FillTones(double[] cents, List<TrackNote> notes, double startMilliseconds, double framePeriod)
{
var index = 0;
foreach (var note in notes)
{
while (index < cents.Length && startMilliseconds + index * framePeriod < note.EndMilliseconds)
{
cents[index] = note.Cents;
index++;
}
}
if (index == 0)
{
Array.Fill(cents, notes[^1].Cents);
return;
}
for (var i = index; i < cents.Length; i++)
cents[i] = cents[i - 1];
}
static void ApplyVibrato(double[] cents, List<TrackNote> notes, double startMilliseconds, double framePeriod)
{
foreach (var note in notes)
{
if (!note.Note.Vibrato.IsEnabled)
continue;
var from = Math.Max((int)Math.Ceiling((note.StartMilliseconds - startMilliseconds) / framePeriod), 0);
var to = Math.Min((int)((note.EndMilliseconds - startMilliseconds) / framePeriod), cents.Length);
for (var i = from; i < to; i++)
cents[i] = note.Cents + note.Note.Vibrato.Evaluate(startMilliseconds + i * framePeriod - note.StartMilliseconds, note.LengthMilliseconds);
}
}
static void ApplyPortamento(double[] cents, List<TrackNote> notes, double startMilliseconds, double framePeriod)
{
for (var n = 0; n < notes.Count; n++)
{
var note = notes[n];
if (note.Note.PitchPoints.Count == 0 || note.Note.LengthTicks <= 0)
continue;
var scale = note.LengthMilliseconds / note.Note.LengthTicks;
var points = new List<(double X, double Y, PitchPointShape Shape)>(note.Note.PitchPoints.Count + 2);
foreach (var point in note.Note.PitchPoints)
points.Add((note.StartMilliseconds + point.Ticks * scale, note.Cents + point.Cents, point.Shape));
var opensPhrase = n == 0 || notes[n - 1].EndMilliseconds < note.StartMilliseconds;
var lead = opensPhrase
? Math.Max(startMilliseconds, note.AudioStartMilliseconds)
: note.StartMilliseconds;
if (points[0].X > lead)
points.Insert(0, (lead, points[0].Y, points[0].Shape));
if (points[^1].X < note.EndMilliseconds)
points.Add((note.EndMilliseconds, points[^1].Y, points[^1].Shape));
for (var s = 0; s < points.Count - 1; s++)
{
var from = points[s];
var to = points[s + 1];
var first = Math.Max((int)Math.Ceiling((from.X - startMilliseconds) / framePeriod), 0);
var last = Math.Min((int)Math.Ceiling((to.X - startMilliseconds) / framePeriod), cents.Length);
var span = to.X - from.X;
for (var i = first; i < last; i++)
{
var x = startMilliseconds + i * framePeriod;
var progress = span <= 0.0 ? 1.0 : (x - from.X) / span;
var pitch = PitchPoint.Interpolate(from.Y, to.Y, progress, from.Shape);
var basePitch = n > 0 && x < notes[n - 1].EndMilliseconds ? notes[n - 1].Cents : note.Cents;
cents[i] += pitch - basePitch;
}
}
}
}
}
+9 -5
ファイルの表示
@@ -314,6 +314,12 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
Array.Clear(voicedWeight, 0, frameCount);
Array.Clear(logF0Sum, 0, frameCount);
var track = PitchTrack.Create(
[.. segment.TimingIndices.Select(x => timings[x])],
offset + segment.StartFrame * framePeriod,
framePeriod,
frameCount);
foreach (var index in segment.TimingIndices)
{
var source = BuildSource(requests[index], arena);
@@ -323,6 +329,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
AccumulateUnit(
timings[index],
source,
track,
offset,
framePeriod,
segment.StartFrame,
@@ -359,6 +366,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
void AccumulateUnit(
UnitTiming timing,
UnitSource source,
PitchTrack track,
double offset,
double framePeriod,
int segmentStartFrame,
@@ -420,11 +428,7 @@ internal sealed class UtauRenderer(RenderSettings settings, RenderCurves curves,
if (sourceF0 <= 0.0)
continue;
var progress = unit.NoteLengthMilliseconds > 0.0
? (absolute - unit.NoteStartMilliseconds) / unit.NoteLengthMilliseconds
: 0.0;
var cents = note.EvaluatePitchOffsetCents(progress, unit.NoteLengthMilliseconds);
var targetF0 = MusicalTone.FrequencyOf(unit.Tone + cents / 100.0);
var targetF0 = MusicalTone.FrequencyOf(track.CentsAt(frame) / 100.0);
var ratio = source.MeanF0 > 0.0 ? sourceF0 / source.MeanF0 : 1.0;
var value = targetF0 * Math.Pow(ratio, modulation);
if (!double.IsFinite(value) || value <= 0.0)
+1 -1
ファイルの表示
@@ -5,7 +5,7 @@
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.6.1</Version>
<Version>1.6.2</Version>
<Platforms>AnyCPU;x64;x64</Platforms>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>