Skip to content

Commit

Permalink
Merge pull request #1186 from oxygen-dioxide/moreconfig-patch
Browse files Browse the repository at this point in the history
Check and patch moreconfig.txt when launching
  • Loading branch information
stakira committed Sep 3, 2024
2 parents 84ae7e1 + 25544c4 commit d541154
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions OpenUtau.Core/Classic/ExeResampler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -34,6 +36,27 @@ public ResamplerManifest LoadManifest() {
}
}

void FixMoreConfig(string moreConfigPath) {
var lines = new List<string> { };
if (File.Exists(moreConfigPath)) {
lines = File.ReadAllLines(moreConfigPath).ToList();
}
for (int i = 0; i < lines.Count; i++) {
if (lines[i].StartsWith("resampler-compatibility")) {
if(lines[i] == "resampler-compatibility on"){
//moreconfig.txt is correct
return;
} else {
lines[i] = "resampler-compatibility on";
File.WriteAllLines(moreConfigPath, lines);
return;
}
}
}
lines.Add("resampler-compatibility on");
File.WriteAllLines(moreConfigPath, lines);
}

public ExeResampler(string filePath, string basePath) {
if (File.Exists(filePath)) {
FilePath = filePath;
Expand All @@ -42,6 +65,16 @@ public ExeResampler(string filePath, string basePath) {
}
//Load Resampler Manifest
Manifest = LoadManifest();
//Make moresampler happy
try{
if(Path.GetFileNameWithoutExtension(filePath) == "moresampler"){
//Load moreconfig.txt under the same folder with filePath
var moreConfigPath = Path.Combine(Path.GetDirectoryName(filePath), "moreconfig.txt");
FixMoreConfig(moreConfigPath);
}
} catch (Exception ex){
Log.Error($"Failed fixing moreconfig.txt for {filePath}: {ex}");
}
}

public float[] DoResampler(ResamplerItem args, ILogger logger) {
Expand Down

0 comments on commit d541154

Please sign in to comment.