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.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Xna.Framework.Audio;
|
using Microsoft.Xna.Framework.Audio;
|
||||||
|
using NAudio.Vorbis;
|
||||||
using NAudio.Wave;
|
using NAudio.Wave;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
|
||||||
|
@ -87,41 +88,58 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
{
|
{
|
||||||
List<string> wavFiles = Directory.GetFiles(this.songsDirectory, "*.wav").ToList();
|
List<string> wavFiles = Directory.GetFiles(this.songsDirectory, "*.wav").ToList();
|
||||||
wavFiles.AddRange(Directory.GetFiles(this.songsDirectory, "*.mp3"));
|
wavFiles.AddRange(Directory.GetFiles(this.songsDirectory, "*.mp3"));
|
||||||
|
wavFiles.AddRange(Directory.GetFiles(this.songsDirectory, "*.ogg"));
|
||||||
|
|
||||||
DateTime span = DateTime.Now;
|
DateTime span = DateTime.Now;
|
||||||
foreach (string wav in wavFiles)
|
foreach (string wav in wavFiles)
|
||||||
{
|
{
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
|
||||||
AudioFileReader fileReader = new AudioFileReader(wav);
|
|
||||||
fileReader.CopyTo(memoryStream);
|
|
||||||
byte[] wavData = memoryStream.ToArray();
|
|
||||||
|
|
||||||
SoundEffect eff = null;
|
SoundEffect eff = null;
|
||||||
|
|
||||||
Stream waveFileStream = File.OpenRead(wav); //TitleContainer.OpenStream(file);
|
Stream waveFileStream = File.OpenRead(wav); //TitleContainer.OpenStream(file);
|
||||||
|
|
||||||
|
|
||||||
if (wav.Contains(".wav"))
|
if (wav.Contains(".wav"))
|
||||||
|
{
|
||||||
eff = SoundEffect.FromStream(waveFileStream);
|
eff = SoundEffect.FromStream(waveFileStream);
|
||||||
|
waveFileStream.Close();
|
||||||
|
}
|
||||||
else if (wav.Contains(".mp3"))
|
else if (wav.Contains(".mp3"))
|
||||||
{
|
{
|
||||||
using (Mp3FileReader reader = new Mp3FileReader(waveFileStream))
|
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");
|
StardewSymphony.DebugLog("Converting: " + this.songsDirectory + Path.GetFileName(wav));
|
||||||
WaveFileWriter.CreateWaveFile(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")), pcmStream);
|
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);
|
eff = SoundEffect.FromStream(waveFileStream);
|
||||||
|
|
||||||
|
waveFileStream.Close();
|
||||||
File.Delete(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")));
|
File.Delete(Path.Combine(this.songsDirectory, (Path.GetFileNameWithoutExtension(wav) + ".wav")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (wav.Contains(".ogg"))
|
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"?>
|
<?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')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
@ -11,6 +11,8 @@
|
||||||
<AssemblyName>StardewSymphonyRemastered</AssemblyName>
|
<AssemblyName>StardewSymphonyRemastered</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
@ -66,10 +68,18 @@
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NAudio" Version="1.8.5" />
|
<Reference Include="NAudio">
|
||||||
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" />
|
<HintPath>..\..\..\..\..\..\..\..\Desktop\NAudio.dll</HintPath>
|
||||||
</ItemGroup>
|
</Reference>
|
||||||
<ItemGroup>
|
<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" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
@ -213,6 +223,7 @@
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<None Include="manifest.json" />
|
<None Include="manifest.json" />
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Content\Graphics\MusicMenu\MusicDisk.png">
|
<Content Include="Content\Graphics\MusicMenu\MusicDisk.png">
|
||||||
|
@ -233,11 +244,24 @@
|
||||||
<Folder Include="Content\Music\XACT\" />
|
<Folder Include="Content\Music\XACT\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\StardustCore\StardustCore.csproj">
|
<Analyzer Include="..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
|
||||||
<Project>{0756d36a-95c8-480d-8ea6-4584c03010c6}</Project>
|
|
||||||
<Name>StardustCore</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(SolutionDir)\deploy.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>
|
</Project>
|
|
@ -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",
|
||||||
|
|
|
@ -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