Skip to content

Commit

Permalink
add support for more formats
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelTulach committed Oct 30, 2021
1 parent 738e559 commit c4447bc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A BSIPA compatible mod that can change following in-game sounds:
Make sure that you have core mods installed with [ModAssistant](/~https://github.com/Assistant/ModAssistant) (BSIPA, Harmony, BSML). Go to the [releases page](/~https://github.com/SamuelTulach/SoundReplacer/releases) and download the latest build (or build compatible with your Beat Saber version). Extract the zip file and move the DLL file into plugins folder located in Beat Saber install directory.

## Usage
First, you will need to find sounds that you want to use. They have to be in OGG format. Please note that certain sounds should have offset, otherwise it might seem like the sound is played before the action happens. To download ready to use sounds, check out [BSMG discord's](https://discord.gg/beatsabermods) #game-sounds section.
First, you will need to find sounds that you want to use. They have to be in OGG/MPEG/WAV format. Please note that certain sounds should have offset, otherwise it might seem like the sound is played before the action happens. To download ready to use sounds, check out [BSMG discord's](https://discord.gg/beatsabermods) #game-sounds section.

Once you have sounds that you want to use, simply move them to Beat Saber install directory -> UserData -> SoundReplacer (should be created automatically if you run the game with mod once, do not put them within subfolders). After you have done so, (re)start the game and choose which sounds you want to use in the in-game menu. If you are unsure how the folder structure should look, check out the screenshot bellow.

Expand Down
4 changes: 2 additions & 2 deletions SoundReplacer/SoundReplacer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("ca60fd0d-b67b-4fd6-8081-3d8349bdcc89")]
[assembly: AssemblyVersion("0.0.2")]
[assembly: AssemblyFileVersion("0.0.2")]
[assembly: AssemblyVersion("0.0.3")]
[assembly: AssemblyFileVersion("0.0.3")]
33 changes: 26 additions & 7 deletions SoundReplacer/SoundReplacer/SoundLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public static void GetSoundLists()
foreach (var file in files)
{
var fileInfo = new FileInfo(file);
if (fileInfo.Extension != ".ogg")
continue;

GlobalSoundList.Add(fileInfo.Name);
if (fileInfo.Extension == ".ogg" ||
fileInfo.Extension == ".mp3" ||
fileInfo.Extension == ".wav")
{
GlobalSoundList.Add(fileInfo.Name);
}
}
}

Expand All @@ -42,12 +44,29 @@ public static string GetFullPath(string name)
return fileInfo.FullName;
}

public static UnityWebRequest GetRequest(string fullPath)
{
var fileUrl = "file:///" + fullPath;
var fileInfo = new FileInfo(fullPath);
var extension = fileInfo.Extension;
switch (extension)
{
case ".ogg":
return UnityWebRequestMultimedia.GetAudioClip(fileUrl, AudioType.OGGVORBIS);
case ".mp3":
return UnityWebRequestMultimedia.GetAudioClip(fileUrl, AudioType.MPEG);
case ".wav":
return UnityWebRequestMultimedia.GetAudioClip(fileUrl, AudioType.WAV);
default:
return UnityWebRequestMultimedia.GetAudioClip(fileUrl, AudioType.UNKNOWN);
}
}

public static AudioClip LoadAudioClip(string name)
{
var fullPath = GetFullPath(name);
var fileUrl = "file:///" + fullPath;
var request = UnityWebRequestMultimedia.GetAudioClip(fileUrl, AudioType.OGGVORBIS);

var request = GetRequest(fullPath);

AudioClip loadedAudio = null;
var task = request.SendWebRequest();

Expand Down
2 changes: 1 addition & 1 deletion SoundReplacer/SoundReplacer/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "SoundReplacer",
"name": "SoundReplacer",
"author": "Otiosum",
"version": "0.0.2",
"version": "0.0.3",
"description": "Easily replace in-game sounds",
"gameVersion": "1.18.1",
"dependsOn": {
Expand Down

0 comments on commit c4447bc

Please sign in to comment.