Skip to content

Commit

Permalink
Merge pull request #485 from corykim/feature/batch-isolate-vocals-fil…
Browse files Browse the repository at this point in the history
…ter-unsupported-songs

feat: Batch Isolate Vocals should filter out songs with unsupported a…
  • Loading branch information
achimmihca authored Oct 29, 2024
2 parents c1dc57b + ed475b5 commit 7d774e3
Showing 1 changed file with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UniInject;
using UniRx;
Expand Down Expand Up @@ -39,7 +40,7 @@ public List<IModSettingControl> GetModSettingControls()

private void OnSelectAll()
{
toggles.ForEach(toggle => toggle.value = true);
toggles.FindAll(toggle => toggle.enabledSelf).ForEach(toggle => toggle.value = true);
}

private void OnDeselectAll()
Expand Down Expand Up @@ -152,13 +153,33 @@ public VisualElement CreateVisualElement()
toggle.label = SongMetaUtils.GetArtistDashTitle(songMeta);
toggle.value = false;
toggle.userData = songMeta;

toggles.Add(toggle);

if (!IsSongSupported(songMeta))
{
toggle.SetEnabled(false);
}
toggles.Add(toggle);
toggleContainer.Add(toggle);
}

return toggleContainer;
}

private readonly string[] supportedExtensions = { "wav", "mp3", "ogg", "m4a", "wma", "flac" };

private bool IsSongSupported(SongMeta songMeta)
{
string audio = songMeta.Audio;
string extension = Path.GetExtension(audio).ToLower();
if (extension.StartsWith("."))
{
extension = extension.Substring(1);
}
bool result = Array.Exists(supportedExtensions, ext => ext.Equals(extension));
Debug.Log($"Checking support for {audio}, extension: {extension}, result: {result}");
return result;
}


}
}

0 comments on commit 7d774e3

Please sign in to comment.