Skip to content

Commit

Permalink
Adding NVorbis as a submodule and adding *.ogg as a supported file fo…
Browse files Browse the repository at this point in the history
…rmat
  • Loading branch information
tstavropoulos committed Nov 27, 2018
1 parent 3bd4ec1 commit 23afa30
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "taglib-sharp"]
path = taglib-sharp
url = https://github.com/tstavropoulos/taglib-sharp
[submodule "NVorbis"]
path = NVorbis
url = https://github.com/ioctlLR/NVorbis
7 changes: 6 additions & 1 deletion MusegicianInstallerv2/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@
<File Id="CSCoreDLL" Name="CSCore.dll" Source="$(var.Musegician.TargetDir)CSCore.dll" KeyPath="yes"/>
</Component>

<!--NVorbis-->
<Component Id="NVorbisLib" Guid="9ECD4CD5-4FFB-46D3-AB0E-A77C5164E4A5">
<File Id="NVorbisLibDLL" Name="taglib-sharp.dll" Source="$(var.Musegician.TargetDir)taglib-sharp.dll" KeyPath="yes"/>
</Component>

<!--taglib-sharp-->
<Component Id="NewTagLib" Guid="7A0D0F5D-B5F3-4C6D-A22E-9AC99EF4EAF3">
<File Id="NewTagLibDLL" Name="taglib-sharp.dll" Source="$(var.Musegician.TargetDir)taglib-sharp.dll" KeyPath="yes"/>
<File Id="NewTagLibDLL" Name="NVorbis.dll" Source="$(var.Musegician.TargetDir)NVorbis.dll" KeyPath="yes"/>
</Component>

<!--RibbonControlsLibrary-->
Expand Down
19 changes: 19 additions & 0 deletions MusicPlayer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Musegician", "MusicPlayer\Musegician.csproj", "{ECA191D8-A68D-438C-A94A-5958D7D83834}"
ProjectSection(ProjectDependencies) = postProject
{14D2843A-B10E-4357-8F7C-534287695F33} = {14D2843A-B10E-4357-8F7C-534287695F33}
{2C4CF582-73D3-4736-9040-78817A7B26A4} = {2C4CF582-73D3-4736-9040-78817A7B26A4}
EndProjectSection
EndProject
Expand All @@ -14,6 +15,8 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "MusegicianBootstrapperInsta
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "taglib-sharp", "taglib-sharp\src\taglib-sharp.csproj", "{2C4CF582-73D3-4736-9040-78817A7B26A4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NVorbis", "NVorbis\NVorbis\NVorbis.csproj", "{14D2843A-B10E-4357-8F7C-534287695F33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -80,6 +83,22 @@ Global
{2C4CF582-73D3-4736-9040-78817A7B26A4}.Release|x64.Build.0 = Release|Any CPU
{2C4CF582-73D3-4736-9040-78817A7B26A4}.Release|x86.ActiveCfg = Release|Any CPU
{2C4CF582-73D3-4736-9040-78817A7B26A4}.Release|x86.Build.0 = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|ARM.ActiveCfg = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|ARM.Build.0 = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|x64.ActiveCfg = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|x64.Build.0 = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|x86.ActiveCfg = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Debug|x86.Build.0 = Debug|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|Any CPU.Build.0 = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|ARM.ActiveCfg = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|ARM.Build.0 = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|x64.ActiveCfg = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|x64.Build.0 = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|x86.ActiveCfg = Release|Any CPU
{14D2843A-B10E-4357-8F7C-534287695F33}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
77 changes: 77 additions & 0 deletions MusicPlayer/AudioUtilities/NVorbisSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.IO;
using CSCore;
using NVorbis;

namespace Musegician.Sources
{
/// <summary>
/// Stolen shamelessly from CSCore Examples
/// </summary>
public sealed class NVorbisSource : ISampleSource
{
private readonly Stream _stream;
private readonly VorbisReader _vorbisReader;
private bool _disposed;

public NVorbisSource(Stream stream)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}

if (!stream.CanRead)
{
throw new ArgumentException("Stream is not readable.", "stream");
}

_stream = stream;
_vorbisReader = new VorbisReader(stream, false);
WaveFormat = new WaveFormat(_vorbisReader.SampleRate, 32, _vorbisReader.Channels, AudioEncoding.IeeeFloat);
}

public bool CanSeek => _stream.CanSeek;

public WaveFormat WaveFormat { get; }

public long Length => CanSeek ?
(long)(_vorbisReader.TotalTime.TotalSeconds * WaveFormat.SampleRate * WaveFormat.Channels) : 0;

public long Position
{
get => CanSeek ? (long)(_vorbisReader.DecodedTime.TotalSeconds * _vorbisReader.SampleRate * _vorbisReader.Channels) : 0;
set
{
if (!CanSeek)
{
throw new InvalidOperationException("NVorbisSource is not seekable.");
}

if (value < 0 || value > Length)
{
throw new ArgumentOutOfRangeException("value");
}

_vorbisReader.DecodedTime = TimeSpan.FromSeconds((double)value / _vorbisReader.SampleRate / _vorbisReader.Channels);
}
}

public int Read(float[] buffer, int offset, int count) =>
_vorbisReader.ReadSamples(buffer, offset, count);

public void Dispose()
{
if (!_disposed)
{
_vorbisReader.Dispose();
}
else
{
throw new ObjectDisposedException("NVorbisSource");
}

_disposed = true;
}
}
}
6 changes: 6 additions & 0 deletions MusicPlayer/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using CSCore;
using CSCore.Codecs;
using Musegician.Sources;

namespace Musegician
{
Expand All @@ -13,6 +16,9 @@ public class EntryPoint
[STAThread]
static void Main()
{
//Register our custom ogg reader
CodecFactory.Instance.Register("ogg-vorbis", new CodecFactoryEntry(s => new NVorbisSource(s).ToWaveSource(), ".ogg"));

using (FileManager.Instance = new FileManager())
using (Player.MusicManager.Instance = new Player.MusicManager())
using (KeyboardHook hook = new KeyboardHook(Player.MusicManager.GetHookKeys()))
Expand Down
5 changes: 5 additions & 0 deletions MusicPlayer/Musegician.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
<Compile Include="AlbumArtPicker\AlbumViewModel.cs" />
<Compile Include="AlbumArtPicker\IAlbumArtPickerRequestHandler.cs" />
<Compile Include="AlbumArtPicker\SelectorViewModel.cs" />
<Compile Include="AudioUtilities\NVorbisSource.cs" />
<Compile Include="AudioUtilities\SpatializerStream.cs" />
<Compile Include="AudioUtilities\SpectralPowerStream.cs" />
<Compile Include="Core\DBCommands\PlaylistCommands.cs" />
Expand Down Expand Up @@ -624,6 +625,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NVorbis\NVorbis\NVorbis.csproj">
<Project>{14d2843a-b10e-4357-8f7c-534287695f33}</Project>
<Name>NVorbis</Name>
</ProjectReference>
<ProjectReference Include="..\taglib-sharp\src\taglib-sharp.csproj">
<Project>{2c4cf582-73d3-4736-9040-78817a7b26a4}</Project>
<Name>taglib-sharp</Name>
Expand Down
2 changes: 1 addition & 1 deletion MusicPlayer/Player/MusicManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ public void PlaySong(PlayData playData, bool preserveLoopBounds = false)

_spatializer = null;
_equalizer = null;

ISampleSource sampleSource = CodecFactory.Instance.GetCodec(playData.recording.Filename)
.ToSampleSource()
.ToStereo();
Expand Down
4 changes: 2 additions & 2 deletions MusicPlayer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.11.0")]
[assembly: AssemblyFileVersion("0.8.11.0")]
[assembly: AssemblyVersion("0.8.12.0")]
[assembly: AssemblyFileVersion("0.8.12.0")]
[assembly: Guid("C6D85D0B-5661-41EE-9405-7DFCF7E63798")]

1 change: 1 addition & 0 deletions NVorbis
Submodule NVorbis added at 42d336

0 comments on commit 23afa30

Please sign in to comment.