Skip to content

Commit

Permalink
check and patch moreconfig.txt when launching
Browse files Browse the repository at this point in the history
  • Loading branch information
oxygen-dioxide committed Jun 17, 2024
1 parent ec23a29 commit 25544c4
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 25544c4

Please sign in to comment.