|
7 | 7 | using OpenUtau.Core; |
8 | 8 | using OpenUtau.Core.Format; |
9 | 9 | using OpenUtau.Core.Util; |
| 10 | +using OpenUtau.Core.Ustx; |
10 | 11 | using Serilog; |
11 | 12 |
|
12 | 13 | namespace OpenUtau.Classic { |
13 | 14 | internal class ExeResampler : IResampler { |
14 | 15 | public string Name { get; private set; } |
15 | 16 | public string FilePath { get; private set; } |
16 | 17 | public bool isLegalPlugin => _isLegalPlugin; |
| 18 | + public ResamplerManifest Manifest { get; private set; } |
17 | 19 | readonly string _name; |
18 | 20 | readonly bool _isLegalPlugin = false; |
19 | 21 |
|
| 22 | + |
| 23 | + public ResamplerManifest LoadManifest() { |
| 24 | + try { |
| 25 | + var ManifestPath = Path.ChangeExtension(FilePath, ".yaml"); |
| 26 | + if (!File.Exists(ManifestPath)) { |
| 27 | + //TODO: Write Resampler Manifests shipped by OpenUtau |
| 28 | + return new ResamplerManifest(); |
| 29 | + } |
| 30 | + return ResamplerManifest.Load(ManifestPath); |
| 31 | + } catch (Exception ex) { |
| 32 | + Log.Error($"Failed loading resampler manifest for {_name}: {ex}"); |
| 33 | + return new ResamplerManifest(); |
| 34 | + } |
| 35 | + } |
| 36 | + |
20 | 37 | public ExeResampler(string filePath, string basePath) { |
21 | 38 | if (File.Exists(filePath)) { |
22 | 39 | FilePath = filePath; |
23 | 40 | _name = Path.GetRelativePath(basePath, filePath); |
24 | 41 | _isLegalPlugin = true; |
25 | 42 | } |
| 43 | + //Load Resampler Manifest |
| 44 | + Manifest = LoadManifest(); |
26 | 45 | } |
27 | 46 |
|
28 | 47 | public float[] DoResampler(ResamplerItem args, ILogger logger) { |
@@ -59,6 +78,13 @@ public void CheckPermissions() { |
59 | 78 | chmod(FilePath, mode); |
60 | 79 | } |
61 | 80 |
|
| 81 | + public bool SupportsFlag(string abbr) { |
| 82 | + if(Manifest == null || !Manifest.expressionFilter){ |
| 83 | + return true; |
| 84 | + } |
| 85 | + return Manifest.expressions.ContainsKey(abbr); |
| 86 | + } |
| 87 | + |
62 | 88 | public override string ToString() => _name; |
63 | 89 | } |
64 | 90 | } |
0 commit comments