merge Vorbis code from develop

This commit is contained in:
Jesse Plamondon-Willard 2019-01-05 05:03:18 -05:00
commit 7b719c2edc
No known key found for this signature in database
GPG Key ID: 7D7C8097B62033CE
4 changed files with 20 additions and 8 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using NAudio.Vorbis;
using NAudio.Wave;
using StardewModdingAPI;
using StardewValley;
@ -166,10 +167,6 @@ namespace StardewSymphonyRemastered.Framework
DirectoryInfo songFolder = new DirectoryInfo(Path.Combine(this.ContentPack.DirectoryPath, this.MusicFolderName));
foreach (FileInfo file in songFolder.GetFiles())
{
//MemoryStream memoryStream = new MemoryStream();
//AudioFileReader fileReader = new AudioFileReader(file.FullName);
//fileReader.CopyTo(memoryStream);
// get name
string name = Path.GetFileNameWithoutExtension(file.Name);
if (this.Sounds.ContainsKey(name))
@ -190,7 +187,7 @@ namespace StardewSymphonyRemastered.Framework
using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader))
{
string tempPath = Path.Combine(songFolder.FullName, $"{name}.wav");
StardewSymphony.ModMonitor.Log($"MP3 CONVERT! {tempPath}");
StardewSymphony.ModMonitor.Log($"Converting: {tempPath}");
WaveFileWriter.CreateWaveFile(tempPath, pcmStream);
using (Stream tempStream = File.OpenRead(tempPath))
@ -199,6 +196,20 @@ namespace StardewSymphonyRemastered.Framework
}
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:
StardewSymphony.ModMonitor.Log($"Unsupported file extension {file.Extension}.", LogLevel.Warn);
break;

View File

@ -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.
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
(without extensions) will be shown in-game as the song names.
2. Create a `songs` subfolder containing the `.mp3`, `.ogg`, or `.wav` files to include. The file
names (without extensions) will be shown in-game as the song names.
## For SMAPI mod creators
You can reference Stardew Symphony in your own SMAPI mods in order to add new events, festivals,

View File

@ -67,6 +67,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NAudio" Version="1.8.5" />
<PackageReference Include="NAudio.Vorbis" Version="1.0.0" />
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
{
"Name": "Stardew Symphony Remastered",
"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!",
"UniqueID": "Omegasis.StardewSymphonyRemastered",
"EntryDll": "StardewSymphonyRemastered.dll",