Added vorbis/ogg support to Stardew Symphony
This commit is contained in:
parent
08d1e15e45
commit
5f053d9442
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using NAudio.Vorbis;
|
||||
using NAudio.Wave;
|
||||
using StardewValley;
|
||||
|
||||
|
@ -87,41 +88,58 @@ namespace StardewSymphonyRemastered.Framework
|
|||
{
|
||||
List<string> wavFiles = Directory.GetFiles(this.songsDirectory, "*.wav").ToList();
|
||||
wavFiles.AddRange(Directory.GetFiles(this.songsDirectory, "*.mp3"));
|
||||
wavFiles.AddRange(Directory.GetFiles(this.songsDirectory, "*.ogg"));
|
||||
|
||||
DateTime span = DateTime.Now;
|
||||
foreach (string wav in wavFiles)
|
||||
{
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
AudioFileReader fileReader = new AudioFileReader(wav);
|
||||
fileReader.CopyTo(memoryStream);
|
||||
byte[] wavData = memoryStream.ToArray();
|
||||
|
||||
SoundEffect eff = null;
|
||||
|
||||
Stream waveFileStream = File.OpenRead(wav); //TitleContainer.OpenStream(file);
|
||||
|
||||
|
||||
if (wav.Contains(".wav"))
|
||||
{
|
||||
eff = SoundEffect.FromStream(waveFileStream);
|
||||
waveFileStream.Close();
|
||||
}
|
||||
else if (wav.Contains(".mp3"))
|
||||
{
|
||||
using (Mp3FileReader reader = new Mp3FileReader(waveFileStream))
|
||||
{
|
||||
using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader))
|
||||
using (WaveStream pcmMP3Stream = WaveFormatConversionStream.CreatePcmStream(reader))
|
||||
{
|
||||
StardewSymphony.ModMonitor.Log("MP3 CONVERT! " + Path.GetFileNameWithoutExtension(wav) + ".wav");
|
||||
WaveFileWriter.CreateWaveFile(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")), pcmStream);
|
||||
StardewSymphony.DebugLog("Converting: " + this.songsDirectory + Path.GetFileName(wav));
|
||||
WaveFileWriter.CreateWaveFile(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")), pcmMP3Stream);
|
||||
|
||||
waveFileStream = File.OpenRead((Path.GetFileNameWithoutExtension(wav) + ".wav")); //TitleContainer.OpenStream(file);
|
||||
waveFileStream = File.OpenRead(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav"))); //TitleContainer.OpenStream(file);
|
||||
eff = SoundEffect.FromStream(waveFileStream);
|
||||
|
||||
waveFileStream.Close();
|
||||
File.Delete(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (wav.Contains(".ogg"))
|
||||
{
|
||||
StardewSymphony.ModMonitor.Log("Sorry, but .ogg files are currently not supported. Keep bugging the mod author (me) for this if you want it!", StardewModdingAPI.LogLevel.Alert);
|
||||
continue;
|
||||
|
||||
//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(wav))
|
||||
{
|
||||
|
||||
StardewSymphony.DebugLog("Converting: " + this.songsDirectory+Path.GetFileName(wav));
|
||||
WaveFileWriter.CreateWaveFile(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")), vorbisStream.ToWaveProvider16());
|
||||
|
||||
//WaveFileReader reader = new WaveFileReader(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")));
|
||||
|
||||
waveFileStream = File.OpenRead(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav"))); //TitleContainer.OpenStream(file);
|
||||
eff = SoundEffect.FromStream(waveFileStream);
|
||||
|
||||
waveFileStream.Close();
|
||||
|
||||
File.Delete(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -11,6 +11,8 @@
|
|||
<AssemblyName>StardewSymphonyRemastered</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -66,10 +68,18 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NAudio" Version="1.8.5" />
|
||||
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NAudio">
|
||||
<HintPath>..\..\..\..\..\..\..\..\Desktop\NAudio.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NAudio.Vorbis">
|
||||
<HintPath>..\..\..\..\..\..\..\..\Desktop\NAudioVorbis\NAudio.Vorbis\obj\Debug\NAudio.Vorbis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NVorbis">
|
||||
<HintPath>..\..\..\..\..\..\..\..\Desktop\NAudioVorbis\bin\NVorbis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="StardustCore">
|
||||
<HintPath>..\..\StardustCore\bin\Release\StardustCore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
@ -213,6 +223,7 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="manifest.json" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Graphics\MusicMenu\MusicDisk.png">
|
||||
|
@ -233,11 +244,24 @@
|
|||
<Folder Include="Content\Music\XACT\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StardustCore\StardustCore.csproj">
|
||||
<Project>{0756d36a-95c8-480d-8ea6-4584c03010c6}</Project>
|
||||
<Name>StardustCore</Name>
|
||||
</ProjectReference>
|
||||
<Analyzer Include="..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\deploy.targets" />
|
||||
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -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",
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.2.0" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue