Skip to content

Commit

Permalink
fix: C0Shift, LogF0Shift
Browse files Browse the repository at this point in the history
  • Loading branch information
InuInu2022 committed Jan 13, 2024
1 parent 06911d2 commit 957ebaf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
24 changes: 18 additions & 6 deletions LibSasara.VoiSona/Model/Talk/Utterance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,39 @@ public decimal SpeedRatio {
/// <summary>
/// セリフの音量(Volume)
/// </summary>
/// <value>7.00 ~ -7.00</value>
public decimal C0Shift {
get => TreeUtil
.GetValueOnlyChildValue<decimal>(this, nameof(C0Shift));
get => FromC0Shift(TreeUtil
.GetValueOnlyChildValue<decimal>(this, nameof(C0Shift)));
set => TreeUtil.SetValueOnlyChildValue(
this,
nameof(C0Shift),
value);
ToC0Shift(value));
}

private static decimal FromC0Shift(decimal value)
=> (value + 0.00000001758793963m) / 0.1151292877m;
private static decimal ToC0Shift(decimal value)
=> (value * 0.1151292877m) + 0.00000001758793963m;

/// <summary>
/// セリフの高さ(Pitch) -600 ~ +600
/// </summary>
/// <value>-600 ~ +600</value>
public decimal LogF0Shift {
get => TreeUtil
.GetValueOnlyChildValue<decimal>(this, nameof(LogF0Shift));
get => FromLogF0Shift(TreeUtil
.GetValueOnlyChildValue<decimal>(this, nameof(LogF0Shift)));
set => TreeUtil.SetValueOnlyChildValue(
this,
nameof(LogF0Shift),
value);
ToLogF0Shift(value));
}

private static decimal FromLogF0Shift(decimal value)
=> (value + -0.00000007838179519m) / 0.0005776230847m;
private static decimal ToLogF0Shift(decimal value)
=> (value * 0.0005776230847m) + -0.00000007838179519m;

/// <summary>
/// セリフの声質・声の幼さ(Alpha)
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion LibSasara.VoiSona/Util/HeaderUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static Header Analysis(dynamic value)
var b = BitConverter.GetBytes((bool)value);
return new(b.Length, VoiSonaValueType.Bool, b);
}
else if (typeof(double) == type)
else if (typeof(double) == type || typeof(decimal) == type)
{
var b = BitConverter.GetBytes((double)value);
return new(b.Length, VoiSonaValueType.Double, b);
Expand Down
6 changes: 5 additions & 1 deletion LibSasara.VoiSona/Util/TreeUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ string childName
}
else if (typeof(T) == typeof(decimal))
{
return SasaraUtil.ConvertDecimal(value);
return value switch
{
T d => d,
_ => throw new InvalidCastException($"{value} is error!"),
};
}else if(typeof(T) == typeof(bool)){
return SasaraUtil.ConvertBool(value);
}else if(typeof(T) == typeof(string)){
Expand Down

0 comments on commit 957ebaf

Please sign in to comment.