Skip to content

Commit f13ca18

Browse files
Merge branch 'stakira:master' into master
2 parents c49715e + f810f08 commit f13ca18

File tree

162 files changed

+31803
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+31803
-406
lines changed

LICENSE.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-
23-
This license covers both OpenUtau source code and Worldline prebuilt binaries.

OpenUtau.Core/Api/Phonemizer.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,21 @@ public struct PhonemeAttributes {
9797
public string voiceColor;
9898
}
9999

100+
public struct PhonemeExpression {
101+
public string abbr;
102+
public float value;
103+
}
104+
100105
/// <summary>
101106
/// The output struct that represents a phoneme.
102107
/// </summary>
103108
public struct Phoneme {
109+
/// <summary>
110+
/// Number to manage phonemes in note.
111+
/// Optional. Whether to specify an index or not should be consistent within Phonemizer (All phonemes should be indexed, or all should be unindexed).
112+
/// </summary>
113+
public int? index;
114+
104115
/// <summary>
105116
/// Phoneme name. Should match one of oto alias.
106117
/// Note that you don't have to return tone-mapped phonemes. OpenUtau will do it afterwards.
@@ -111,16 +122,14 @@ public struct Phoneme {
111122

112123
/// <summary>
113124
/// Position of phoneme in note. Measured in ticks.
114-
/// Use TickToMs() and MsToTick() to convert between ticks and milliseconds .
125+
/// Use TickToMs() and MsToTick() to convert between ticks and milliseconds.
115126
/// </summary>
116127
public int position;
117128

118129
/// <summary>
119-
/// Suggested attributes. May or may not be used eventually.
130+
/// Suggested attributes. It may later be overwritten with a user-specified value.
120131
/// </summary>
121-
public PhonemeAttributes attributes;
122-
123-
public int? index;
132+
public List<PhonemeExpression> expressions;
124133

125134
public override string ToString() => $"\"{phoneme}\" pos:{position}";
126135
}
@@ -161,7 +170,7 @@ public struct Result {
161170
/// </summary>
162171
public virtual bool LegacyMapping => false;
163172

164-
public virtual void SetUp(Note[][] notes) { }
173+
public virtual void SetUp(Note[][] notes, UProject project, UTrack track) { }
165174

166175
/// <summary>
167176
/// Phonemize a consecutive sequence of notes. This is the main logic of a phonemizer.

OpenUtau.Core/Api/PhonemizerRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static PhonemizerResponse Phonemize(PhonemizerRequest request) {
9999
phonemizer.SetSinger(request.singer);
100100
phonemizer.SetTiming(request.timeAxis);
101101
try {
102-
phonemizer.SetUp(notes);
102+
phonemizer.SetUp(notes, DocManager.Inst.Project, DocManager.Inst.Project.tracks[request.part.trackNo]);
103103
} catch (Exception e) {
104104
Log.Error(e, $"phonemizer failed to setup.");
105105
}

OpenUtau.Core/BaseChinesePhonemizer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
4-
using OpenUtau.Core.G2p;
53
using OpenUtau.Api;
4+
using OpenUtau.Core.G2p;
5+
using OpenUtau.Core.Ustx;
66

77
namespace OpenUtau.Core {
88
public abstract class BaseChinesePhonemizer : Phonemizer {
@@ -43,7 +43,7 @@ public static void RomanizeNotes(Note[][] groups) {
4343
Enumerable.Zip(groups, ResultLyrics, ChangeLyric).Last();
4444
}
4545

46-
public override void SetUp(Note[][] groups) {
46+
public override void SetUp(Note[][] groups, UProject project, UTrack track) {
4747
RomanizeNotes(groups);
4848
}
4949
}

OpenUtau.Core/Classic/ClassicRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class ClassicRenderer : IRenderer {
2525
Ustx.ATK,
2626
Ustx.DEC,
2727
Ustx.MOD,
28+
Ustx.MODP,
2829
Ustx.ALT,
2930
};
3031

OpenUtau.Core/Classic/ClassicSingerLoader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ static USinger AdjustSingerType(Voicebank v) {
1111
return new Core.Enunu.EnunuSinger(v) as USinger;
1212
case USingerType.DiffSinger:
1313
return new Core.DiffSinger.DiffSingerSinger(v) as USinger;
14+
case USingerType.Voicevox:
15+
return new Core.Voicevox.VoicevoxSinger(v) as USinger;
1416
default:
1517
return new ClassicSinger(v) as USinger;
1618
}

OpenUtau.Core/Classic/Frq.cs

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Linq;
44
using System.Text;
5+
using OpenUtau.Core;
56

67
namespace OpenUtau.Classic {
78
public class Frq {
@@ -12,22 +13,40 @@ public class Frq {
1213
public double[] f0 = new double[0];
1314
public double[] amp = new double[0];
1415

15-
public void Load(Stream stream) {
16-
using (var reader = new BinaryReader(stream)) {
17-
string header = new string(reader.ReadChars(8));
18-
if (header != "FREQ0003") {
19-
throw new FormatException("FREQ0003 header not found.");
20-
}
21-
hopSize = reader.ReadInt32();
22-
averageF0 = reader.ReadDouble();
23-
_ = reader.ReadBytes(16); // blank
24-
int length = reader.ReadInt32();
25-
f0 = new double[length];
26-
amp = new double[length];
27-
for (int i = 0; i < length; i++) {
28-
f0[i] = reader.ReadDouble();
29-
amp[i] = reader.ReadDouble();
16+
/// <summary>
17+
/// If the wav path is null (machine learning voicebank), return false.
18+
/// <summary>
19+
public bool Load(string wavPath) {
20+
if (string.IsNullOrEmpty(wavPath)) {
21+
return false;
22+
}
23+
string frqFile = VoicebankFiles.GetFrqFile(wavPath);
24+
if (!File.Exists(frqFile)) {
25+
return false;
26+
}
27+
try {
28+
using (var fileStream = File.OpenRead(frqFile)) {
29+
using (var reader = new BinaryReader(fileStream)) {
30+
string header = new string(reader.ReadChars(8));
31+
if (header != "FREQ0003") {
32+
throw new FormatException("FREQ0003 header not found.");
33+
}
34+
hopSize = reader.ReadInt32();
35+
averageF0 = reader.ReadDouble();
36+
_ = reader.ReadBytes(16); // blank
37+
int length = reader.ReadInt32();
38+
f0 = new double[length];
39+
amp = new double[length];
40+
for (int i = 0; i < length; i++) {
41+
f0[i] = reader.ReadDouble();
42+
amp[i] = reader.ReadDouble();
43+
}
44+
}
3045
}
46+
return true;
47+
} catch (Exception e) {
48+
DocManager.Inst.ExecuteCmd(new ErrorMessageNotification("failed to load frq file", e));
49+
return false;
3150
}
3251
}
3352

OpenUtau.Core/Classic/Plugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void Run(string tempFile) {
1818
}
1919
var startInfo = new ProcessStartInfo() {
2020
FileName = Executable,
21-
Arguments = tempFile,
21+
Arguments = $"\"{tempFile}\"",
2222
WorkingDirectory = Path.GetDirectoryName(Executable),
2323
UseShellExecute = UseShell,
2424
};

OpenUtau.Core/Classic/WorldlineRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class WorldlineRenderer : IRenderer {
2525
Ustx.VEL,
2626
Ustx.VOL,
2727
Ustx.MOD,
28+
Ustx.MODP,
2829
Ustx.ALT,
2930
Ustx.GENC,
3031
Ustx.BREC,

OpenUtau.Core/Commands/NoteCommands.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,44 @@ public override void Unexecute() {
9595
}
9696

9797
public class ResizeNoteCommand : NoteCommand {
98+
readonly int NewPartDuration;
99+
readonly int OldPartDuration;
98100
readonly int DeltaDur;
99101
public ResizeNoteCommand(UVoicePart part, UNote note, int deltaDur) : base(part, note) {
100102
DeltaDur = deltaDur;
103+
OldPartDuration = part.Duration;
104+
DocManager.Inst.Project.timeAxis.TickPosToBarBeat(note.End + deltaDur, out int bar, out int beat, out int remainingTicks);
105+
int minDurTick = DocManager.Inst.Project.timeAxis.BarBeatToTickPos(bar + 2, 0) - part.position;
106+
if (part.Duration < minDurTick) {
107+
NewPartDuration = minDurTick;
108+
}
101109
}
102110
public ResizeNoteCommand(UVoicePart part, List<UNote> notes, int deltaDur) : base(part, notes) {
103111
DeltaDur = deltaDur;
112+
OldPartDuration = part.Duration;
113+
DocManager.Inst.Project.timeAxis.TickPosToBarBeat((Notes.LastOrDefault()?.End ?? 1) + deltaDur, out int bar, out int beat, out int remainingTicks);
114+
int minDurTick = DocManager.Inst.Project.timeAxis.BarBeatToTickPos(bar + 2, 0) - part.position;
115+
if (part.Duration < minDurTick) {
116+
NewPartDuration = minDurTick;
117+
}
104118
}
105119
public override string ToString() { return $"Change {Notes.Count()} notes duration"; }
106120
public override void Execute() {
107121
lock (Part) {
108122
foreach (var note in Notes) {
109123
note.duration += DeltaDur;
110124
}
125+
if (NewPartDuration > 0) {
126+
Part.Duration = NewPartDuration;
127+
}
111128
}
112129
}
113130
public override void Unexecute() {
114131
lock (Part) {
115132
foreach (var note in Notes) {
116133
note.duration -= DeltaDur;
117134
}
135+
Part.Duration = OldPartDuration;
118136
}
119137
}
120138
}
@@ -502,11 +520,11 @@ public ChangePhonemeAliasCommand(UVoicePart part, UNote note, int index, string?
502520

503521
public override void Execute() {
504522
var o = note.GetPhonemeOverride(index);
505-
o.phoneme = string.IsNullOrWhiteSpace(newAlias) ? string.Empty : newAlias;
523+
o.phoneme = string.IsNullOrWhiteSpace(newAlias) ? null : newAlias;
506524
}
507525
public override void Unexecute() {
508526
var o = note.GetPhonemeOverride(index);
509-
o.phoneme = string.IsNullOrWhiteSpace(oldAlias) ? string.Empty : oldAlias;
527+
o.phoneme = string.IsNullOrWhiteSpace(oldAlias) ? null : oldAlias;
510528
}
511529
public override string ToString() => "Change phoneme alias";
512530
}

0 commit comments

Comments
 (0)