Skip to content

Commit

Permalink
Merge branch 'master' into ShowReadmeTxt
Browse files Browse the repository at this point in the history
  • Loading branch information
stakira authored Oct 2, 2023
2 parents 4e06a39 + 3aa8677 commit 6cfab88
Show file tree
Hide file tree
Showing 32 changed files with 581 additions and 119 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "openutau-devcontainer",
"image": "mcr.microsoft.com/devcontainers/dotnet:6.0", // Any generic, debian-based image.
"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit"
]
}
}
}
1 change: 1 addition & 0 deletions OpenUtau.Core/Classic/ClassicSinger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ClassicSinger : USinger {
public override float PortraitOpacity => voicebank.PortraitOpacity;
public override int PortraitHeight => voicebank.PortraitHeight;
public override string DefaultPhonemizer => voicebank.DefaultPhonemizer;
public override string Sample => voicebank.Sample == null ? null : Path.Combine(Location, voicebank.Sample);
public override Encoding TextFileEncoding => voicebank.TextFileEncoding;
public override IList<USubbank> Subbanks => subbanks;
public override IList<UOto> Otos => otos;
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau.Core/Classic/VoiceBank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Voicebank {
public string Voice;
public string Web;
public string Version;
public string Sample;
public string OtherInfo;
public string DefaultPhonemizer;
public Encoding TextFileEncoding;
Expand All @@ -34,6 +35,7 @@ public void Reload() {
Voice = null;
Web = null;
Version = null;
Sample = null;
OtherInfo = null;
TextFileEncoding = null;
SingerType = USingerType.Classic;
Expand Down
3 changes: 2 additions & 1 deletion OpenUtau.Core/Classic/VoicebankConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ public class VoicebankConfig {
public string Image;
public string Portrait;
public float PortraitOpacity = 0.67f;
public int PortraitHeight = 800;
public int PortraitHeight = 0;
public string Author;
public string Voice;
public string Web;
public string Version;
public string Sample;
public string DefaultPhonemizer;
public SymbolSet SymbolSet { get; set; }
public Subbank[] Subbanks { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions OpenUtau.Core/Classic/VoicebankLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public static void ParseCharacterTxt(Voicebank voicebank, Stream stream, string
} else if (s[0].StartsWith("voice") || s[0] == "cv") {
voicebank.Voice = s[1];
} else if (s[0] == "sample") {
voicebank.Sample = s[1];
} else if (s[0] == "web") {
voicebank.Web = s[1];
} else if (s[0] == "version") {
Expand Down Expand Up @@ -201,6 +202,9 @@ public static void ApplyConfig(Voicebank bank, VoicebankConfig bankConfig) {
if (!string.IsNullOrWhiteSpace(bankConfig.Version)) {
bank.Version = bankConfig.Version;
}
if (!string.IsNullOrWhiteSpace(bankConfig.Sample)) {
bank.Sample = bankConfig.Sample;
}
if (!string.IsNullOrWhiteSpace(bankConfig.DefaultPhonemizer)) {
bank.DefaultPhonemizer = bankConfig.DefaultPhonemizer;
}
Expand Down
24 changes: 24 additions & 0 deletions OpenUtau.Core/Commands/NoteCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,30 @@ public override void Unexecute() {
}
}

public class VibratoVolumeLinkCommand : VibratoCommand {
readonly UNote note;
readonly float newVolLink;
readonly float oldVolLink;
public VibratoVolumeLinkCommand(UVoicePart part, UNote note, float volLink) : base(part, note) {
this.note = note;
newVolLink = volLink;
oldVolLink = note.vibrato.volLink;
}
public override string ToString() {
return "Change vibrato volume link";
}
public override void Execute() {
lock (Part) {
note.vibrato.volLink = newVolLink;
}
}
public override void Unexecute() {
lock (Part) {
note.vibrato.volLink = oldVolLink;
}
}
}


public class PhonemeOffsetCommand : NoteCommand {
readonly UNote note;
Expand Down
27 changes: 27 additions & 0 deletions OpenUtau.Core/Editing/LyricBatchEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,31 @@ protected override string Transform(string lyric) {
}
}
}

public class InsertSlur : BatchEdit{
public virtual string Name => name;
private string name;

public InsertSlur() {
name = "pianoroll.menu.lyrics.insertslur";
}

public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, DocManager docManager) {
if(selectedNotes.Count == 0){
return;
}
var startPos = selectedNotes.First().position;
Queue<string> lyricsQueue = new Queue<string>();
docManager.StartUndoGroup(true);
foreach(var note in part.notes.Where(n => n.position >= startPos)){
lyricsQueue.Enqueue(note.lyric);
if(selectedNotes.Contains(note)){
docManager.ExecuteCmd(new ChangeNoteLyricCommand(part, note, "+~"));
} else {
docManager.ExecuteCmd(new ChangeNoteLyricCommand(part, note, lyricsQueue.Dequeue()));
}
}
docManager.EndUndoGroup();
}
}
}
7 changes: 7 additions & 0 deletions OpenUtau.Core/Enunu/EnunuSinger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class EnunuSinger : USinger {
public override string Portrait => voicebank.Portrait == null ? null : Path.Combine(Location, voicebank.Portrait);
public override float PortraitOpacity => voicebank.PortraitOpacity;
public override int PortraitHeight => voicebank.PortraitHeight;
public override string Sample => voicebank.Sample == null ? null : Path.Combine(Location, voicebank.Sample);
public override string DefaultPhonemizer => voicebank.DefaultPhonemizer;
public override Encoding TextFileEncoding => voicebank.TextFileEncoding;
public override IList<USubbank> Subbanks => subbanks;
Expand Down Expand Up @@ -190,5 +191,11 @@ public override byte[] LoadPortrait() {
? null
: File.ReadAllBytes(Portrait);
}

public override byte[] LoadSample() {
return string.IsNullOrEmpty(Sample)
? null
: File.ReadAllBytes(Sample);
}
}
}
3 changes: 3 additions & 0 deletions OpenUtau.Core/Format/Wave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public static WaveStream OpenFile(string filepath) {
if (tag == "fLaC") {
return new FlacReader(filepath);
}
if (ext == ".aiff" || ext == ".aif" || ext == ".aifc") {
return new AiffFileReader(filepath);
}
throw new Exception("Unsupported audio file format.");
}

Expand Down
18 changes: 18 additions & 0 deletions OpenUtau.Core/Render/RenderPhrase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,24 @@ internal RenderPhrase(UProject project, UTrack track, UVoicePart part, IEnumerab
break;
}
}
// Linking vibrato and volume
// int dynamicsInterval = 5;
foreach (var note in uNotes) {
if (note.vibrato.length <= 0 || note.vibrato.volLink == 0) {
continue;
}
if (dynamics == null) {
dynamics = new float[(end - part.position - pitchStart) / pitchInterval + 1];
}
int startIndex = Math.Max(0, (int)Math.Ceiling((float)(note.position - pitchStart) / pitchInterval));
int endIndex = Math.Min(pitches.Length, (note.End - pitchStart) / pitchInterval);
float nPeriod = (float)(note.vibrato.period / note.DurationMs);
for (int i = startIndex; i < endIndex; ++i) {
float nPos = (float)(pitchStart + i * pitchInterval - note.position) / note.duration;
float ratio = note.vibrato.EvaluateVolume(nPos, nPeriod);
dynamics[i] = dynamics[i] * ratio;
}
}
this.curves = curves.ToArray();
preEffectHash = Hash(false);
hash = Hash(true);
Expand Down
38 changes: 36 additions & 2 deletions OpenUtau.Core/Ustx/UNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ public class UVibrato {
float _out = NotePresets.Default.DefaultVibrato.VibratoOut;
// Shift percentage of period length.
float _shift = NotePresets.Default.DefaultVibrato.VibratoShift;
// Shift the whole vibrato up and down
// Shift the whole vibrato up and down.
float _drift = NotePresets.Default.DefaultVibrato.VibratoDrift;
// Percentage of volume reduction in linkage with vibrato. When this is 100%, volume will be 1.2 times to 0.2 times regardless of depth.
float _volLink = NotePresets.Default.DefaultVibrato.VibratoVolLink;

public float length { get => _length; set => _length = Math.Max(0, Math.Min(100, value)); }
public float period { get => _period; set => _period = Math.Max(5, Math.Min(500, value)); }
Expand All @@ -254,6 +256,7 @@ public float @out {
}
public float shift { get => _shift; set => _shift = Math.Max(0, Math.Min(100, value)); }
public float drift { get => _drift; set => _drift = Math.Max(-100, Math.Min(100, value)); }
public float volLink { get => _volLink; set => _volLink = Math.Max(-100, Math.Min(100, value)); }

[YamlIgnore] public float NormalizedStart => 1f - length / 100f;

Expand All @@ -265,7 +268,8 @@ public UVibrato Clone() {
@in = @in,
@out = @out,
shift = shift,
drift = drift
drift = drift,
volLink = volLink
};
return result;
}
Expand Down Expand Up @@ -297,6 +301,36 @@ public Vector2 Evaluate(float nPos, float nPeriod, UNote note) {
}
return new Vector2(note.position + note.duration * nPos, note.tone + y / 100f);
}
/// <summary>
/// Evaluate the volume of the position on the vibrato curve.
/// </summary>
public float EvaluateVolume(float nPos, float nPeriod) {
float nStart = NormalizedStart;
float nIn = length / 100f * @in / 100f;
float nInPos = nStart + nIn;
float nOut = length / 100f * @out / 100f;
float nOutPos = 1f - nOut;
float shift = this.shift;
float volLink = this.volLink;
if (volLink < 0) {
shift += 50;
if (shift > 100) {
shift -= 100;
}
volLink *= -1;
}
float t = (nPos - nStart) / nPeriod + shift / 100f;
float reduction = (-(float)Math.Sin(2 * Math.PI * t) / 2 + 0.3f) * volLink / 100;
if (nPos < nStart) {
reduction = 0;
} else if (nPos < nInPos) {
reduction *= (nPos - nStart) / nIn;
} else if (nPos > nOutPos) {
reduction *= (1f - nPos) / nOut;
}
float y = 1 - reduction;
return y;
}

public Vector2 GetEnvelopeStart(UNote note) {
return new Vector2(
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau.Core/Ustx/USinger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public class USinger : INotifyPropertyChanged {
public virtual string Portrait { get; }
public virtual float PortraitOpacity { get; }
public virtual int PortraitHeight { get; }
public virtual string Sample { get; }
public virtual string DefaultPhonemizer { get; }
public virtual Encoding TextFileEncoding => Encoding.UTF8;
public virtual IList<USubbank> Subbanks { get; }
Expand Down Expand Up @@ -246,6 +247,7 @@ public virtual bool TryGetMappedOto(string phoneme, int tone, string color, out

public virtual IEnumerable<UOto> GetSuggestions(string text) { return emptyOtos; }
public virtual byte[] LoadPortrait() => null;
public virtual byte[] LoadSample() => null;
public override string ToString() => Name;

public static USinger CreateMissing(string name) {
Expand Down
14 changes: 8 additions & 6 deletions OpenUtau.Core/Util/NotePresets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public static void Reset() {
new PortamentoPreset("Snap", 2, -1),
});
Default.VibratoPresets.AddRange(new List<VibratoPreset> {
new VibratoPreset("Standard", 75, 175, 25, 10, 10, 0, 0),
new VibratoPreset("UTAU Default", 65, 180, 35, 20, 20, 0, 0),
new VibratoPreset("UTAU Strong", 65, 210, 55, 25, 25, 0, 0),
new VibratoPreset("UTAU Weak", 65, 165, 20, 25, 25, 0, 0)
new VibratoPreset("Standard", 75, 175, 25, 10, 10, 0, 0, 0),
new VibratoPreset("UTAU Default", 65, 180, 35, 20, 20, 0, 0, 0),
new VibratoPreset("UTAU Strong", 65, 210, 55, 25, 25, 0, 0, 0),
new VibratoPreset("UTAU Weak", 65, 165, 20, 25, 25, 0, 0, 0)
});

Save();
Expand All @@ -60,7 +60,7 @@ public class SerializableNotePresets {
public string DefaultLyric = "a";
public PortamentoPreset DefaultPortamento = new PortamentoPreset("Standard", 80, -40);
public List<PortamentoPreset> PortamentoPresets = new List<PortamentoPreset> { };
public VibratoPreset DefaultVibrato = new VibratoPreset("Standard", 75, 175, 25, 10, 10, 0, 0);
public VibratoPreset DefaultVibrato = new VibratoPreset("Standard", 75, 175, 25, 10, 10, 0, 0, 0);
public List<VibratoPreset> VibratoPresets = new List<VibratoPreset> { };
public bool AutoVibratoToggle = false;
public int AutoVibratoNoteDuration = 481;
Expand Down Expand Up @@ -89,8 +89,9 @@ public class VibratoPreset {
public float VibratoOut = 10;
public float VibratoShift = 0;
public float VibratoDrift = 0;
public float VibratoVolLink = 0;

public VibratoPreset(string name, float length, float period, float depth, float fadein, float fadeout, float shift, float drift) {
public VibratoPreset(string name, float length, float period, float depth, float fadein, float fadeout, float shift, float drift, float volLink) {
Name = name;
VibratoLength = length;
VibratoPeriod = period;
Expand All @@ -99,6 +100,7 @@ public VibratoPreset(string name, float length, float period, float depth, float
VibratoOut = fadeout;
VibratoShift = shift;
VibratoDrift = drift;
VibratoVolLink = volLink;
}

public override string ToString() => Name;
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau.Core/Vogen/VogenSingerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class VogenMeta {
public string avatar;
public string portrait;
public float portraitOpacity = 0.67f;
public int portraitHeight = 800;
public int portraitHeight = 0;
public string web;
public string misc;
}
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau.Test/Classic/VoicebankConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ static VoicebankConfig CreateConfig() {
return new VoicebankConfig() {
PortraitOpacity = 0.75f,
PortraitHeight = 675,
Sample = "sample.wav",
SymbolSet = new SymbolSet() {
Preset = SymbolSetPreset.hiragana,
},
Expand Down Expand Up @@ -55,6 +56,7 @@ public void SerializationTest() {
//"" evaluates to " in verbatim string literals
Assert.Equal(@"portrait_opacity: 0.75
portrait_height: 675
sample: sample.wav
symbol_set:
preset: hiragana
head: '-'
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau.Test/Core/USTx/UstxYamlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void UNoteSerializationTest() {
- {x: -5, y: 0, shape: io}
- {x: 5, y: 0, shape: io}
snap_first: true
vibrato: {length: 0, period: 175, depth: 25, in: 10, out: 10, shift: 0, drift: 0}
vibrato: {length: 0, period: 175, depth: 25, in: 10, out: 10, shift: 0, drift: 0, vol_link: 0}
phoneme_expressions:
- {index: 0, abbr: vel, value: 123}
phoneme_overrides: []
Expand Down
7 changes: 7 additions & 0 deletions OpenUtau/Controls/NotePropertiesControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true"
GotFocus="OnGotFocus" LostFocus="OnLostFocus"/>
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.vollink}"/>
<TextBox Grid.Column="2" Text="{Binding VibratoVolLink}" GotFocus="OnGotFocus" LostFocus="OnLostFocus"/>
<Slider Grid.Column="4" Classes="fader" Value="{Binding VibratoVolLink}" Minimum="-100" Maximum="100"
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true"
GotFocus="OnGotFocus" LostFocus="OnLostFocus"/>
</Grid>
<Grid ColumnDefinitions="123,20,*">
<Label Content="{DynamicResource noteproperty.setlongnote}"/>
<CheckBox Grid.Column="2" IsChecked="{Binding AutoVibratoToggle}"/>
Expand Down
Loading

0 comments on commit 6cfab88

Please sign in to comment.