merge Vorbis code from develop
This commit is contained in:
commit
7b719c2edc
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Xna.Framework.Audio;
|
using Microsoft.Xna.Framework.Audio;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using NAudio.Vorbis;
|
||||||
using NAudio.Wave;
|
using NAudio.Wave;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
@ -166,10 +167,6 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
DirectoryInfo songFolder = new DirectoryInfo(Path.Combine(this.ContentPack.DirectoryPath, this.MusicFolderName));
|
DirectoryInfo songFolder = new DirectoryInfo(Path.Combine(this.ContentPack.DirectoryPath, this.MusicFolderName));
|
||||||
foreach (FileInfo file in songFolder.GetFiles())
|
foreach (FileInfo file in songFolder.GetFiles())
|
||||||
{
|
{
|
||||||
//MemoryStream memoryStream = new MemoryStream();
|
|
||||||
//AudioFileReader fileReader = new AudioFileReader(file.FullName);
|
|
||||||
//fileReader.CopyTo(memoryStream);
|
|
||||||
|
|
||||||
// get name
|
// get name
|
||||||
string name = Path.GetFileNameWithoutExtension(file.Name);
|
string name = Path.GetFileNameWithoutExtension(file.Name);
|
||||||
if (this.Sounds.ContainsKey(name))
|
if (this.Sounds.ContainsKey(name))
|
||||||
|
@ -190,7 +187,7 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader))
|
using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader))
|
||||||
{
|
{
|
||||||
string tempPath = Path.Combine(songFolder.FullName, $"{name}.wav");
|
string tempPath = Path.Combine(songFolder.FullName, $"{name}.wav");
|
||||||
StardewSymphony.ModMonitor.Log($"MP3 CONVERT! {tempPath}");
|
StardewSymphony.ModMonitor.Log($"Converting: {tempPath}");
|
||||||
|
|
||||||
WaveFileWriter.CreateWaveFile(tempPath, pcmStream);
|
WaveFileWriter.CreateWaveFile(tempPath, pcmStream);
|
||||||
using (Stream tempStream = File.OpenRead(tempPath))
|
using (Stream tempStream = File.OpenRead(tempPath))
|
||||||
|
@ -199,6 +196,20 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ".ogg":
|
||||||
|
// Credits: https://social.msdn.microsoft.com/Forums/vstudio/en-US/100a97af-2a1c-4b28-b464-d43611b9b5d6/converting-multichannel-ogg-to-stereo-wav-file?forum=csharpgeneral
|
||||||
|
using (VorbisWaveReader vorbisStream = new VorbisWaveReader(file.FullName))
|
||||||
|
{
|
||||||
|
string tempPath = Path.Combine(songFolder.FullName, $"{name}.wav");
|
||||||
|
StardewSymphony.DebugLog($"Converting: {tempPath}");
|
||||||
|
|
||||||
|
WaveFileWriter.CreateWaveFile(tempPath, vorbisStream.ToWaveProvider16());
|
||||||
|
using (Stream tempStream = File.OpenRead(tempPath))
|
||||||
|
effect = SoundEffect.FromStream(tempStream);
|
||||||
|
File.Delete(tempPath);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
StardewSymphony.ModMonitor.Log($"Unsupported file extension {file.Extension}.", LogLevel.Warn);
|
StardewSymphony.ModMonitor.Log($"Unsupported file extension {file.Extension}.", LogLevel.Warn);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,8 +58,8 @@ To create a content pack:
|
||||||
|
|
||||||
1. [Create a standard content pack](https://stardewvalleywiki.com/Modding:Content_packs), using `Omegasis.StardewSymphonyRemastered` as the 'content pack for' ID.
|
1. [Create a standard content pack](https://stardewvalleywiki.com/Modding:Content_packs), using `Omegasis.StardewSymphonyRemastered` as the 'content pack for' ID.
|
||||||
2. Add an `icon.png` image, which is the album logo to show in-game.
|
2. Add an `icon.png` image, which is the album logo to show in-game.
|
||||||
2. Create a `songs` subfolder containing the `.mp3` or `.wav` files to include. The file names
|
2. Create a `songs` subfolder containing the `.mp3`, `.ogg`, or `.wav` files to include. The file
|
||||||
(without extensions) will be shown in-game as the song names.
|
names (without extensions) will be shown in-game as the song names.
|
||||||
|
|
||||||
## For SMAPI mod creators
|
## For SMAPI mod creators
|
||||||
You can reference Stardew Symphony in your own SMAPI mods in order to add new events, festivals,
|
You can reference Stardew Symphony in your own SMAPI mods in order to add new events, festivals,
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NAudio" Version="1.8.5" />
|
<PackageReference Include="NAudio" Version="1.8.5" />
|
||||||
|
<PackageReference Include="NAudio.Vorbis" Version="1.0.0" />
|
||||||
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" />
|
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Name": "Stardew Symphony Remastered",
|
"Name": "Stardew Symphony Remastered",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "2.2.0",
|
"Version": "2.3.0",
|
||||||
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
||||||
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
||||||
"EntryDll": "StardewSymphonyRemastered.dll",
|
"EntryDll": "StardewSymphonyRemastered.dll",
|
||||||
|
|
Loading…
Reference in New Issue