- Added OggUtils Support project by making use of the csogg and csvorbis projects
- Implemented native Song playback in OpenAL and XAudio2 - Some tweaks in the MediaPlayer and MediaQueue - Added a testmusic.ogg file to the media folder
This commit is contained in:
parent
e5ac8228ca
commit
0d25ca7589
@ -36,6 +36,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AnxContentImporterContext.cs" />
|
||||
|
@ -36,6 +36,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>bin\Debug\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -28,7 +28,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<OutputPath>bin\Release\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -38,6 +38,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AnxContentImporterContext.cs" />
|
||||
|
@ -17,7 +17,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\Debug\</OutputPath>
|
||||
<OutputPath>..\bin\Debug\ModernUI</OutputPath>
|
||||
<DefineConstants>XNAEXT;DEBUG;TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -26,7 +26,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<OutputPath>..\bin\Release\ModernUI</OutputPath>
|
||||
<DefineConstants>XNAEXT;TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -62,6 +62,7 @@
|
||||
<Compile Include="ReflectionLearningTests.cs" />
|
||||
<Compile Include="Strukturen\CurveKeyCollectionTest.cs" />
|
||||
<Compile Include="Strukturen\CurveKeyTest.cs" />
|
||||
<Compile Include="Strukturen\Graphics\PackedVector\Alpha8Test.cs" />
|
||||
<Compile Include="Strukturen\Input\GamePadButtonsTest.cs" />
|
||||
<Compile Include="Strukturen\Input\GamePadDPadTest.cs" />
|
||||
<Compile Include="Strukturen\Design\TypeConverterTest.cs" />
|
||||
|
@ -63,6 +63,7 @@
|
||||
<Compile Include="ReflectionLearningTests.cs" />
|
||||
<Compile Include="Strukturen\CurveKeyCollectionTest.cs" />
|
||||
<Compile Include="Strukturen\CurveKeyTest.cs" />
|
||||
<Compile Include="Strukturen\Graphics\PackedVector\Alpha8Test.cs" />
|
||||
<Compile Include="Strukturen\Input\GamePadButtonsTest.cs" />
|
||||
<Compile Include="Strukturen\Input\GamePadDPadTest.cs" />
|
||||
<Compile Include="Strukturen\Design\TypeConverterTest.cs" />
|
||||
|
@ -19,7 +19,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\Debug\</OutputPath>
|
||||
<OutputPath>..\bin\Debug\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -28,7 +28,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<OutputPath>..\bin\Release\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -64,6 +64,7 @@
|
||||
<Compile Include="ReflectionLearningTests.cs" />
|
||||
<Compile Include="Strukturen\CurveKeyCollectionTest.cs" />
|
||||
<Compile Include="Strukturen\CurveKeyTest.cs" />
|
||||
<Compile Include="Strukturen\Graphics\PackedVector\Alpha8Test.cs" />
|
||||
<Compile Include="Strukturen\Input\GamePadButtonsTest.cs" />
|
||||
<Compile Include="Strukturen\Input\GamePadDPadTest.cs" />
|
||||
<Compile Include="Strukturen\Design\TypeConverterTest.cs" />
|
||||
@ -131,10 +132,6 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\InputSystems\ANX.InputDevices.Windows.XInput\ANX.InputDevices.Windows.XInput_WindowsMetro.csproj">
|
||||
<Project>{60D08399-244F-46A3-91F1-4CFD26D961A3}</Project>
|
||||
<Name>ANX.InputDevices.Windows.XInput</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\InputSystems\ANX.InputSystem.Standard\ANX.InputSystem.Standard_WindowsMetro.csproj">
|
||||
<Project>{49066074-3B7B-4A55-B122-6BD33AB73558}</Project>
|
||||
<Name>ANX.InputSystem.Standard</Name>
|
||||
|
@ -197,6 +197,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.InputDevices.Windows.Mo
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnlineStatusGenerator", "Tools\OnlineStatusGenerator\OnlineStatusGenerator.csproj", "{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OggUtils", "Support\OggUtils\OggUtils.csproj", "{ABECEC14-6BF4-4432-833C-69714EB4E8E6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleNoContent", "Samples\SimpleNoContent\SimpleNoContent.csproj", "{AA3DF4D7-F072-47B5-B88C-20140B5F704A}"
|
||||
EndProject
|
||||
Global
|
||||
@ -998,6 +1000,20 @@ Global
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x64.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.Build.0 = Release|x86
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
@ -1073,6 +1089,7 @@ Global
|
||||
{2B6D0EFF-7874-495F-9226-873ED9649C60} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{2CF3FE4D-586E-4B07-8BF0-1E84B670F0AD} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
EndGlobalSection
|
||||
GlobalSection(SubversionScc) = preSolution
|
||||
Svn-Managed = True
|
||||
|
@ -98,6 +98,7 @@
|
||||
<Compile Include="Content\MathTypeReaders\RectangleReader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector2Reader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector3Reader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SongReader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SoundEffectReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\BooleanReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\ByteReader.cs" />
|
||||
|
@ -98,6 +98,7 @@
|
||||
<Compile Include="Content\MathTypeReaders\RectangleReader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector2Reader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector3Reader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SongReader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SoundEffectReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\BooleanReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\ByteReader.cs" />
|
||||
@ -445,7 +446,9 @@
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IDynamicSoundEffectInstance.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\ISong.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\IServiceProvider.cs" />
|
||||
|
@ -100,6 +100,7 @@
|
||||
<Compile Include="Content\MathTypeReaders\RectangleReader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector2Reader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector3Reader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SongReader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SoundEffectReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\BooleanReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\ByteReader.cs" />
|
||||
@ -447,7 +448,9 @@
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IDynamicSoundEffectInstance.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\ISong.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\IServiceProvider.cs" />
|
||||
|
@ -101,6 +101,7 @@
|
||||
<Compile Include="Content\MathTypeReaders\RectangleReader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector2Reader.cs" />
|
||||
<Compile Include="Content\MathTypeReaders\Vector3Reader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SongReader.cs" />
|
||||
<Compile Include="Content\MediaTypeReaders\SoundEffectReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\BooleanReader.cs" />
|
||||
<Compile Include="Content\PrimitiveTypeReaders\ByteReader.cs" />
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.PlatformSystem;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA.Reflection;
|
||||
|
||||
@ -463,5 +464,27 @@ namespace ANX.Framework.Content
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
internal string GetAbsolutePathToReference(string referenceName)
|
||||
{
|
||||
referenceName = GetPathToReference(referenceName);
|
||||
referenceName = Path.Combine(ContentManager.RootDirectory, referenceName);
|
||||
|
||||
Assembly assembly = Assembly.GetEntryAssembly();
|
||||
if (assembly == null)
|
||||
assembly = Assembly.GetCallingAssembly();
|
||||
string titleLocationPath = Path.GetDirectoryName(assembly.Location);
|
||||
referenceName = Path.Combine(titleLocationPath, referenceName);
|
||||
return TitleContainer.GetCleanPath(referenceName);
|
||||
}
|
||||
|
||||
private string GetPathToReference(string referenceName)
|
||||
{
|
||||
int num = AssetName.LastIndexOfAny(new[] { '\\', '/', Path.DirectorySeparatorChar });
|
||||
string path = "";
|
||||
if (num != -1)
|
||||
path = AssetName.Substring(0, num);
|
||||
return Path.Combine(path, referenceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
ANX.Framework/Content/MediaTypeReaders/SongReader.cs
Normal file
23
ANX.Framework/Content/MediaTypeReaders/SongReader.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using ANX.Framework.Media;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.Framework.Content
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[Developer("AstrorEnales")]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
internal class SongReader : ContentTypeReader<Song>
|
||||
{
|
||||
protected internal override Song Read(ContentReader input, Song existingInstance)
|
||||
{
|
||||
string text = input.ReadString();
|
||||
text = input.GetAbsolutePathToReference(text);
|
||||
int duration = input.ReadObject<int>();
|
||||
return new Song(input.AssetName, text, duration);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,17 @@
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.Framework.Content
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[Developer("AstrorEnales")]
|
||||
[TestState(TestStateAttribute.TestState.InProgress)]
|
||||
internal class SoundEffectReader : ContentTypeReader<SoundEffect>
|
||||
{
|
||||
private struct WaveFormatEx
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.PlatformSystem;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
@ -8,6 +9,9 @@ using ANX.Framework.NonXNA.PlatformSystem;
|
||||
|
||||
namespace ANX.Framework.Media
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[Developer("AstrorEnales")]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
public sealed class MediaLibrary : IDisposable
|
||||
{
|
||||
private INativeMediaLibrary nativeLibrary;
|
||||
|
@ -8,8 +8,8 @@ using ANX.Framework.NonXNA.Development;
|
||||
namespace ANX.Framework.Media
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
[Developer("AstrorEnales")]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
public static class MediaPlayer
|
||||
{
|
||||
#region Events
|
||||
@ -61,7 +61,8 @@ namespace ANX.Framework.Media
|
||||
return;
|
||||
|
||||
currentState = value;
|
||||
MediaStateChanged(null, EventArgs.Empty);
|
||||
if (MediaStateChanged != null)
|
||||
MediaStateChanged(null, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,6 +158,8 @@ namespace ANX.Framework.Media
|
||||
return;
|
||||
}
|
||||
|
||||
Queue.ActiveSong.NativeSong.Update();
|
||||
|
||||
State = Queue.ActiveSong.State;
|
||||
if (Queue.ActiveSong.State != MediaState.Stopped)
|
||||
return;
|
||||
@ -164,7 +167,8 @@ namespace ANX.Framework.Media
|
||||
if (Queue.MoveNext(isRepeating))
|
||||
State = MediaState.Playing;
|
||||
|
||||
ActiveSongChanged(null, EventArgs.Empty);
|
||||
if (ActiveSongChanged != null)
|
||||
ActiveSongChanged(null, EventArgs.Empty);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -144,7 +144,7 @@ namespace ANX.Framework.Media
|
||||
}
|
||||
|
||||
#region MoveNext
|
||||
internal bool MoveNext(bool stopIfEnded)
|
||||
internal bool MoveNext(bool isRepeating)
|
||||
{
|
||||
if (Count <= 0)
|
||||
return false;
|
||||
@ -156,7 +156,7 @@ namespace ANX.Framework.Media
|
||||
else
|
||||
{
|
||||
ActiveSongIndex = 0;
|
||||
if (stopIfEnded)
|
||||
if (isRepeating == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,21 @@ namespace ANX.Framework.Media
|
||||
|
||||
#region Constructor
|
||||
internal Song(string setName, Uri uri)
|
||||
{
|
||||
NativeSong = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>().CreateSong(this, uri);
|
||||
{
|
||||
var creator = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
|
||||
NativeSong = creator.CreateSong(this, uri);
|
||||
Name = setName;
|
||||
IsDisposed = false;
|
||||
}
|
||||
|
||||
internal Song(string setName, string filename, int duration)
|
||||
{
|
||||
var creator = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
|
||||
NativeSong = creator.CreateSong(this, filename, duration);
|
||||
Name = setName;
|
||||
IsDisposed = false;
|
||||
}
|
||||
|
||||
~Song()
|
||||
{
|
||||
Dispose();
|
||||
@ -108,15 +117,15 @@ namespace ANX.Framework.Media
|
||||
|
||||
public bool Equals(Song other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return other != null && Name == other.Name;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Song)
|
||||
return Equals(obj as Song);
|
||||
if (ReferenceEquals(this, obj) == false)
|
||||
return Equals((Song)obj);
|
||||
|
||||
return base.Equals(obj);
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -167,13 +176,13 @@ namespace ANX.Framework.Media
|
||||
|
||||
#region Operator overloading
|
||||
public static bool operator ==(Song first, Song second)
|
||||
{
|
||||
return first != null && first.Equals(second);
|
||||
{
|
||||
return object.Equals(first, second);
|
||||
}
|
||||
|
||||
public static bool operator !=(Song first, Song second)
|
||||
{
|
||||
return first == null || first.Equals(second) == false;
|
||||
{
|
||||
return !(first == second);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ namespace ANX.Framework.NonXNA.SoundSystem
|
||||
int GetDefaultMicrophone(ReadOnlyCollection<Microphone> allMicrophones);
|
||||
|
||||
ISong CreateSong(Song parentSong, Uri uri);
|
||||
ISong CreateSong(Song parentSong, string filepath, int duration);
|
||||
|
||||
IDynamicSoundEffectInstance CreateDynamicSoundEffectInstance();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2010
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.Framework", "ANX.Framework\ANX.Framework_Linux.csproj", "{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.Framework.TestCenter", "ANX.Framework.TestCenter\ANX.Framework.TestCenter_Linux.csproj", "{7344BBEB-A1C7-43A8-B68E-D42B81973DA9}"
|
||||
@ -195,6 +195,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.RenderSystem.Windows.DX
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.InputDevices.Windows.ModernUI", "InputSystems\ANX.InputDevices.Windows.ModernUI\ANX.InputDevices.Windows.ModernUI_Linux.csproj", "{628AB80A-B1B9-4878-A810-7A58D4840F60}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnlineStatusGenerator", "Tools\OnlineStatusGenerator\OnlineStatusGenerator.csproj", "{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OggUtils", "Support\OggUtils\OggUtils_Linux.csproj", "{ABECEC14-6BF4-4432-833C-69714EB4E8E6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleNoContent", "Samples\SimpleNoContent\SimpleNoContent_Linux.csproj", "{AA3DF4D7-F072-47B5-B88C-20140B5F704A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -980,6 +986,48 @@ Global
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x64.Build.0 = Release|x64
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x86.ActiveCfg = Release|x86
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x86.Build.0 = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|ARM.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x86.Build.0 = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|ARM.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x64.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.Build.0 = Release|x86
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -995,6 +1043,7 @@ Global
|
||||
{938D5F88-B888-4B04-BEEE-EE701FBA51EF} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{14B39F89-C9B0-407E-877A-B515C985E96E} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{45DD7B40-C498-4DD2-A16B-FD6C4E6991B3} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{B30DE9C2-0926-46B6-8351-9AF276C472D5} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
{FF0AB665-2796-4354-9630-76C2751DB3C2} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
{2B71A7C2-0D18-4E3D-AE5A-320641D1162A} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
@ -1018,6 +1067,7 @@ Global
|
||||
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{9259CC4E-AE6B-403C-8FAB-2408448C3935} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{D810F12D-6CE9-4755-AC6A-5DFEC7D1C782} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{DB88DDEB-7281-405D-8FCA-5681B6B2BD7A} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
{49066074-3B7B-4A55-B122-6BD33AB73558} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
{60D08399-244F-46A3-91F1-4CFD26D961A3} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
@ -1039,6 +1089,7 @@ Global
|
||||
{2B6D0EFF-7874-495F-9226-873ED9649C60} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{2CF3FE4D-586E-4B07-8BF0-1E84B670F0AD} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
EndGlobalSection
|
||||
GlobalSection(SubversionScc) = preSolution
|
||||
Svn-Managed = True
|
||||
|
@ -1,5 +1,5 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2010
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.Framework", "ANX.Framework\ANX.Framework_PSVita.csproj", "{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.Framework.TestCenter", "ANX.Framework.TestCenter\ANX.Framework.TestCenter_PSVita.csproj", "{7344BBEB-A1C7-43A8-B68E-D42B81973DA9}"
|
||||
@ -195,6 +195,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.RenderSystem.Windows.DX
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.InputDevices.Windows.ModernUI", "InputSystems\ANX.InputDevices.Windows.ModernUI\ANX.InputDevices.Windows.ModernUI_PSVita.csproj", "{628AB80A-B1B9-4878-A810-7A58D4840F60}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnlineStatusGenerator", "Tools\OnlineStatusGenerator\OnlineStatusGenerator.csproj", "{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OggUtils", "Support\OggUtils\OggUtils_PSVita.csproj", "{ABECEC14-6BF4-4432-833C-69714EB4E8E6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleNoContent", "Samples\SimpleNoContent\SimpleNoContent_PSVita.csproj", "{AA3DF4D7-F072-47B5-B88C-20140B5F704A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -980,6 +986,48 @@ Global
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x64.Build.0 = Release|x64
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x86.ActiveCfg = Release|x86
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x86.Build.0 = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|ARM.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x86.Build.0 = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|ARM.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x64.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.Build.0 = Release|x86
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -995,6 +1043,7 @@ Global
|
||||
{938D5F88-B888-4B04-BEEE-EE701FBA51EF} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{14B39F89-C9B0-407E-877A-B515C985E96E} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{45DD7B40-C498-4DD2-A16B-FD6C4E6991B3} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{B30DE9C2-0926-46B6-8351-9AF276C472D5} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
{FF0AB665-2796-4354-9630-76C2751DB3C2} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
{2B71A7C2-0D18-4E3D-AE5A-320641D1162A} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
@ -1018,6 +1067,7 @@ Global
|
||||
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{9259CC4E-AE6B-403C-8FAB-2408448C3935} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{D810F12D-6CE9-4755-AC6A-5DFEC7D1C782} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{DB88DDEB-7281-405D-8FCA-5681B6B2BD7A} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
{49066074-3B7B-4A55-B122-6BD33AB73558} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
{60D08399-244F-46A3-91F1-4CFD26D961A3} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
@ -1039,6 +1089,7 @@ Global
|
||||
{2B6D0EFF-7874-495F-9226-873ED9649C60} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{2CF3FE4D-586E-4B07-8BF0-1E84B670F0AD} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
EndGlobalSection
|
||||
GlobalSection(SubversionScc) = preSolution
|
||||
Svn-Managed = True
|
||||
|
@ -1,5 +1,5 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2010
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.Framework", "ANX.Framework\ANX.Framework_WindowsMetro.csproj", "{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.Framework.TestCenter", "ANX.Framework.TestCenter\ANX.Framework.TestCenter_WindowsMetro.csproj", "{7344BBEB-A1C7-43A8-B68E-D42B81973DA9}"
|
||||
@ -195,6 +195,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.RenderSystem.Windows.DX
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.InputDevices.Windows.ModernUI", "InputSystems\ANX.InputDevices.Windows.ModernUI\ANX.InputDevices.Windows.ModernUI_WindowsMetro.csproj", "{628AB80A-B1B9-4878-A810-7A58D4840F60}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnlineStatusGenerator", "Tools\OnlineStatusGenerator\OnlineStatusGenerator.csproj", "{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OggUtils", "Support\OggUtils\OggUtils_WindowsMetro.csproj", "{ABECEC14-6BF4-4432-833C-69714EB4E8E6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleNoContent", "Samples\SimpleNoContent\SimpleNoContent_WindowsMetro.csproj", "{AA3DF4D7-F072-47B5-B88C-20140B5F704A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -980,6 +986,48 @@ Global
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x64.Build.0 = Release|x64
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x86.ActiveCfg = Release|x86
|
||||
{628AB80A-B1B9-4878-A810-7A58D4840F60}.Release|x86.Build.0 = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|ARM.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Debug|x86.Build.0 = Debug|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|ARM.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x64.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.ActiveCfg = Release|x86
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01}.Release|x86.Build.0 = Release|x86
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -995,6 +1043,7 @@ Global
|
||||
{938D5F88-B888-4B04-BEEE-EE701FBA51EF} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{14B39F89-C9B0-407E-877A-B515C985E96E} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{45DD7B40-C498-4DD2-A16B-FD6C4E6991B3} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{6119ADEE-7047-4E29-BEC2-00F8D6D0EA01} = {B24A8593-562A-4A25-BB08-46C163F10F3F}
|
||||
{B30DE9C2-0926-46B6-8351-9AF276C472D5} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
{FF0AB665-2796-4354-9630-76C2751DB3C2} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
{2B71A7C2-0D18-4E3D-AE5A-320641D1162A} = {D421509A-9AE3-4D7E-881B-EAFED598B028}
|
||||
@ -1018,6 +1067,7 @@ Global
|
||||
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{9259CC4E-AE6B-403C-8FAB-2408448C3935} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{D810F12D-6CE9-4755-AC6A-5DFEC7D1C782} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{AA3DF4D7-F072-47B5-B88C-20140B5F704A} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
|
||||
{DB88DDEB-7281-405D-8FCA-5681B6B2BD7A} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
{49066074-3B7B-4A55-B122-6BD33AB73558} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
{60D08399-244F-46A3-91F1-4CFD26D961A3} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
|
||||
@ -1039,6 +1089,7 @@ Global
|
||||
{2B6D0EFF-7874-495F-9226-873ED9649C60} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{2CF3FE4D-586E-4B07-8BF0-1E84B670F0AD} = {1436F7C9-29D3-4FEF-8914-10B45F13D142}
|
||||
{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
{ABECEC14-6BF4-4432-833C-69714EB4E8E6} = {3E29A6C6-9487-46A7-A161-D8DB84514933}
|
||||
EndGlobalSection
|
||||
GlobalSection(SubversionScc) = preSolution
|
||||
Svn-Managed = True
|
||||
|
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.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>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{628AB80A-B1B9-4878-A810-7A58D4840F60}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.InputDevices.Windows.ModernUI</RootNamespace>
|
||||
<AssemblyName>ANX.InputDevices.Windows.ModernUI</AssemblyName>
|
||||
<DefaultLanguage>de-DE</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;LINUX;</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;LINUX;</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;LINUX;</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;LINUX;</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;LINUX;</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;LINUX;</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FormatConverter.cs" />
|
||||
<Compile Include="GamePad.cs" />
|
||||
<Compile Include="GamePadCreator.cs" />
|
||||
<Compile Include="Keyboard.cs" />
|
||||
<Compile Include="KeyboardCreator.cs" />
|
||||
<Compile Include="Mouse.cs" />
|
||||
<Compile Include="MouseCreator.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpDX">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\Win8Metro\SharpDX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.XInput">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\Win8Metro\SharpDX.XInput.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_Linux.csproj">
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ">
|
||||
<VisualStudioVersion>11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.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>
|
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.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>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{628AB80A-B1B9-4878-A810-7A58D4840F60}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.InputDevices.Windows.ModernUI</RootNamespace>
|
||||
<AssemblyName>ANX.InputDevices.Windows.ModernUI</AssemblyName>
|
||||
<DefaultLanguage>de-DE</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{69878862-DA7D-4DC6-B0A1-50D8FAB4242F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;PSVITA;</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;PSVITA;</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;PSVITA;</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;PSVITA;</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;DEBUG;PSVITA;</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>NETFX_CORE;TRACE;PSVITA;</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FormatConverter.cs" />
|
||||
<Compile Include="GamePad.cs" />
|
||||
<Compile Include="GamePadCreator.cs" />
|
||||
<Compile Include="Keyboard.cs" />
|
||||
<Compile Include="KeyboardCreator.cs" />
|
||||
<Compile Include="Mouse.cs" />
|
||||
<Compile Include="MouseCreator.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpDX">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\Win8Metro\SharpDX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.XInput">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\Win8Metro\SharpDX.XInput.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_PSVita.csproj">
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ">
|
||||
<VisualStudioVersion>11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.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>
|
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.RenderSystem.GL3</RootNamespace>
|
||||
<AssemblyName>ANX.RenderSystem.GL3</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{69878862-DA7D-4DC6-B0A1-50D8FAB4242F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>XNAEXT;DEBUG;TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<DefineConstants>XNAEXT;TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BlendStateGL3.cs" />
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="Helpers\DatatypesMapping.cs" />
|
||||
<Compile Include="DepthStencilStateGL3.cs" />
|
||||
<Compile Include="EffectGL3.cs" />
|
||||
<Compile Include="EffectParameterGL3.cs" />
|
||||
<Compile Include="EffectPassGL3.cs" />
|
||||
<Compile Include="EffectTechniqueGL3.cs" />
|
||||
<Compile Include="ErrorHelper.cs" />
|
||||
<Compile Include="GraphicsDeviceWindowsGL3.cs" />
|
||||
<Compile Include="Helpers\GraphicsResourceManager.cs" />
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
<Compile Include="SamplerStateGL3.cs" />
|
||||
<Compile Include="ShaderAttributeGL3.cs" />
|
||||
<Compile Include="ShaderByteCode.cs" />
|
||||
<Compile Include="ShaderData.cs" />
|
||||
<Compile Include="ShaderHelper.cs" />
|
||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||
<Compile Include="Texture2DGL3.cs" />
|
||||
<Compile Include="VertexBufferGL3.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_PSVita.csproj">
|
||||
<Project>{6899f0c9-70b9-4eb0-9dd3-e598d4be3e35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Sce\Sce.Psm.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent></PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- 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>
|
@ -89,6 +89,10 @@
|
||||
<Project>{068EB2E9-963C-4E1B-8831-E25011F11FFE}</Project>
|
||||
<Name>ANX.PlatformSystem.Windows</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10_Linux.csproj">
|
||||
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
|
||||
<Name>ANX.RenderSystem.Windows.DX10</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.OpenAL\ANX.SoundSystem.OpenAL_Linux.csproj">
|
||||
<Project>{14EF49AB-6D3F-458D-9D5C-D120B86EDD7A}</Project>
|
||||
<Name>ANX.SoundSystem.OpenAL</Name>
|
||||
|
@ -92,6 +92,10 @@
|
||||
<Project>{068EB2E9-963C-4E1B-8831-E25011F11FFE}</Project>
|
||||
<Name>ANX.PlatformSystem.Windows</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10_PSVita.csproj">
|
||||
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
|
||||
<Name>ANX.RenderSystem.Windows.DX10</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.OpenAL\ANX.SoundSystem.OpenAL_PSVita.csproj">
|
||||
<Project>{14EF49AB-6D3F-458D-9D5C-D120B86EDD7A}</Project>
|
||||
<Name>ANX.SoundSystem.OpenAL</Name>
|
||||
|
@ -1,5 +1,9 @@
|
||||
using System.IO;
|
||||
using ANX.Framework;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.Media;
|
||||
using System;
|
||||
using ANX.Framework.Input;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -11,9 +15,12 @@ namespace AudioSample
|
||||
{
|
||||
private GraphicsDeviceManager graphics;
|
||||
private SoundEffect sound;
|
||||
private Song song;
|
||||
private float timer;
|
||||
private float duration;
|
||||
|
||||
private const bool UseMusicPlayback = false;
|
||||
|
||||
public Game1()
|
||||
{
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
@ -23,6 +30,8 @@ namespace AudioSample
|
||||
protected override void LoadContent()
|
||||
{
|
||||
sound = Content.Load<SoundEffect>("Sounds\\testsound");
|
||||
string testmusicPath = Path.GetFullPath("../../../../../media/testmusic.ogg");
|
||||
song = Song.FromUri(testmusicPath, new Uri(testmusicPath));
|
||||
timer = duration = (float)sound.Duration.TotalSeconds;
|
||||
}
|
||||
|
||||
@ -36,7 +45,21 @@ namespace AudioSample
|
||||
if (timer >= duration)
|
||||
{
|
||||
timer -= duration;
|
||||
sound.Play(1f, 1f, 0f);
|
||||
if (UseMusicPlayback)
|
||||
MediaPlayer.Play(song);
|
||||
else
|
||||
sound.Play(1f, 1f, 0f);
|
||||
}
|
||||
|
||||
if (UseMusicPlayback)
|
||||
{
|
||||
Window.Title = "PlayTime = " + MediaPlayer.PlayPosition;
|
||||
|
||||
if (Keyboard.GetState().IsKeyDown(Keys.A))
|
||||
MediaPlayer.Pause();
|
||||
|
||||
if (Keyboard.GetState().IsKeyDown(Keys.S))
|
||||
MediaPlayer.Resume();
|
||||
}
|
||||
|
||||
base.Update(gameTime);
|
||||
|
BIN
Samples/SimpleNoContent/Assets/Logo.png
Normal file
BIN
Samples/SimpleNoContent/Assets/Logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
BIN
Samples/SimpleNoContent/Assets/SmallLogo.png
Normal file
BIN
Samples/SimpleNoContent/Assets/SmallLogo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 558 B |
BIN
Samples/SimpleNoContent/Assets/SplashScreen.png
Normal file
BIN
Samples/SimpleNoContent/Assets/SplashScreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
Samples/SimpleNoContent/Assets/StoreLogo.png
Normal file
BIN
Samples/SimpleNoContent/Assets/StoreLogo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
27
Samples/SimpleNoContent/Manifest.appxmanifest
Normal file
27
Samples/SimpleNoContent/Manifest.appxmanifest
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
|
||||
<Identity Name="SimpleNoContent" Publisher="CN=ANX-Team" Version="1.0.0.0" />
|
||||
<Properties>
|
||||
<DisplayName>SimpleNoContent</DisplayName>
|
||||
<PublisherDisplayName>ANX Developer Team</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Prerequisites>
|
||||
<OSMinVersion>6.2.0</OSMinVersion>
|
||||
<OSMaxVersionTested>6.2.0</OSMaxVersionTested>
|
||||
</Prerequisites>
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="WindowsGame1.Program">
|
||||
<VisualElements DisplayName="SimpleNoContent" Logo="Assets\Logo.png" SmallLogo="Assets\SmallLogo.png" Description="SimpleNoContent" ForegroundText="light" BackgroundColor="#464646">
|
||||
<DefaultTile ShowName="allLogos" ShortName="SimpleNoContent" />
|
||||
<SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package>
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.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>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
87
Samples/SimpleNoContent/SimpleNoContent_Linux.csproj
Normal file
87
Samples/SimpleNoContent/SimpleNoContent_Linux.csproj
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AA3DF4D7-F072-47B5-B88C-20140B5F704A}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SimpleNoContent</RootNamespace>
|
||||
<AssemblyName>SimpleNoContent</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Game1.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_Linux.csproj">
|
||||
<Project>{6899f0c9-70b9-4eb0-9dd3-e598d4be3e35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\InputSystems\ANX.InputDevices.Windows.XInput\ANX.InputDevices.Windows.XInput_Linux.csproj">
|
||||
<Project>{60d08399-244f-46a3-91f1-4cfd26d961a3}</Project>
|
||||
<Name>ANX.InputDevices.Windows.XInput</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\InputSystems\ANX.InputSystem.Standard\ANX.InputSystem.Standard_Linux.csproj">
|
||||
<Project>{49066074-3b7b-4a55-b122-6bd33ab73558}</Project>
|
||||
<Name>ANX.InputSystem.Standard</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\PlatformSystems\ANX.PlatformSystem.Windows\ANX.PlatformSystem.Windows_Linux.csproj">
|
||||
<Project>{068eb2e9-963c-4e1b-8831-e25011f11ffe}</Project>
|
||||
<Name>ANX.PlatformSystem.Windows</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX11\ANX.RenderSystem.Windows.DX11_Linux.csproj">
|
||||
<Project>{b30de9c2-0926-46b6-8351-9af276c472d5}</Project>
|
||||
<Name>ANX.RenderSystem.Windows.DX11</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio_Linux.csproj">
|
||||
<Project>{6a582788-c4d2-410c-96cd-177f75712d65}</Project>
|
||||
<Name>ANX.SoundSystem.Windows.XAudio</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>
|
90
Samples/SimpleNoContent/SimpleNoContent_PSVita.csproj
Normal file
90
Samples/SimpleNoContent/SimpleNoContent_PSVita.csproj
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AA3DF4D7-F072-47B5-B88C-20140B5F704A}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SimpleNoContent</RootNamespace>
|
||||
<AssemblyName>SimpleNoContent</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{69878862-DA7D-4DC6-B0A1-50D8FAB4242F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Game1.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_PSVita.csproj">
|
||||
<Project>{6899f0c9-70b9-4eb0-9dd3-e598d4be3e35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\InputSystems\ANX.InputDevices.Windows.XInput\ANX.InputDevices.Windows.XInput_PSVita.csproj">
|
||||
<Project>{60d08399-244f-46a3-91f1-4cfd26d961a3}</Project>
|
||||
<Name>ANX.InputDevices.Windows.XInput</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\InputSystems\ANX.InputSystem.Standard\ANX.InputSystem.Standard_PSVita.csproj">
|
||||
<Project>{49066074-3b7b-4a55-b122-6bd33ab73558}</Project>
|
||||
<Name>ANX.InputSystem.Standard</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\PlatformSystems\ANX.PlatformSystem.Windows\ANX.PlatformSystem.Windows_PSVita.csproj">
|
||||
<Project>{068eb2e9-963c-4e1b-8831-e25011f11ffe}</Project>
|
||||
<Name>ANX.PlatformSystem.Windows</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX11\ANX.RenderSystem.Windows.DX11_PSVita.csproj">
|
||||
<Project>{b30de9c2-0926-46b6-8351-9af276c472d5}</Project>
|
||||
<Name>ANX.RenderSystem.Windows.DX11</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio_PSVita.csproj">
|
||||
<Project>{6a582788-c4d2-410c-96cd-177f75712d65}</Project>
|
||||
<Name>ANX.SoundSystem.Windows.XAudio</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Sce\Sce.Psm.CSharp.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>
|
91
Samples/SimpleNoContent/SimpleNoContent_WindowsMetro.csproj
Normal file
91
Samples/SimpleNoContent/SimpleNoContent_WindowsMetro.csproj
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AA3DF4D7-F072-47B5-B88C-20140B5F704A}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SimpleNoContent</RootNamespace>
|
||||
<AssemblyName>SimpleNoContent</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<PackageCertificateKeyFile>Test_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Game1.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_WindowsMetro.csproj">
|
||||
<Project>{6899f0c9-70b9-4eb0-9dd3-e598d4be3e35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\InputSystems\ANX.InputSystem.Standard\ANX.InputSystem.Standard_WindowsMetro.csproj">
|
||||
<Project>{49066074-3b7b-4a55-b122-6bd33ab73558}</Project>
|
||||
<Name>ANX.InputSystem.Standard</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio_WindowsMetro.csproj">
|
||||
<Project>{6a582788-c4d2-410c-96cd-177f75712d65}</Project>
|
||||
<Name>ANX.SoundSystem.Windows.XAudio</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.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>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<None Include="Test_TemporaryKey.pfx" />
|
||||
<AppxManifest Include="Manifest.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<Content Include="Assets\Logo.png" />
|
||||
<Content Include="Assets\SmallLogo.png" />
|
||||
<Content Include="Assets\SplashScreen.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ">
|
||||
<VisualStudioVersion>11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
</Project>
|
@ -105,6 +105,10 @@
|
||||
<Project>{49066074-3B7B-4A55-B122-6BD33AB73558}</Project>
|
||||
<Name>ANX.InputSystem.Standard</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.Framework.GL3\ANX.RenderSystem.GL3_Linux.csproj">
|
||||
<Project>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</Project>
|
||||
<Name>ANX.RenderSystem.GL3</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10_Linux.csproj">
|
||||
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
|
||||
<Name>ANX.RenderSystem.Windows.DX10</Name>
|
||||
|
@ -106,6 +106,10 @@
|
||||
<Project>{49066074-3B7B-4A55-B122-6BD33AB73558}</Project>
|
||||
<Name>ANX.InputSystem.Standard</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.Framework.GL3\ANX.RenderSystem.GL3_PSVita.csproj">
|
||||
<Project>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</Project>
|
||||
<Name>ANX.RenderSystem.GL3</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10_PSVita.csproj">
|
||||
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
|
||||
<Name>ANX.RenderSystem.Windows.DX10</Name>
|
||||
|
@ -42,6 +42,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="OpenALAudioListener.cs" />
|
||||
<Compile Include="OpenALSong.cs" />
|
||||
<Compile Include="OpenALSoundEffect.cs" />
|
||||
<Compile Include="OpenALSoundEffectInstance.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -52,6 +53,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\WaveUtils\WaveUtils.csproj">
|
||||
<Project>{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}</Project>
|
||||
<Name>WaveUtils</Name>
|
||||
|
@ -42,6 +42,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="OpenALAudioListener.cs" />
|
||||
<Compile Include="OpenALSong.cs" />
|
||||
<Compile Include="OpenALSoundEffect.cs" />
|
||||
<Compile Include="OpenALSoundEffectInstance.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -52,6 +53,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils_Linux.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\WaveUtils\WaveUtils_Linux.csproj">
|
||||
<Project>{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}</Project>
|
||||
<Name>WaveUtils</Name>
|
||||
|
@ -43,6 +43,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="OpenALAudioListener.cs" />
|
||||
<Compile Include="OpenALSong.cs" />
|
||||
<Compile Include="OpenALSoundEffect.cs" />
|
||||
<Compile Include="OpenALSoundEffectInstance.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -53,6 +54,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils_PSVita.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\WaveUtils\WaveUtils_PSVita.csproj">
|
||||
<Project>{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}</Project>
|
||||
<Name>WaveUtils</Name>
|
||||
|
@ -44,6 +44,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="OpenALAudioListener.cs" />
|
||||
<Compile Include="OpenALSong.cs" />
|
||||
<Compile Include="OpenALSoundEffect.cs" />
|
||||
<Compile Include="OpenALSoundEffectInstance.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -54,6 +55,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils_WindowsMetro.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\WaveUtils\WaveUtils_WindowsMetro.csproj">
|
||||
<Project>{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}</Project>
|
||||
<Name>WaveUtils</Name>
|
||||
|
@ -162,7 +162,13 @@ namespace ANX.SoundSystem.OpenAL
|
||||
public ISong CreateSong(Song parentSong, Uri uri)
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
return new OpenALSong(parentSong, uri);
|
||||
}
|
||||
|
||||
public ISong CreateSong(Song parentSong, string filepath, int duration)
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new OpenALSong(parentSong, filepath, duration);
|
||||
}
|
||||
|
||||
public IDynamicSoundEffectInstance CreateDynamicSoundEffectInstance()
|
||||
|
179
SoundSystems/ANX.SoundSystem.OpenAL/OpenALSong.cs
Normal file
179
SoundSystems/ANX.SoundSystem.OpenAL/OpenALSong.cs
Normal file
@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.Media;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
using OggUtils;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.SoundSystem.OpenAL
|
||||
{
|
||||
[Developer("AstrorEnales")]
|
||||
public class OpenALSong : ISong
|
||||
{
|
||||
private Song parent;
|
||||
private FileStream oggFileStream;
|
||||
private OggInputStream oggStream;
|
||||
private int[] bufferHandles;
|
||||
private int sourceHandle = InvalidHandle;
|
||||
private const int InvalidHandle = -1;
|
||||
private static readonly byte[] streamReadBuffer = new byte[4096 * 8];
|
||||
|
||||
public TimeSpan Duration { get; private set; }
|
||||
public TimeSpan PlayPosition { get; private set; }
|
||||
public MediaState State { get; private set; }
|
||||
|
||||
public OpenALSong(Song setParent, Uri uri)
|
||||
{
|
||||
parent = setParent;
|
||||
Init(uri.AbsolutePath);
|
||||
// TODO: duration
|
||||
}
|
||||
|
||||
public OpenALSong(Song setParent, string filepath, int duration)
|
||||
{
|
||||
parent = setParent;
|
||||
Init(filepath);
|
||||
Duration = new TimeSpan(0, 0, 0, 0, duration);
|
||||
}
|
||||
|
||||
private void Init(string filepath)
|
||||
{
|
||||
PlayPosition = TimeSpan.Zero;
|
||||
|
||||
State = MediaState.Stopped;
|
||||
oggFileStream = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
oggStream = new OggInputStream(oggFileStream);
|
||||
bufferHandles = AL.GenBuffers(2);
|
||||
sourceHandle = AL.GenSource();
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (State == MediaState.Playing)
|
||||
return;
|
||||
|
||||
if (State == MediaState.Stopped)
|
||||
{
|
||||
Rewind();
|
||||
if (Stream(bufferHandles[0]) == false || Stream(bufferHandles[1]) == false)
|
||||
return;
|
||||
|
||||
AL.SourceQueueBuffers(sourceHandle, bufferHandles.Length, bufferHandles);
|
||||
}
|
||||
|
||||
AL.SourcePlay(sourceHandle);
|
||||
State = MediaState.Playing;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (State == MediaState.Stopped)
|
||||
return;
|
||||
|
||||
State = MediaState.Stopped;
|
||||
AL.SourceStop(sourceHandle);
|
||||
AL.SourceUnqueueBuffers(sourceHandle, bufferHandles.Length);
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (State == MediaState.Paused)
|
||||
return;
|
||||
|
||||
State = MediaState.Paused;
|
||||
AL.SourcePause(sourceHandle);
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
Play();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (sourceHandle == InvalidHandle || State == MediaState.Paused)
|
||||
return;
|
||||
|
||||
int processed;
|
||||
AL.GetSource(sourceHandle, ALGetSourcei.BuffersProcessed, out processed);
|
||||
while (processed-- != 0)
|
||||
{
|
||||
int buffer = AL.SourceUnqueueBuffer(sourceHandle);
|
||||
if (Stream(buffer) == false)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
AL.SourceQueueBuffer(sourceHandle, buffer);
|
||||
}
|
||||
|
||||
int state;
|
||||
AL.GetSource(sourceHandle, ALGetSourcei.SourceState, out state);
|
||||
switch ((ALSourceState)state)
|
||||
{
|
||||
case ALSourceState.Stopped:
|
||||
case ALSourceState.Initial:
|
||||
State = MediaState.Stopped;
|
||||
break;
|
||||
case ALSourceState.Playing:
|
||||
State = MediaState.Playing;
|
||||
break;
|
||||
default:
|
||||
State = MediaState.Paused;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Rewind()
|
||||
{
|
||||
PlayPosition = TimeSpan.Zero;
|
||||
oggFileStream.Position = 0;
|
||||
oggStream = new OggInputStream(oggFileStream);
|
||||
}
|
||||
|
||||
internal bool Stream(int bufferHandle)
|
||||
{
|
||||
int size = oggStream.Read(streamReadBuffer);
|
||||
bool dataAvailable = size > 0;
|
||||
if (dataAvailable)
|
||||
{
|
||||
var channels = (AudioChannels)oggStream.Channels;
|
||||
PlayPosition = PlayPosition.Add(SoundEffect.GetSampleDuration(size, oggStream.SampleRate, channels));
|
||||
ALFormat format = oggStream.Channels > 1 ? ALFormat.Stereo16 : ALFormat.Mono16;
|
||||
AL.BufferData(bufferHandle, format, streamReadBuffer, size, oggStream.SampleRate);
|
||||
}
|
||||
|
||||
return dataAvailable;
|
||||
}
|
||||
|
||||
public void GetVisualizationData(VisualizationData data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (oggFileStream != null)
|
||||
oggFileStream.Close();
|
||||
|
||||
oggFileStream = null;
|
||||
oggStream = null;
|
||||
|
||||
if (sourceHandle == InvalidHandle)
|
||||
return;
|
||||
|
||||
AL.SourceStop(sourceHandle);
|
||||
AL.SourceUnqueueBuffers(sourceHandle, bufferHandles.Length);
|
||||
AL.DeleteSource(sourceHandle);
|
||||
sourceHandle = InvalidHandle;
|
||||
AL.DeleteBuffers(bufferHandles);
|
||||
}
|
||||
}
|
||||
}
|
@ -172,6 +172,12 @@ namespace ANX.SoundSystem.PsVita
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ISong CreateSong(Song parentSong, string filepath, int duration)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.SoundSystem);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDynamicSoundEffectInstance CreateDynamicSoundEffectInstance()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.SoundSystem);
|
||||
|
@ -21,6 +21,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -29,6 +30,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpDX, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -42,6 +44,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="XAudioOggInputStream.cs" />
|
||||
<Compile Include="XAudioSong.cs" />
|
||||
<Compile Include="XAudioSoundEffectInstance.cs" />
|
||||
<Compile Include="XAudioSoundEffect.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -52,6 +56,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -21,6 +21,7 @@
|
||||
<DefineConstants>TRACE;DEBUG;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -29,6 +30,7 @@
|
||||
<DefineConstants>TRACE;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpDX, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -42,6 +44,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="XAudioOggInputStream.cs" />
|
||||
<Compile Include="XAudioSong.cs" />
|
||||
<Compile Include="XAudioSoundEffectInstance.cs" />
|
||||
<Compile Include="XAudioSoundEffect.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -52,6 +56,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils_Linux.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -21,6 +21,7 @@
|
||||
<DefineConstants>TRACE;DEBUG;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -29,6 +30,7 @@
|
||||
<DefineConstants>TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpDX, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -43,6 +45,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="XAudioOggInputStream.cs" />
|
||||
<Compile Include="XAudioSong.cs" />
|
||||
<Compile Include="XAudioSoundEffectInstance.cs" />
|
||||
<Compile Include="XAudioSoundEffect.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -53,6 +57,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils_PSVita.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Sce\Sce.Psm.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -23,6 +23,7 @@
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -31,6 +32,7 @@
|
||||
<DefineConstants>TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpDX">
|
||||
@ -43,6 +45,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="XAudioOggInputStream.cs" />
|
||||
<Compile Include="XAudioSong.cs" />
|
||||
<Compile Include="XAudioSoundEffectInstance.cs" />
|
||||
<Compile Include="XAudioSoundEffect.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -53,6 +57,10 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Support\OggUtils\OggUtils_WindowsMetro.csproj">
|
||||
<Project>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</Project>
|
||||
<Name>OggUtils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -15,10 +15,10 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
{
|
||||
public class Creator : ISoundSystemCreator
|
||||
{
|
||||
private XAudio2 device;
|
||||
private float distanceScale;
|
||||
private float dopplerScale;
|
||||
private float speedOfSound;
|
||||
private XAudio2 device;
|
||||
internal static MasteringVoice MasteringVoice { get; private set; }
|
||||
|
||||
#region Public
|
||||
@ -34,7 +34,7 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
|
||||
public bool IsSupported
|
||||
{
|
||||
get { return OSInformation.IsWindows; }
|
||||
get { return OSInformation.IsWindows || OSInformation.GetName() == PlatformName.Windows8ModernUI; }
|
||||
}
|
||||
|
||||
public float DistanceScale
|
||||
@ -59,21 +59,11 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
|
||||
public float MasterVolume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MasteringVoice != null)
|
||||
{
|
||||
return MasteringVoice.Volume;
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
get { return MasteringVoice != null ? MasteringVoice.Volume : 0f; }
|
||||
set
|
||||
{
|
||||
if (MasteringVoice != null)
|
||||
{
|
||||
MasteringVoice.SetVolume(value, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,28 +79,27 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public Creator()
|
||||
public Creator()
|
||||
{
|
||||
distanceScale = 1f;
|
||||
distanceScale = 1f;
|
||||
dopplerScale = 1f;
|
||||
speedOfSound = 343.5f;
|
||||
try
|
||||
{
|
||||
device = new XAudio2();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
device = null;
|
||||
//TODO: error handling
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
|
||||
if (device != null)
|
||||
{
|
||||
MasteringVoice = new MasteringVoice(device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate);
|
||||
}
|
||||
}
|
||||
|
||||
~Creator()
|
||||
~Creator()
|
||||
{
|
||||
if (MasteringVoice != null)
|
||||
{
|
||||
@ -161,6 +150,12 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
}
|
||||
#endregion
|
||||
|
||||
public IDynamicSoundEffectInstance CreateDynamicSoundEffectInstance()
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMicrophone CreateMicrophone(Microphone managedMicrophone)
|
||||
{
|
||||
PreventSystemChange();
|
||||
@ -179,17 +174,19 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#region CreateSong
|
||||
public ISong CreateSong(Song parentSong, Uri uri)
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
return new XAudioSong(device, uri);
|
||||
}
|
||||
|
||||
public IDynamicSoundEffectInstance CreateDynamicSoundEffectInstance()
|
||||
public ISong CreateSong(Song parentSong, string filepath, int duration)
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
return new XAudioSong(device, filepath, duration);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static void PreventSystemChange()
|
||||
{
|
||||
|
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using OggUtils;
|
||||
using SharpDX;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.SoundSystem.Windows.XAudio
|
||||
{
|
||||
internal class XAudioOggInputStream : OggInputStream
|
||||
{
|
||||
public const int BufferLength = 4096 * 8;
|
||||
|
||||
public XAudioOggInputStream(Stream input)
|
||||
: base(input)
|
||||
{
|
||||
}
|
||||
|
||||
public int Read(DataStream buffer)
|
||||
{
|
||||
if (StreamData.EndOfStream)
|
||||
return 0;
|
||||
|
||||
int length = BufferLength;
|
||||
int readOffset = 0;
|
||||
while (length > 0)
|
||||
{
|
||||
if (FillConversionBufferIfNeeded() == false)
|
||||
break;
|
||||
|
||||
int convertedBytesAvailable = ConversionBufferSize - ConversionBufferOffset;
|
||||
int bytesToCopy = Math.Min(length, convertedBytesAvailable);
|
||||
buffer.WriteRange(ConversionBuffer, ConversionBufferOffset, bytesToCopy);
|
||||
ConversionBufferOffset += bytesToCopy;
|
||||
length -= bytesToCopy;
|
||||
readOffset += bytesToCopy;
|
||||
}
|
||||
|
||||
return readOffset;
|
||||
}
|
||||
}
|
||||
}
|
155
SoundSystems/ANX.SoundSystem.Windows.XAudio/XAudioSong.cs
Normal file
155
SoundSystems/ANX.SoundSystem.Windows.XAudio/XAudioSong.cs
Normal file
@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.Media;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
using SharpDX;
|
||||
using SharpDX.Multimedia;
|
||||
using SharpDX.XAudio2;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.SoundSystem.Windows.XAudio
|
||||
{
|
||||
[Developer("AstrorEnales")]
|
||||
public class XAudioSong : ISong
|
||||
{
|
||||
private FileStream oggFileStream;
|
||||
private XAudioOggInputStream oggStream;
|
||||
private SourceVoice source;
|
||||
private readonly AudioBuffer[] buffers = new AudioBuffer[2];
|
||||
private int nextBufferIndex;
|
||||
|
||||
public TimeSpan Duration { get; private set; }
|
||||
public TimeSpan PlayPosition { get; private set; }
|
||||
public MediaState State { get; private set; }
|
||||
|
||||
public XAudioSong(XAudio2 device, Uri uri)
|
||||
{
|
||||
Init(device, uri.AbsolutePath);
|
||||
// TODO: duration
|
||||
}
|
||||
|
||||
public XAudioSong(XAudio2 device, string filepath, int duration)
|
||||
{
|
||||
Init(device, filepath);
|
||||
Duration = new TimeSpan(0, 0, 0, 0, duration);
|
||||
}
|
||||
|
||||
private void Init(XAudio2 device, string filepath)
|
||||
{
|
||||
PlayPosition = TimeSpan.Zero;
|
||||
State = MediaState.Stopped;
|
||||
|
||||
oggFileStream = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
oggStream = new XAudioOggInputStream(oggFileStream);
|
||||
var format = new WaveFormat(oggStream.SampleRate, 16, oggStream.Channels);
|
||||
source = new SourceVoice(device, format, true);
|
||||
source.BufferEnd += StreamBuffer;
|
||||
|
||||
for (int index = 0; index < buffers.Length; index++)
|
||||
buffers[index] = new AudioBuffer { Stream = new DataStream(XAudioOggInputStream.BufferLength, false, true) };
|
||||
}
|
||||
|
||||
private void StreamBuffer(IntPtr handle)
|
||||
{
|
||||
if (Stream() == false)
|
||||
Stop();
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (State == MediaState.Playing)
|
||||
return;
|
||||
|
||||
if (State == MediaState.Stopped)
|
||||
{
|
||||
Rewind();
|
||||
|
||||
for (int index = 0; index < buffers.Length; index++)
|
||||
if (Stream() == false)
|
||||
return;
|
||||
}
|
||||
|
||||
source.Start();
|
||||
State = MediaState.Playing;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (State == MediaState.Stopped)
|
||||
return;
|
||||
|
||||
State = MediaState.Stopped;
|
||||
source.Stop();
|
||||
source.FlushSourceBuffers();
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (State == MediaState.Paused)
|
||||
return;
|
||||
|
||||
State = MediaState.Paused;
|
||||
source.Stop();
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
Play();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public void GetVisualizationData(VisualizationData data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal void Rewind()
|
||||
{
|
||||
PlayPosition = TimeSpan.Zero;
|
||||
oggFileStream.Position = 0;
|
||||
oggStream = new XAudioOggInputStream(oggFileStream);
|
||||
}
|
||||
|
||||
internal bool Stream()
|
||||
{
|
||||
AudioBuffer currentBuffer = buffers[nextBufferIndex];
|
||||
currentBuffer.Stream.Position = 0;
|
||||
int size = oggStream.Read(currentBuffer.Stream);
|
||||
if (size <= 0)
|
||||
return false;
|
||||
|
||||
var channels = (AudioChannels)oggStream.Channels;
|
||||
PlayPosition = PlayPosition.Add(SoundEffect.GetSampleDuration(size, oggStream.SampleRate, channels));
|
||||
currentBuffer.PlayLength = size / 4;
|
||||
source.SubmitSourceBuffer(currentBuffer, null);
|
||||
nextBufferIndex = (nextBufferIndex + 1) % buffers.Length;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (oggFileStream != null)
|
||||
oggFileStream.Close();
|
||||
|
||||
oggFileStream = null;
|
||||
oggStream = null;
|
||||
if (source != null)
|
||||
{
|
||||
source.FlushSourceBuffers();
|
||||
source.DestroyVoice();
|
||||
source.Dispose();
|
||||
}
|
||||
|
||||
source = null;
|
||||
}
|
||||
}
|
||||
}
|
230
Support/OggUtils/OggInputStream.cs
Normal file
230
Support/OggUtils/OggInputStream.cs
Normal file
@ -0,0 +1,230 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace OggUtils
|
||||
{
|
||||
public class OggInputStream
|
||||
{
|
||||
protected readonly OggStreamingData StreamData;
|
||||
private const int DefaultConvsize = 4096 * 2;
|
||||
private readonly int[] indexCache;
|
||||
private static int convsizePerChannel = DefaultConvsize;
|
||||
protected int ConversionBufferOffset;
|
||||
protected int ConversionBufferSize;
|
||||
protected static readonly byte[] ConversionBuffer = new byte[DefaultConvsize];
|
||||
private readonly float[][][] pcmCache = new float[1][][];
|
||||
|
||||
public int SampleRate
|
||||
{
|
||||
get { return StreamData.Info.rate; }
|
||||
}
|
||||
|
||||
public int Channels
|
||||
{
|
||||
get { return StreamData.Info.channels; }
|
||||
}
|
||||
|
||||
public OggInputStream(Stream input)
|
||||
{
|
||||
StreamData = new OggStreamingData(input);
|
||||
try
|
||||
{
|
||||
InitVorbis();
|
||||
convsizePerChannel = DefaultConvsize / StreamData.Info.channels;
|
||||
indexCache = new int[StreamData.Info.channels];
|
||||
}
|
||||
catch
|
||||
{
|
||||
StreamData.EndOfStream = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int Read(byte[] buffer)
|
||||
{
|
||||
if (StreamData.EndOfStream)
|
||||
return 0;
|
||||
|
||||
int length = buffer.Length;
|
||||
int readOffset = 0;
|
||||
while (length > 0)
|
||||
{
|
||||
if (FillConversionBufferIfNeeded() == false)
|
||||
break;
|
||||
|
||||
int convertedBytesAvailable = ConversionBufferSize - ConversionBufferOffset;
|
||||
int bytesToCopy = Math.Min(length, convertedBytesAvailable);
|
||||
Array.Copy(ConversionBuffer, ConversionBufferOffset, buffer, readOffset, bytesToCopy);
|
||||
ConversionBufferOffset += bytesToCopy;
|
||||
length -= bytesToCopy;
|
||||
readOffset += bytesToCopy;
|
||||
}
|
||||
|
||||
return readOffset;
|
||||
}
|
||||
|
||||
private void InitVorbis()
|
||||
{
|
||||
if (StreamData.InitSyncState() == false)
|
||||
return;
|
||||
|
||||
StreamData.InitStreamState();
|
||||
StreamData.Info.init();
|
||||
|
||||
if (StreamData.PageIn() < 0)
|
||||
throw new Exception("Error reading first page of Ogg bitstream data.");
|
||||
if (StreamData.PacketOut() != 1)
|
||||
throw new Exception("Error reading initial header packet.");
|
||||
if (StreamData.Info.synthesis_headerin(StreamData.Comment, StreamData.Packet) < 0)
|
||||
throw new Exception("This Ogg bitstream does not contain Vorbis audio data.");
|
||||
|
||||
int headerIndex = 0;
|
||||
while (headerIndex < 2)
|
||||
{
|
||||
while (headerIndex < 2)
|
||||
{
|
||||
int result = StreamData.PageOut();
|
||||
if (result == 0)
|
||||
break;
|
||||
if (result != 1)
|
||||
continue;
|
||||
|
||||
StreamData.PageIn();
|
||||
while (headerIndex < 2)
|
||||
{
|
||||
result = StreamData.PacketOut();
|
||||
if (result == 0)
|
||||
break;
|
||||
if (result == -1)
|
||||
throw new Exception("Corrupt secondary header. Exiting.");
|
||||
|
||||
StreamData.Info.synthesis_headerin(StreamData.Comment, StreamData.Packet);
|
||||
headerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
int index = StreamData.SyncState.buffer(4096);
|
||||
int bytes = Math.Max(0, StreamData.ReadSyncStateDataAt(index));
|
||||
if (bytes == 0 && headerIndex < 2)
|
||||
throw new Exception("End of file before finding all Vorbis headers!");
|
||||
|
||||
StreamData.SyncState.wrote(bytes);
|
||||
}
|
||||
|
||||
StreamData.DspState.synthesis_init(StreamData.Info);
|
||||
StreamData.Block.init(StreamData.DspState);
|
||||
}
|
||||
|
||||
protected bool FillConversionBufferIfNeeded()
|
||||
{
|
||||
if (ConversionBufferOffset < ConversionBufferSize)
|
||||
return true;
|
||||
|
||||
ConversionBufferSize = GetNextPacket();
|
||||
ConversionBufferOffset = 0;
|
||||
if (ConversionBufferSize == -1)
|
||||
{
|
||||
StreamData.EndOfStream = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
ConversionBufferSize = DecodePacket();
|
||||
return true;
|
||||
}
|
||||
|
||||
private int GetNextPacket()
|
||||
{
|
||||
bool fetchedPacket = false;
|
||||
while (StreamData.EndOfStream == false && fetchedPacket == false)
|
||||
{
|
||||
int result1 = StreamData.PacketOut();
|
||||
if (result1 == 0)
|
||||
{
|
||||
int result2 = 0;
|
||||
while (StreamData.EndOfStream == false && result2 == 0)
|
||||
{
|
||||
result2 = StreamData.PageOut();
|
||||
if (result2 == 0)
|
||||
FetchData();
|
||||
}
|
||||
|
||||
if (result2 == 0 && StreamData.EndOfPage)
|
||||
return -1;
|
||||
|
||||
if (result2 == 0)
|
||||
FetchData();
|
||||
else if (result2 == -1)
|
||||
return -1;
|
||||
else
|
||||
StreamData.PageIn();
|
||||
}
|
||||
else if (result1 == -1)
|
||||
return -1;
|
||||
else
|
||||
fetchedPacket = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void FetchData()
|
||||
{
|
||||
if (StreamData.EndOfStream)
|
||||
return;
|
||||
|
||||
int index = StreamData.SyncState.buffer(4096);
|
||||
if (index >= 0)
|
||||
{
|
||||
int bytesRead = StreamData.ReadSyncStateDataAt(index);
|
||||
StreamData.SyncState.wrote(bytesRead);
|
||||
if (bytesRead > 0)
|
||||
return;
|
||||
}
|
||||
|
||||
StreamData.EndOfStream = true;
|
||||
}
|
||||
|
||||
private int DecodePacket()
|
||||
{
|
||||
if (StreamData.Block.synthesis(StreamData.Packet) == 0)
|
||||
StreamData.DspState.synthesis_blockin(StreamData.Block);
|
||||
|
||||
int conversionOffset = 0;
|
||||
int samplesToProcess;
|
||||
while ((samplesToProcess = StreamData.DspState.synthesis_pcmout(pcmCache, indexCache)) > 0)
|
||||
{
|
||||
float[][] pcmDataPerChannel = pcmCache[0];
|
||||
int bout = Math.Min(samplesToProcess, convsizePerChannel);
|
||||
|
||||
for (int channelIndex = 0; channelIndex < StreamData.Info.channels; channelIndex++)
|
||||
{
|
||||
int ptr = (channelIndex << 1) + conversionOffset;
|
||||
int mono = indexCache[channelIndex];
|
||||
|
||||
for (int sampleOffset = 0; sampleOffset < bout; sampleOffset++)
|
||||
{
|
||||
int pcmSample = ConvertPcmData(pcmDataPerChannel[channelIndex][mono + sampleOffset]);
|
||||
ConversionBuffer[ptr + 0] = (byte)pcmSample;
|
||||
ConversionBuffer[ptr + 1] = (byte)(int)((uint)pcmSample >> 8);
|
||||
ptr += StreamData.Info.channels << 1;
|
||||
}
|
||||
}
|
||||
|
||||
conversionOffset += 2 * StreamData.Info.channels * bout;
|
||||
StreamData.DspState.synthesis_read(bout);
|
||||
}
|
||||
|
||||
return conversionOffset;
|
||||
}
|
||||
|
||||
private static int ConvertPcmData(float sourceSample)
|
||||
{
|
||||
sourceSample = Math.Max(-1f, Math.Min(1f, sourceSample));
|
||||
int pcmSampleResult = (int)(sourceSample * 32767);
|
||||
return pcmSampleResult | (pcmSampleResult < 0 ? 0x8000 : 0);
|
||||
}
|
||||
}
|
||||
}
|
84
Support/OggUtils/OggStreamingData.cs
Normal file
84
Support/OggUtils/OggStreamingData.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using csogg;
|
||||
using csvorbis;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace OggUtils
|
||||
{
|
||||
public class OggStreamingData
|
||||
{
|
||||
private readonly Page page;
|
||||
|
||||
public Block Block;
|
||||
public readonly DspState DspState;
|
||||
public readonly SyncState SyncState;
|
||||
public readonly StreamState StreamState;
|
||||
public readonly Packet Packet;
|
||||
public readonly Info Info;
|
||||
public readonly Comment Comment;
|
||||
public bool EndOfStream;
|
||||
public Stream Input { get; private set; }
|
||||
public bool EndOfPage
|
||||
{
|
||||
get { return page.eos() != 0; }
|
||||
}
|
||||
|
||||
public OggStreamingData(Stream setInput)
|
||||
{
|
||||
Input = setInput;
|
||||
page = new Page();
|
||||
DspState = new DspState();
|
||||
SyncState = new SyncState();
|
||||
StreamState = new StreamState();
|
||||
Packet = new Packet();
|
||||
Info = new Info();
|
||||
Comment = new Comment();
|
||||
Block = new Block(DspState);
|
||||
}
|
||||
|
||||
public bool InitSyncState()
|
||||
{
|
||||
SyncState.init();
|
||||
SyncState.buffer(4096);
|
||||
byte[] readData = SyncState.data;
|
||||
int bytes = Input.Read(readData, 0, readData.Length);
|
||||
SyncState.wrote(bytes);
|
||||
|
||||
if (PageOut() == 1)
|
||||
return true;
|
||||
if (bytes < 4096)
|
||||
return false;
|
||||
|
||||
throw new Exception("Input does not appear to be an Ogg bitstream.");
|
||||
}
|
||||
|
||||
public int ReadSyncStateDataAt(int index)
|
||||
{
|
||||
return Input.Read(SyncState.data, index, 4096);
|
||||
}
|
||||
|
||||
public void InitStreamState()
|
||||
{
|
||||
StreamState.init(page.serialno());
|
||||
}
|
||||
|
||||
public int PageIn()
|
||||
{
|
||||
return StreamState.pagein(page);
|
||||
}
|
||||
|
||||
public int PageOut()
|
||||
{
|
||||
return SyncState.pageout(page);
|
||||
}
|
||||
|
||||
public int PacketOut()
|
||||
{
|
||||
return StreamState.packetout(Packet);
|
||||
}
|
||||
}
|
||||
}
|
89
Support/OggUtils/OggUtils.csproj
Normal file
89
Support/OggUtils/OggUtils.csproj
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OggUtils</RootNamespace>
|
||||
<AssemblyName>OggUtils</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="csogg\Buffer.cs" />
|
||||
<Compile Include="csogg\Packet.cs" />
|
||||
<Compile Include="csogg\Page.cs" />
|
||||
<Compile Include="csogg\StreamState.cs" />
|
||||
<Compile Include="csogg\SyncState.cs" />
|
||||
<Compile Include="csvorbis\AllocChain.cs" />
|
||||
<Compile Include="csvorbis\Block.cs" />
|
||||
<Compile Include="csvorbis\CodeBook.cs" />
|
||||
<Compile Include="csvorbis\Comment.cs" />
|
||||
<Compile Include="csvorbis\csorbisException.cs" />
|
||||
<Compile Include="csvorbis\Drft.cs" />
|
||||
<Compile Include="csvorbis\DspState.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxNearestMatch.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxThreshMatch.cs" />
|
||||
<Compile Include="csvorbis\Floor0.cs" />
|
||||
<Compile Include="csvorbis\Floor1.cs" />
|
||||
<Compile Include="csvorbis\FuncFloor.cs" />
|
||||
<Compile Include="csvorbis\FuncMapping.cs" />
|
||||
<Compile Include="csvorbis\FuncResidue.cs" />
|
||||
<Compile Include="csvorbis\FuncTime.cs" />
|
||||
<Compile Include="csvorbis\Info.cs" />
|
||||
<Compile Include="csvorbis\InfoMode.cs" />
|
||||
<Compile Include="csvorbis\Lookup.cs" />
|
||||
<Compile Include="csvorbis\Lpc.cs" />
|
||||
<Compile Include="csvorbis\Lsp.cs" />
|
||||
<Compile Include="csvorbis\Mapping0.cs" />
|
||||
<Compile Include="csvorbis\Mdct.cs" />
|
||||
<Compile Include="csvorbis\PsyInfo.cs" />
|
||||
<Compile Include="csvorbis\PsyLook.cs" />
|
||||
<Compile Include="csvorbis\Residue0.cs" />
|
||||
<Compile Include="csvorbis\Residue1.cs" />
|
||||
<Compile Include="csvorbis\Residue2.cs" />
|
||||
<Compile Include="csvorbis\StaticCodeBook.cs" />
|
||||
<Compile Include="csvorbis\Time0.cs" />
|
||||
<Compile Include="csvorbis\VorbisFile.cs" />
|
||||
<Compile Include="OggInputStream.cs" />
|
||||
<Compile Include="OggStreamingData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>
|
88
Support/OggUtils/OggUtils_Linux.csproj
Normal file
88
Support/OggUtils/OggUtils_Linux.csproj
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OggUtils</RootNamespace>
|
||||
<AssemblyName>OggUtils</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="csogg\Buffer.cs" />
|
||||
<Compile Include="csogg\Packet.cs" />
|
||||
<Compile Include="csogg\Page.cs" />
|
||||
<Compile Include="csogg\StreamState.cs" />
|
||||
<Compile Include="csogg\SyncState.cs" />
|
||||
<Compile Include="csvorbis\AllocChain.cs" />
|
||||
<Compile Include="csvorbis\Block.cs" />
|
||||
<Compile Include="csvorbis\CodeBook.cs" />
|
||||
<Compile Include="csvorbis\Comment.cs" />
|
||||
<Compile Include="csvorbis\csorbisException.cs" />
|
||||
<Compile Include="csvorbis\Drft.cs" />
|
||||
<Compile Include="csvorbis\DspState.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxNearestMatch.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxThreshMatch.cs" />
|
||||
<Compile Include="csvorbis\Floor0.cs" />
|
||||
<Compile Include="csvorbis\Floor1.cs" />
|
||||
<Compile Include="csvorbis\FuncFloor.cs" />
|
||||
<Compile Include="csvorbis\FuncMapping.cs" />
|
||||
<Compile Include="csvorbis\FuncResidue.cs" />
|
||||
<Compile Include="csvorbis\FuncTime.cs" />
|
||||
<Compile Include="csvorbis\Info.cs" />
|
||||
<Compile Include="csvorbis\InfoMode.cs" />
|
||||
<Compile Include="csvorbis\Lookup.cs" />
|
||||
<Compile Include="csvorbis\Lpc.cs" />
|
||||
<Compile Include="csvorbis\Lsp.cs" />
|
||||
<Compile Include="csvorbis\Mapping0.cs" />
|
||||
<Compile Include="csvorbis\Mdct.cs" />
|
||||
<Compile Include="csvorbis\PsyInfo.cs" />
|
||||
<Compile Include="csvorbis\PsyLook.cs" />
|
||||
<Compile Include="csvorbis\Residue0.cs" />
|
||||
<Compile Include="csvorbis\Residue1.cs" />
|
||||
<Compile Include="csvorbis\Residue2.cs" />
|
||||
<Compile Include="csvorbis\StaticCodeBook.cs" />
|
||||
<Compile Include="csvorbis\Time0.cs" />
|
||||
<Compile Include="csvorbis\VorbisFile.cs" />
|
||||
<Compile Include="OggInputStream.cs" />
|
||||
<Compile Include="OggStreamingData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>
|
89
Support/OggUtils/OggUtils_PSVita.csproj
Normal file
89
Support/OggUtils/OggUtils_PSVita.csproj
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OggUtils</RootNamespace>
|
||||
<AssemblyName>OggUtils</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{69878862-DA7D-4DC6-B0A1-50D8FAB4242F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="csogg\Buffer.cs" />
|
||||
<Compile Include="csogg\Packet.cs" />
|
||||
<Compile Include="csogg\Page.cs" />
|
||||
<Compile Include="csogg\StreamState.cs" />
|
||||
<Compile Include="csogg\SyncState.cs" />
|
||||
<Compile Include="csvorbis\AllocChain.cs" />
|
||||
<Compile Include="csvorbis\Block.cs" />
|
||||
<Compile Include="csvorbis\CodeBook.cs" />
|
||||
<Compile Include="csvorbis\Comment.cs" />
|
||||
<Compile Include="csvorbis\csorbisException.cs" />
|
||||
<Compile Include="csvorbis\Drft.cs" />
|
||||
<Compile Include="csvorbis\DspState.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxNearestMatch.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxThreshMatch.cs" />
|
||||
<Compile Include="csvorbis\Floor0.cs" />
|
||||
<Compile Include="csvorbis\Floor1.cs" />
|
||||
<Compile Include="csvorbis\FuncFloor.cs" />
|
||||
<Compile Include="csvorbis\FuncMapping.cs" />
|
||||
<Compile Include="csvorbis\FuncResidue.cs" />
|
||||
<Compile Include="csvorbis\FuncTime.cs" />
|
||||
<Compile Include="csvorbis\Info.cs" />
|
||||
<Compile Include="csvorbis\InfoMode.cs" />
|
||||
<Compile Include="csvorbis\Lookup.cs" />
|
||||
<Compile Include="csvorbis\Lpc.cs" />
|
||||
<Compile Include="csvorbis\Lsp.cs" />
|
||||
<Compile Include="csvorbis\Mapping0.cs" />
|
||||
<Compile Include="csvorbis\Mdct.cs" />
|
||||
<Compile Include="csvorbis\PsyInfo.cs" />
|
||||
<Compile Include="csvorbis\PsyLook.cs" />
|
||||
<Compile Include="csvorbis\Residue0.cs" />
|
||||
<Compile Include="csvorbis\Residue1.cs" />
|
||||
<Compile Include="csvorbis\Residue2.cs" />
|
||||
<Compile Include="csvorbis\StaticCodeBook.cs" />
|
||||
<Compile Include="csvorbis\Time0.cs" />
|
||||
<Compile Include="csvorbis\VorbisFile.cs" />
|
||||
<Compile Include="OggInputStream.cs" />
|
||||
<Compile Include="OggStreamingData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Sce\Sce.Psm.CSharp.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>
|
94
Support/OggUtils/OggUtils_WindowsMetro.csproj
Normal file
94
Support/OggUtils/OggUtils_WindowsMetro.csproj
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{ABECEC14-6BF4-4432-833C-69714EB4E8E6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OggUtils</RootNamespace>
|
||||
<AssemblyName>OggUtils</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<PackageCertificateKeyFile>Test_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="csogg\Buffer.cs" />
|
||||
<Compile Include="csogg\Packet.cs" />
|
||||
<Compile Include="csogg\Page.cs" />
|
||||
<Compile Include="csogg\StreamState.cs" />
|
||||
<Compile Include="csogg\SyncState.cs" />
|
||||
<Compile Include="csvorbis\AllocChain.cs" />
|
||||
<Compile Include="csvorbis\Block.cs" />
|
||||
<Compile Include="csvorbis\CodeBook.cs" />
|
||||
<Compile Include="csvorbis\Comment.cs" />
|
||||
<Compile Include="csvorbis\csorbisException.cs" />
|
||||
<Compile Include="csvorbis\Drft.cs" />
|
||||
<Compile Include="csvorbis\DspState.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxNearestMatch.cs" />
|
||||
<Compile Include="csvorbis\EncodeAuxThreshMatch.cs" />
|
||||
<Compile Include="csvorbis\Floor0.cs" />
|
||||
<Compile Include="csvorbis\Floor1.cs" />
|
||||
<Compile Include="csvorbis\FuncFloor.cs" />
|
||||
<Compile Include="csvorbis\FuncMapping.cs" />
|
||||
<Compile Include="csvorbis\FuncResidue.cs" />
|
||||
<Compile Include="csvorbis\FuncTime.cs" />
|
||||
<Compile Include="csvorbis\Info.cs" />
|
||||
<Compile Include="csvorbis\InfoMode.cs" />
|
||||
<Compile Include="csvorbis\Lookup.cs" />
|
||||
<Compile Include="csvorbis\Lpc.cs" />
|
||||
<Compile Include="csvorbis\Lsp.cs" />
|
||||
<Compile Include="csvorbis\Mapping0.cs" />
|
||||
<Compile Include="csvorbis\Mdct.cs" />
|
||||
<Compile Include="csvorbis\PsyInfo.cs" />
|
||||
<Compile Include="csvorbis\PsyLook.cs" />
|
||||
<Compile Include="csvorbis\Residue0.cs" />
|
||||
<Compile Include="csvorbis\Residue1.cs" />
|
||||
<Compile Include="csvorbis\Residue2.cs" />
|
||||
<Compile Include="csvorbis\StaticCodeBook.cs" />
|
||||
<Compile Include="csvorbis\Time0.cs" />
|
||||
<Compile Include="csvorbis\VorbisFile.cs" />
|
||||
<Compile Include="OggInputStream.cs" />
|
||||
<Compile Include="OggStreamingData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.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>
|
||||
-->
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ">
|
||||
<VisualStudioVersion>11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
</Project>
|
36
Support/OggUtils/Properties/AssemblyInfo.cs
Normal file
36
Support/OggUtils/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die mit einer Assembly verknüpft sind.
|
||||
[assembly: AssemblyTitle("OggUtils")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("ANX.Framework Team")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
|
||||
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("774a9cc9-2e64-4bae-9038-c857edfe3e08")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.7.0.*")]
|
||||
[assembly: AssemblyFileVersion("0.7.0.*")]
|
302
Support/OggUtils/csogg/Buffer.cs
Normal file
302
Support/OggUtils/csogg/Buffer.cs
Normal file
@ -0,0 +1,302 @@
|
||||
/* csogg
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace csogg
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for csBuffer.
|
||||
/// </summary>
|
||||
public class csBuffer
|
||||
{
|
||||
private static int BUFFER_INCREMENT = 256;
|
||||
|
||||
private static uint[] mask={
|
||||
0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
|
||||
0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
|
||||
0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
|
||||
0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff,
|
||||
0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff,
|
||||
0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,
|
||||
0x3fffffff,0x7fffffff,0xffffffff
|
||||
};
|
||||
int ptr = 0;
|
||||
byte[] buffer = null;
|
||||
int endbit = 0;
|
||||
int endbyte = 0;
|
||||
int storage = 0;
|
||||
|
||||
public void writeinit()
|
||||
{
|
||||
buffer = new byte[BUFFER_INCREMENT];
|
||||
ptr = 0;
|
||||
buffer[0] = (byte)'\0';
|
||||
storage = BUFFER_INCREMENT;
|
||||
}
|
||||
|
||||
public void write(byte[] s)
|
||||
{
|
||||
for(int i = 0; i < s.Length; i++)
|
||||
{
|
||||
if(s[i] == 0) break;
|
||||
write(s[i], 8);
|
||||
}
|
||||
}
|
||||
|
||||
public void read (byte[] s, int bytes)
|
||||
{
|
||||
int i = 0;
|
||||
while(bytes--!=0)
|
||||
{
|
||||
s[i++]=(byte)(read(8));
|
||||
}
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
ptr = 0;
|
||||
buffer[0] = (byte)'\0';
|
||||
endbit = endbyte = 0;
|
||||
}
|
||||
|
||||
public void writeclear()
|
||||
{
|
||||
buffer = null;
|
||||
}
|
||||
|
||||
public void readinit(byte[] buf, int start, int bytes)
|
||||
{
|
||||
ptr = start;
|
||||
buffer = buf;
|
||||
endbit = endbyte = 0;
|
||||
storage = bytes;
|
||||
}
|
||||
|
||||
public void write(int vvalue, int bits)
|
||||
{
|
||||
if(endbyte + 4 >= storage)
|
||||
{
|
||||
byte[] foo = new byte[storage + BUFFER_INCREMENT];
|
||||
Array.Copy(buffer, 0, foo, 0, storage);
|
||||
buffer = foo;
|
||||
storage += BUFFER_INCREMENT;
|
||||
}
|
||||
|
||||
vvalue = (int)((uint)vvalue & mask[bits]);
|
||||
bits += endbit;
|
||||
buffer[ptr] |= (byte)(vvalue << endbit);
|
||||
|
||||
if(bits >= 8)
|
||||
{
|
||||
buffer[ptr+1] = (byte)((uint)vvalue >> (8-endbit));
|
||||
if(bits >= 16)
|
||||
{
|
||||
buffer[ptr+2] = (byte)((uint)vvalue >> (16-endbit));
|
||||
if (bits >= 24)
|
||||
{
|
||||
buffer[ptr+3] = (byte)((uint)vvalue >> (24-endbit));
|
||||
if(bits >= 32)
|
||||
{
|
||||
if(endbit > 0)
|
||||
buffer[ptr+4] = (byte)((uint)vvalue >> (32-endbit));
|
||||
else
|
||||
buffer[ptr+4]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endbyte += bits / 8;
|
||||
ptr += bits/8;
|
||||
endbit = bits & 7;
|
||||
}
|
||||
|
||||
public int look(int bits)
|
||||
{
|
||||
int ret;
|
||||
uint m = mask[bits];
|
||||
|
||||
bits += endbit;
|
||||
|
||||
if(endbyte + 4 >= storage)
|
||||
{
|
||||
if(endbyte+(bits-1)/8 >= storage)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
ret = ((buffer[ptr]) & 0xff) >> endbit;
|
||||
|
||||
if(bits > 8)
|
||||
{
|
||||
ret |= ((buffer[ptr+1]) & 0xff) << (8 - endbit);
|
||||
if(bits > 16)
|
||||
{
|
||||
ret |= ((buffer[ptr+2])&0xff) << (16-endbit);
|
||||
if(bits > 24)
|
||||
{
|
||||
ret |= ((buffer[ptr+3])&0xff) << (24-endbit);
|
||||
if((bits > 32) && (endbit != 0))
|
||||
{
|
||||
ret |= ((buffer[ptr+4])&0xff) << (32-endbit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = (int)(m & ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
public int look1()
|
||||
{
|
||||
if(endbyte >= storage)
|
||||
return(-1);
|
||||
return((buffer[ptr] >> endbit) & 1);
|
||||
}
|
||||
|
||||
public void adv(int bits)
|
||||
{
|
||||
bits += endbit;
|
||||
ptr += bits / 8;
|
||||
endbyte += bits / 8;
|
||||
endbit = bits & 7;
|
||||
}
|
||||
|
||||
public void adv1()
|
||||
{
|
||||
++endbit;
|
||||
if(endbit > 7)
|
||||
{
|
||||
endbit = 0;
|
||||
ptr++;
|
||||
endbyte++;
|
||||
}
|
||||
}
|
||||
|
||||
public int read(int bits)
|
||||
{
|
||||
int ret;
|
||||
uint m=mask[bits];
|
||||
|
||||
bits += endbit;
|
||||
|
||||
if(endbyte+4 >= storage)
|
||||
{
|
||||
ret = -1;
|
||||
if(endbyte + (bits-1)/8 >= storage)
|
||||
{
|
||||
ptr += bits/8;
|
||||
endbyte += bits/8;
|
||||
endbit = bits&7;
|
||||
return(ret);
|
||||
}
|
||||
}
|
||||
|
||||
ret = ((buffer[ptr]) & 0xff) >> endbit;
|
||||
if(bits > 8)
|
||||
{
|
||||
ret|=((buffer[ptr+1])&0xff)<<(8-endbit);
|
||||
if(bits > 16)
|
||||
{
|
||||
ret|=((buffer[ptr+2])&0xff)<<(16-endbit);
|
||||
if(bits > 24)
|
||||
{
|
||||
ret|=((buffer[ptr+3])&0xff)<<(24-endbit);
|
||||
|
||||
if((bits > 32) && (endbit != 0))
|
||||
{
|
||||
ret|=((buffer[ptr+4])&0xff)<<(32-endbit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret &= (int)m;
|
||||
|
||||
ptr += bits/8;
|
||||
endbyte += bits/8;
|
||||
endbit = bits&7;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
public int read1()
|
||||
{
|
||||
int ret;
|
||||
if(endbyte>=storage)
|
||||
{
|
||||
ret = -1;
|
||||
endbit++;
|
||||
if(endbit > 7)
|
||||
{
|
||||
endbit = 0;
|
||||
ptr++;
|
||||
endbyte++;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
ret=(buffer[ptr] >> endbit) & 1;
|
||||
|
||||
endbit++;
|
||||
if(endbit > 7)
|
||||
{
|
||||
endbit = 0;
|
||||
ptr++;
|
||||
endbyte++;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
public int bytes()
|
||||
{
|
||||
return(endbyte+(endbit+7)/8);
|
||||
}
|
||||
|
||||
public int bits()
|
||||
{
|
||||
return(endbyte*8+endbit);
|
||||
}
|
||||
|
||||
public static int ilog(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v > 0)
|
||||
{
|
||||
ret++;
|
||||
v >>= 1;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
public byte[] buf()
|
||||
{
|
||||
return(buffer);
|
||||
}
|
||||
|
||||
public csBuffer()
|
||||
{
|
||||
// Really a noop?
|
||||
}
|
||||
}
|
||||
}
|
53
Support/OggUtils/csogg/Packet.cs
Normal file
53
Support/OggUtils/csogg/Packet.cs
Normal file
@ -0,0 +1,53 @@
|
||||
/* csogg
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace csogg
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Packet.
|
||||
/// </summary>
|
||||
public class Packet
|
||||
{
|
||||
public byte[] packet_base;
|
||||
public int packet;
|
||||
public int bytes;
|
||||
public int b_o_s;
|
||||
public int e_o_s;
|
||||
|
||||
public long granulepos;
|
||||
|
||||
public long packetno; // sequence number for decode; the framing
|
||||
// knows where there's a hole in the data,
|
||||
// but we need coupling so that the codec
|
||||
// (which is in a seperate abstraction
|
||||
// layer) also knows about the gap
|
||||
|
||||
public Packet()
|
||||
{
|
||||
// No constructor
|
||||
}
|
||||
}
|
||||
}
|
140
Support/OggUtils/csogg/Page.cs
Normal file
140
Support/OggUtils/csogg/Page.cs
Normal file
@ -0,0 +1,140 @@
|
||||
/* csogg
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace csogg
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Page.
|
||||
/// </summary>
|
||||
public class Page
|
||||
{
|
||||
private static uint[] crc_lookup=new uint[256];
|
||||
|
||||
private static uint crc_entry(uint index)
|
||||
{
|
||||
uint r = index << 24;
|
||||
for(int i=0; i<8; i++)
|
||||
{
|
||||
if((r& 0x80000000)!=0)
|
||||
{
|
||||
r=(r << 1)^0x04c11db7; /* The same as the ethernet generator
|
||||
polynomial, although we use an
|
||||
unreflected alg and an init/final
|
||||
of 0, not 0xffffffff */
|
||||
}
|
||||
else
|
||||
{
|
||||
r <<= 1;
|
||||
}
|
||||
}
|
||||
return (r & 0xffffffff);
|
||||
}
|
||||
|
||||
public byte[] header_base;
|
||||
public int header;
|
||||
public int header_len;
|
||||
public byte[] body_base;
|
||||
public int body;
|
||||
public int body_len;
|
||||
|
||||
internal int version()
|
||||
{
|
||||
return header_base[header+4]&0xff;
|
||||
}
|
||||
internal int continued()
|
||||
{
|
||||
return (header_base[header+5]&0x01);
|
||||
}
|
||||
public int bos()
|
||||
{
|
||||
return (header_base[header+5]&0x02);
|
||||
}
|
||||
public int eos()
|
||||
{
|
||||
return (header_base[header+5]&0x04);
|
||||
}
|
||||
public long granulepos()
|
||||
{
|
||||
long foo = header_base[header+13]&0xff;
|
||||
foo = (foo<<8) | (uint)(header_base[header+12]&0xff);
|
||||
foo = (foo<<8) | (uint)(header_base[header+11]&0xff);
|
||||
foo = (foo<<8) | (uint)(header_base[header+10]&0xff);
|
||||
foo = (foo<<8) | (uint)(header_base[header+9]&0xff);
|
||||
foo = (foo<<8) | (uint)(header_base[header+8]&0xff);
|
||||
foo = (foo<<8) | (uint)(header_base[header+7]&0xff);
|
||||
foo = (foo<<8) | (uint)(header_base[header+6]&0xff);
|
||||
return(foo);
|
||||
}
|
||||
public int serialno()
|
||||
{
|
||||
return (header_base[header+14]&0xff)|
|
||||
((header_base[header+15]&0xff)<<8)|
|
||||
((header_base[header+16]&0xff)<<16)|
|
||||
((header_base[header+17]&0xff)<<24);
|
||||
}
|
||||
internal int pageno()
|
||||
{
|
||||
return (header_base[header+18]&0xff)|
|
||||
((header_base[header+19]&0xff)<<8)|
|
||||
((header_base[header+20]&0xff)<<16)|
|
||||
((header_base[header+21]&0xff)<<24);
|
||||
}
|
||||
|
||||
internal void checksum()
|
||||
{
|
||||
uint crc_reg=0;
|
||||
uint a, b;
|
||||
|
||||
for(int i=0;i<header_len;i++)
|
||||
{
|
||||
a = header_base[header+i] & 0xffu;
|
||||
b = (crc_reg >> 24) & 0xff;
|
||||
crc_reg = (crc_reg<<8)^crc_lookup[a^b];
|
||||
//crc_reg = (crc_reg<<8)^(uint)(crc_lookup[((crc_reg >> 24)&0xff)^(header_base[header+i]&0xff)]);
|
||||
}
|
||||
for(int i=0;i<body_len;i++)
|
||||
{
|
||||
a = body_base[body+i] & 0xffu;
|
||||
b = (crc_reg >> 24) & 0xff;
|
||||
crc_reg = (crc_reg<<8)^crc_lookup[a^b];
|
||||
|
||||
//crc_reg = (crc_reg<<8)^(uint)(crc_lookup[((crc_reg >> 24)&0xff)^(body_base[body+i]&0xff)]);
|
||||
}
|
||||
header_base[header+22]=(byte)crc_reg/*&0xff*/;
|
||||
header_base[header+23]=(byte)(crc_reg>>8)/*&0xff*/;
|
||||
header_base[header+24]=(byte)(crc_reg>>16)/*&0xff*/;
|
||||
header_base[header+25]=(byte)(crc_reg>>24)/*&0xff*/;
|
||||
}
|
||||
|
||||
public Page()
|
||||
{
|
||||
for(uint i=0; i<crc_lookup.Length; i++)
|
||||
{
|
||||
crc_lookup[i]=crc_entry(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
581
Support/OggUtils/csogg/StreamState.cs
Normal file
581
Support/OggUtils/csogg/StreamState.cs
Normal file
@ -0,0 +1,581 @@
|
||||
/* csogg
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace csogg
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for StreamState.
|
||||
/// </summary>
|
||||
public class StreamState
|
||||
{
|
||||
byte[] body_data; /* bytes from packet bodies */
|
||||
int body_storage; /* storage elements allocated */
|
||||
int body_fill; /* elements stored; fill mark */
|
||||
private int body_returned; /* elements of fill returned */
|
||||
|
||||
|
||||
int[] lacing_vals; /* The values that will go to the segment table */
|
||||
long[] granule_vals; /* pcm_pos values for headers. Not compact
|
||||
this way, but it is simple coupled to the
|
||||
lacing fifo */
|
||||
int lacing_storage;
|
||||
int lacing_fill;
|
||||
int lacing_packet;
|
||||
int lacing_returned;
|
||||
|
||||
byte[] header=new byte[282]; /* working space for header encode */
|
||||
int header_fill;
|
||||
|
||||
public int e_o_s; /* set when we have buffered the last packet in the
|
||||
logical bitstream */
|
||||
int b_o_s; /* set after we've written the initial page
|
||||
of a logical bitstream */
|
||||
int serialno;
|
||||
int pageno;
|
||||
long packetno; /* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
layer) also knows about the gap */
|
||||
long granulepos;
|
||||
|
||||
StreamState(int serialno) : this()
|
||||
{
|
||||
init(serialno);
|
||||
}
|
||||
|
||||
public StreamState()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
body_storage=16*1024;
|
||||
body_data=new byte[body_storage];
|
||||
lacing_storage=1024;
|
||||
lacing_vals=new int[lacing_storage];
|
||||
granule_vals=new long[lacing_storage];
|
||||
}
|
||||
public void init(int serialno)
|
||||
{
|
||||
if(body_data==null){ init(); }
|
||||
else
|
||||
{
|
||||
for(int i=0; i<body_data.Length; i++) body_data[i]=0;
|
||||
for(int i=0; i<lacing_vals.Length; i++) lacing_vals[i]=0;
|
||||
for(int i=0; i<granule_vals.Length; i++) granule_vals[i]=0;
|
||||
}
|
||||
this.serialno=serialno;
|
||||
}
|
||||
public void clear()
|
||||
{
|
||||
body_data=null;
|
||||
lacing_vals=null;
|
||||
granule_vals=null;
|
||||
//memset(os,0,sizeof(ogg_stream_state));
|
||||
}
|
||||
void destroy()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
void body_expand(int needed)
|
||||
{
|
||||
if(body_storage<=body_fill+needed)
|
||||
{
|
||||
body_storage+=(needed+1024);
|
||||
byte[] foo=new byte[body_storage];
|
||||
Array.Copy(body_data, 0, foo, 0, body_data.Length);
|
||||
body_data=foo;
|
||||
}
|
||||
}
|
||||
void lacing_expand(int needed)
|
||||
{
|
||||
if(lacing_storage<=lacing_fill+needed)
|
||||
{
|
||||
lacing_storage+=(needed+32);
|
||||
int[] foo=new int[lacing_storage];
|
||||
Array.Copy(lacing_vals, 0, foo, 0, lacing_vals.Length);
|
||||
lacing_vals=foo;
|
||||
|
||||
long[] bar=new long[lacing_storage];
|
||||
Array.Copy(granule_vals, 0, bar, 0, granule_vals.Length);
|
||||
granule_vals=bar;
|
||||
}
|
||||
}
|
||||
|
||||
/* submit data to the internal buffer of the framing engine */
|
||||
public int packetin(Packet op)
|
||||
{
|
||||
int lacing_val=op.bytes/255+1;
|
||||
|
||||
if(body_returned!=0)
|
||||
{
|
||||
/* advance packet data according to the body_returned pointer. We
|
||||
had to keep it around to return a pointer into the buffer last
|
||||
call */
|
||||
|
||||
body_fill-=body_returned;
|
||||
if(body_fill!=0)
|
||||
{
|
||||
Array.Copy(body_data, body_returned, body_data, 0, body_fill);
|
||||
}
|
||||
body_returned=0;
|
||||
}
|
||||
|
||||
/* make sure we have the buffer storage */
|
||||
body_expand(op.bytes);
|
||||
lacing_expand(lacing_val);
|
||||
|
||||
/* Copy in the submitted packet. Yes, the copy is a waste; this is
|
||||
the liability of overly clean abstraction for the time being. It
|
||||
will actually be fairly easy to eliminate the extra copy in the
|
||||
future */
|
||||
|
||||
Array.Copy(op.packet_base, op.packet, body_data, body_fill, op.bytes);
|
||||
body_fill+=op.bytes;
|
||||
//System.out.println("add: "+body_fill);
|
||||
|
||||
/* Store lacing vals for this packet */
|
||||
int j;
|
||||
for(j=0;j<lacing_val-1;j++)
|
||||
{
|
||||
lacing_vals[lacing_fill+j]=255;
|
||||
granule_vals[lacing_fill+j]=granulepos;
|
||||
}
|
||||
lacing_vals[lacing_fill+j]=(op.bytes)%255;
|
||||
granulepos=granule_vals[lacing_fill+j]=op.granulepos;
|
||||
|
||||
/* flag the first segment as the beginning of the packet */
|
||||
lacing_vals[lacing_fill]|= 0x100;
|
||||
|
||||
lacing_fill+=lacing_val;
|
||||
|
||||
/* for the sake of completeness */
|
||||
packetno++;
|
||||
|
||||
if(op.e_o_s!=0)e_o_s=1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
public int packetout(Packet op)
|
||||
{
|
||||
|
||||
/* The last part of decode. We have the stream broken into packet
|
||||
segments. Now we need to group them into packets (or return the
|
||||
out of sync markers) */
|
||||
|
||||
int ptr=lacing_returned;
|
||||
|
||||
if(lacing_packet<=ptr)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
if((lacing_vals[ptr]&0x400)!=0)
|
||||
{
|
||||
/* We lost sync here; let the app know */
|
||||
lacing_returned++;
|
||||
|
||||
/* we need to tell the codec there's a gap; it might need to
|
||||
handle previous packet dependencies. */
|
||||
packetno++;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Gather the whole packet. We'll have no holes or a partial packet */
|
||||
{
|
||||
int size=lacing_vals[ptr]&0xff;
|
||||
int bytes=0;
|
||||
|
||||
op.packet_base=body_data;
|
||||
op.packet=body_returned;
|
||||
op.e_o_s=lacing_vals[ptr]&0x200; /* last packet of the stream? */
|
||||
op.b_o_s=lacing_vals[ptr]&0x100; /* first packet of the stream? */
|
||||
bytes+=size;
|
||||
|
||||
while(size==255)
|
||||
{
|
||||
int val=lacing_vals[++ptr];
|
||||
size=val&0xff;
|
||||
if((val&0x200)!=0)op.e_o_s=0x200;
|
||||
bytes+=size;
|
||||
}
|
||||
|
||||
op.packetno=packetno;
|
||||
op.granulepos=granule_vals[ptr];
|
||||
op.bytes=bytes;
|
||||
|
||||
//System.out.println(this+" # body_returned="+body_returned);
|
||||
body_returned+=bytes;
|
||||
//System.out.println(this+"## body_returned="+body_returned);
|
||||
|
||||
lacing_returned=ptr+1;
|
||||
}
|
||||
packetno++;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
// add the incoming page to the stream state; we decompose the page
|
||||
// into packet segments here as well.
|
||||
|
||||
public int pagein(Page og)
|
||||
{
|
||||
byte[] header_base=og.header_base;
|
||||
int header=og.header;
|
||||
byte[] body_base=og.body_base;
|
||||
int body=og.body;
|
||||
int bodysize=og.body_len;
|
||||
int segptr=0;
|
||||
|
||||
int version=og.version();
|
||||
int continued=og.continued();
|
||||
int bos=og.bos();
|
||||
int eos=og.eos();
|
||||
long granulepos=og.granulepos();
|
||||
int _serialno=og.serialno();
|
||||
int _pageno=og.pageno();
|
||||
int segments=header_base[header+26]&0xff;
|
||||
|
||||
// clean up 'returned data'
|
||||
{
|
||||
int lr=lacing_returned;
|
||||
int br=body_returned;
|
||||
|
||||
// body data
|
||||
|
||||
//System.out.println("br="+br+", body_fill="+body_fill);
|
||||
|
||||
if(br!=0)
|
||||
{
|
||||
body_fill-=br;
|
||||
if(body_fill!=0)
|
||||
{
|
||||
Array.Copy(body_data, br, body_data, 0, body_fill);
|
||||
}
|
||||
body_returned=0;
|
||||
}
|
||||
|
||||
//System.out.println("?? br="+br+", body_fill="+body_fill+" body_returned="+body_returned);
|
||||
|
||||
if(lr!=0)
|
||||
{
|
||||
// segment table
|
||||
if((lacing_fill-lr)!=0)
|
||||
{
|
||||
Array.Copy(lacing_vals, lr, lacing_vals, 0, lacing_fill-lr);
|
||||
Array.Copy(granule_vals, lr, granule_vals, 0, lacing_fill-lr);
|
||||
}
|
||||
lacing_fill-=lr;
|
||||
lacing_packet-=lr;
|
||||
lacing_returned=0;
|
||||
}
|
||||
}
|
||||
|
||||
// check the serial number
|
||||
if(_serialno!=serialno)return(-1);
|
||||
if(version>0)return(-1);
|
||||
|
||||
lacing_expand(segments+1);
|
||||
|
||||
// are we in sequence?
|
||||
if(_pageno!=pageno)
|
||||
{
|
||||
int i;
|
||||
|
||||
// unroll previous partial packet (if any)
|
||||
for(i=lacing_packet;i<lacing_fill;i++)
|
||||
{
|
||||
body_fill-=lacing_vals[i]&0xff;
|
||||
//System.out.println("??");
|
||||
}
|
||||
lacing_fill=lacing_packet;
|
||||
|
||||
// make a note of dropped data in segment table
|
||||
if(pageno!=-1)
|
||||
{
|
||||
lacing_vals[lacing_fill++]=0x400;
|
||||
lacing_packet++;
|
||||
}
|
||||
|
||||
// are we a 'continued packet' page? If so, we'll need to skip
|
||||
// some segments
|
||||
if(continued!=0)
|
||||
{
|
||||
bos=0;
|
||||
for(;segptr<segments;segptr++)
|
||||
{
|
||||
int val=(header_base[header+27+segptr]&0xff);
|
||||
body+=val;
|
||||
bodysize-=val;
|
||||
if(val<255)
|
||||
{
|
||||
segptr++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//System.out.println("bodysize="+bodysize);
|
||||
|
||||
if(bodysize!=0)
|
||||
{
|
||||
body_expand(bodysize);
|
||||
Array.Copy(body_base, body, body_data, body_fill, bodysize);
|
||||
body_fill+=bodysize;
|
||||
}
|
||||
|
||||
//System.out.println("bodyfill="+body_fill);
|
||||
|
||||
{
|
||||
int saved=-1;
|
||||
while(segptr<segments)
|
||||
{
|
||||
int val=(header_base[header+27+segptr]&0xff);
|
||||
lacing_vals[lacing_fill]=val;
|
||||
granule_vals[lacing_fill]=-1;
|
||||
|
||||
if(bos!=0)
|
||||
{
|
||||
lacing_vals[lacing_fill]|=0x100;
|
||||
bos=0;
|
||||
}
|
||||
|
||||
if(val<255)saved=lacing_fill;
|
||||
|
||||
lacing_fill++;
|
||||
segptr++;
|
||||
|
||||
if(val<255)lacing_packet=lacing_fill;
|
||||
}
|
||||
|
||||
/* set the granulepos on the last pcmval of the last full packet */
|
||||
if(saved!=-1)
|
||||
{
|
||||
granule_vals[saved]=granulepos;
|
||||
}
|
||||
}
|
||||
|
||||
if(eos!=0)
|
||||
{
|
||||
e_o_s=1;
|
||||
if(lacing_fill>0)
|
||||
lacing_vals[lacing_fill-1]|=0x200;
|
||||
}
|
||||
|
||||
pageno=_pageno+1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* This will flush remaining packets into a page (returning nonzero),
|
||||
even if there is not enough data to trigger a flush normally
|
||||
(undersized page). If there are no packets or partial packets to
|
||||
flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will
|
||||
try to flush a normal sized page like ogg_stream_pageout; a call to
|
||||
ogg_stream_flush does not gurantee that all packets have flushed.
|
||||
Only a return value of 0 from ogg_stream_flush indicates all packet
|
||||
data is flushed into pages.
|
||||
|
||||
ogg_stream_page will flush the last page in a stream even if it's
|
||||
undersized; you almost certainly want to use ogg_stream_pageout
|
||||
(and *not* ogg_stream_flush) unless you need to flush an undersized
|
||||
page in the middle of a stream for some reason. */
|
||||
|
||||
public int flush(Page og)
|
||||
{
|
||||
|
||||
//System.out.println(this+" ---body_returned: "+body_returned);
|
||||
|
||||
int i;
|
||||
int vals=0;
|
||||
int maxvals=(lacing_fill>255?255:lacing_fill);
|
||||
int bytes=0;
|
||||
int acc=0;
|
||||
long granule_pos=granule_vals[0];
|
||||
|
||||
if(maxvals==0)return(0);
|
||||
|
||||
/* construct a page */
|
||||
/* decide how many segments to include */
|
||||
|
||||
/* If this is the initial header case, the first page must only include
|
||||
the initial header packet */
|
||||
if(b_o_s==0)
|
||||
{ /* 'initial header page' case */
|
||||
granule_pos=0;
|
||||
for(vals=0;vals<maxvals;vals++)
|
||||
{
|
||||
if((lacing_vals[vals]&0x0ff)<255)
|
||||
{
|
||||
vals++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(vals=0;vals<maxvals;vals++)
|
||||
{
|
||||
if(acc>4096)break;
|
||||
acc+=(lacing_vals[vals]&0x0ff);
|
||||
granule_pos=granule_vals[vals];
|
||||
}
|
||||
}
|
||||
|
||||
/* construct the header in temp storage */
|
||||
|
||||
String oggs_str = "OggS";
|
||||
Encoding AE = Encoding.UTF8;
|
||||
byte[] oggs_byt = AE.GetBytes(oggs_str);
|
||||
Array.Copy(oggs_byt, 0, header, 0, oggs_byt.Length);
|
||||
|
||||
/* stream structure version */
|
||||
header[4]=0x00;
|
||||
|
||||
/* continued packet flag? */
|
||||
header[5]=0x00;
|
||||
if((lacing_vals[0]&0x100)==0)header[5]|=0x01;
|
||||
/* first page flag? */
|
||||
if(b_o_s==0) header[5]|=0x02;
|
||||
/* last page flag? */
|
||||
if(e_o_s!=0 && lacing_fill==vals) header[5]|=0x04;
|
||||
b_o_s=1;
|
||||
|
||||
/* 64 bits of PCM position */
|
||||
for(i=6;i<14;i++)
|
||||
{
|
||||
header[i]=(byte)granule_pos;
|
||||
granule_pos>>=8;
|
||||
}
|
||||
|
||||
/* 32 bits of stream serial number */
|
||||
{
|
||||
int _serialno=serialno;
|
||||
for(i=14;i<18;i++)
|
||||
{
|
||||
header[i]=(byte)_serialno;
|
||||
_serialno>>=8;
|
||||
}
|
||||
}
|
||||
|
||||
/* 32 bits of page counter (we have both counter and page header
|
||||
because this val can roll over) */
|
||||
if(pageno==-1)pageno=0; /* because someone called
|
||||
stream_reset; this would be a
|
||||
strange thing to do in an
|
||||
encode stream, but it has
|
||||
plausible uses */
|
||||
{
|
||||
int _pageno=pageno++;
|
||||
for(i=18;i<22;i++)
|
||||
{
|
||||
header[i]=(byte)_pageno;
|
||||
_pageno>>=8;
|
||||
}
|
||||
}
|
||||
|
||||
/* zero for computation; filled in later */
|
||||
header[22]=0;
|
||||
header[23]=0;
|
||||
header[24]=0;
|
||||
header[25]=0;
|
||||
|
||||
/* segment table */
|
||||
header[26]=(byte)vals;
|
||||
for(i=0;i<vals;i++)
|
||||
{
|
||||
header[i+27]=(byte)lacing_vals[i];
|
||||
bytes+=(header[i+27]&0xff);
|
||||
}
|
||||
|
||||
/* set pointers in the ogg_page struct */
|
||||
og.header_base=header;
|
||||
og.header=0;
|
||||
og.header_len=header_fill=vals+27;
|
||||
og.body_base=body_data;
|
||||
og.body=body_returned;
|
||||
og.body_len=bytes;
|
||||
|
||||
/* advance the lacing data and set the body_returned pointer */
|
||||
|
||||
lacing_fill-=vals;
|
||||
Array.Copy(lacing_vals, vals, lacing_vals, 0, lacing_fill*4);
|
||||
Array.Copy(granule_vals, vals, granule_vals, 0, lacing_fill*8);
|
||||
body_returned+=bytes;
|
||||
|
||||
/* calculate the checksum */
|
||||
|
||||
og.checksum();
|
||||
|
||||
/* done */
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* This constructs pages from buffered packet segments. The pointers
|
||||
returned are to static buffers; do not free. The returned buffers are
|
||||
good only until the next call (using the same ogg_stream_state) */
|
||||
public int pageout(Page og)
|
||||
{
|
||||
if((e_o_s!=0&&lacing_fill!=0) || /* 'were done, now flush' case */
|
||||
body_fill-body_returned> 4096 || /* 'page nominal size' case */
|
||||
lacing_fill>=255 || /* 'segment table full' case */
|
||||
(lacing_fill!=0&&b_o_s==0))
|
||||
{ /* 'initial header page' case */
|
||||
return flush(og);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int eof()
|
||||
{
|
||||
return e_o_s;
|
||||
}
|
||||
|
||||
public int reset()
|
||||
{
|
||||
body_fill=0;
|
||||
body_returned=0;
|
||||
|
||||
lacing_fill=0;
|
||||
lacing_packet=0;
|
||||
lacing_returned=0;
|
||||
|
||||
header_fill=0;
|
||||
|
||||
e_o_s=0;
|
||||
b_o_s=0;
|
||||
pageno=-1;
|
||||
packetno=0;
|
||||
granulepos=0;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
289
Support/OggUtils/csogg/SyncState.cs
Normal file
289
Support/OggUtils/csogg/SyncState.cs
Normal file
@ -0,0 +1,289 @@
|
||||
/* csogg
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace csogg
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for SyncState.
|
||||
/// </summary>
|
||||
public class SyncState
|
||||
{
|
||||
public byte[] data;
|
||||
int storage;
|
||||
int fill;
|
||||
int returned;
|
||||
|
||||
int unsynced;
|
||||
int headerbytes;
|
||||
int bodybytes;
|
||||
|
||||
public int clear()
|
||||
{
|
||||
data=null;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// !!!!!!!!!!!!
|
||||
// byte[] buffer(int size){
|
||||
public int buffer(int size)
|
||||
{
|
||||
// first, clear out any space that has been previously returned
|
||||
if(returned!=0)
|
||||
{
|
||||
fill-=returned;
|
||||
if(fill>0)
|
||||
{
|
||||
Array.Copy(data, returned, data, 0, fill);
|
||||
}
|
||||
returned=0;
|
||||
}
|
||||
|
||||
if(size>storage-fill)
|
||||
{
|
||||
// We need to extend the internal buffer
|
||||
int newsize=size+fill+4096; // an extra page to be nice
|
||||
if(data!=null)
|
||||
{
|
||||
byte[] foo=new byte[newsize];
|
||||
Array.Copy(data, 0, foo, 0, data.Length);
|
||||
data=foo;
|
||||
}
|
||||
else
|
||||
{
|
||||
data=new byte[newsize];
|
||||
}
|
||||
storage=newsize;
|
||||
}
|
||||
|
||||
// expose a segment at least as large as requested at the fill mark
|
||||
// return((char *)oy->data+oy->fill);
|
||||
// return(data);
|
||||
return(fill);
|
||||
}
|
||||
|
||||
public int wrote(int bytes)
|
||||
{
|
||||
if(fill+bytes>storage)return(-1);
|
||||
fill+=bytes;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// sync the stream. This is meant to be useful for finding page
|
||||
// boundaries.
|
||||
//
|
||||
// return values for this:
|
||||
// -n) skipped n bytes
|
||||
// 0) page not ready; more data (no bytes skipped)
|
||||
// n) page synced at current location; page length n bytes
|
||||
private Page pageseek_p=new Page();
|
||||
private byte[] chksum=new byte[4];
|
||||
public int pageseek(Page og)
|
||||
{
|
||||
int page=returned;
|
||||
int next;
|
||||
int bytes=fill-returned;
|
||||
|
||||
if(headerbytes==0)
|
||||
{
|
||||
int _headerbytes,i;
|
||||
if(bytes<27)return(0); // not enough for a header
|
||||
|
||||
/* verify capture pattern */
|
||||
//!!!!!!!!!!!
|
||||
if(data[page]!='O' ||
|
||||
data[page+1]!='g' ||
|
||||
data[page+2]!='g' ||
|
||||
data[page+3]!='S')
|
||||
{
|
||||
headerbytes=0;
|
||||
bodybytes=0;
|
||||
|
||||
// search for possible capture
|
||||
next=0;
|
||||
for(int ii=0; ii<bytes-1; ii++)
|
||||
{
|
||||
if(data[page+1+ii]=='O'){next=page+1+ii; break;}
|
||||
}
|
||||
//next=memchr(page+1,'O',bytes-1);
|
||||
if(next==0) next=fill;
|
||||
|
||||
returned=next;
|
||||
return(-(next-page));
|
||||
}
|
||||
_headerbytes=(data[page+26]&0xff)+27;
|
||||
if(bytes<_headerbytes)return(0); // not enough for header + seg table
|
||||
|
||||
// count up body length in the segment table
|
||||
|
||||
for(i=0;i<(data[page+26]&0xff);i++)
|
||||
{
|
||||
bodybytes+=(data[page+27+i]&0xff);
|
||||
}
|
||||
headerbytes=_headerbytes;
|
||||
}
|
||||
|
||||
if(bodybytes+headerbytes>bytes)return(0);
|
||||
|
||||
// The whole test page is buffered. Verify the checksum
|
||||
lock(chksum)
|
||||
{
|
||||
// Grab the checksum bytes, set the header field to zero
|
||||
|
||||
Array.Copy(data, page+22, chksum, 0, 4);
|
||||
data[page+22]=0;
|
||||
data[page+23]=0;
|
||||
data[page+24]=0;
|
||||
data[page+25]=0;
|
||||
|
||||
// set up a temp page struct and recompute the checksum
|
||||
Page log=pageseek_p;
|
||||
log.header_base=data;
|
||||
log.header=page;
|
||||
log.header_len=headerbytes;
|
||||
|
||||
log.body_base=data;
|
||||
log.body=page+headerbytes;
|
||||
log.body_len=bodybytes;
|
||||
log.checksum();
|
||||
|
||||
// Compare
|
||||
if(chksum[0]!=data[page+22] ||
|
||||
chksum[1]!=data[page+23] ||
|
||||
chksum[2]!=data[page+24] ||
|
||||
chksum[3]!=data[page+25])
|
||||
{
|
||||
// D'oh. Mismatch! Corrupt page (or miscapture and not a page at all)
|
||||
// replace the computed checksum with the one actually read in
|
||||
Array.Copy(chksum, 0, data, page+22, 4);
|
||||
// Bad checksum. Lose sync */
|
||||
|
||||
headerbytes=0;
|
||||
bodybytes=0;
|
||||
// search for possible capture
|
||||
next=0;
|
||||
for(int ii=0; ii<bytes-1; ii++)
|
||||
{
|
||||
if(data[page+1+ii]=='O'){next=page+1+ii; break;}
|
||||
}
|
||||
//next=memchr(page+1,'O',bytes-1);
|
||||
if(next==0) next=fill;
|
||||
returned=next;
|
||||
return(-(next-page));
|
||||
}
|
||||
}
|
||||
|
||||
// yes, have a whole page all ready to go
|
||||
{
|
||||
page=returned;
|
||||
|
||||
if(og!=null)
|
||||
{
|
||||
og.header_base=data;
|
||||
og.header=page;
|
||||
og.header_len=headerbytes;
|
||||
og.body_base=data;
|
||||
og.body=page+headerbytes;
|
||||
og.body_len=bodybytes;
|
||||
}
|
||||
|
||||
unsynced=0;
|
||||
returned+=(bytes=headerbytes+bodybytes);
|
||||
headerbytes=0;
|
||||
bodybytes=0;
|
||||
return(bytes);
|
||||
}
|
||||
// headerbytes=0;
|
||||
// bodybytes=0;
|
||||
// next=0;
|
||||
// for(int ii=0; ii<bytes-1; ii++){
|
||||
// if(data[page+1+ii]=='O'){next=page+1+ii;}
|
||||
// }
|
||||
// //next=memchr(page+1,'O',bytes-1);
|
||||
// if(next==0) next=fill;
|
||||
// returned=next;
|
||||
// return(-(next-page));
|
||||
}
|
||||
|
||||
|
||||
// sync the stream and get a page. Keep trying until we find a page.
|
||||
// Supress 'sync errors' after reporting the first.
|
||||
//
|
||||
// return values:
|
||||
// -1) recapture (hole in data)
|
||||
// 0) need more data
|
||||
// 1) page returned
|
||||
//
|
||||
// Returns pointers into buffered data; invalidated by next call to
|
||||
// _stream, _clear, _init, or _buffer
|
||||
|
||||
public int pageout(Page og)
|
||||
{
|
||||
// all we need to do is verify a page at the head of the stream
|
||||
// buffer. If it doesn't verify, we look for the next potential
|
||||
// frame
|
||||
|
||||
while(true)
|
||||
{
|
||||
int ret=pageseek(og);
|
||||
if(ret>0)
|
||||
{
|
||||
// have a page
|
||||
return(1);
|
||||
}
|
||||
if(ret==0)
|
||||
{
|
||||
// need more data
|
||||
return(0);
|
||||
}
|
||||
|
||||
// head did not start a synced page... skipped some bytes
|
||||
if(unsynced==0)
|
||||
{
|
||||
unsynced=1;
|
||||
return(-1);
|
||||
}
|
||||
// loop. keep looking
|
||||
}
|
||||
}
|
||||
|
||||
// clear things to an initial state. Good to call, eg, before seeking
|
||||
public int reset()
|
||||
{
|
||||
fill=0;
|
||||
returned=0;
|
||||
unsynced=0;
|
||||
headerbytes=0;
|
||||
bodybytes=0;
|
||||
return(0);
|
||||
}
|
||||
public void init(){}
|
||||
|
||||
public SyncState()
|
||||
{
|
||||
// No constructor needed
|
||||
}
|
||||
}
|
||||
}
|
36
Support/OggUtils/csvorbis/AllocChain.cs
Normal file
36
Support/OggUtils/csvorbis/AllocChain.cs
Normal file
@ -0,0 +1,36 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* So, again, why is this here? Kill it soon */
|
||||
|
||||
using System;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class AllocChain
|
||||
{
|
||||
//Object ptr;
|
||||
//AllocChain next;
|
||||
};
|
||||
}
|
205
Support/OggUtils/csvorbis/Block.cs
Normal file
205
Support/OggUtils/csvorbis/Block.cs
Normal file
@ -0,0 +1,205 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
public class Block
|
||||
{
|
||||
///necessary stream state for linking to the framing abstraction
|
||||
internal float[][] pcm=new float[0][]; // this is a pointer into local storage
|
||||
internal csBuffer opb=new csBuffer();
|
||||
|
||||
internal int lW;
|
||||
internal int W;
|
||||
internal int nW;
|
||||
internal int pcmend;
|
||||
internal int mode;
|
||||
|
||||
internal int eofflag;
|
||||
internal long granulepos;
|
||||
internal long sequence;
|
||||
internal DspState vd; // For read-only access of configuration
|
||||
|
||||
// local storage to avoid remallocing; it's up to the mapping to
|
||||
// structure it
|
||||
//byte[] localstore;
|
||||
//int localtop;
|
||||
//int localalloc;
|
||||
//int totaluse;
|
||||
//AllocChain reap;
|
||||
|
||||
// bitmetrics for the frame
|
||||
internal int glue_bits;
|
||||
internal int time_bits;
|
||||
internal int floor_bits;
|
||||
internal int res_bits;
|
||||
|
||||
public Block(DspState vd)
|
||||
{
|
||||
this.vd=vd;
|
||||
// localalloc=0;
|
||||
// localstore=null;
|
||||
if(vd.analysisp!=0)
|
||||
{
|
||||
opb.writeinit();
|
||||
}
|
||||
}
|
||||
|
||||
public void init(DspState vd)
|
||||
{
|
||||
this.vd=vd;
|
||||
}
|
||||
|
||||
// int alloc(int bytes){
|
||||
// bytes=(bytes+(8-1))&(~(8-1));
|
||||
// if(bytes+localtop>localalloc){
|
||||
// if(localstore!=null){
|
||||
// AllocChain link=new AllocChain();
|
||||
// totaluse+=localtop;
|
||||
// link.next=reap;
|
||||
// link.ptr=localstore;
|
||||
// reap=link;
|
||||
// }
|
||||
// // highly conservative
|
||||
// localalloc=bytes;
|
||||
// localstore=new byte[localalloc];
|
||||
// localtop=0;
|
||||
// }
|
||||
// {
|
||||
// int foo=localtop;
|
||||
// //void *ret=(void *)(((char *)vb->localstore)+vb->localtop);
|
||||
// localtop+=bytes;
|
||||
// return foo;
|
||||
// }
|
||||
// }
|
||||
|
||||
// reap the chain, pull the ripcord
|
||||
// void ripcord(){
|
||||
// // reap the chain
|
||||
// while(reap!=null){
|
||||
// AllocChain next=reap.next;
|
||||
// //free(reap->ptr);
|
||||
// reap.ptr=null;
|
||||
// //memset(reap,0,sizeof(struct alloc_chain));
|
||||
// //free(reap);
|
||||
// reap=next;
|
||||
// }
|
||||
// // consolidate storage
|
||||
// if(totaluse!=0){
|
||||
// //vb->localstore=realloc(vb->localstore,vb->totaluse+vb->localalloc);
|
||||
// byte[] foo=new byte[totaluse+localalloc];
|
||||
// Array.Copy(localstore, 0, foo, 0, localstore.length);
|
||||
// localstore=foo;
|
||||
// localalloc+=totaluse;
|
||||
// totaluse=0;
|
||||
// }
|
||||
// // pull the ripcord
|
||||
// localtop=0;
|
||||
// reap=null;
|
||||
// }
|
||||
|
||||
public int clear()
|
||||
{
|
||||
if(vd!=null)
|
||||
{
|
||||
if(vd.analysisp!=0)
|
||||
{
|
||||
opb.writeclear();
|
||||
}
|
||||
}
|
||||
//ripcord();
|
||||
//if(localstore!=null)
|
||||
// localstore=null;
|
||||
//memset(vb,0,sizeof(vorbis_block));
|
||||
return(0);
|
||||
}
|
||||
|
||||
public int synthesis(Packet op)
|
||||
{
|
||||
Info vi=vd.vi;
|
||||
|
||||
// first things first. Make sure decode is ready
|
||||
// ripcord();
|
||||
opb.readinit(op.packet_base, op.packet, op.bytes);
|
||||
|
||||
// Check the packet type
|
||||
if(opb.read(1)!=0)
|
||||
{
|
||||
// Oops. This is not an audio data packet
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// read our mode and pre/post windowsize
|
||||
int _mode=opb.read(vd.modebits);
|
||||
if(_mode==-1)return(-1);
|
||||
|
||||
mode=_mode;
|
||||
W=vi.mode_param[mode].blockflag;
|
||||
if(W!=0)
|
||||
{
|
||||
lW=opb.read(1);
|
||||
nW=opb.read(1);
|
||||
if(nW==-1) return(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
lW=0;
|
||||
nW=0;
|
||||
}
|
||||
|
||||
// more setup
|
||||
granulepos=op.granulepos;
|
||||
sequence=op.packetno-3; // first block is third packet
|
||||
eofflag=op.e_o_s;
|
||||
|
||||
// alloc pcm passback storage
|
||||
pcmend=vi.blocksizes[W];
|
||||
//pcm=alloc(vi.channels);
|
||||
if(pcm.Length<vi.channels)
|
||||
{
|
||||
pcm=new float[vi.channels][];
|
||||
}
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
if(pcm[i]==null || pcm[i].Length<pcmend)
|
||||
{
|
||||
pcm[i]=new float[pcmend];
|
||||
//pcm[i]=alloc(pcmend);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int j=0;j<pcmend;j++){ pcm[i][j]=0; }
|
||||
}
|
||||
}
|
||||
|
||||
// unpack_header enforces range checking
|
||||
int type=vi.map_type[vi.mode_param[mode].mapping];
|
||||
return(FuncMapping.mapping_P[type].inverse(this, vd.mode[mode]));
|
||||
}
|
||||
}
|
||||
}
|
627
Support/OggUtils/csvorbis/CodeBook.cs
Normal file
627
Support/OggUtils/csvorbis/CodeBook.cs
Normal file
@ -0,0 +1,627 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class CodeBook
|
||||
{
|
||||
internal int dim; // codebook dimensions (elements per vector)
|
||||
internal int entries; // codebook entries
|
||||
internal StaticCodeBook c=new StaticCodeBook();
|
||||
|
||||
internal float[] valuelist; // list of dim*entries actual entry values
|
||||
internal int[] codelist; // list of bitstream codewords for each entry
|
||||
internal DecodeAux decode_tree;
|
||||
|
||||
// returns the number of bits
|
||||
internal int encode(int a, csBuffer b)
|
||||
{
|
||||
b.write(codelist[a], c.lengthlist[a]);
|
||||
return(c.lengthlist[a]);
|
||||
}
|
||||
|
||||
// One the encode side, our vector writers are each designed for a
|
||||
// specific purpose, and the encoder is not flexible without modification:
|
||||
//
|
||||
// The LSP vector coder uses a single stage nearest-match with no
|
||||
// interleave, so no step and no error return. This is specced by floor0
|
||||
// and doesn't change.
|
||||
//
|
||||
// Residue0 encoding interleaves, uses multiple stages, and each stage
|
||||
// peels of a specific amount of resolution from a lattice (thus we want
|
||||
// to match by threshhold, not nearest match). Residue doesn't *have* to
|
||||
// be encoded that way, but to change it, one will need to add more
|
||||
// infrastructure on the encode side (decode side is specced and simpler)
|
||||
|
||||
// floor0 LSP (single stage, non interleaved, nearest match)
|
||||
// returns entry number and *modifies a* to the quantization value
|
||||
internal int errorv(float[] a)
|
||||
{
|
||||
int bestt=best(a,1);
|
||||
for(int k=0;k<dim;k++)
|
||||
{
|
||||
a[k]=valuelist[bestt*dim+k];
|
||||
}
|
||||
return(bestt);
|
||||
}
|
||||
|
||||
// returns the number of bits and *modifies a* to the quantization value
|
||||
internal int encodev(int best, float[] a, csBuffer b)
|
||||
{
|
||||
for(int k=0;k<dim;k++)
|
||||
{
|
||||
a[k]=valuelist[best*dim+k];
|
||||
}
|
||||
return(encode(best,b));
|
||||
}
|
||||
|
||||
// res0 (multistage, interleave, lattice)
|
||||
// returns the number of bits and *modifies a* to the remainder value
|
||||
internal int encodevs(float[] a, csBuffer b, int step,int addmul)
|
||||
{
|
||||
int best=besterror(a,step,addmul);
|
||||
return(encode(best,b));
|
||||
}
|
||||
|
||||
internal int[] t=new int[15]; // decodevs_add is synchronized for re-using t.
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
internal int decodevs_add(float[]a, int offset, csBuffer b, int n)
|
||||
{
|
||||
int step=n/dim;
|
||||
int entry;
|
||||
int i,j,o;
|
||||
|
||||
if(t.Length<step)
|
||||
{
|
||||
t=new int[step];
|
||||
}
|
||||
|
||||
for(i = 0; i < step; i++)
|
||||
{
|
||||
entry=decode(b);
|
||||
if(entry==-1)return(-1);
|
||||
t[i]=entry*dim;
|
||||
}
|
||||
for(i=0,o=0;i<dim;i++,o+=step)
|
||||
{
|
||||
for(j=0;j<step;j++)
|
||||
{
|
||||
a[offset+o+j]+=valuelist[t[j]+i];
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
internal int decodev_add(float[]a, int offset, csBuffer b,int n)
|
||||
{
|
||||
int i,j,k,entry;
|
||||
int t;
|
||||
|
||||
if(dim>8)
|
||||
{
|
||||
for(i=0;i<n;)
|
||||
{
|
||||
entry = decode(b);
|
||||
if(entry==-1)return(-1);
|
||||
t=entry*dim;
|
||||
for(j=0;j<dim;)
|
||||
{
|
||||
a[offset+(i++)]+=valuelist[t+(j++)];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<n;)
|
||||
{
|
||||
entry=decode(b);
|
||||
if(entry==-1)return(-1);
|
||||
t=entry*dim;
|
||||
j=0;
|
||||
for(k=0; k < dim; k++)
|
||||
{
|
||||
a[offset+(i++)]+=valuelist[t+(j++)];
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
internal int decodev_set(float[] a,int offset, csBuffer b, int n)
|
||||
{
|
||||
int i,j,entry;
|
||||
int t;
|
||||
|
||||
for(i=0;i<n;)
|
||||
{
|
||||
entry = decode(b);
|
||||
if(entry==-1)return(-1);
|
||||
t=entry*dim;
|
||||
for(j=0;j<dim;)
|
||||
{
|
||||
a[offset+i++]=valuelist[t+(j++)];
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
internal int decodevv_add(float[][] a, int offset,int ch, csBuffer b,int n)
|
||||
{
|
||||
int i,j,entry;
|
||||
int chptr=0;
|
||||
//System.out.println("decodevv_add: a="+a+",b="+b+",valuelist="+valuelist);
|
||||
|
||||
for(i=offset/ch;i<(offset+n)/ch;)
|
||||
{
|
||||
entry = decode(b);
|
||||
if(entry==-1)return(-1);
|
||||
|
||||
int t = entry*dim;
|
||||
for(j=0;j<dim;j++)
|
||||
{
|
||||
a[chptr][i]+=valuelist[t+j];
|
||||
chptr++;
|
||||
if(chptr==ch)
|
||||
{
|
||||
chptr=0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// Decode side is specced and easier, because we don't need to find
|
||||
// matches using different criteria; we simply read and map. There are
|
||||
// two things we need to do 'depending':
|
||||
//
|
||||
// We may need to support interleave. We don't really, but it's
|
||||
// convenient to do it here rather than rebuild the vector later.
|
||||
//
|
||||
// Cascades may be additive or multiplicitive; this is not inherent in
|
||||
// the codebook, but set in the code using the codebook. Like
|
||||
// interleaving, it's easiest to do it here.
|
||||
// stage==0 -> declarative (set the value)
|
||||
// stage==1 -> additive
|
||||
// stage==2 -> multiplicitive
|
||||
|
||||
// returns the entry number or -1 on eof
|
||||
internal int decode(csBuffer b)
|
||||
{
|
||||
int ptr=0;
|
||||
DecodeAux t=decode_tree;
|
||||
int lok=b.look(t.tabn);
|
||||
//System.err.println(this+" "+t+" lok="+lok+", tabn="+t.tabn);
|
||||
|
||||
if(lok>=0)
|
||||
{
|
||||
ptr=t.tab[lok];
|
||||
b.adv(t.tabl[lok]);
|
||||
if(ptr<=0)
|
||||
{
|
||||
return -ptr;
|
||||
}
|
||||
}
|
||||
do
|
||||
{
|
||||
switch(b.read1())
|
||||
{
|
||||
case 0:
|
||||
ptr=t.ptr0[ptr];
|
||||
break;
|
||||
case 1:
|
||||
ptr=t.ptr1[ptr];
|
||||
break;
|
||||
case -1:
|
||||
default:
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
while(ptr>0);
|
||||
return(-ptr);
|
||||
}
|
||||
|
||||
// returns the entry number or -1 on eof
|
||||
internal int decodevs(float[] a, int index, csBuffer b, int step,int addmul)
|
||||
{
|
||||
int entry=decode(b);
|
||||
if(entry==-1)return(-1);
|
||||
switch(addmul)
|
||||
{
|
||||
case -1:
|
||||
for(int i=0,o=0;i<dim;i++,o+=step)
|
||||
a[index+o]=valuelist[entry*dim+i];
|
||||
break;
|
||||
case 0:
|
||||
for(int i=0,o=0;i<dim;i++,o+=step)
|
||||
a[index+o]+=valuelist[entry*dim+i];
|
||||
break;
|
||||
case 1:
|
||||
for(int i=0,o=0;i<dim;i++,o+=step)
|
||||
a[index+o]*=valuelist[entry*dim+i];
|
||||
break;
|
||||
default:
|
||||
//nothing
|
||||
break;
|
||||
}
|
||||
return(entry);
|
||||
}
|
||||
|
||||
internal int best(float[] a, int step)
|
||||
{
|
||||
EncodeAuxNearestMatch nt=c.nearest_tree;
|
||||
EncodeAuxThreshMatch tt=c.thresh_tree;
|
||||
int ptr=0;
|
||||
|
||||
// we assume for now that a thresh tree is the only other possibility
|
||||
if(tt!=null)
|
||||
{
|
||||
int index=0;
|
||||
// find the quant val of each scalar
|
||||
for(int k=0,o=step*(dim-1);k<dim;k++,o-=step)
|
||||
{
|
||||
int i;
|
||||
// linear search the quant list for now; it's small and although
|
||||
// with > 8 entries, it would be faster to bisect, this would be
|
||||
// a misplaced optimization for now
|
||||
for(i=0;i<tt.threshvals-1;i++)
|
||||
{
|
||||
if(a[o]<tt.quantthresh[i])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
index=(index*tt.quantvals)+tt.quantmap[i];
|
||||
}
|
||||
// regular lattices are easy :-)
|
||||
if(c.lengthlist[index]>0)
|
||||
{
|
||||
// is this unused? If so, we'll
|
||||
// use a decision tree after all
|
||||
// and fall through
|
||||
return(index);
|
||||
}
|
||||
}
|
||||
if(nt!=null)
|
||||
{
|
||||
// optimized using the decision tree
|
||||
while(true)
|
||||
{
|
||||
double cc=0.0;
|
||||
int p=nt.p[ptr];
|
||||
int q=nt.q[ptr];
|
||||
for(int k=0,o=0;k<dim;k++,o+=step)
|
||||
{
|
||||
cc+=(valuelist[p+k]-valuelist[q+k])*
|
||||
(a[o]-(valuelist[p+k]+valuelist[q+k])*.5);
|
||||
}
|
||||
if(cc>0.0)
|
||||
{ // in A
|
||||
ptr= -nt.ptr0[ptr];
|
||||
}
|
||||
else
|
||||
{ // in B
|
||||
ptr= -nt.ptr1[ptr];
|
||||
}
|
||||
if(ptr<=0)break;
|
||||
}
|
||||
return(-ptr);
|
||||
}
|
||||
|
||||
// brute force it!
|
||||
{
|
||||
int besti=-1;
|
||||
float best=0.0f;
|
||||
int e=0;
|
||||
for(int i=0;i<entries;i++)
|
||||
{
|
||||
if(c.lengthlist[i]>0)
|
||||
{
|
||||
float _this=dist(dim, valuelist, e, a, step);
|
||||
if(besti==-1 || _this<best)
|
||||
{
|
||||
best=_this;
|
||||
besti=i;
|
||||
}
|
||||
}
|
||||
e+=dim;
|
||||
}
|
||||
return(besti);
|
||||
}
|
||||
}
|
||||
|
||||
// returns the entry number and *modifies a* to the remainder value
|
||||
internal int besterror(float[] a, int step, int addmul)
|
||||
{
|
||||
int bestt=best(a,step);
|
||||
switch(addmul)
|
||||
{
|
||||
case 0:
|
||||
for(int i=0,o=0;i<dim;i++,o+=step)
|
||||
a[o]-=valuelist[bestt*dim+i];
|
||||
break;
|
||||
case 1:
|
||||
for(int i=0,o=0;i<dim;i++,o+=step)
|
||||
{
|
||||
float val=valuelist[bestt*dim+i];
|
||||
if(val==0)
|
||||
{
|
||||
a[o]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
a[o]/=val;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return(bestt);
|
||||
}
|
||||
|
||||
internal void clear()
|
||||
{
|
||||
// static book is not cleared; we're likely called on the lookup and
|
||||
// the static codebook belongs to the info struct
|
||||
//if(decode_tree!=null){
|
||||
// free(b->decode_tree->ptr0);
|
||||
// free(b->decode_tree->ptr1);
|
||||
// memset(b->decode_tree,0,sizeof(decode_aux));
|
||||
// free(b->decode_tree);
|
||||
//}
|
||||
//if(valuelist!=null)free(b->valuelist);
|
||||
//if(codelist!=null)free(b->codelist);
|
||||
//memset(b,0,sizeof(codebook));
|
||||
}
|
||||
|
||||
internal static float dist(int el, float[] rref, int index, float[] b, int step)
|
||||
{
|
||||
float acc=(float)0.0;
|
||||
for(int i=0; i<el; i++)
|
||||
{
|
||||
float val=(rref[index+i]-b[i*step]);
|
||||
acc+=val*val;
|
||||
}
|
||||
return(acc);
|
||||
}
|
||||
|
||||
/*
|
||||
int init_encode(StaticCodeBook s){
|
||||
//memset(c,0,sizeof(codebook));
|
||||
c=s;
|
||||
entries=s.entries;
|
||||
dim=s.dim;
|
||||
codelist=make_words(s.lengthlist, s.entries);
|
||||
valuelist=s.unquantize();
|
||||
return(0);
|
||||
}
|
||||
*/
|
||||
|
||||
internal int init_decode(StaticCodeBook s)
|
||||
{
|
||||
//memset(c,0,sizeof(codebook));
|
||||
c=s;
|
||||
entries=s.entries;
|
||||
dim=s.dim;
|
||||
valuelist=s.unquantize();
|
||||
|
||||
decode_tree=make_decode_tree();
|
||||
if(decode_tree==null)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
// err_out:
|
||||
// vorbis_book_clear(c);
|
||||
// return(-1);
|
||||
}
|
||||
|
||||
// given a list of word lengths, generate a list of codewords. Works
|
||||
// for length ordered or unordered, always assigns the lowest valued
|
||||
// codewords first. Extended to handle unused entries (length 0)
|
||||
internal static int[] make_words(int[] l, int n)
|
||||
{
|
||||
int[] marker=new int[33];
|
||||
int[] r=new int[n];
|
||||
//memset(marker,0,sizeof(marker));
|
||||
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
int length=l[i];
|
||||
if(length>0)
|
||||
{
|
||||
int entry=marker[length];
|
||||
|
||||
// when we claim a node for an entry, we also claim the nodes
|
||||
// below it (pruning off the imagined tree that may have dangled
|
||||
// from it) as well as blocking the use of any nodes directly
|
||||
// above for leaves
|
||||
|
||||
// update ourself
|
||||
if(length<32 && ((uint)entry>>length)!=0)
|
||||
{
|
||||
// error condition; the lengths must specify an overpopulated tree
|
||||
//free(r);
|
||||
return(null);
|
||||
}
|
||||
r[i]=entry;
|
||||
|
||||
// Look to see if the next shorter marker points to the node
|
||||
// above. if so, update it and repeat.
|
||||
{
|
||||
for(int j=length;j>0;j--)
|
||||
{
|
||||
if((marker[j]&1)!=0)
|
||||
{
|
||||
// have to jump branches
|
||||
if(j==1)marker[1]++;
|
||||
else marker[j]=marker[j-1]<<1;
|
||||
break; // invariant says next upper marker would already
|
||||
// have been moved if it was on the same path
|
||||
}
|
||||
marker[j]++;
|
||||
}
|
||||
}
|
||||
|
||||
// prune the tree; the implicit invariant says all the longer
|
||||
// markers were dangling from our just-taken node. Dangle them
|
||||
// from our *new* node.
|
||||
for(int j=length+1;j<33;j++)
|
||||
{
|
||||
if(((uint)marker[j]>>1) == entry)
|
||||
{
|
||||
entry=marker[j];
|
||||
marker[j]=marker[j-1]<<1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bitreverse the words because our bitwise packer/unpacker is LSb
|
||||
// endian
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
int temp=0;
|
||||
for(int j=0;j<l[i];j++)
|
||||
{
|
||||
temp<<=1;
|
||||
temp = (int)((uint)temp | ((uint)r[i]>>j)&1);
|
||||
}
|
||||
r[i]=temp;
|
||||
}
|
||||
|
||||
return(r);
|
||||
}
|
||||
|
||||
// build the decode helper tree from the codewords
|
||||
internal DecodeAux make_decode_tree()
|
||||
{
|
||||
int top=0;
|
||||
DecodeAux t=new DecodeAux();
|
||||
int[] ptr0=t.ptr0=new int[entries*2];
|
||||
int[] ptr1=t.ptr1=new int[entries*2];
|
||||
int[] codelist=make_words(c.lengthlist, c.entries);
|
||||
|
||||
if(codelist==null)return(null);
|
||||
t.aux=entries*2;
|
||||
|
||||
for(int i=0;i<entries;i++)
|
||||
{
|
||||
if(c.lengthlist[i]>0)
|
||||
{
|
||||
int ptr=0;
|
||||
int j;
|
||||
for(j=0;j<c.lengthlist[i]-1;j++)
|
||||
{
|
||||
int bit=(int)(((uint)codelist[i]>>j)&1);
|
||||
if(bit==0)
|
||||
{
|
||||
if(ptr0[ptr]==0)
|
||||
{
|
||||
ptr0[ptr]=++top;
|
||||
}
|
||||
ptr=ptr0[ptr];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ptr1[ptr]==0)
|
||||
{
|
||||
ptr1[ptr]= ++top;
|
||||
}
|
||||
ptr=ptr1[ptr];
|
||||
}
|
||||
}
|
||||
|
||||
if((((uint)codelist[i]>>j)&1)==0){ ptr0[ptr]=-i; }
|
||||
else{ ptr1[ptr]=-i; }
|
||||
|
||||
}
|
||||
}
|
||||
//free(codelist);
|
||||
|
||||
t.tabn = ilog(entries)-4;
|
||||
|
||||
if(t.tabn<5)t.tabn=5;
|
||||
int n = 1<<t.tabn;
|
||||
t.tab = new int[n];
|
||||
t.tabl = new int[n];
|
||||
for(int i = 0; i < n; i++)
|
||||
{
|
||||
int p = 0;
|
||||
int j=0;
|
||||
for(j = 0; j < t.tabn && (p > 0 || j == 0); j++)
|
||||
{
|
||||
if ((i&(1<<j))!=0)
|
||||
{
|
||||
p = ptr1[p];
|
||||
}
|
||||
else
|
||||
{
|
||||
p = ptr0[p];
|
||||
}
|
||||
}
|
||||
t.tab[i]=p; // -code
|
||||
t.tabl[i]=j; // length
|
||||
}
|
||||
|
||||
return(t);
|
||||
}
|
||||
|
||||
internal static int ilog(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v!=0)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DecodeAux
|
||||
{
|
||||
internal int[] tab;
|
||||
internal int[] tabl;
|
||||
internal int tabn;
|
||||
|
||||
internal int[] ptr0;
|
||||
internal int[] ptr1;
|
||||
internal int aux; // number of tree entries
|
||||
}
|
||||
}
|
308
Support/OggUtils/csvorbis/Comment.cs
Normal file
308
Support/OggUtils/csvorbis/Comment.cs
Normal file
@ -0,0 +1,308 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
// the comments are not part of vorbis_info so that vorbis_info can be
|
||||
// static storage
|
||||
public class Comment
|
||||
{
|
||||
private static String _vorbis="vorbis";
|
||||
|
||||
//private static int OV_EFAULT=-129;
|
||||
private static int OV_EIMPL=-130;
|
||||
|
||||
// unlimited user comment fields. libvorbis writes 'libvorbis'
|
||||
// whatever vendor is set to in encode
|
||||
public byte[][] user_comments;
|
||||
public int[] comment_lengths;
|
||||
public int comments;
|
||||
public byte[] vendor;
|
||||
|
||||
public void init()
|
||||
{
|
||||
user_comments=null;
|
||||
comments=0;
|
||||
vendor=null;
|
||||
}
|
||||
|
||||
public void add(String comment)
|
||||
{
|
||||
Encoding AE = Encoding.UTF8;
|
||||
byte[] comment_byt = AE.GetBytes(comment);
|
||||
add(comment_byt);
|
||||
}
|
||||
|
||||
private void add(byte[] comment)
|
||||
{
|
||||
byte[][] foo=new byte[comments+2][];
|
||||
if(user_comments!=null)
|
||||
{
|
||||
Array.Copy(user_comments, 0, foo, 0, comments);
|
||||
}
|
||||
user_comments=foo;
|
||||
|
||||
int[] goo=new int[comments+2];
|
||||
if(comment_lengths!=null)
|
||||
{
|
||||
Array.Copy(comment_lengths, 0, goo, 0, comments);
|
||||
}
|
||||
comment_lengths=goo;
|
||||
|
||||
byte[] bar=new byte[comment.Length+1];
|
||||
Array.Copy(comment, 0, bar, 0, comment.Length);
|
||||
user_comments[comments]=bar;
|
||||
comment_lengths[comments]=comment.Length;
|
||||
comments++;
|
||||
user_comments[comments]=null;
|
||||
}
|
||||
|
||||
public void add_tag(String tag, String contents)
|
||||
{
|
||||
if(contents==null) contents="";
|
||||
add(tag+"="+contents);
|
||||
}
|
||||
|
||||
/*
|
||||
private void add_tag(byte[] tag, byte[] contents){
|
||||
byte[] foo=new byte[tag.length+contents.length+1];
|
||||
int j=0;
|
||||
for(int i=0; i<tag.length; i++){foo[j++]=tag[i];}
|
||||
foo[j++]=(byte)'='; j++;
|
||||
for(int i=0; i<contents.length; i++){foo[j++]=tag[i];}
|
||||
add(foo);
|
||||
}
|
||||
*/
|
||||
|
||||
// This is more or less the same as strncasecmp - but that doesn't exist
|
||||
// * everywhere, and this is a fairly trivial function, so we include it
|
||||
static bool tagcompare(byte[] s1, byte[] s2, int n)
|
||||
{
|
||||
int c=0;
|
||||
byte u1, u2;
|
||||
while(c < n)
|
||||
{
|
||||
u1=s1[c]; u2=s2[c];
|
||||
if(u1>='A')u1=(byte)(u1-'A'+'a');
|
||||
if(u2>='A')u2=(byte)(u2-'A'+'a');
|
||||
if(u1!=u2){ return false; }
|
||||
c++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String query(String tag)
|
||||
{
|
||||
return query(tag, 0);
|
||||
}
|
||||
|
||||
public String query(String tag, int count)
|
||||
{
|
||||
Encoding AE = Encoding.UTF8;
|
||||
byte[] tag_byt = AE.GetBytes(tag);
|
||||
|
||||
int foo=query(tag_byt, count);
|
||||
if(foo==-1)return null;
|
||||
byte[] comment=user_comments[foo];
|
||||
for(int i=0; i<comment_lengths[foo]; i++)
|
||||
{
|
||||
if(comment[i]=='=')
|
||||
{
|
||||
char[] comment_uni = AE.GetChars(comment);
|
||||
return new String(comment_uni, i+1, comment_lengths[foo]-(i+1));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int query(byte[] tag, int count)
|
||||
{
|
||||
int i=0;
|
||||
int found = 0;
|
||||
int taglen = tag.Length;
|
||||
byte[] fulltag = new byte[taglen+2];
|
||||
Array.Copy(tag, 0, fulltag, 0, tag.Length);
|
||||
fulltag[tag.Length]=(byte)'=';
|
||||
|
||||
for(i=0;i<comments;i++)
|
||||
{
|
||||
if(tagcompare(user_comments[i], fulltag, taglen))
|
||||
{
|
||||
if(count==found)
|
||||
{
|
||||
// We return a pointer to the data, not a copy
|
||||
//return user_comments[i] + taglen + 1;
|
||||
return i;
|
||||
}
|
||||
else{ found++; }
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
internal int unpack(csBuffer opb)
|
||||
{
|
||||
int vendorlen=opb.read(32);
|
||||
if(vendorlen<0)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
vendor=new byte[vendorlen+1];
|
||||
opb.read(vendor,vendorlen);
|
||||
comments=opb.read(32);
|
||||
if(comments<0)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
user_comments=new byte[comments+1][];
|
||||
comment_lengths=new int[comments+1];
|
||||
|
||||
for(int i=0;i<comments;i++)
|
||||
{
|
||||
int len=opb.read(32);
|
||||
if(len<0)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
comment_lengths[i]=len;
|
||||
user_comments[i]=new byte[len+1];
|
||||
opb.read(user_comments[i], len);
|
||||
}
|
||||
if(opb.read(1)!=1)
|
||||
{
|
||||
//goto err_out; // EOP check
|
||||
clear();
|
||||
return(-1);
|
||||
|
||||
}
|
||||
return(0);
|
||||
// err_out:
|
||||
// comment_clear(vc);
|
||||
// return(-1);
|
||||
}
|
||||
|
||||
int pack(csBuffer opb)
|
||||
{
|
||||
String temp="Xiphophorus libVorbis I 20000508";
|
||||
|
||||
Encoding AE = Encoding.UTF8;
|
||||
byte[] temp_byt = AE.GetBytes(temp);
|
||||
byte[] _vorbis_byt = AE.GetBytes(_vorbis);
|
||||
|
||||
// preamble
|
||||
opb.write(0x03,8);
|
||||
opb.write(_vorbis_byt);
|
||||
|
||||
// vendor
|
||||
opb.write(temp.Length,32);
|
||||
opb.write(temp_byt);
|
||||
|
||||
// comments
|
||||
|
||||
opb.write(comments,32);
|
||||
if(comments!=0)
|
||||
{
|
||||
for(int i=0;i<comments;i++)
|
||||
{
|
||||
if(user_comments[i]!=null)
|
||||
{
|
||||
opb.write(comment_lengths[i],32);
|
||||
opb.write(user_comments[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
opb.write(0,32);
|
||||
}
|
||||
}
|
||||
}
|
||||
opb.write(1,1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
public int header_out(Packet op)
|
||||
{
|
||||
csBuffer opb=new csBuffer();
|
||||
opb.writeinit();
|
||||
|
||||
if(pack(opb)!=0) return OV_EIMPL;
|
||||
|
||||
op.packet_base = new byte[opb.bytes()];
|
||||
op.packet=0;
|
||||
op.bytes=opb.bytes();
|
||||
Array.Copy(opb.buf(), 0, op.packet_base, 0, op.bytes);
|
||||
op.b_o_s=0;
|
||||
op.e_o_s=0;
|
||||
op.granulepos=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal void clear()
|
||||
{
|
||||
for(int i=0;i<comments;i++)
|
||||
user_comments[i]=null;
|
||||
user_comments=null;
|
||||
vendor=null;
|
||||
}
|
||||
|
||||
public String getVendor()
|
||||
{
|
||||
Encoding AE = Encoding.UTF8;
|
||||
char[] vendor_uni = AE.GetChars(vendor);
|
||||
return new String(vendor_uni);
|
||||
}
|
||||
|
||||
public String getComment(int i)
|
||||
{
|
||||
Encoding AE = Encoding.UTF8;
|
||||
if(comments<=i)return null;
|
||||
|
||||
char[] user_comments_uni = AE.GetChars(user_comments[i]);
|
||||
return new String(user_comments_uni);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
Encoding AE = Encoding.UTF8;
|
||||
String long_string = "Vendor: " + new String(AE.GetChars(vendor));
|
||||
|
||||
for(int i=0; i < comments; i++)
|
||||
long_string = long_string + "\nComment: " + new String(AE.GetChars(user_comments[i]));
|
||||
|
||||
long_string = long_string + "\n";
|
||||
|
||||
return long_string;
|
||||
}
|
||||
}
|
||||
}
|
1313
Support/OggUtils/csvorbis/Drft.cs
Normal file
1313
Support/OggUtils/csvorbis/Drft.cs
Normal file
File diff suppressed because it is too large
Load Diff
445
Support/OggUtils/csvorbis/DspState.cs
Normal file
445
Support/OggUtils/csvorbis/DspState.cs
Normal file
@ -0,0 +1,445 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
using csvorbis;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
public class DspState
|
||||
{
|
||||
static float M_PI=3.1415926539f;
|
||||
static int VI_TRANSFORMB=1;
|
||||
static int VI_WINDOWB=1;
|
||||
|
||||
internal int analysisp;
|
||||
internal Info vi;
|
||||
internal int modebits;
|
||||
|
||||
float[][] pcm;
|
||||
//float[][] pcmret;
|
||||
int pcm_storage;
|
||||
int pcm_current;
|
||||
int pcm_returned;
|
||||
|
||||
float[] multipliers;
|
||||
int envelope_storage;
|
||||
int envelope_current;
|
||||
|
||||
int eofflag;
|
||||
|
||||
int lW;
|
||||
int W;
|
||||
int nW;
|
||||
int centerW;
|
||||
|
||||
long granulepos;
|
||||
public long sequence;
|
||||
|
||||
long glue_bits;
|
||||
long time_bits;
|
||||
long floor_bits;
|
||||
long res_bits;
|
||||
|
||||
// local lookup storage
|
||||
//!! Envelope ve=new Envelope(); // envelope
|
||||
//float **window[2][2][2]; // block, leadin, leadout, type
|
||||
internal float[][][][][] wnd; // block, leadin, leadout, type
|
||||
//vorbis_look_transform **transform[2]; // block, type
|
||||
internal Object[][] transform;
|
||||
internal CodeBook[] fullbooks;
|
||||
// backend lookups are tied to the mode, not the backend or naked mapping
|
||||
internal Object[] mode;
|
||||
|
||||
// local storage, only used on the encoding side. This way the
|
||||
// application does not need to worry about freeing some packets'
|
||||
// memory and not others'; packet storage is always tracked.
|
||||
// Cleared next call to a _dsp_ function
|
||||
byte[] header;
|
||||
byte[] header1;
|
||||
byte[] header2;
|
||||
|
||||
public DspState()
|
||||
{
|
||||
transform=new Object[2][];
|
||||
wnd=new float[2][][][][];
|
||||
wnd[0]=new float[2][][][];
|
||||
wnd[0][0]=new float[2][][];
|
||||
wnd[0][1]=new float[2][][];
|
||||
wnd[0][0][0]=new float[2][];
|
||||
wnd[0][0][1]=new float[2][];
|
||||
wnd[0][1][0]=new float[2][];
|
||||
wnd[0][1][1]=new float[2][];
|
||||
wnd[1]=new float[2][][][];
|
||||
wnd[1][0]=new float[2][][];
|
||||
wnd[1][1]=new float[2][][];
|
||||
wnd[1][0][0]=new float[2][];
|
||||
wnd[1][0][1]=new float[2][];
|
||||
wnd[1][1][0]=new float[2][];
|
||||
wnd[1][1][1]=new float[2][];
|
||||
}
|
||||
|
||||
private static int ilog2(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v>1)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
internal static float[] window(int type, int wnd, int left, int right)
|
||||
{
|
||||
float[] ret=new float[wnd];
|
||||
switch(type)
|
||||
{
|
||||
case 0:
|
||||
// The 'vorbis window' (window 0) is sin(sin(x)*sin(x)*2pi)
|
||||
{
|
||||
int leftbegin=wnd/4-left/2;
|
||||
int rightbegin=wnd-wnd/4-right/2;
|
||||
|
||||
for(int i=0;i<left;i++)
|
||||
{
|
||||
float x=(float)((i+.5)/left*M_PI/2.0);
|
||||
x=(float)Math.Sin(x);
|
||||
x*=x;
|
||||
x*=(float)(M_PI/2.0);
|
||||
x=(float)Math.Sin(x);
|
||||
ret[i+leftbegin]=x;
|
||||
}
|
||||
|
||||
for(int i=leftbegin+left;i<rightbegin;i++)
|
||||
{
|
||||
ret[i]=1.0f;
|
||||
}
|
||||
|
||||
for(int i=0;i<right;i++)
|
||||
{
|
||||
float x=(float)((right-i-.5)/right*M_PI/2.0);
|
||||
x=(float)Math.Sin(x);
|
||||
x*=x;
|
||||
x*=(float)(M_PI/2.0);
|
||||
x=(float)Math.Sin(x);
|
||||
ret[i+rightbegin]=x;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//free(ret);
|
||||
return(null);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
// Analysis side code, but directly related to blocking. Thus it's
|
||||
// here and not in analysis.c (which is for analysis transforms only).
|
||||
// The init is here because some of it is shared
|
||||
|
||||
int init(Info vi, bool encp)
|
||||
{
|
||||
//memset(v,0,sizeof(vorbis_dsp_state));
|
||||
this.vi=vi;
|
||||
modebits=ilog2(vi.modes);
|
||||
|
||||
transform[0]=new Object[VI_TRANSFORMB];
|
||||
transform[1]=new Object[VI_TRANSFORMB];
|
||||
|
||||
// MDCT is tranform 0
|
||||
|
||||
transform[0][0]=new Mdct();
|
||||
transform[1][0]=new Mdct();
|
||||
((Mdct)transform[0][0]).init(vi.blocksizes[0]);
|
||||
((Mdct)transform[1][0]).init(vi.blocksizes[1]);
|
||||
|
||||
wnd[0][0][0]=new float[VI_WINDOWB][];
|
||||
wnd[0][0][1]=wnd[0][0][0];
|
||||
wnd[0][1][0]=wnd[0][0][0];
|
||||
wnd[0][1][1]=wnd[0][0][0];
|
||||
wnd[1][0][0]=new float[VI_WINDOWB][];
|
||||
wnd[1][0][1]=new float[VI_WINDOWB][];
|
||||
wnd[1][1][0]=new float[VI_WINDOWB][];
|
||||
wnd[1][1][1]=new float[VI_WINDOWB][];
|
||||
|
||||
for(int i=0;i<VI_WINDOWB;i++)
|
||||
{
|
||||
wnd[0][0][0][i]=
|
||||
window(i,vi.blocksizes[0],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
|
||||
wnd[1][0][0][i]=
|
||||
window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
|
||||
wnd[1][0][1][i]=
|
||||
window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[1]/2);
|
||||
wnd[1][1][0][i]=
|
||||
window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[0]/2);
|
||||
wnd[1][1][1][i]=
|
||||
window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[1]/2);
|
||||
}
|
||||
|
||||
// if(encp){ // encode/decode differ here
|
||||
// // finish the codebooks
|
||||
// fullbooks=new CodeBook[vi.books];
|
||||
// for(int i=0;i<vi.books;i++){
|
||||
// fullbooks[i]=new CodeBook();
|
||||
// fullbooks[i].init_encode(vi.book_param[i]);
|
||||
// }
|
||||
// analysisp=1;
|
||||
// }
|
||||
// else{
|
||||
// finish the codebooks
|
||||
fullbooks=new CodeBook[vi.books];
|
||||
for(int i=0;i<vi.books;i++)
|
||||
{
|
||||
fullbooks[i]=new CodeBook();
|
||||
fullbooks[i].init_decode(vi.book_param[i]);
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
// initialize the storage vectors to a decent size greater than the
|
||||
// minimum
|
||||
|
||||
pcm_storage=8192; // we'll assume later that we have
|
||||
// a minimum of twice the blocksize of
|
||||
// accumulated samples in analysis
|
||||
pcm=new float[vi.channels][];
|
||||
//pcmret=new float[vi.channels][];
|
||||
{
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
pcm[i]=new float[pcm_storage];
|
||||
}
|
||||
}
|
||||
|
||||
// all 1 (large block) or 0 (small block)
|
||||
// explicitly set for the sake of clarity
|
||||
lW=0; // previous window size
|
||||
W=0; // current window size
|
||||
|
||||
// all vector indexes; multiples of samples_per_envelope_step
|
||||
centerW=vi.blocksizes[1]/2;
|
||||
|
||||
pcm_current=centerW;
|
||||
|
||||
// initialize all the mapping/backend lookups
|
||||
mode=new Object[vi.modes];
|
||||
|
||||
for(int i=0;i<vi.modes;i++)
|
||||
{
|
||||
int mapnum=vi.mode_param[i].mapping;
|
||||
int maptype=vi.map_type[mapnum];
|
||||
|
||||
mode[i]=FuncMapping.mapping_P[maptype].look(this,vi.mode_param[i],
|
||||
vi.map_param[mapnum]);
|
||||
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
public int synthesis_init(Info vi)
|
||||
{
|
||||
init(vi, false);
|
||||
// Adjust centerW to allow an easier mechanism for determining output
|
||||
pcm_returned=centerW;
|
||||
centerW-= vi.blocksizes[W]/4+vi.blocksizes[lW]/4;
|
||||
granulepos=-1;
|
||||
sequence=-1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
DspState(Info vi) : this()
|
||||
{
|
||||
init(vi, false);
|
||||
// Adjust centerW to allow an easier mechanism for determining output
|
||||
pcm_returned=centerW;
|
||||
centerW-= vi.blocksizes[W]/4+vi.blocksizes[lW]/4;
|
||||
granulepos=-1;
|
||||
sequence=-1;
|
||||
}
|
||||
|
||||
// Unike in analysis, the window is only partially applied for each
|
||||
// block. The time domain envelope is not yet handled at the point of
|
||||
// calling (as it relies on the previous block).
|
||||
|
||||
public int synthesis_blockin(Block vb)
|
||||
{
|
||||
// Shift out any PCM/multipliers that we returned previously
|
||||
// centerW is currently the center of the last block added
|
||||
if(centerW>vi.blocksizes[1]/2 && pcm_returned>8192)
|
||||
{
|
||||
// don't shift too much; we need to have a minimum PCM buffer of
|
||||
// 1/2 long block
|
||||
|
||||
int shiftPCM=centerW-vi.blocksizes[1]/2;
|
||||
shiftPCM=(pcm_returned<shiftPCM?pcm_returned:shiftPCM);
|
||||
|
||||
pcm_current-=shiftPCM;
|
||||
centerW-=shiftPCM;
|
||||
pcm_returned-=shiftPCM;
|
||||
if(shiftPCM!=0)
|
||||
{
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
Array.Copy(pcm[i], shiftPCM, pcm[i], 0, pcm_current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lW=W;
|
||||
W=vb.W;
|
||||
nW=-1;
|
||||
|
||||
glue_bits+=vb.glue_bits;
|
||||
time_bits+=vb.time_bits;
|
||||
floor_bits+=vb.floor_bits;
|
||||
res_bits+=vb.res_bits;
|
||||
|
||||
if(sequence+1 != vb.sequence)granulepos=-1; // out of sequence; lose count
|
||||
|
||||
sequence=vb.sequence;
|
||||
|
||||
{
|
||||
int sizeW=vi.blocksizes[W];
|
||||
int _centerW=centerW+vi.blocksizes[lW]/4+sizeW/4;
|
||||
int beginW=_centerW-sizeW/2;
|
||||
int endW=beginW+sizeW;
|
||||
int beginSl=0;
|
||||
int endSl=0;
|
||||
|
||||
// Do we have enough PCM/mult storage for the block?
|
||||
if(endW>pcm_storage)
|
||||
{
|
||||
// expand the storage
|
||||
pcm_storage=endW+vi.blocksizes[1];
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
float[] foo=new float[pcm_storage];
|
||||
Array.Copy(pcm[i], 0, foo, 0, pcm[i].Length);
|
||||
pcm[i]=foo;
|
||||
}
|
||||
}
|
||||
|
||||
// overlap/add PCM
|
||||
switch(W)
|
||||
{
|
||||
case 0:
|
||||
beginSl=0;
|
||||
endSl=vi.blocksizes[0]/2;
|
||||
break;
|
||||
case 1:
|
||||
beginSl=vi.blocksizes[1]/4-vi.blocksizes[lW]/4;
|
||||
endSl=beginSl+vi.blocksizes[lW]/2;
|
||||
break;
|
||||
}
|
||||
|
||||
for(int j=0;j<vi.channels;j++)
|
||||
{
|
||||
int _pcm=beginW;
|
||||
// the overlap/add section
|
||||
int i=0;
|
||||
for(i=beginSl;i<endSl;i++)
|
||||
{
|
||||
pcm[j][_pcm+i]+=vb.pcm[j][i];
|
||||
}
|
||||
// the remaining section
|
||||
for(;i<sizeW;i++)
|
||||
{
|
||||
pcm[j][_pcm+i]=vb.pcm[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
// track the frame number... This is for convenience, but also
|
||||
// making sure our last packet doesn't end with added padding. If
|
||||
// the last packet is partial, the number of samples we'll have to
|
||||
// return will be past the vb->granulepos.
|
||||
//
|
||||
// This is not foolproof! It will be confused if we begin
|
||||
// decoding at the last page after a seek or hole. In that case,
|
||||
// we don't have a starting point to judge where the last frame
|
||||
// is. For this reason, vorbisfile will always try to make sure
|
||||
// it reads the last two marked pages in proper sequence
|
||||
|
||||
if(granulepos==-1)
|
||||
{
|
||||
granulepos=vb.granulepos;
|
||||
}
|
||||
else
|
||||
{
|
||||
granulepos+=(_centerW-centerW);
|
||||
if(vb.granulepos!=-1 && granulepos!=vb.granulepos)
|
||||
{
|
||||
if(granulepos>vb.granulepos && vb.eofflag!=0)
|
||||
{
|
||||
// partial last frame. Strip the padding off
|
||||
_centerW = _centerW - (int)(granulepos-vb.granulepos);
|
||||
}// else{ Shouldn't happen *unless* the bitstream is out of
|
||||
// spec. Either way, believe the bitstream }
|
||||
granulepos=vb.granulepos;
|
||||
}
|
||||
}
|
||||
|
||||
// Update, cleanup
|
||||
|
||||
centerW=_centerW;
|
||||
pcm_current=endW;
|
||||
if(vb.eofflag!=0)eofflag=1;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
// pcm==NULL indicates we just want the pending samples, no more
|
||||
public int synthesis_pcmout(float[][][] _pcm, int[] index)
|
||||
{
|
||||
if(pcm_returned<centerW)
|
||||
{
|
||||
if(_pcm!=null)
|
||||
{
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
// pcmret[i]=pcm[i]+v.pcm_returned;
|
||||
//!!!!!!!!
|
||||
index[i]=pcm_returned;
|
||||
}
|
||||
_pcm[0]=pcm;
|
||||
}
|
||||
return(centerW-pcm_returned);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
public int synthesis_read(int bytes)
|
||||
{
|
||||
if(bytes!=0 && pcm_returned+bytes>centerW)return(-1);
|
||||
pcm_returned+=bytes;
|
||||
return(0);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
40
Support/OggUtils/csvorbis/EncodeAuxNearestMatch.cs
Normal file
40
Support/OggUtils/csvorbis/EncodeAuxNearestMatch.cs
Normal file
@ -0,0 +1,40 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class EncodeAuxNearestMatch
|
||||
{
|
||||
internal int[] ptr0;
|
||||
internal int[] ptr1;
|
||||
|
||||
internal int[] p; // decision points (each is an entry)
|
||||
internal int[] q; // decision points (each is an entry)
|
||||
internal int aux; // number of tree entries
|
||||
internal int alloc;
|
||||
}
|
||||
}
|
37
Support/OggUtils/csvorbis/EncodeAuxThreshMatch.cs
Normal file
37
Support/OggUtils/csvorbis/EncodeAuxThreshMatch.cs
Normal file
@ -0,0 +1,37 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class EncodeAuxThreshMatch
|
||||
{
|
||||
internal float[] quantthresh;
|
||||
internal int[] quantmap;
|
||||
internal int quantvals;
|
||||
internal int threshvals;
|
||||
}
|
||||
}
|
405
Support/OggUtils/csvorbis/Floor0.cs
Normal file
405
Support/OggUtils/csvorbis/Floor0.cs
Normal file
@ -0,0 +1,405 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Floor0 : FuncFloor
|
||||
{
|
||||
|
||||
override public void pack(Object i, csBuffer opb)
|
||||
{
|
||||
InfoFloor0 info=(InfoFloor0)i;
|
||||
opb.write(info.order,8);
|
||||
opb.write(info.rate,16);
|
||||
opb.write(info.barkmap,16);
|
||||
opb.write(info.ampbits,6);
|
||||
opb.write(info.ampdB,8);
|
||||
opb.write(info.numbooks-1,4);
|
||||
for(int j=0;j<info.numbooks;j++)
|
||||
opb.write(info.books[j],8);
|
||||
}
|
||||
|
||||
override public Object unpack(Info vi , csBuffer opb)
|
||||
{
|
||||
InfoFloor0 info=new InfoFloor0();
|
||||
info.order=opb.read(8);
|
||||
info.rate=opb.read(16);
|
||||
info.barkmap=opb.read(16);
|
||||
info.ampbits=opb.read(6);
|
||||
info.ampdB=opb.read(8);
|
||||
info.numbooks=opb.read(4)+1;
|
||||
|
||||
if((info.order<1)||
|
||||
(info.rate<1)||
|
||||
(info.barkmap<1)||
|
||||
(info.numbooks<1))
|
||||
{
|
||||
//free_info(info);
|
||||
return(null);
|
||||
}
|
||||
|
||||
for(int j=0;j<info.numbooks;j++)
|
||||
{
|
||||
info.books[j]=opb.read(8);
|
||||
if(info.books[j]<0 || info.books[j]>=vi.books)
|
||||
{
|
||||
//free_info(info);
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
return(info);
|
||||
// err_out:
|
||||
// free_info(info);
|
||||
// return(NULL);
|
||||
}
|
||||
override public Object look(DspState vd, InfoMode mi, Object i)
|
||||
{
|
||||
float scale;
|
||||
|
||||
Info vi=vd.vi;
|
||||
InfoFloor0 info=(InfoFloor0)i;
|
||||
LookFloor0 look=new LookFloor0();
|
||||
look.m=info.order;
|
||||
look.n=vi.blocksizes[mi.blockflag]/2;
|
||||
look.ln=info.barkmap;
|
||||
look.vi=info;
|
||||
look.lpclook.init(look.ln,look.m);
|
||||
|
||||
// we choose a scaling constant so that:
|
||||
// floor(bark(rate/2-1)*C)=mapped-1
|
||||
// floor(bark(rate/2)*C)=mapped
|
||||
scale = look.ln / (float)toBARK((float)(info.rate/2.0));
|
||||
|
||||
// the mapping from a linear scale to a smaller bark scale is
|
||||
// straightforward. We do *not* make sure that the linear mapping
|
||||
// does not skip bark-scale bins; the decoder simply skips them and
|
||||
// the encoder may do what it wishes in filling them. They're
|
||||
// necessary in some mapping combinations to keep the scale spacing
|
||||
// accurate
|
||||
look.linearmap=new int[look.n];
|
||||
|
||||
for(int j=0; j<look.n; j++)
|
||||
{
|
||||
int val=(int)Math.Floor(toBARK((float)((info.rate/2.0)/look.n*j))
|
||||
*scale); // bark numbers represent band edges
|
||||
if(val>=look.ln) val=look.ln; // guard against the approximation
|
||||
look.linearmap[j]=val;
|
||||
}
|
||||
return look;
|
||||
}
|
||||
|
||||
static double toBARK(float f)
|
||||
{
|
||||
double a,b,c;
|
||||
a = 13.1 * Math.Atan(0.00074 * f);
|
||||
b = 2.24 * Math.Atan(f * f * 1.85e-8);
|
||||
c = 1.0e-4 * f;
|
||||
|
||||
return (a + b + c);
|
||||
}
|
||||
|
||||
private object state(object i)
|
||||
{
|
||||
EchstateFloor0 state=new EchstateFloor0();
|
||||
InfoFloor0 info=(InfoFloor0)i;
|
||||
|
||||
// a safe size if usually too big (dim==1)
|
||||
state.codewords=new int[info.order];
|
||||
state.curve=new float[info.barkmap];
|
||||
state.frameno=-1;
|
||||
return(state);
|
||||
}
|
||||
override public void free_info(Object i){}
|
||||
override public void free_look(Object i){}
|
||||
override public void free_state(Object vs){}
|
||||
override public int forward(Block vb, Object i, float[] fin, float[] fout, Object vs){return 0;}
|
||||
|
||||
float[] lsp=null;
|
||||
int inverse(Block vb, Object i, float[] fout)
|
||||
{
|
||||
//System.err.println("Floor0.inverse "+i.getClass()+"]");
|
||||
LookFloor0 look=(LookFloor0)i;
|
||||
InfoFloor0 info=look.vi;
|
||||
int ampraw=vb.opb.read(info.ampbits);
|
||||
if(ampraw>0)
|
||||
{ // also handles the -1 out of data case
|
||||
int maxval=(1<<info.ampbits)-1;
|
||||
float amp=(float)ampraw/maxval*info.ampdB;
|
||||
int booknum=vb.opb.read(ilog(info.numbooks));
|
||||
|
||||
if(booknum!=-1 && booknum<info.numbooks)
|
||||
{
|
||||
|
||||
lock(this)
|
||||
{
|
||||
if(lsp==null||lsp.Length<look.m)
|
||||
{
|
||||
lsp=new float[look.m];
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int j=0; j<look.m; j++)lsp[j]=0.0f;
|
||||
}
|
||||
|
||||
CodeBook b=vb.vd.fullbooks[info.books[booknum]];
|
||||
float last=0.0f;
|
||||
|
||||
//memset(out,0,sizeof(float)*look->m);
|
||||
for(int j=0; j<look.m; j++)fout[j]=0.0f;
|
||||
|
||||
for(int j=0;j<look.m;j+=b.dim)
|
||||
{
|
||||
if(b.decodevs(lsp, j, vb.opb, 1, -1)==-1)
|
||||
{
|
||||
//goto eop;
|
||||
// memset(out,0,sizeof(float)*look->n);
|
||||
for(int k=0; k<look.n; k++)fout[k]=0.0f;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
for(int j=0;j<look.m;)
|
||||
{
|
||||
for(int k=0;k<b.dim;k++,j++)lsp[j]+=last;
|
||||
last=lsp[j-1];
|
||||
}
|
||||
// take the coefficients back to a spectral envelope curve
|
||||
/*
|
||||
lsp_to_lpc(out,out,look.m);
|
||||
lpc_to_curve(out,out,amp,look,"",0);
|
||||
for(int j=0;j<look.n;j++){
|
||||
out[j]=fromdB(out[j]-info.ampdB);
|
||||
}
|
||||
*/
|
||||
Lsp.lsp_to_curve(fout,look.linearmap,look.n,look.ln,
|
||||
lsp,look.m,amp,info.ampdB);
|
||||
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// eop:
|
||||
// memset(out,0,sizeof(float)*look->n);
|
||||
return(0);
|
||||
}
|
||||
|
||||
override public Object inverse1(Block vb, Object i, Object memo)
|
||||
{
|
||||
//System.err.println("Floor0.inverse "+i.getClass()+"]");
|
||||
LookFloor0 look=(LookFloor0)i;
|
||||
InfoFloor0 info=look.vi;
|
||||
float[] lsp=null;
|
||||
if(memo is float[])
|
||||
{
|
||||
lsp=(float[])memo;
|
||||
}
|
||||
|
||||
int ampraw=vb.opb.read(info.ampbits);
|
||||
if(ampraw>0)
|
||||
{ // also handles the -1 out of data case
|
||||
int maxval=(1<<info.ampbits)-1;
|
||||
float amp=(float)ampraw/maxval*info.ampdB;
|
||||
int booknum=vb.opb.read(ilog(info.numbooks));
|
||||
|
||||
if(booknum!=-1 && booknum<info.numbooks)
|
||||
{
|
||||
CodeBook b=vb.vd.fullbooks[info.books[booknum]];
|
||||
float last=0.0f;
|
||||
|
||||
if(lsp==null||lsp.Length<look.m+1)
|
||||
{
|
||||
lsp=new float[look.m+1];
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int j=0; j<lsp.Length; j++)lsp[j]=0.0f;
|
||||
}
|
||||
|
||||
for(int j=0;j<look.m;j+=b.dim)
|
||||
{
|
||||
if(b.decodev_set(lsp, j, vb.opb, b.dim)==-1)
|
||||
{
|
||||
//goto eop;
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
|
||||
for(int j=0;j<look.m;)
|
||||
{
|
||||
for(int k=0;k<b.dim;k++,j++)lsp[j]+=last;
|
||||
last=lsp[j-1];
|
||||
}
|
||||
lsp[look.m]=amp;
|
||||
return(lsp);
|
||||
}
|
||||
}
|
||||
// eop:
|
||||
return(null);
|
||||
}
|
||||
|
||||
override public int inverse2(Block vb, Object i, Object memo, float[] fout)
|
||||
{
|
||||
//System.err.println("Floor0.inverse "+i.getClass()+"]");
|
||||
LookFloor0 look=(LookFloor0)i;
|
||||
InfoFloor0 info=look.vi;
|
||||
|
||||
if(memo!=null)
|
||||
{
|
||||
float[] lsp=(float[])memo;
|
||||
float amp=lsp[look.m];
|
||||
|
||||
Lsp.lsp_to_curve(fout,look.linearmap,look.n,look.ln,
|
||||
lsp,look.m,amp,info.ampdB);
|
||||
return(1);
|
||||
}
|
||||
// eop:
|
||||
// memset(out,0,sizeof(float)*look->n);
|
||||
for(int j=0; j<look.n; j++)
|
||||
{
|
||||
fout[j]=0.0f;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static float fromdB(float x)
|
||||
{
|
||||
return (float)(Math.Exp((x)*.11512925));
|
||||
}
|
||||
private static int ilog(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v!=0)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void lsp_to_lpc(float[] lsp, float[] lpc, int m)
|
||||
{
|
||||
int i,j,m2=m/2;
|
||||
float[] O=new float[m2];
|
||||
float[] E=new float[m2];
|
||||
float A;
|
||||
float[] Ae=new float[m2+1];
|
||||
float[] Ao=new float[m2+1];
|
||||
float B;
|
||||
float[] Be=new float[m2];
|
||||
float[] Bo=new float[m2];
|
||||
float temp;
|
||||
|
||||
// even/odd roots setup
|
||||
for(i=0;i<m2;i++)
|
||||
{
|
||||
O[i]=(float)(-2.0*Math.Cos(lsp[i*2]));
|
||||
E[i]=(float)(-2.0*Math.Cos(lsp[i*2+1]));
|
||||
}
|
||||
|
||||
// set up impulse response
|
||||
for(j=0;j<m2;j++)
|
||||
{
|
||||
Ae[j]=0.0f;
|
||||
Ao[j]=1.0f;
|
||||
Be[j]=0.0f;
|
||||
Bo[j]=1.0f;
|
||||
}
|
||||
Ao[j]=1.0f;
|
||||
Ae[j]=1.0f;
|
||||
|
||||
// run impulse response
|
||||
for(i=1;i<m+1;i++)
|
||||
{
|
||||
A=B=0.0f;
|
||||
for(j=0;j<m2;j++)
|
||||
{
|
||||
temp=O[j]*Ao[j]+Ae[j];
|
||||
Ae[j]=Ao[j];
|
||||
Ao[j]=A;
|
||||
A+=temp;
|
||||
|
||||
temp=E[j]*Bo[j]+Be[j];
|
||||
Be[j]=Bo[j];
|
||||
Bo[j]=B;
|
||||
B+=temp;
|
||||
}
|
||||
lpc[i-1]=(A+Ao[j]+B-Ae[j])/2;
|
||||
Ao[j]=A;
|
||||
Ae[j]=B;
|
||||
}
|
||||
}
|
||||
|
||||
static void lpc_to_curve(float[] curve, float[] lpc,float amp,
|
||||
LookFloor0 l, String name, int frameno)
|
||||
{
|
||||
// l->m+1 must be less than l->ln, but guard in case we get a bad stream
|
||||
float[] lcurve=new float[Math.Max(l.ln*2,l.m*2+2)];
|
||||
|
||||
if(amp==0)
|
||||
{
|
||||
//memset(curve,0,sizeof(float)*l->n);
|
||||
for(int j=0; j<l.n; j++)curve[j]=0.0f;
|
||||
return;
|
||||
}
|
||||
l.lpclook.lpc_to_curve(lcurve,lpc,amp);
|
||||
|
||||
for(int i=0;i<l.n;i++)curve[i]=lcurve[l.linearmap[i]];
|
||||
}
|
||||
}
|
||||
|
||||
class InfoFloor0
|
||||
{
|
||||
internal int order;
|
||||
internal int rate;
|
||||
internal int barkmap;
|
||||
|
||||
internal int ampbits;
|
||||
internal int ampdB;
|
||||
|
||||
internal int numbooks; // <= 16
|
||||
internal int[] books=new int[16];
|
||||
}
|
||||
|
||||
class LookFloor0
|
||||
{
|
||||
internal int n;
|
||||
internal int ln;
|
||||
internal int m;
|
||||
internal int[] linearmap;
|
||||
|
||||
internal InfoFloor0 vi;
|
||||
internal Lpc lpclook=new Lpc();
|
||||
}
|
||||
|
||||
class EchstateFloor0
|
||||
{
|
||||
internal int[] codewords;
|
||||
internal float[] curve;
|
||||
internal long frameno;
|
||||
//internal long codes;
|
||||
}
|
||||
}
|
721
Support/OggUtils/csvorbis/Floor1.cs
Normal file
721
Support/OggUtils/csvorbis/Floor1.cs
Normal file
@ -0,0 +1,721 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Floor1 : FuncFloor
|
||||
{
|
||||
static int floor1_rangedb=140;
|
||||
static int VIF_POSIT=63;
|
||||
|
||||
override public void pack(Object i, csBuffer opb)
|
||||
{
|
||||
InfoFloor1 info=(InfoFloor1)i;
|
||||
|
||||
int count=0;
|
||||
int rangebits;
|
||||
int maxposit=info.postlist[1];
|
||||
int maxclass=-1;
|
||||
|
||||
/* save out partitions */
|
||||
opb.write(info.partitions,5); /* only 0 to 31 legal */
|
||||
for(int j=0;j<info.partitions;j++)
|
||||
{
|
||||
opb.write(info.partitionclass[j],4); /* only 0 to 15 legal */
|
||||
if(maxclass<info.partitionclass[j])
|
||||
maxclass=info.partitionclass[j];
|
||||
}
|
||||
|
||||
/* save out partition classes */
|
||||
for(int j=0;j<maxclass+1;j++)
|
||||
{
|
||||
opb.write(info.class_dim[j]-1,3); /* 1 to 8 */
|
||||
opb.write(info.class_subs[j],2); /* 0 to 3 */
|
||||
if(info.class_subs[j]!=0)
|
||||
{
|
||||
opb.write(info.class_book[j],8);
|
||||
}
|
||||
for(int k=0;k<(1<<info.class_subs[j]);k++)
|
||||
{
|
||||
opb.write(info.class_subbook[j][k]+1,8);
|
||||
}
|
||||
}
|
||||
|
||||
/* save out the post list */
|
||||
opb.write(info.mult-1,2); /* only 1,2,3,4 legal now */
|
||||
opb.write(ilog2(maxposit),4);
|
||||
rangebits=ilog2(maxposit);
|
||||
|
||||
for(int j=0,k=0;j<info.partitions;j++)
|
||||
{
|
||||
count+=info.class_dim[info.partitionclass[j]];
|
||||
for(;k<count;k++)
|
||||
{
|
||||
opb.write(info.postlist[k+2],rangebits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public Object unpack(Info vi , csBuffer opb)
|
||||
{
|
||||
int count=0,maxclass=-1,rangebits;
|
||||
InfoFloor1 info=new InfoFloor1();
|
||||
|
||||
/* read partitions */
|
||||
info.partitions=opb.read(5); /* only 0 to 31 legal */
|
||||
for(int j=0;j<info.partitions;j++)
|
||||
{
|
||||
info.partitionclass[j]=opb.read(4); /* only 0 to 15 legal */
|
||||
if(maxclass<info.partitionclass[j])
|
||||
maxclass=info.partitionclass[j];
|
||||
}
|
||||
|
||||
/* read partition classes */
|
||||
for(int j=0;j<maxclass+1;j++)
|
||||
{
|
||||
info.class_dim[j]=opb.read(3)+1; /* 1 to 8 */
|
||||
info.class_subs[j]=opb.read(2); /* 0,1,2,3 bits */
|
||||
if(info.class_subs[j]<0)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
if(info.class_subs[j]!=0)
|
||||
{
|
||||
info.class_book[j]=opb.read(8);
|
||||
}
|
||||
if(info.class_book[j]<0 || info.class_book[j]>=vi.books)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
for(int k=0;k<(1<<info.class_subs[j]);k++)
|
||||
{
|
||||
info.class_subbook[j][k]=opb.read(8)-1;
|
||||
if(info.class_subbook[j][k]<-1 || info.class_subbook[j][k]>=vi.books)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* read the post list */
|
||||
info.mult=opb.read(2)+1; /* only 1,2,3,4 legal now */
|
||||
rangebits=opb.read(4);
|
||||
|
||||
for(int j=0,k=0;j<info.partitions;j++)
|
||||
{
|
||||
count+=info.class_dim[info.partitionclass[j]];
|
||||
for(;k<count;k++)
|
||||
{
|
||||
int t=info.postlist[k+2]=opb.read(rangebits);
|
||||
if(t<0 || t>=(1<<rangebits))
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
info.postlist[0]=0;
|
||||
info.postlist[1]=1<<rangebits;
|
||||
|
||||
return(info);
|
||||
// err_out:
|
||||
// info.free();
|
||||
// return(null);
|
||||
}
|
||||
|
||||
override public Object look(DspState vd, InfoMode mi, Object i)
|
||||
{
|
||||
int _n=0;
|
||||
|
||||
int[] sortpointer=new int[VIF_POSIT+2];
|
||||
|
||||
// Info vi=vd.vi;
|
||||
|
||||
InfoFloor1 info=(InfoFloor1)i;
|
||||
LookFloor1 look=new LookFloor1();
|
||||
look.vi=info;
|
||||
look.n=info.postlist[1];
|
||||
|
||||
/* we drop each position value in-between already decoded values,
|
||||
and use linear interpolation to predict each new value past the
|
||||
edges. The positions are read in the order of the position
|
||||
list... we precompute the bounding positions in the lookup. Of
|
||||
course, the neighbors can change (if a position is declined), but
|
||||
this is an initial mapping */
|
||||
|
||||
for(int j=0;j<info.partitions;j++)
|
||||
{
|
||||
_n+=info.class_dim[info.partitionclass[j]];
|
||||
}
|
||||
_n+=2;
|
||||
look.posts=_n;
|
||||
|
||||
/* also store a sorted position index */
|
||||
for(int j=0;j<_n;j++)
|
||||
{
|
||||
sortpointer[j]=j;
|
||||
}
|
||||
// qsort(sortpointer,n,sizeof(int),icomp); // !!
|
||||
|
||||
int foo;
|
||||
for(int j=0; j<_n-1; j++)
|
||||
{
|
||||
for(int k=j; k<_n; k++)
|
||||
{
|
||||
if(info.postlist[sortpointer[j]]>info.postlist[sortpointer[k]])
|
||||
{
|
||||
foo=sortpointer[k];
|
||||
sortpointer[k]=sortpointer[j];
|
||||
sortpointer[j]=foo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* points from sort order back to range number */
|
||||
for(int j=0;j<_n;j++)
|
||||
{
|
||||
look.forward_index[j]=sortpointer[j];
|
||||
}
|
||||
/* points from range order to sorted position */
|
||||
for(int j=0;j<_n;j++)
|
||||
{
|
||||
look.reverse_index[look.forward_index[j]]=j;
|
||||
}
|
||||
/* we actually need the post values too */
|
||||
for(int j=0;j<_n;j++)
|
||||
{
|
||||
look.sorted_index[j]=info.postlist[look.forward_index[j]];
|
||||
}
|
||||
|
||||
|
||||
/* quantize values to multiplier spec */
|
||||
switch(info.mult)
|
||||
{
|
||||
case 1: /* 1024 -> 256 */
|
||||
look.quant_q=256;
|
||||
break;
|
||||
case 2: /* 1024 -> 128 */
|
||||
look.quant_q=128;
|
||||
break;
|
||||
case 3: /* 1024 -> 86 */
|
||||
look.quant_q=86;
|
||||
break;
|
||||
case 4: /* 1024 -> 64 */
|
||||
look.quant_q=64;
|
||||
break;
|
||||
default:
|
||||
look.quant_q=-1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* discover our neighbors for decode where we don't use fit flags
|
||||
(that would push the neighbors outward) */
|
||||
for(int j=0;j<_n-2;j++)
|
||||
{
|
||||
int lo=0;
|
||||
int hi=1;
|
||||
int lx=0;
|
||||
int hx=look.n;
|
||||
int currentx=info.postlist[j+2];
|
||||
for(int k=0;k<j+2;k++)
|
||||
{
|
||||
int x=info.postlist[k];
|
||||
if(x>lx && x<currentx)
|
||||
{
|
||||
lo=k;
|
||||
lx=x;
|
||||
}
|
||||
if(x<hx && x>currentx)
|
||||
{
|
||||
hi=k;
|
||||
hx=x;
|
||||
}
|
||||
}
|
||||
look.loneighbor[j]=lo;
|
||||
look.hineighbor[j]=hi;
|
||||
}
|
||||
|
||||
return look;
|
||||
}
|
||||
|
||||
override public void free_info(Object i){}
|
||||
override public void free_look(Object i){}
|
||||
override public void free_state(Object vs){}
|
||||
|
||||
override public int forward(Block vb, Object i, float[] fin, float[] fout, Object vs){return 0;}
|
||||
|
||||
override public Object inverse1(Block vb, Object ii, Object memo)
|
||||
{
|
||||
LookFloor1 look=(LookFloor1)ii;
|
||||
InfoFloor1 info=look.vi;
|
||||
CodeBook[] books=vb.vd.fullbooks;
|
||||
|
||||
/* unpack wrapped/predicted values from stream */
|
||||
if(vb.opb.read(1)==1)
|
||||
{
|
||||
int[] fit_value=null;
|
||||
if(memo is int[])
|
||||
{
|
||||
fit_value=(int[])memo;
|
||||
}
|
||||
if(fit_value==null || fit_value.Length<look.posts)
|
||||
{
|
||||
fit_value=new int[look.posts];
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=0; i<fit_value.Length; i++) fit_value[i]=0;
|
||||
}
|
||||
|
||||
fit_value[0]=vb.opb.read(ilog(look.quant_q-1));
|
||||
fit_value[1]=vb.opb.read(ilog(look.quant_q-1));
|
||||
|
||||
/* partition by partition */
|
||||
for(int i=0,j=2;i<info.partitions;i++)
|
||||
{
|
||||
int clss=info.partitionclass[i];
|
||||
int cdim=info.class_dim[clss];
|
||||
int csubbits=info.class_subs[clss];
|
||||
int csub=1<<csubbits;
|
||||
int cval=0;
|
||||
|
||||
/* decode the partition's first stage cascade value */
|
||||
if(csubbits!=0)
|
||||
{
|
||||
cval=books[info.class_book[clss]].decode(vb.opb);
|
||||
|
||||
if(cval==-1)
|
||||
{
|
||||
//goto eop;
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
|
||||
for(int k=0;k<cdim;k++)
|
||||
{
|
||||
int book=info.class_subbook[clss][cval&(csub-1)];
|
||||
cval = (int)((uint)cval >> csubbits);
|
||||
if(book>=0)
|
||||
{
|
||||
if((fit_value[j+k]=books[book].decode(vb.opb))==-1)
|
||||
{
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fit_value[j+k]=0;
|
||||
}
|
||||
}
|
||||
j+=cdim;
|
||||
}
|
||||
|
||||
/* unwrap positive values and reconsitute via linear interpolation */
|
||||
for(int i=2;i<look.posts;i++)
|
||||
{
|
||||
int predicted=render_point(info.postlist[look.loneighbor[i-2]],
|
||||
info.postlist[look.hineighbor[i-2]],
|
||||
fit_value[look.loneighbor[i-2]],
|
||||
fit_value[look.hineighbor[i-2]],
|
||||
info.postlist[i]);
|
||||
int hiroom=look.quant_q-predicted;
|
||||
int loroom=predicted;
|
||||
int room=(hiroom<loroom?hiroom:loroom)<<1;
|
||||
int val=fit_value[i];
|
||||
|
||||
if(val!=0)
|
||||
{
|
||||
if(val>=room)
|
||||
{
|
||||
if(hiroom>loroom)
|
||||
{
|
||||
val = val-loroom;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = -1-(val-hiroom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((val&1)!=0)
|
||||
{
|
||||
val= (int)(-((uint)(val+1) >> 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
val>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
fit_value[i]=val+predicted;
|
||||
fit_value[look.loneighbor[i-2]]&=0x7fff;
|
||||
fit_value[look.hineighbor[i-2]]&=0x7fff;
|
||||
}
|
||||
else
|
||||
{
|
||||
fit_value[i]=predicted|0x8000;
|
||||
}
|
||||
}
|
||||
return(fit_value);
|
||||
}
|
||||
|
||||
// eop:
|
||||
// return(NULL);
|
||||
return(null);
|
||||
}
|
||||
|
||||
private static int render_point(int x0,int x1,int y0,int y1,int x)
|
||||
{
|
||||
y0&=0x7fff; /* mask off flag */
|
||||
y1&=0x7fff;
|
||||
|
||||
{
|
||||
int dy=y1-y0;
|
||||
int adx=x1-x0;
|
||||
int ady=Math.Abs(dy);
|
||||
int err=ady*(x-x0);
|
||||
|
||||
int off=(int)(err/adx);
|
||||
if(dy<0)return(y0-off);
|
||||
return(y0+off);
|
||||
}
|
||||
}
|
||||
|
||||
override public int inverse2(Block vb, Object i, Object memo, float[] fout)
|
||||
{
|
||||
LookFloor1 look=(LookFloor1)i;
|
||||
InfoFloor1 info=look.vi;
|
||||
int n=vb.vd.vi.blocksizes[vb.mode]/2;
|
||||
|
||||
if(memo!=null)
|
||||
{
|
||||
/* render the lines */
|
||||
int[] fit_value=(int[] )memo;
|
||||
int hx=0;
|
||||
int lx=0;
|
||||
int ly=fit_value[0]*info.mult;
|
||||
for(int j=1;j<look.posts;j++)
|
||||
{
|
||||
int current=look.forward_index[j];
|
||||
int hy=fit_value[current]&0x7fff;
|
||||
if(hy==fit_value[current])
|
||||
{
|
||||
hy*=info.mult;
|
||||
hx=info.postlist[current];
|
||||
|
||||
render_line(lx,hx,ly,hy,fout);
|
||||
|
||||
lx=hx;
|
||||
ly=hy;
|
||||
}
|
||||
}
|
||||
for(int j=hx;j<n;j++)
|
||||
{
|
||||
fout[j]*=fout[j-1]; /* be certain */
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
for(int j=0; j<n; j++)
|
||||
{
|
||||
fout[j]=0.0f;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
private static float[] FLOOR_fromdB_LOOKUP={
|
||||
1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F,
|
||||
1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F,
|
||||
1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F,
|
||||
2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F,
|
||||
2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F,
|
||||
3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F,
|
||||
4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F,
|
||||
6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F,
|
||||
7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F,
|
||||
1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F,
|
||||
1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F,
|
||||
1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F,
|
||||
2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F,
|
||||
2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F,
|
||||
3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F,
|
||||
4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F,
|
||||
5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F,
|
||||
7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F,
|
||||
9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F,
|
||||
1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F,
|
||||
1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F,
|
||||
2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F,
|
||||
2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F,
|
||||
3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F,
|
||||
4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F,
|
||||
5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F,
|
||||
7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F,
|
||||
9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F,
|
||||
0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F,
|
||||
0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F,
|
||||
0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F,
|
||||
0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F,
|
||||
0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F,
|
||||
0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F,
|
||||
0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F,
|
||||
0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F,
|
||||
0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F,
|
||||
0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
|
||||
0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
|
||||
0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
|
||||
0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F,
|
||||
0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F,
|
||||
0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F,
|
||||
0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F,
|
||||
0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F,
|
||||
0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F,
|
||||
0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
|
||||
0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F,
|
||||
0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F,
|
||||
0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F,
|
||||
0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F,
|
||||
0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F,
|
||||
0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F,
|
||||
0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F,
|
||||
0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F,
|
||||
0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
|
||||
0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F,
|
||||
0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F,
|
||||
0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F,
|
||||
0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F,
|
||||
0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F,
|
||||
0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F,
|
||||
0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F,
|
||||
0.82788260F, 0.88168307F, 0.9389798F, 1.0F
|
||||
};
|
||||
|
||||
private static void render_line(int x0, int x1,int y0,int y1,float[] d)
|
||||
{
|
||||
int dy=y1-y0;
|
||||
int adx=x1-x0;
|
||||
int ady=Math.Abs(dy);
|
||||
int bbase=dy/adx;
|
||||
int sy=( (dy < 0) ? bbase-1 : bbase+1);
|
||||
int x=x0;
|
||||
int y=y0;
|
||||
int err=0;
|
||||
|
||||
ady-=Math.Abs(bbase*adx);
|
||||
|
||||
d[x]*=FLOOR_fromdB_LOOKUP[y];
|
||||
while(++x<x1)
|
||||
{
|
||||
err=err+ady;
|
||||
if(err>=adx)
|
||||
{
|
||||
err-=adx;
|
||||
y+=sy;
|
||||
}
|
||||
else
|
||||
{
|
||||
y+=bbase;
|
||||
}
|
||||
d[x]*=FLOOR_fromdB_LOOKUP[y];
|
||||
}
|
||||
}
|
||||
|
||||
static int ilog(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v!=0)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
private static int ilog2(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v>1)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
}
|
||||
|
||||
class InfoFloor1
|
||||
{
|
||||
const int VIF_POSIT=63;
|
||||
const int VIF_CLASS=16;
|
||||
const int VIF_PARTS=31;
|
||||
|
||||
internal int partitions; /* 0 to 31 */
|
||||
internal int[] partitionclass=new int[VIF_PARTS]; /* 0 to 15 */
|
||||
|
||||
internal int[] class_dim=new int[VIF_CLASS]; /* 1 to 8 */
|
||||
internal int[] class_subs=new int[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */
|
||||
internal int[] class_book=new int[VIF_CLASS]; /* subs ^ dim entries */
|
||||
internal int[][] class_subbook=new int[VIF_CLASS][]; /* [VIF_CLASS][subs] */
|
||||
|
||||
|
||||
internal int mult; /* 1 2 3 or 4 */
|
||||
internal int[] postlist=new int[VIF_POSIT+2]; /* first two implicit */
|
||||
|
||||
|
||||
/* encode side analysis parameters */
|
||||
internal float maxover;
|
||||
internal float maxunder;
|
||||
internal float maxerr;
|
||||
|
||||
internal int twofitminsize;
|
||||
internal int twofitminused;
|
||||
internal int twofitweight;
|
||||
internal float twofitatten;
|
||||
internal int unusedminsize;
|
||||
internal int unusedmin_n;
|
||||
|
||||
internal int n;
|
||||
|
||||
internal InfoFloor1()
|
||||
{
|
||||
for(int i=0; i<class_subbook.Length; i++)
|
||||
{
|
||||
class_subbook[i]=new int[8];
|
||||
}
|
||||
}
|
||||
|
||||
internal void free()
|
||||
{
|
||||
partitionclass=null;
|
||||
class_dim=null;
|
||||
class_subs=null;
|
||||
class_book=null;
|
||||
class_subbook=null;
|
||||
postlist=null;
|
||||
}
|
||||
|
||||
internal Object copy_info()
|
||||
{
|
||||
InfoFloor1 info=this;
|
||||
InfoFloor1 ret=new InfoFloor1();
|
||||
|
||||
ret.partitions=info.partitions;
|
||||
Array.Copy(info.partitionclass, 0, ret.partitionclass, 0, VIF_PARTS);
|
||||
Array.Copy(info.class_dim, 0, ret.class_dim, 0, VIF_CLASS);
|
||||
Array.Copy(info.class_subs, 0, ret.class_subs, 0, VIF_CLASS);
|
||||
Array.Copy(info.class_book, 0, ret.class_book, 0, VIF_CLASS);
|
||||
|
||||
for(int j=0; j<VIF_CLASS; j++)
|
||||
{
|
||||
Array.Copy(info.class_subbook[j], 0,
|
||||
ret.class_subbook[j], 0, 8);
|
||||
}
|
||||
|
||||
ret.mult=info.mult;
|
||||
Array.Copy(info.postlist, 0, ret.postlist, 0, VIF_POSIT+2);
|
||||
|
||||
ret.maxover=info.maxover;
|
||||
ret.maxunder=info.maxunder;
|
||||
ret.maxerr=info.maxerr;
|
||||
|
||||
ret.twofitminsize=info.twofitminsize;
|
||||
ret.twofitminused=info.twofitminused;
|
||||
ret.twofitweight=info.twofitweight;
|
||||
ret.twofitatten=info.twofitatten;
|
||||
ret.unusedminsize=info.unusedminsize;
|
||||
ret.unusedmin_n=info.unusedmin_n;
|
||||
|
||||
ret.n=info.n;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LookFloor1
|
||||
{
|
||||
static int VIF_POSIT=63;
|
||||
|
||||
internal int[] sorted_index=new int[VIF_POSIT+2];
|
||||
internal int[] forward_index=new int[VIF_POSIT+2];
|
||||
internal int[] reverse_index=new int[VIF_POSIT+2];
|
||||
internal int[] hineighbor=new int[VIF_POSIT];
|
||||
internal int[] loneighbor=new int[VIF_POSIT];
|
||||
internal int posts;
|
||||
|
||||
internal int n;
|
||||
internal int quant_q;
|
||||
internal InfoFloor1 vi;
|
||||
|
||||
//internal int phrasebits;
|
||||
//internal int postbits;
|
||||
//internal int frames;
|
||||
|
||||
void free()
|
||||
{
|
||||
sorted_index=null;
|
||||
forward_index=null;
|
||||
reverse_index=null;
|
||||
hineighbor=null;
|
||||
loneighbor=null;
|
||||
}
|
||||
}
|
||||
|
||||
class Lsfit_acc
|
||||
{
|
||||
//long x0;
|
||||
//long x1;
|
||||
|
||||
//long xa;
|
||||
//long ya;
|
||||
//long x2a;
|
||||
//long y2a;
|
||||
//long xya;
|
||||
//long n;
|
||||
//long an;
|
||||
//long un;
|
||||
//long edgey0;
|
||||
//long edgey1;
|
||||
}
|
||||
|
||||
class EchstateFloor1
|
||||
{
|
||||
//int[] codewords;
|
||||
//float[] curve;
|
||||
//long frameno;
|
||||
//long codes;
|
||||
}
|
||||
}
|
45
Support/OggUtils/csvorbis/FuncFloor.cs
Normal file
45
Support/OggUtils/csvorbis/FuncFloor.cs
Normal file
@ -0,0 +1,45 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
abstract class FuncFloor
|
||||
{
|
||||
public static FuncFloor[] floor_P={new Floor0(),new Floor1()};
|
||||
|
||||
public abstract void pack(Object i, csBuffer opb);
|
||||
public abstract Object unpack(Info vi, csBuffer opb);
|
||||
public abstract Object look(DspState vd, InfoMode mi, Object i);
|
||||
public abstract void free_info(Object i);
|
||||
public abstract void free_look(Object i);
|
||||
public abstract void free_state(Object vs);
|
||||
public abstract int forward(Block vb, Object i, float[] fin, float[] fout, Object vs);
|
||||
public abstract Object inverse1(Block vb, Object i, Object memo);
|
||||
public abstract int inverse2(Block vb, Object i, Object memo, float[] fout);
|
||||
}
|
||||
}
|
42
Support/OggUtils/csvorbis/FuncMapping.cs
Normal file
42
Support/OggUtils/csvorbis/FuncMapping.cs
Normal file
@ -0,0 +1,42 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
abstract class FuncMapping
|
||||
{
|
||||
public static FuncMapping[] mapping_P={new Mapping0()};
|
||||
|
||||
public abstract void pack(Info info , Object imap, csBuffer buffer);
|
||||
public abstract Object unpack(Info info , csBuffer buffer);
|
||||
public abstract Object look(DspState vd, InfoMode vm, Object m);
|
||||
public abstract void free_info(Object imap);
|
||||
public abstract void free_look(Object imap);
|
||||
public abstract int inverse(Block vd, Object lm);
|
||||
}
|
||||
}
|
46
Support/OggUtils/csvorbis/FuncResidue.cs
Normal file
46
Support/OggUtils/csvorbis/FuncResidue.cs
Normal file
@ -0,0 +1,46 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
abstract class FuncResidue
|
||||
{
|
||||
public static FuncResidue[] residue_P={new Residue0(),
|
||||
new Residue1(),
|
||||
new Residue2()};
|
||||
|
||||
public abstract void pack(Object vr, csBuffer opb);
|
||||
public abstract Object unpack(Info vi, csBuffer opb);
|
||||
public abstract Object look(DspState vd, InfoMode vm, Object vr);
|
||||
public abstract void free_info(Object i);
|
||||
public abstract void free_look(Object i);
|
||||
public abstract int forward(Block vb,Object vl, float[][] fin, int ch);
|
||||
|
||||
public abstract int inverse(Block vb, Object vl, float[][] fin, int[] nonzero,int ch);
|
||||
}
|
||||
}
|
43
Support/OggUtils/csvorbis/FuncTime.cs
Normal file
43
Support/OggUtils/csvorbis/FuncTime.cs
Normal file
@ -0,0 +1,43 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
abstract class FuncTime
|
||||
{
|
||||
public static FuncTime[] time_P={new Time0()};
|
||||
|
||||
public abstract void pack(Object i, csBuffer opb);
|
||||
public abstract Object unpack(Info vi , csBuffer opb);
|
||||
public abstract Object look(DspState vd, InfoMode vm, Object i);
|
||||
public abstract void free_info(Object i);
|
||||
public abstract void free_look(Object i);
|
||||
public abstract int forward(Block vb, Object i);
|
||||
public abstract int inverse(Block vb, Object i, float[] fin, float[] fout);
|
||||
}
|
||||
}
|
574
Support/OggUtils/csvorbis/Info.cs
Normal file
574
Support/OggUtils/csvorbis/Info.cs
Normal file
@ -0,0 +1,574 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
public class Info
|
||||
{
|
||||
private static int OV_EBADPACKET=-136;
|
||||
private static int OV_ENOTAUDIO=-135;
|
||||
private static string _vorbis="vorbis";
|
||||
private static int VI_TIMEB=1;
|
||||
private static int VI_FLOORB=2;
|
||||
private static int VI_RESB=3;
|
||||
private static int VI_MAPB=1;
|
||||
private static int VI_WINDOWB=1;
|
||||
|
||||
public int version;
|
||||
public int channels;
|
||||
public int rate;
|
||||
|
||||
// The below bitrate declarations are *hints*.
|
||||
// Combinations of the three values carry the following implications:
|
||||
//
|
||||
// all three set to the same value:
|
||||
// implies a fixed rate bitstream
|
||||
// only nominal set:
|
||||
// implies a VBR stream that averages the nominal bitrate. No hard
|
||||
// upper/lower limit
|
||||
// upper and or lower set:
|
||||
// implies a VBR bitstream that obeys the bitrate limits. nominal
|
||||
// may also be set to give a nominal rate.
|
||||
// none set:
|
||||
// the coder does not care to speculate.
|
||||
|
||||
internal int bitrate_upper;
|
||||
internal int bitrate_nominal;
|
||||
internal int bitrate_lower;
|
||||
|
||||
// Vorbis supports only short and long blocks, but allows the
|
||||
// encoder to choose the sizes
|
||||
|
||||
internal int[] blocksizes=new int[2];
|
||||
|
||||
// modes are the primary means of supporting on-the-fly different
|
||||
// blocksizes, different channel mappings (LR or mid-side),
|
||||
// different residue backends, etc. Each mode consists of a
|
||||
// blocksize flag and a mapping (along with the mapping setup
|
||||
|
||||
internal int modes;
|
||||
internal int maps;
|
||||
internal int times;
|
||||
internal int floors;
|
||||
internal int residues;
|
||||
internal int books;
|
||||
internal int psys; // encode only
|
||||
|
||||
internal InfoMode[] mode_param=null;
|
||||
|
||||
internal int[] map_type=null;
|
||||
internal Object[] map_param=null;
|
||||
|
||||
internal int[] time_type=null;
|
||||
internal Object[] time_param=null;
|
||||
|
||||
internal int[] floor_type=null;
|
||||
internal Object[] floor_param=null;
|
||||
|
||||
internal int[] residue_type=null;
|
||||
internal Object[] residue_param=null;
|
||||
|
||||
internal StaticCodeBook[] book_param=null;
|
||||
|
||||
internal PsyInfo[] psy_param=new PsyInfo[64]; // encode only
|
||||
|
||||
// for block long/sort tuning; encode only
|
||||
//internal int envelopesa;
|
||||
//internal float preecho_thresh;
|
||||
//internal float preecho_clamp;
|
||||
|
||||
// used by synthesis, which has a full, alloced vi
|
||||
public void init()
|
||||
{
|
||||
rate=0;
|
||||
//memset(vi,0,sizeof(vorbis_info));
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
for(int i=0;i<modes;i++){ mode_param[i]=null; }
|
||||
mode_param=null;
|
||||
|
||||
for(int i=0;i<maps;i++)
|
||||
{ // unpack does the range checking
|
||||
FuncMapping.mapping_P[map_type[i]].free_info(map_param[i]);
|
||||
}
|
||||
map_param=null;
|
||||
|
||||
for(int i=0;i<times;i++)
|
||||
{ // unpack does the range checking
|
||||
FuncTime.time_P[time_type[i]].free_info(time_param[i]);
|
||||
}
|
||||
time_param=null;
|
||||
|
||||
for(int i=0;i<floors;i++)
|
||||
{ // unpack does the range checking
|
||||
FuncFloor.floor_P[floor_type[i]].free_info(floor_param[i]);
|
||||
}
|
||||
floor_param=null;
|
||||
|
||||
for(int i=0;i<residues;i++)
|
||||
{ // unpack does the range checking
|
||||
FuncResidue.residue_P[residue_type[i]].free_info(residue_param[i]);
|
||||
}
|
||||
residue_param=null;
|
||||
|
||||
// the static codebooks *are* freed if you call info_clear, because
|
||||
// decode side does alloc a 'static' codebook. Calling clear on the
|
||||
// full codebook does not clear the static codebook (that's our
|
||||
// responsibility)
|
||||
for(int i=0;i<books;i++)
|
||||
{
|
||||
// just in case the decoder pre-cleared to save space
|
||||
if(book_param[i]!=null)
|
||||
{
|
||||
book_param[i].clear();
|
||||
book_param[i]=null;
|
||||
}
|
||||
}
|
||||
//if(vi->book_param)free(vi->book_param);
|
||||
book_param=null;
|
||||
|
||||
for(int i=0;i<psys;i++)
|
||||
{
|
||||
psy_param[i].free();
|
||||
}
|
||||
//if(vi->psy_param)free(vi->psy_param);
|
||||
//memset(vi,0,sizeof(vorbis_info));
|
||||
}
|
||||
|
||||
// Header packing/unpacking
|
||||
int unpack_info(csBuffer opb)
|
||||
{
|
||||
version=opb.read(32);
|
||||
if(version!=0)return(-1);
|
||||
|
||||
channels=opb.read(8);
|
||||
rate=opb.read(32);
|
||||
|
||||
bitrate_upper=opb.read(32);
|
||||
bitrate_nominal=opb.read(32);
|
||||
bitrate_lower=opb.read(32);
|
||||
|
||||
blocksizes[0]=1<<opb.read(4);
|
||||
blocksizes[1]=1<<opb.read(4);
|
||||
|
||||
if((rate<1) ||
|
||||
(channels<1)||
|
||||
(blocksizes[0]<8)||
|
||||
(blocksizes[1]<blocksizes[0]) ||
|
||||
(opb.read(1)!=1))
|
||||
{
|
||||
//goto err_out; // EOP check
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
// err_out:
|
||||
// vorbis_info_clear(vi);
|
||||
// return(-1);
|
||||
}
|
||||
|
||||
// all of the real encoding details are here. The modes, books,
|
||||
// everything
|
||||
int unpack_books(csBuffer opb)
|
||||
{
|
||||
|
||||
//d* codebooks
|
||||
books=opb.read(8)+1;
|
||||
|
||||
if(book_param==null || book_param.Length!=books)
|
||||
book_param=new StaticCodeBook[books];
|
||||
for(int i=0;i<books;i++)
|
||||
{
|
||||
book_param[i]=new StaticCodeBook();
|
||||
if(book_param[i].unpack(opb)!=0)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// time backend settings
|
||||
times=opb.read(6)+1;
|
||||
if(time_type==null || time_type.Length!=times) time_type=new int[times];
|
||||
if(time_param==null || time_param.Length!=times)
|
||||
time_param=new Object[times];
|
||||
for(int i=0;i<times;i++)
|
||||
{
|
||||
time_type[i]=opb.read(16);
|
||||
if(time_type[i]<0 || time_type[i]>=VI_TIMEB)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
time_param[i]=FuncTime.time_P[time_type[i]].unpack(this, opb);
|
||||
if(time_param[i]==null)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// floor backend settings
|
||||
floors=opb.read(6)+1;
|
||||
if(floor_type==null || floor_type.Length!=floors)
|
||||
floor_type=new int[floors];
|
||||
if(floor_param==null || floor_param.Length!=floors)
|
||||
floor_param=new Object[floors];
|
||||
|
||||
for(int i=0;i<floors;i++)
|
||||
{
|
||||
floor_type[i]=opb.read(16);
|
||||
if(floor_type[i]<0 || floor_type[i]>=VI_FLOORB)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
|
||||
floor_param[i]=FuncFloor.floor_P[floor_type[i]].unpack(this,opb);
|
||||
if(floor_param[i]==null)
|
||||
{
|
||||
//goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// residue backend settings
|
||||
residues=opb.read(6)+1;
|
||||
|
||||
if(residue_type==null || residue_type.Length!=residues)
|
||||
residue_type=new int[residues];
|
||||
|
||||
if(residue_param==null || residue_param.Length!=residues)
|
||||
residue_param=new Object[residues];
|
||||
|
||||
for(int i=0;i<residues;i++)
|
||||
{
|
||||
residue_type[i]=opb.read(16);
|
||||
if(residue_type[i]<0 || residue_type[i]>=VI_RESB)
|
||||
{
|
||||
// goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
residue_param[i]=FuncResidue.residue_P[residue_type[i]].unpack(this,opb);
|
||||
if(residue_param[i]==null)
|
||||
{
|
||||
// goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// map backend settings
|
||||
maps=opb.read(6)+1;
|
||||
if(map_type==null || map_type.Length!=maps) map_type=new int[maps];
|
||||
if(map_param==null || map_param.Length!=maps) map_param=new Object[maps];
|
||||
for(int i=0;i<maps;i++)
|
||||
{
|
||||
map_type[i]=opb.read(16);
|
||||
if(map_type[i]<0 || map_type[i]>=VI_MAPB)
|
||||
{
|
||||
// goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
map_param[i]=FuncMapping.mapping_P[map_type[i]].unpack(this,opb);
|
||||
if(map_param[i]==null)
|
||||
{
|
||||
// goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// mode settings
|
||||
modes=opb.read(6)+1;
|
||||
if(mode_param==null || mode_param.Length!=modes)
|
||||
mode_param=new InfoMode[modes];
|
||||
for(int i=0;i<modes;i++)
|
||||
{
|
||||
mode_param[i]=new InfoMode();
|
||||
mode_param[i].blockflag=opb.read(1);
|
||||
mode_param[i].windowtype=opb.read(16);
|
||||
mode_param[i].transformtype=opb.read(16);
|
||||
mode_param[i].mapping=opb.read(8);
|
||||
|
||||
if((mode_param[i].windowtype>=VI_WINDOWB)||
|
||||
(mode_param[i].transformtype>=VI_WINDOWB)||
|
||||
(mode_param[i].mapping>=maps))
|
||||
{
|
||||
// goto err_out;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if(opb.read(1)!=1)
|
||||
{
|
||||
//goto err_out; // top level EOP check
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
// err_out:
|
||||
// vorbis_info_clear(vi);
|
||||
// return(-1);
|
||||
}
|
||||
|
||||
// The Vorbis header is in three packets; the initial small packet in
|
||||
// the first page that identifies basic parameters, a second packet
|
||||
// with bitstream comments and a third packet that holds the
|
||||
// codebook.
|
||||
|
||||
public int synthesis_headerin(Comment vc, Packet op)
|
||||
{
|
||||
csBuffer opb=new csBuffer();
|
||||
|
||||
if(op!=null)
|
||||
{
|
||||
opb.readinit(op.packet_base, op.packet, op.bytes);
|
||||
|
||||
// Which of the three types of header is this?
|
||||
// Also verify header-ness, vorbis
|
||||
{
|
||||
byte[] buffer=new byte[6];
|
||||
int packtype=opb.read(8);
|
||||
//memset(buffer,0,6);
|
||||
opb.read(buffer,6);
|
||||
if(buffer[0]!='v' || buffer[1]!='o' || buffer[2]!='r' ||
|
||||
buffer[3]!='b' || buffer[4]!='i' || buffer[5]!='s')
|
||||
{
|
||||
// not a vorbis header
|
||||
return(-1);
|
||||
}
|
||||
switch(packtype)
|
||||
{
|
||||
case 0x01: // least significant *bit* is read first
|
||||
if(op.b_o_s==0)
|
||||
{
|
||||
// Not the initial packet
|
||||
return(-1);
|
||||
}
|
||||
if(rate!=0)
|
||||
{
|
||||
// previously initialized info header
|
||||
return(-1);
|
||||
}
|
||||
return(unpack_info(opb));
|
||||
case 0x03: // least significant *bit* is read first
|
||||
if(rate==0)
|
||||
{
|
||||
// um... we didn't get the initial header
|
||||
return(-1);
|
||||
}
|
||||
return(vc.unpack(opb));
|
||||
case 0x05: // least significant *bit* is read first
|
||||
if(rate==0 || vc.vendor==null)
|
||||
{
|
||||
// um... we didn;t get the initial header or comments yet
|
||||
return(-1);
|
||||
}
|
||||
return(unpack_books(opb));
|
||||
default:
|
||||
// Not a valid vorbis header type
|
||||
//return(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// pack side
|
||||
int pack_info(csBuffer opb)
|
||||
{
|
||||
Encoding AE = Encoding.UTF8;
|
||||
byte[] _vorbis_byt = AE.GetBytes(_vorbis);
|
||||
|
||||
// preamble
|
||||
opb.write(0x01,8);
|
||||
opb.write(_vorbis_byt);
|
||||
|
||||
// basic information about the stream
|
||||
opb.write(0x00,32);
|
||||
opb.write(channels,8);
|
||||
opb.write(rate,32);
|
||||
|
||||
opb.write(bitrate_upper,32);
|
||||
opb.write(bitrate_nominal,32);
|
||||
opb.write(bitrate_lower,32);
|
||||
|
||||
opb.write(ilog2(blocksizes[0]),4);
|
||||
opb.write(ilog2(blocksizes[1]),4);
|
||||
opb.write(1,1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int pack_books(csBuffer opb)
|
||||
{
|
||||
Encoding AE = Encoding.UTF8;
|
||||
byte[] _vorbis_byt = AE.GetBytes(_vorbis);
|
||||
|
||||
opb.write(0x05,8);
|
||||
opb.write(_vorbis_byt);
|
||||
|
||||
// books
|
||||
opb.write(books-1,8);
|
||||
for(int i=0;i<books;i++)
|
||||
{
|
||||
if(book_param[i].pack(opb)!=0)
|
||||
{
|
||||
//goto err_out;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// times
|
||||
opb.write(times-1,6);
|
||||
for(int i=0;i<times;i++)
|
||||
{
|
||||
opb.write(time_type[i],16);
|
||||
FuncTime.time_P[time_type[i]].pack(this.time_param[i],opb);
|
||||
}
|
||||
|
||||
// floors
|
||||
opb.write(floors-1,6);
|
||||
for(int i=0;i<floors;i++)
|
||||
{
|
||||
opb.write(floor_type[i],16);
|
||||
FuncFloor.floor_P[floor_type[i]].pack(floor_param[i],opb);
|
||||
}
|
||||
|
||||
// residues
|
||||
opb.write(residues-1,6);
|
||||
for(int i=0;i<residues;i++)
|
||||
{
|
||||
opb.write(residue_type[i],16);
|
||||
FuncResidue.residue_P[residue_type[i]].pack(residue_param[i],opb);
|
||||
}
|
||||
|
||||
// maps
|
||||
opb.write(maps-1,6);
|
||||
for(int i=0;i<maps;i++)
|
||||
{
|
||||
opb.write(map_type[i],16);
|
||||
FuncMapping.mapping_P[map_type[i]].pack(this,map_param[i],opb);
|
||||
}
|
||||
|
||||
// modes
|
||||
opb.write(modes-1,6);
|
||||
for(int i=0;i<modes;i++)
|
||||
{
|
||||
opb.write(mode_param[i].blockflag,1);
|
||||
opb.write(mode_param[i].windowtype,16);
|
||||
opb.write(mode_param[i].transformtype,16);
|
||||
opb.write(mode_param[i].mapping,8);
|
||||
}
|
||||
opb.write(1,1);
|
||||
return(0);
|
||||
//err_out:
|
||||
//return(-1);
|
||||
}
|
||||
|
||||
// static void v_writestring(csBuffer o, byte[] s){
|
||||
// int i=0;
|
||||
// while(s[i]!=0){
|
||||
// o.write(s[i++],8);
|
||||
// }
|
||||
// }
|
||||
|
||||
// static void v_readstring(csBuffer o, byte[] buf, int bytes){
|
||||
// int i=0
|
||||
// while(bytes--!=0){
|
||||
// buf[i++]=o.read(8);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private csBuffer opb_blocksize=new csBuffer();
|
||||
public int blocksize(Packet op)
|
||||
{
|
||||
//codec_setup_info *ci=vi->codec_setup;
|
||||
csBuffer opb=new csBuffer();
|
||||
// synchronized(opb_blocksize){
|
||||
int mode;
|
||||
|
||||
opb.readinit(op.packet_base, op.packet, op.bytes);
|
||||
|
||||
/* Check the packet type */
|
||||
if(opb.read(1)!=0)
|
||||
{
|
||||
/* Oops. This is not an audio data packet */
|
||||
return(OV_ENOTAUDIO);
|
||||
}
|
||||
{
|
||||
int modebits=0;
|
||||
int v=modes;
|
||||
while(v>1)
|
||||
{
|
||||
modebits++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
|
||||
/* read our mode and pre/post windowsize */
|
||||
mode=opb.read(modebits);
|
||||
}
|
||||
if(mode==-1)return(OV_EBADPACKET);
|
||||
return(blocksizes[mode_param[mode].blockflag]);
|
||||
// }
|
||||
}
|
||||
|
||||
private static int ilog2(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v>1)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "version:"+ version.ToString() +
|
||||
", channels:"+ channels.ToString() +
|
||||
", rate:"+ rate.ToString() +
|
||||
", bitrate:"+ bitrate_upper.ToString() +","+
|
||||
bitrate_nominal.ToString() +","+
|
||||
bitrate_lower.ToString();
|
||||
}
|
||||
}
|
||||
}
|
38
Support/OggUtils/csvorbis/InfoMode.cs
Normal file
38
Support/OggUtils/csvorbis/InfoMode.cs
Normal file
@ -0,0 +1,38 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class InfoMode
|
||||
{
|
||||
internal int blockflag;
|
||||
internal int windowtype;
|
||||
internal int transformtype;
|
||||
internal int mapping;
|
||||
}
|
||||
}
|
161
Support/OggUtils/csvorbis/Lookup.cs
Normal file
161
Support/OggUtils/csvorbis/Lookup.cs
Normal file
@ -0,0 +1,161 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Lookup
|
||||
{
|
||||
static int COS_LOOKUP_SZ=128;
|
||||
static float[] COS_LOOKUP={
|
||||
+1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f,
|
||||
+0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f,
|
||||
+0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f,
|
||||
+0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f,
|
||||
+0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f,
|
||||
+0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f,
|
||||
+0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f,
|
||||
+0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f,
|
||||
+0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f,
|
||||
+0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f,
|
||||
+0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f,
|
||||
+0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f,
|
||||
+0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f,
|
||||
+0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f,
|
||||
+0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f,
|
||||
+0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f,
|
||||
+0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f,
|
||||
-0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f,
|
||||
-0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f,
|
||||
-0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f,
|
||||
-0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f,
|
||||
-0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f,
|
||||
-0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f,
|
||||
-0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f,
|
||||
-0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f,
|
||||
-0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f,
|
||||
-0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f,
|
||||
-0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f,
|
||||
-0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f,
|
||||
-0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f,
|
||||
-0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f,
|
||||
-0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f,
|
||||
-1.0000000000000f,
|
||||
};
|
||||
/* interpolated lookup based cos function, domain 0 to PI only */
|
||||
internal static float coslook(float a)
|
||||
{
|
||||
double d=a*(.31830989*(float)COS_LOOKUP_SZ);
|
||||
int i=(int)d;
|
||||
return COS_LOOKUP[i]+ ((float)(d-i))*(COS_LOOKUP[i+1]-COS_LOOKUP[i]);
|
||||
}
|
||||
|
||||
static int INVSQ_LOOKUP_SZ=32;
|
||||
static float[] INVSQ_LOOKUP={
|
||||
1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f,
|
||||
1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f,
|
||||
1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f,
|
||||
1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f,
|
||||
1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f,
|
||||
1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f,
|
||||
1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f,
|
||||
1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f,
|
||||
1.000000000000f,
|
||||
};
|
||||
/* interpolated 1./sqrt(p) where .5 <= p < 1. */
|
||||
internal static float invsqlook(float a)
|
||||
{
|
||||
// System.out.println(a);
|
||||
double d=a*(2.0f*(float)INVSQ_LOOKUP_SZ)-(float)INVSQ_LOOKUP_SZ;
|
||||
int i=(int)d;
|
||||
return INVSQ_LOOKUP[i]+ ((float)(d-i))*(INVSQ_LOOKUP[i+1]-INVSQ_LOOKUP[i]);
|
||||
}
|
||||
|
||||
static int INVSQ2EXP_LOOKUP_MIN=-32;
|
||||
//static int INVSQ2EXP_LOOKUP_MAX=32;
|
||||
static float[] INVSQ2EXP_LOOKUP={
|
||||
65536.0f, 46340.95001f, 32768.0f, 23170.47501f,
|
||||
16384.0f, 11585.2375f, 8192.0f, 5792.618751f,
|
||||
4096.0f, 2896.309376f, 2048.0f, 1448.154688f,
|
||||
1024.0f, 724.0773439f, 512.0f, 362.038672f,
|
||||
256.0f, 181.019336f, 128.0f, 90.50966799f,
|
||||
64.0f, 45.254834f, 32.0f, 22.627417f,
|
||||
16.0f, 11.3137085f, 8.0f, 5.656854249f,
|
||||
4.0f, 2.828427125f, 2.0f, 1.414213562f,
|
||||
1.0f, 0.7071067812f, 0.5f, 0.3535533906f,
|
||||
0.25f, 0.1767766953f, 0.125f, 0.08838834765f,
|
||||
0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f,
|
||||
0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f,
|
||||
0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f,
|
||||
0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f,
|
||||
0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f,
|
||||
6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f,
|
||||
1.525878906e-05f,
|
||||
};
|
||||
/* interpolated 1./sqrt(p) where .5 <= p < 1. */
|
||||
internal static float invsq2explook(int a)
|
||||
{
|
||||
return INVSQ2EXP_LOOKUP[a-INVSQ2EXP_LOOKUP_MIN];
|
||||
}
|
||||
|
||||
const int FROMdB_LOOKUP_SZ=35;
|
||||
const int FROMdB2_LOOKUP_SZ=32;
|
||||
const int FROMdB_SHIFT=5;
|
||||
const int FROMdB2_SHIFT=3;
|
||||
const int FROMdB2_MASK=31;
|
||||
static float[] FROMdB_LOOKUP = {
|
||||
1.0f, 0.6309573445f, 0.3981071706f, 0.2511886432f,
|
||||
0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f,
|
||||
0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f,
|
||||
0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f,
|
||||
0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f,
|
||||
0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f,
|
||||
1.584893192e-05f, 1e-05f,6.309573445e-06f,3.981071706e-06f,
|
||||
2.511886432e-06f,1.584893192e-06f, 1e-06f,6.309573445e-07f,
|
||||
3.981071706e-07f,2.511886432e-07f,1.584893192e-07f,
|
||||
};
|
||||
static float[] FROMdB2_LOOKUP = {
|
||||
0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f,
|
||||
0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f,
|
||||
0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f,
|
||||
0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f,
|
||||
0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f,
|
||||
0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f,
|
||||
0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f,
|
||||
0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f,
|
||||
};
|
||||
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */
|
||||
internal static float fromdBlook(float a)
|
||||
{
|
||||
int i=(int)(a*((float)(-(1<<FROMdB2_SHIFT))));
|
||||
return (i<0)?1.0f:
|
||||
((i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))?0.0f:
|
||||
FROMdB_LOOKUP[(uint)i>>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
200
Support/OggUtils/csvorbis/Lpc.cs
Normal file
200
Support/OggUtils/csvorbis/Lpc.cs
Normal file
@ -0,0 +1,200 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Lpc
|
||||
{
|
||||
Drft fft=new Drft();
|
||||
|
||||
int ln;
|
||||
int m;
|
||||
|
||||
// Autocorrelation LPC coeff generation algorithm invented by
|
||||
// N. Levinson in 1947, modified by J. Durbin in 1959.
|
||||
|
||||
// Input : n elements of time doamin data
|
||||
// Output: m lpc coefficients, excitation energy
|
||||
|
||||
static float lpc_from_data(float[] data, float[] lpc,int n,int m)
|
||||
{
|
||||
float[] aut=new float[m+1];
|
||||
float error;
|
||||
int i,j;
|
||||
|
||||
// autocorrelation, p+1 lag coefficients
|
||||
|
||||
j=m+1;
|
||||
while(j--!=0)
|
||||
{
|
||||
float d=0.0F;
|
||||
for(i=j;i<n;i++)d+=data[i]*data[i-j];
|
||||
aut[j]=d;
|
||||
}
|
||||
|
||||
// Generate lpc coefficients from autocorr values
|
||||
|
||||
error=aut[0];
|
||||
/*
|
||||
if(error==0){
|
||||
for(int k=0; k<m; k++) lpc[k]=0.0f;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
for(i=0;i<m;i++)
|
||||
{
|
||||
float r=-aut[i+1];
|
||||
|
||||
if(error==0)
|
||||
{
|
||||
for(int k=0; k<m; k++) lpc[k]=0.0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sum up this iteration's reflection coefficient; note that in
|
||||
// Vorbis we don't save it. If anyone wants to recycle this code
|
||||
// and needs reflection coefficients, save the results of 'r' from
|
||||
// each iteration.
|
||||
|
||||
for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
|
||||
r/=error;
|
||||
|
||||
// Update LPC coefficients and total error
|
||||
|
||||
lpc[i]=r;
|
||||
for(j=0;j<i/2;j++)
|
||||
{
|
||||
float tmp=lpc[j];
|
||||
lpc[j]+=r*lpc[i-1-j];
|
||||
lpc[i-1-j]+=r*tmp;
|
||||
}
|
||||
if(i%2!=0)lpc[j]+=lpc[j]*r;
|
||||
|
||||
error*=(float)(1.0-r*r);
|
||||
}
|
||||
|
||||
// we need the error value to know how big an impulse to hit the
|
||||
// filter with later
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
// Input : n element envelope spectral curve
|
||||
// Output: m lpc coefficients, excitation energy
|
||||
|
||||
float lpc_from_curve(float[] curve, float[] lpc)
|
||||
{
|
||||
int n=ln;
|
||||
float[] work=new float[n+n];
|
||||
float fscale=(float)(.5/n);
|
||||
int i,j;
|
||||
|
||||
// input is a real curve. make it complex-real
|
||||
// This mixes phase, but the LPC generation doesn't care.
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
work[i*2]=curve[i]*fscale;
|
||||
work[i*2+1]=0;
|
||||
}
|
||||
work[n*2-1]=curve[n-1]*fscale;
|
||||
|
||||
n*=2;
|
||||
fft.backward(work);
|
||||
|
||||
// The autocorrelation will not be circular. Shift, else we lose
|
||||
// most of the power in the edges.
|
||||
|
||||
for(i=0,j=n/2;i<n/2;)
|
||||
{
|
||||
float temp=work[i];
|
||||
work[i++]=work[j];
|
||||
work[j++]=temp;
|
||||
}
|
||||
|
||||
return(lpc_from_data(work,lpc,n,m));
|
||||
}
|
||||
|
||||
internal void init(int mapped, int m)
|
||||
{
|
||||
//memset(l,0,sizeof(lpc_lookup));
|
||||
|
||||
ln=mapped;
|
||||
this.m=m;
|
||||
|
||||
// we cheat decoding the LPC spectrum via FFTs
|
||||
fft.init(mapped*2);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
fft.clear();
|
||||
}
|
||||
|
||||
static float FAST_HYPOT(float a, float b)
|
||||
{
|
||||
return (float)Math.Sqrt((a)*(a) + (b)*(b));
|
||||
}
|
||||
|
||||
// One can do this the long way by generating the transfer function in
|
||||
// the time domain and taking the forward FFT of the result. The
|
||||
// results from direct calculation are cleaner and faster.
|
||||
//
|
||||
// This version does a linear curve generation and then later
|
||||
// interpolates the log curve from the linear curve.
|
||||
|
||||
internal void lpc_to_curve(float[] curve, float[] lpc, float amp)
|
||||
{
|
||||
|
||||
//memset(curve,0,sizeof(float)*l->ln*2);
|
||||
for(int i=0; i<ln*2; i++)curve[i]=0.0f;
|
||||
|
||||
if(amp==0)return;
|
||||
|
||||
for(int i=0;i<m;i++)
|
||||
{
|
||||
curve[i*2+1]=lpc[i]/(4*amp);
|
||||
curve[i*2+2]=-lpc[i]/(4*amp);
|
||||
}
|
||||
|
||||
fft.backward(curve); // reappropriated ;-)
|
||||
|
||||
int l2=ln*2;
|
||||
float unit=(float)(1.0/amp);
|
||||
curve[0]=(float)(1.0/(curve[0]*2+unit));
|
||||
for(int i=1;i<ln;i++)
|
||||
{
|
||||
float real=(curve[i]+curve[l2-i]);
|
||||
float imag=(curve[i]-curve[l2-i]);
|
||||
|
||||
float a = real + unit;
|
||||
curve[i] = (float)(1.0 / FAST_HYPOT(a, imag));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
Support/OggUtils/csvorbis/Lsp.cs
Normal file
133
Support/OggUtils/csvorbis/Lsp.cs
Normal file
@ -0,0 +1,133 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
/*
|
||||
function: LSP (also called LSF) conversion routines
|
||||
|
||||
The LSP generation code is taken (with minimal modification) from
|
||||
"On the Computation of the LSP Frequencies" by Joseph Rothweiler
|
||||
<rothwlr@altavista.net>, available at:
|
||||
|
||||
http://www2.xtdl.com/~rothwlr/lsfpaper/lsfpage.html
|
||||
********************************************************************/
|
||||
|
||||
class Lsp
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size=32, CharSet=CharSet.Ansi)]
|
||||
struct FloatHack
|
||||
{
|
||||
[FieldOffset(0)] public float fh_float;
|
||||
[FieldOffset(0)] public int fh_int;
|
||||
}
|
||||
static float M_PI=(float)(3.1415926539);
|
||||
|
||||
internal static void lsp_to_curve(float[] curve,
|
||||
int[] map, int n, int ln,
|
||||
float[] lsp, int m,
|
||||
float amp, float ampoffset)
|
||||
{
|
||||
int i;
|
||||
float wdel=M_PI/ln;
|
||||
for(i=0;i<m;i++)lsp[i]=Lookup.coslook(lsp[i]);
|
||||
int m2=(m/2)*2;
|
||||
|
||||
i=0;
|
||||
while(i<n)
|
||||
{
|
||||
FloatHack fh = new FloatHack();
|
||||
int k=map[i];
|
||||
float p=.7071067812f;
|
||||
float q=.7071067812f;
|
||||
float w=Lookup.coslook(wdel*k);
|
||||
//int ftmp=0;
|
||||
int c=(int)((uint)m >> 1);
|
||||
|
||||
for(int j=0;j<m2;j+=2)
|
||||
{
|
||||
q*=lsp[j]-w;
|
||||
p*=lsp[j+1]-w;
|
||||
}
|
||||
|
||||
if((m&1)!=0)
|
||||
{
|
||||
/* odd order filter; slightly assymetric */
|
||||
/* the last coefficient */
|
||||
q*=lsp[m-1]-w;
|
||||
q*=q;
|
||||
p*=p*(1.0f-w*w);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* even order filter; still symmetric */
|
||||
q*=q*(1.0f+w);
|
||||
p*=p*(1.0f-w);
|
||||
}
|
||||
|
||||
// q=frexp(p+q,&qexp);
|
||||
q=p+q;
|
||||
fh.fh_float = q;
|
||||
int hx=fh.fh_int;
|
||||
int ix=0x7fffffff&hx;
|
||||
int qexp=0;
|
||||
|
||||
if(ix>=0x7f800000||(ix==0))
|
||||
{
|
||||
// 0,inf,nan
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ix<0x00800000)
|
||||
{ // subnormal
|
||||
q*=3.3554432000e+07F; // 0x4c000000
|
||||
fh.fh_float = q;
|
||||
hx=fh.fh_int;
|
||||
ix=0x7fffffff&hx;
|
||||
qexp=-25;
|
||||
}
|
||||
qexp += (int)(((uint)ix >> 23)-126);
|
||||
hx=(int)((hx&0x807fffff)|0x3f000000);
|
||||
fh.fh_int = hx;
|
||||
q=fh.fh_float;
|
||||
}
|
||||
|
||||
q=Lookup.fromdBlook(amp*
|
||||
Lookup.invsqlook(q)*
|
||||
Lookup.invsq2explook(qexp+m)-ampoffset);
|
||||
|
||||
do{curve[i]*=q; i++;}
|
||||
// do{curve[i++]=q;}
|
||||
while(i<n&&map[i]==k);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
456
Support/OggUtils/csvorbis/Mapping0.cs
Normal file
456
Support/OggUtils/csvorbis/Mapping0.cs
Normal file
@ -0,0 +1,456 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Mapping0 : FuncMapping
|
||||
{
|
||||
//static int seq=0;
|
||||
override public void free_info(Object imap){}
|
||||
override public void free_look(Object imap){}
|
||||
|
||||
override public Object look(DspState vd, InfoMode vm, Object m)
|
||||
{
|
||||
Info vi=vd.vi;
|
||||
LookMapping0 looks=new LookMapping0();
|
||||
InfoMapping0 info=looks.map=(InfoMapping0)m;
|
||||
looks.mode=vm;
|
||||
|
||||
looks.time_look=new Object[info.submaps];
|
||||
looks.floor_look=new Object[info.submaps];
|
||||
looks.residue_look=new Object[info.submaps];
|
||||
|
||||
looks.time_func=new FuncTime[info.submaps];
|
||||
looks.floor_func=new FuncFloor[info.submaps];
|
||||
looks.residue_func=new FuncResidue[info.submaps];
|
||||
|
||||
for(int i=0;i<info.submaps;i++)
|
||||
{
|
||||
int timenum=info.timesubmap[i];
|
||||
int floornum=info.floorsubmap[i];
|
||||
int resnum=info.residuesubmap[i];
|
||||
|
||||
looks.time_func[i]=FuncTime.time_P[vi.time_type[timenum]];
|
||||
looks.time_look[i]=looks.time_func[i].look(vd,vm,vi.time_param[timenum]);
|
||||
|
||||
looks.floor_func[i]=FuncFloor.floor_P[vi.floor_type[floornum]];
|
||||
looks.floor_look[i]=looks.floor_func[i].
|
||||
look(vd,vm,vi.floor_param[floornum]);
|
||||
|
||||
looks.residue_func[i]=FuncResidue.residue_P[vi.residue_type[resnum]];
|
||||
looks.residue_look[i]=looks.residue_func[i].
|
||||
look(vd,vm,vi.residue_param[resnum]);
|
||||
}
|
||||
|
||||
if(vi.psys!=0 && vd.analysisp!=0)
|
||||
{
|
||||
}
|
||||
|
||||
looks.ch=vi.channels;
|
||||
|
||||
return(looks);
|
||||
}
|
||||
|
||||
override public void pack(Info vi, Object imap, csBuffer opb)
|
||||
{
|
||||
InfoMapping0 info=(InfoMapping0)imap;
|
||||
|
||||
/* another 'we meant to do it this way' hack... up to beta 4, we
|
||||
packed 4 binary zeros here to signify one submapping in use. We
|
||||
now redefine that to mean four bitflags that indicate use of
|
||||
deeper features; bit0:submappings, bit1:coupling,
|
||||
bit2,3:reserved. This is backward compatable with all actual uses
|
||||
of the beta code. */
|
||||
|
||||
if(info.submaps>1)
|
||||
{
|
||||
opb.write(1,1);
|
||||
opb.write(info.submaps-1,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
opb.write(0,1);
|
||||
}
|
||||
|
||||
if(info.coupling_steps>0)
|
||||
{
|
||||
opb.write(1,1);
|
||||
opb.write(info.coupling_steps-1,8);
|
||||
for(int i=0;i<info.coupling_steps;i++)
|
||||
{
|
||||
opb.write(info.coupling_mag[i],ilog2(vi.channels));
|
||||
opb.write(info.coupling_ang[i],ilog2(vi.channels));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
opb.write(0,1);
|
||||
}
|
||||
|
||||
opb.write(0,2); /* 2,3:reserved */
|
||||
|
||||
/* we don't write the channel submappings if we only have one... */
|
||||
if(info.submaps>1)
|
||||
{
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
opb.write(info.chmuxlist[i],4);
|
||||
}
|
||||
for(int i=0;i<info.submaps;i++)
|
||||
{
|
||||
opb.write(info.timesubmap[i],8);
|
||||
opb.write(info.floorsubmap[i],8);
|
||||
opb.write(info.residuesubmap[i],8);
|
||||
}
|
||||
}
|
||||
|
||||
override public Object unpack(Info vi, csBuffer opb)
|
||||
{
|
||||
// also responsible for range checking
|
||||
InfoMapping0 info=new InfoMapping0();
|
||||
|
||||
// !!!!
|
||||
if(opb.read(1)!=0)
|
||||
{
|
||||
info.submaps=opb.read(4)+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.submaps=1;
|
||||
}
|
||||
|
||||
if(opb.read(1)!=0)
|
||||
{
|
||||
info.coupling_steps=opb.read(8)+1;
|
||||
|
||||
for(int i=0;i<info.coupling_steps;i++)
|
||||
{
|
||||
int testM=info.coupling_mag[i]=opb.read(ilog2(vi.channels));
|
||||
int testA=info.coupling_ang[i]=opb.read(ilog2(vi.channels));
|
||||
|
||||
if(testM<0 ||
|
||||
testA<0 ||
|
||||
testM==testA ||
|
||||
testM>=vi.channels ||
|
||||
testA>=vi.channels)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(opb.read(2)>0)
|
||||
{ /* 2,3:reserved */
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
|
||||
if(info.submaps>1)
|
||||
{
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
info.chmuxlist[i]=opb.read(4);
|
||||
if(info.chmuxlist[i]>=info.submaps)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<info.submaps;i++)
|
||||
{
|
||||
info.timesubmap[i]=opb.read(8);
|
||||
if(info.timesubmap[i]>=vi.times)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
info.floorsubmap[i]=opb.read(8);
|
||||
if(info.floorsubmap[i]>=vi.floors)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
info.residuesubmap[i]=opb.read(8);
|
||||
if(info.residuesubmap[i]>=vi.residues)
|
||||
{
|
||||
//goto err_out;
|
||||
info.free();
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
//err_out:
|
||||
//free_info(info);
|
||||
//return(NULL);
|
||||
}
|
||||
|
||||
|
||||
float[][] pcmbundle=null;
|
||||
int[] zerobundle=null;
|
||||
int[] nonzero=null;
|
||||
Object[] floormemo=null;
|
||||
|
||||
override public int inverse(Block vb, Object l)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
//System.err.println("Mapping0.inverse");
|
||||
DspState vd=vb.vd;
|
||||
Info vi=vd.vi;
|
||||
LookMapping0 look=(LookMapping0)l;
|
||||
InfoMapping0 info=look.map;
|
||||
InfoMode mode=look.mode;
|
||||
int n=vb.pcmend=vi.blocksizes[vb.W];
|
||||
|
||||
float[] window=vd.wnd[vb.W][vb.lW][vb.nW][mode.windowtype];
|
||||
// float[][] pcmbundle=new float[vi.channels][];
|
||||
// int[] nonzero=new int[vi.channels];
|
||||
if(pcmbundle==null || pcmbundle.Length<vi.channels)
|
||||
{
|
||||
pcmbundle=new float[vi.channels][];
|
||||
nonzero=new int[vi.channels];
|
||||
zerobundle=new int[vi.channels];
|
||||
floormemo=new Object[vi.channels];
|
||||
}
|
||||
|
||||
// time domain information decode (note that applying the
|
||||
// information would have to happen later; we'll probably add a
|
||||
// function entry to the harness for that later
|
||||
// NOT IMPLEMENTED
|
||||
|
||||
// recover the spectral envelope; store it in the PCM vector for now
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
float[] pcm=vb.pcm[i];
|
||||
int submap=info.chmuxlist[i];
|
||||
|
||||
floormemo[i]=look.floor_func[submap].inverse1(vb,look.
|
||||
floor_look[submap],
|
||||
floormemo[i]
|
||||
);
|
||||
if(floormemo[i]!=null){ nonzero[i]=1; }
|
||||
else{ nonzero[i]=0; }
|
||||
for(int j=0; j<n/2; j++)
|
||||
{
|
||||
pcm[j]=0;
|
||||
}
|
||||
|
||||
//_analysis_output("ifloor",seq+i,pcm,n/2,0,1);
|
||||
}
|
||||
|
||||
for(int i=0; i<info.coupling_steps; i++)
|
||||
{
|
||||
if(nonzero[info.coupling_mag[i]]!=0 ||
|
||||
nonzero[info.coupling_ang[i]]!=0)
|
||||
{
|
||||
nonzero[info.coupling_mag[i]]=1;
|
||||
nonzero[info.coupling_ang[i]]=1;
|
||||
}
|
||||
}
|
||||
|
||||
// recover the residue, apply directly to the spectral envelope
|
||||
|
||||
for(int i=0;i<info.submaps;i++)
|
||||
{
|
||||
int ch_in_bundle=0;
|
||||
for(int j=0;j<vi.channels;j++)
|
||||
{
|
||||
if(info.chmuxlist[j]==i)
|
||||
{
|
||||
if(nonzero[j]!=0)
|
||||
{
|
||||
zerobundle[ch_in_bundle]=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
zerobundle[ch_in_bundle]=0;
|
||||
}
|
||||
pcmbundle[ch_in_bundle++]=vb.pcm[j];
|
||||
}
|
||||
}
|
||||
|
||||
look.residue_func[i].inverse(vb,look.residue_look[i],
|
||||
pcmbundle,zerobundle,ch_in_bundle);
|
||||
}
|
||||
|
||||
|
||||
for(int i=info.coupling_steps-1;i>=0;i--)
|
||||
{
|
||||
float[] pcmM=vb.pcm[info.coupling_mag[i]];
|
||||
float[] pcmA=vb.pcm[info.coupling_ang[i]];
|
||||
|
||||
for(int j=0;j<n/2;j++)
|
||||
{
|
||||
float mag=pcmM[j];
|
||||
float ang=pcmA[j];
|
||||
|
||||
if(mag>0)
|
||||
{
|
||||
if(ang>0)
|
||||
{
|
||||
pcmM[j]=mag;
|
||||
pcmA[j]=mag-ang;
|
||||
}
|
||||
else
|
||||
{
|
||||
pcmA[j]=mag;
|
||||
pcmM[j]=mag+ang;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ang>0)
|
||||
{
|
||||
pcmM[j]=mag;
|
||||
pcmA[j]=mag+ang;
|
||||
}
|
||||
else
|
||||
{
|
||||
pcmA[j]=mag;
|
||||
pcmM[j]=mag-ang;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /* compute and apply spectral envelope */
|
||||
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
float[] pcm=vb.pcm[i];
|
||||
int submap=info.chmuxlist[i];
|
||||
look.floor_func[submap].inverse2(vb,look.floor_look[submap],floormemo[i],pcm);
|
||||
}
|
||||
|
||||
// transform the PCM data; takes PCM vector, vb; modifies PCM vector
|
||||
// only MDCT right now....
|
||||
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
float[] pcm=vb.pcm[i];
|
||||
//_analysis_output("out",seq+i,pcm,n/2,0,0);
|
||||
((Mdct)vd.transform[vb.W][0]).backward(pcm,pcm);
|
||||
}
|
||||
|
||||
// now apply the decoded pre-window time information
|
||||
// NOT IMPLEMENTED
|
||||
|
||||
// window the data
|
||||
for(int i=0;i<vi.channels;i++)
|
||||
{
|
||||
float[] pcm=vb.pcm[i];
|
||||
if(nonzero[i]!=0)
|
||||
{
|
||||
for(int j=0;j<n;j++)
|
||||
{
|
||||
pcm[j]*=window[j];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int j=0;j<n;j++)
|
||||
{
|
||||
pcm[j]=0.0f;
|
||||
}
|
||||
}
|
||||
//_analysis_output("final",seq++,pcm,n,0,0);
|
||||
}
|
||||
|
||||
// now apply the decoded post-window time information
|
||||
// NOT IMPLEMENTED
|
||||
// all done!
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int ilog2(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v>1)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
}
|
||||
|
||||
class InfoMapping0
|
||||
{
|
||||
internal int submaps; // <= 16
|
||||
internal int[] chmuxlist=new int[256]; // up to 256 channels in a Vorbis stream
|
||||
|
||||
internal int[] timesubmap=new int[16]; // [mux]
|
||||
internal int[] floorsubmap=new int[16]; // [mux] submap to floors
|
||||
internal int[] residuesubmap=new int[16];// [mux] submap to residue
|
||||
internal int[] psysubmap=new int[16]; // [mux]; encode only
|
||||
|
||||
internal int coupling_steps;
|
||||
internal int[] coupling_mag=new int[256];
|
||||
internal int[] coupling_ang=new int[256];
|
||||
|
||||
internal void free()
|
||||
{
|
||||
chmuxlist=null;
|
||||
timesubmap=null;
|
||||
floorsubmap=null;
|
||||
residuesubmap=null;
|
||||
psysubmap=null;
|
||||
|
||||
coupling_mag=null;
|
||||
coupling_ang=null;
|
||||
}
|
||||
}
|
||||
|
||||
class LookMapping0
|
||||
{
|
||||
internal InfoMode mode;
|
||||
internal InfoMapping0 map;
|
||||
internal Object[] time_look;
|
||||
internal Object[] floor_look;
|
||||
//Object[] floor_state;
|
||||
internal Object[] residue_look;
|
||||
//PsyLook[] psy_look;
|
||||
|
||||
internal FuncTime[] time_func;
|
||||
internal FuncFloor[] floor_func;
|
||||
internal FuncResidue[] residue_func;
|
||||
|
||||
internal int ch;
|
||||
//float[][] decay;
|
||||
//int lastframe; // if a different mode is called, we need to
|
||||
// invalidate decay and floor state
|
||||
}
|
||||
}
|
274
Support/OggUtils/csvorbis/Mdct.cs
Normal file
274
Support/OggUtils/csvorbis/Mdct.cs
Normal file
@ -0,0 +1,274 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Mdct
|
||||
{
|
||||
|
||||
//static private float cPI3_8=0.38268343236508977175f;
|
||||
//static private float cPI2_8=0.70710678118654752441f;
|
||||
//static private float cPI1_8=0.92387953251128675613f;
|
||||
|
||||
int n;
|
||||
int log2n;
|
||||
|
||||
float[] trig;
|
||||
int[] bitrev;
|
||||
|
||||
float scale;
|
||||
|
||||
internal void init(int n)
|
||||
{
|
||||
bitrev=new int[n/4];
|
||||
trig=new float[n+n/4];
|
||||
|
||||
int n2=(int)((uint)n >> 1);
|
||||
log2n=(int)Math.Round(Math.Log(n)/Math.Log(2));
|
||||
this.n=n;
|
||||
|
||||
|
||||
int AE=0;
|
||||
int AO=1;
|
||||
int BE=AE+n/2;
|
||||
int BO=BE+1;
|
||||
int CE=BE+n/2;
|
||||
int CO=CE+1;
|
||||
// trig lookups...
|
||||
for(int i=0;i<n/4;i++)
|
||||
{
|
||||
trig[AE+i*2]=(float)Math.Cos((Math.PI/n)*(4*i));
|
||||
trig[AO+i*2]=(float)-Math.Sin((Math.PI/n)*(4*i));
|
||||
trig[BE+i*2]=(float)Math.Cos((Math.PI/(2*n))*(2*i+1));
|
||||
trig[BO+i*2]=(float)Math.Sin((Math.PI/(2*n))*(2*i+1));
|
||||
}
|
||||
for(int i=0;i<n/8;i++)
|
||||
{
|
||||
trig[CE+i*2]=(float)Math.Cos((Math.PI/n)*(4*i+2));
|
||||
trig[CO+i*2]=(float)-Math.Sin((Math.PI/n)*(4*i+2));
|
||||
}
|
||||
|
||||
{
|
||||
int mask=(1<<(log2n-1))-1;
|
||||
int msb=1<<(log2n-2);
|
||||
for(int i=0;i<n/8;i++)
|
||||
{
|
||||
int acc=0;
|
||||
for(int j=0; (((uint)msb) >> j) != 0; j++)
|
||||
if(((((uint)msb>>j))&i) != 0)
|
||||
acc |= 1 << j;
|
||||
bitrev[i*2]=((~acc)&mask);
|
||||
// bitrev[i*2]=((~acc)&mask)-1;
|
||||
bitrev[i*2+1]=acc;
|
||||
}
|
||||
}
|
||||
scale=4.0f/n;
|
||||
}
|
||||
|
||||
internal void clear()
|
||||
{
|
||||
}
|
||||
|
||||
internal void forward(float[] fin, float[] fout)
|
||||
{
|
||||
}
|
||||
|
||||
float[] _x=new float[1024];
|
||||
float[] _w=new float[1024];
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
internal void backward(float[] fin, float[] fout)
|
||||
{
|
||||
if(_x.Length < n/2){_x=new float[n/2];}
|
||||
if(_w.Length < n/2){_w=new float[n/2];}
|
||||
float[] x=_x;
|
||||
float[] w=_w;
|
||||
int n2=(int)((uint)n >> 1);
|
||||
int n4=(int)((uint)n >> 2);
|
||||
int n8=(int)((uint)n >> 3);
|
||||
|
||||
// rotate + step 1
|
||||
{
|
||||
int inO=1;
|
||||
int xO=0;
|
||||
int A=n2;
|
||||
|
||||
int i;
|
||||
for(i=0;i<n8;i++)
|
||||
{
|
||||
A-=2;
|
||||
x[xO++]=-fin[inO+2]*trig[A+1] - fin[inO]*trig[A];
|
||||
x[xO++]= fin[inO]*trig[A+1] - fin[inO+2]*trig[A];
|
||||
inO+=4;
|
||||
}
|
||||
|
||||
inO=n2-4;
|
||||
|
||||
for(i=0;i<n8;i++)
|
||||
{
|
||||
A-=2;
|
||||
x[xO++]=fin[inO]*trig[A+1] + fin[inO+2]*trig[A];
|
||||
x[xO++]=fin[inO]*trig[A] - fin[inO+2]*trig[A+1];
|
||||
inO-=4;
|
||||
}
|
||||
}
|
||||
|
||||
float[] xxx=mdct_kernel(x,w,n,n2,n4,n8);
|
||||
int xx=0;
|
||||
|
||||
// step 8
|
||||
|
||||
{
|
||||
int B=n2;
|
||||
int o1=n4,o2=o1-1;
|
||||
int o3=n4+n2,o4=o3-1;
|
||||
|
||||
for(int i=0;i<n4;i++)
|
||||
{
|
||||
float temp1= (xxx[xx] * trig[B+1] - xxx[xx+1] * trig[B]);
|
||||
float temp2=-(xxx[xx] * trig[B] + xxx[xx+1] * trig[B+1]);
|
||||
|
||||
fout[o1]=-temp1;
|
||||
fout[o2]= temp1;
|
||||
fout[o3]= temp2;
|
||||
fout[o4]= temp2;
|
||||
|
||||
o1++;
|
||||
o2--;
|
||||
o3++;
|
||||
o4--;
|
||||
xx+=2;
|
||||
B+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
internal float[] mdct_kernel(float[] x, float[] w,
|
||||
int n, int n2, int n4, int n8)
|
||||
{
|
||||
// step 2
|
||||
|
||||
int xA=n4;
|
||||
int xB=0;
|
||||
int w2=n4;
|
||||
int A=n2;
|
||||
|
||||
for(int i=0;i<n4;)
|
||||
{
|
||||
float x0=x[xA] - x[xB];
|
||||
float x1;
|
||||
w[w2+i]=x[xA++]+x[xB++];
|
||||
|
||||
x1=x[xA]-x[xB];
|
||||
A-=4;
|
||||
|
||||
w[i++]= x0 * trig[A] + x1 * trig[A+1];
|
||||
w[i]= x1 * trig[A] - x0 * trig[A+1];
|
||||
|
||||
w[w2+i]=x[xA++]+x[xB++];
|
||||
i++;
|
||||
}
|
||||
|
||||
// step 3
|
||||
|
||||
{
|
||||
for(int i=0;i<log2n-3;i++)
|
||||
{
|
||||
int k0=(int)((uint)n >> (i+2));
|
||||
int k1=1 << (i+3);
|
||||
int wbase=n2-2;
|
||||
|
||||
A=0;
|
||||
float[] temp;
|
||||
|
||||
for(int r=0; r<((uint)k0>>2); r++)
|
||||
{
|
||||
int w1=wbase;
|
||||
w2=w1-(k0>>1);
|
||||
float AEv= trig[A],wA;
|
||||
float AOv= trig[A+1],wB;
|
||||
wbase-=2;
|
||||
|
||||
k0++;
|
||||
for(int s=0;s<(2<<i);s++)
|
||||
{
|
||||
wB =w[w1] -w[w2];
|
||||
x[w1] =w[w1] +w[w2];
|
||||
|
||||
wA =w[++w1] -w[++w2];
|
||||
x[w1] =w[w1] +w[w2];
|
||||
|
||||
x[w2] =wA*AEv - wB*AOv;
|
||||
x[w2-1]=wB*AEv + wA*AOv;
|
||||
|
||||
w1-=k0;
|
||||
w2-=k0;
|
||||
}
|
||||
k0--;
|
||||
A+=k1;
|
||||
}
|
||||
|
||||
temp=w;
|
||||
w=x;
|
||||
x=temp;
|
||||
}
|
||||
}
|
||||
|
||||
// step 4, 5, 6, 7
|
||||
{
|
||||
int C=n;
|
||||
int bit=0;
|
||||
int x1=0;
|
||||
int x2=n2-1;
|
||||
|
||||
for(int i=0;i<n8;i++)
|
||||
{
|
||||
int t1=bitrev[bit++];
|
||||
int t2=bitrev[bit++];
|
||||
|
||||
float wA=w[t1]-w[t2+1];
|
||||
float wB=w[t1-1]+w[t2];
|
||||
float wC=w[t1]+w[t2+1];
|
||||
float wD=w[t1-1]-w[t2];
|
||||
|
||||
float wACE=wA* trig[C];
|
||||
float wBCE=wB* trig[C++];
|
||||
float wACO=wA* trig[C];
|
||||
float wBCO=wB* trig[C++];
|
||||
|
||||
x[x1++]=( wC+wACO+wBCE)*.5f;
|
||||
x[x2--]=(-wD+wBCO-wACE)*.5f;
|
||||
x[x1++]=( wD+wBCO-wACE)*.5f;
|
||||
x[x2--]=( wC-wACO-wBCE)*.5f;
|
||||
}
|
||||
}
|
||||
return(x);
|
||||
}
|
||||
}
|
||||
}
|
77
Support/OggUtils/csvorbis/PsyInfo.cs
Normal file
77
Support/OggUtils/csvorbis/PsyInfo.cs
Normal file
@ -0,0 +1,77 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
// psychoacoustic setup
|
||||
class PsyInfo
|
||||
{
|
||||
//int athp;
|
||||
//int decayp;
|
||||
//int smoothp;
|
||||
//int noisefitp;
|
||||
//int noisefit_subblock;
|
||||
//float noisefit_threshdB;
|
||||
|
||||
//float ath_att;
|
||||
|
||||
//int tonemaskp;
|
||||
float[] toneatt_125Hz=new float[5];
|
||||
float[] toneatt_250Hz=new float[5];
|
||||
float[] toneatt_500Hz=new float[5];
|
||||
float[] toneatt_1000Hz=new float[5];
|
||||
float[] toneatt_2000Hz=new float[5];
|
||||
float[] toneatt_4000Hz=new float[5];
|
||||
float[] toneatt_8000Hz=new float[5];
|
||||
|
||||
//int peakattp;
|
||||
float[] peakatt_125Hz=new float[5];
|
||||
float[] peakatt_250Hz=new float[5];
|
||||
float[] peakatt_500Hz=new float[5];
|
||||
float[] peakatt_1000Hz=new float[5];
|
||||
float[] peakatt_2000Hz=new float[5];
|
||||
float[] peakatt_4000Hz=new float[5];
|
||||
float[] peakatt_8000Hz=new float[5];
|
||||
|
||||
//int noisemaskp;
|
||||
float[] noiseatt_125Hz=new float[5];
|
||||
float[] noiseatt_250Hz=new float[5];
|
||||
float[] noiseatt_500Hz=new float[5];
|
||||
float[] noiseatt_1000Hz=new float[5];
|
||||
float[] noiseatt_2000Hz=new float[5];
|
||||
float[] noiseatt_4000Hz=new float[5];
|
||||
float[] noiseatt_8000Hz=new float[5];
|
||||
|
||||
//float max_curve_dB;
|
||||
|
||||
//float attack_coeff;
|
||||
//float decay_coeff;
|
||||
|
||||
internal void free(){}
|
||||
}
|
||||
}
|
46
Support/OggUtils/csvorbis/PsyLook.cs
Normal file
46
Support/OggUtils/csvorbis/PsyLook.cs
Normal file
@ -0,0 +1,46 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class PsyLook
|
||||
{
|
||||
//int n;
|
||||
//PsyInfo vi;
|
||||
|
||||
//float[][][] tonecurves;
|
||||
//float[][] peakatt;
|
||||
//float[][][] noisecurves;
|
||||
|
||||
//float[] ath;
|
||||
//int[] octave;
|
||||
|
||||
void init(PsyInfo vi, int n, int rate)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
415
Support/OggUtils/csvorbis/Residue0.cs
Normal file
415
Support/OggUtils/csvorbis/Residue0.cs
Normal file
@ -0,0 +1,415 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Residue0 : FuncResidue
|
||||
{
|
||||
override public void pack(Object vr, csBuffer opb)
|
||||
{
|
||||
InfoResidue0 info=(InfoResidue0)vr;
|
||||
int acc=0;
|
||||
opb.write(info.begin,24);
|
||||
opb.write(info.end,24);
|
||||
|
||||
opb.write(info.grouping-1,24); /* residue vectors to group and
|
||||
code with a partitioned book */
|
||||
opb.write(info.partitions-1,6); /* possible partition choices */
|
||||
opb.write(info.groupbook,8); /* group huffman book */
|
||||
|
||||
/* secondstages is a bitmask; as encoding progresses pass by pass, a
|
||||
bitmask of one indicates this partition class has bits to write
|
||||
this pass */
|
||||
for(int j=0;j<info.partitions;j++)
|
||||
{
|
||||
if(ilog(info.secondstages[j])>3)
|
||||
{
|
||||
/* yes, this is a minor hack due to not thinking ahead */
|
||||
opb.write(info.secondstages[j],3);
|
||||
opb.write(1,1);
|
||||
opb.write(info.secondstages[j] >> 3,5);
|
||||
}
|
||||
else
|
||||
{
|
||||
opb.write(info.secondstages[j],4); /* trailing zero */
|
||||
}
|
||||
acc+=icount(info.secondstages[j]);
|
||||
}
|
||||
for(int j=0;j<acc;j++)
|
||||
{
|
||||
opb.write(info.booklist[j],8);
|
||||
}
|
||||
}
|
||||
|
||||
override public Object unpack(Info vi, csBuffer opb)
|
||||
{
|
||||
int acc=0;
|
||||
InfoResidue0 info=new InfoResidue0();
|
||||
|
||||
info.begin=opb.read(24);
|
||||
info.end=opb.read(24);
|
||||
info.grouping=opb.read(24)+1;
|
||||
info.partitions=opb.read(6)+1;
|
||||
info.groupbook=opb.read(8);
|
||||
|
||||
for(int j=0;j<info.partitions;j++)
|
||||
{
|
||||
int cascade=opb.read(3);
|
||||
if(opb.read(1)!=0)
|
||||
{
|
||||
cascade|=(opb.read(5)<<3);
|
||||
}
|
||||
info.secondstages[j]=cascade;
|
||||
acc+=icount(cascade);
|
||||
}
|
||||
|
||||
for(int j=0;j<acc;j++)
|
||||
{
|
||||
info.booklist[j]=opb.read(8);
|
||||
// if(info.booklist[j]==255)info.booklist[j]=-1;
|
||||
}
|
||||
|
||||
if(info.groupbook>=vi.books)
|
||||
{
|
||||
free_info(info);
|
||||
return(null);
|
||||
}
|
||||
|
||||
for(int j=0;j<acc;j++)
|
||||
{
|
||||
if(info.booklist[j]>=vi.books)
|
||||
{
|
||||
free_info(info);
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
return(info);
|
||||
// errout:
|
||||
// free_info(info);
|
||||
// return(NULL);
|
||||
}
|
||||
|
||||
override public Object look(DspState vd, InfoMode vm, Object vr)
|
||||
{
|
||||
InfoResidue0 info=(InfoResidue0)vr;
|
||||
LookResidue0 look=new LookResidue0();
|
||||
int acc=0;
|
||||
int dim;
|
||||
int maxstage=0;
|
||||
look.info=info;
|
||||
look.map=vm.mapping;
|
||||
|
||||
look.parts=info.partitions;
|
||||
look.fullbooks=vd.fullbooks;
|
||||
look.phrasebook=vd.fullbooks[info.groupbook];
|
||||
|
||||
dim=look.phrasebook.dim;
|
||||
|
||||
look.partbooks=new int[look.parts][];
|
||||
|
||||
for(int j=0;j<look.parts;j++)
|
||||
{
|
||||
int stages=ilog(info.secondstages[j]);
|
||||
if(stages!=0)
|
||||
{
|
||||
if(stages>maxstage)maxstage=stages;
|
||||
look.partbooks[j]=new int[stages];
|
||||
for(int k=0; k<stages; k++)
|
||||
{
|
||||
if((info.secondstages[j]&(1<<k))!=0)
|
||||
{
|
||||
look.partbooks[j][k]=info.booklist[acc++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
look.partvals=(int)Math.Round(Math.Pow(look.parts,dim));
|
||||
look.stages=maxstage;
|
||||
look.decodemap=new int[look.partvals][];
|
||||
for(int j=0;j<look.partvals;j++)
|
||||
{
|
||||
int val=j;
|
||||
int mult=look.partvals/look.parts;
|
||||
look.decodemap[j]=new int[dim];
|
||||
|
||||
for(int k=0;k<dim;k++)
|
||||
{
|
||||
int deco=val/mult;
|
||||
val-=deco*mult;
|
||||
mult/=look.parts;
|
||||
look.decodemap[j][k]=deco;
|
||||
}
|
||||
}
|
||||
return(look);
|
||||
}
|
||||
|
||||
override public void free_info(Object i){}
|
||||
override public void free_look(Object i){}
|
||||
override public int forward(Block vb,Object vl, float[][] fin, int ch)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int[][][] partword=new int[2][][];
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
internal static int _01inverse(Block vb, Object vl, float[][] fin, int ch, int decodepart)
|
||||
{
|
||||
{
|
||||
int i,j,k,l,s;
|
||||
LookResidue0 look=(LookResidue0 )vl;
|
||||
InfoResidue0 info=look.info;
|
||||
|
||||
// move all this setup out later
|
||||
int samples_per_partition=info.grouping;
|
||||
int partitions_per_word=look.phrasebook.dim;
|
||||
int n=info.end-info.begin;
|
||||
|
||||
int partvals=n/samples_per_partition;
|
||||
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
|
||||
|
||||
if(partword.Length<ch)
|
||||
{
|
||||
partword=new int[ch][][];
|
||||
for(j=0;j<ch;j++)
|
||||
{
|
||||
partword[j]=new int[partwords][];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(j=0;j<ch;j++)
|
||||
{
|
||||
if(partword[j]==null || partword[j].Length<partwords)
|
||||
partword[j]=new int[partwords][];
|
||||
}
|
||||
}
|
||||
|
||||
for(s=0;s<look.stages;s++)
|
||||
{
|
||||
// each loop decodes on partition codeword containing
|
||||
// partitions_pre_word partitions
|
||||
for(i=0,l=0;i<partvals;l++)
|
||||
{
|
||||
if(s==0)
|
||||
{
|
||||
// fetch the partition word for each channel
|
||||
for(j=0;j<ch;j++)
|
||||
{
|
||||
int temp=look.phrasebook.decode(vb.opb);
|
||||
if(temp==-1)
|
||||
{
|
||||
//goto eopbreak;
|
||||
return(0);
|
||||
}
|
||||
partword[j][l]=look.decodemap[temp];
|
||||
if(partword[j][l]==null)
|
||||
{
|
||||
// goto errout;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now we decode residual values for the partitions
|
||||
for(k=0;k<partitions_per_word && i<partvals;k++,i++)
|
||||
for(j=0;j<ch;j++)
|
||||
{
|
||||
int offset=info.begin+i*samples_per_partition;
|
||||
if((info.secondstages[partword[j][l][k]]&(1<<s))!=0)
|
||||
{
|
||||
CodeBook stagebook=look.fullbooks[look.partbooks[partword[j][l][k]][s]];
|
||||
// CodeBook stagebook=look.partbooks[partword[j][l][k]][s];
|
||||
if(stagebook!=null)
|
||||
{
|
||||
if(decodepart==0)
|
||||
{
|
||||
if(stagebook.decodevs_add(fin[j],offset,vb.opb,samples_per_partition)==-1)
|
||||
{
|
||||
// goto errout;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
else if(decodepart==1)
|
||||
{
|
||||
if(stagebook.decodev_add(fin[j], offset, vb.opb,samples_per_partition)==-1)
|
||||
{
|
||||
// goto errout;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
internal static int _2inverse(Block vb, Object vl, float[][] fin, int ch)
|
||||
{
|
||||
int i,k,l,s;
|
||||
LookResidue0 look=(LookResidue0 )vl;
|
||||
InfoResidue0 info=look.info;
|
||||
|
||||
// move all this setup out later
|
||||
int samples_per_partition=info.grouping;
|
||||
int partitions_per_word=look.phrasebook.dim;
|
||||
int n=info.end-info.begin;
|
||||
|
||||
int partvals=n/samples_per_partition;
|
||||
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
|
||||
|
||||
int[][] partword=new int[partwords][];
|
||||
for(s=0;s<look.stages;s++)
|
||||
{
|
||||
for(i=0,l=0;i<partvals;l++)
|
||||
{
|
||||
if(s==0)
|
||||
{
|
||||
// fetch the partition word for each channel
|
||||
int temp=look.phrasebook.decode(vb.opb);
|
||||
if(temp==-1)
|
||||
{
|
||||
// goto eopbreak;
|
||||
return(0);
|
||||
}
|
||||
partword[l]=look.decodemap[temp];
|
||||
if(partword[l]==null)
|
||||
{
|
||||
// goto errout;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
// now we decode residual values for the partitions
|
||||
for(k=0;k<partitions_per_word && i<partvals;k++,i++)
|
||||
{
|
||||
int offset=info.begin+i*samples_per_partition;
|
||||
if((info.secondstages[partword[l][k]]&(1<<s))!=0)
|
||||
{
|
||||
CodeBook stagebook=look.fullbooks[look.partbooks[partword[l][k]][s]];
|
||||
if(stagebook!=null)
|
||||
{
|
||||
if(stagebook.decodevv_add(fin, offset, ch, vb.opb,samples_per_partition)==-1)
|
||||
{
|
||||
// goto errout;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// errout:
|
||||
// eopbreak:
|
||||
return(0);
|
||||
}
|
||||
|
||||
override public int inverse(Block vb, Object vl, float[][] fin, int[] nonzero, int ch)
|
||||
{
|
||||
//System.err.println("Residue0.inverse");
|
||||
int used=0;
|
||||
for(int i=0;i<ch;i++)
|
||||
{
|
||||
if(nonzero[i]!=0)
|
||||
{
|
||||
fin[used++]=fin[i];
|
||||
}
|
||||
}
|
||||
if(used!=0)
|
||||
return(_01inverse(vb, vl, fin, used, 0));
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
internal static int ilog(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v!=0)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
internal static int icount(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v!=0)
|
||||
{
|
||||
ret+=(v&1);
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
}
|
||||
|
||||
class LookResidue0
|
||||
{
|
||||
internal InfoResidue0 info;
|
||||
internal int map;
|
||||
|
||||
internal int parts;
|
||||
internal int stages;
|
||||
internal CodeBook[] fullbooks;
|
||||
internal CodeBook phrasebook;
|
||||
internal int[][] partbooks;
|
||||
// CodeBook[][] partbooks;
|
||||
|
||||
internal int partvals;
|
||||
internal int[][] decodemap;
|
||||
|
||||
//internal int postbits;
|
||||
//internal int phrasebits;
|
||||
// int[][] frames;
|
||||
//internal int frames;
|
||||
}
|
||||
|
||||
class InfoResidue0
|
||||
{
|
||||
// block-partitioned VQ coded straight residue
|
||||
internal int begin;
|
||||
internal int end;
|
||||
|
||||
// first stage (lossless partitioning)
|
||||
internal int grouping; // group n vectors per partition
|
||||
internal int partitions; // possible codebooks for a partition
|
||||
internal int groupbook; // huffbook for partitioning
|
||||
internal int[] secondstages=new int[64]; // expanded out to pointers in lookup
|
||||
internal int[] booklist=new int[256]; // list of second stage books
|
||||
|
||||
// encode-only heuristic settings
|
||||
internal float[] entmax=new float[64]; // book entropy threshholds
|
||||
internal float[] ampmax=new float[64]; // book amp threshholds
|
||||
internal int[] subgrp=new int[64]; // book heuristic subgroup size
|
||||
internal int[] blimit=new int[64]; // subgroup position limits
|
||||
}
|
||||
}
|
59
Support/OggUtils/csvorbis/Residue1.cs
Normal file
59
Support/OggUtils/csvorbis/Residue1.cs
Normal file
@ -0,0 +1,59 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Residue1 : Residue0
|
||||
{
|
||||
new int forward(Block vb,Object vl, float[][] fin, int ch)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
override public int inverse(Block vb, Object vl, float[][] fin, int[] nonzero, int ch)
|
||||
{
|
||||
//System.err.println("Residue0.inverse");
|
||||
int used=0;
|
||||
for(int i=0; i<ch; i++)
|
||||
{
|
||||
if(nonzero[i]!=0)
|
||||
{
|
||||
fin[used++]=fin[i];
|
||||
}
|
||||
}
|
||||
if(used!=0)
|
||||
{
|
||||
return(_01inverse(vb, vl, fin, used, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
48
Support/OggUtils/csvorbis/Residue2.cs
Normal file
48
Support/OggUtils/csvorbis/Residue2.cs
Normal file
@ -0,0 +1,48 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Residue2 : Residue0
|
||||
{
|
||||
override public int forward(Block vb,Object vl, float[][] fin, int ch)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
override public int inverse(Block vb, Object vl, float[][] fin, int[] nonzero, int ch)
|
||||
{
|
||||
//System.err.println("Residue0.inverse");
|
||||
int i=0;
|
||||
for(i=0;i<ch;i++)if(nonzero[i]!=0)break;
|
||||
if(i==ch)return(0); /* no nonzero vectors */
|
||||
|
||||
return(_2inverse(vb, vl, fin, ch));
|
||||
}
|
||||
}
|
||||
}
|
542
Support/OggUtils/csvorbis/StaticCodeBook.cs
Normal file
542
Support/OggUtils/csvorbis/StaticCodeBook.cs
Normal file
@ -0,0 +1,542 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class StaticCodeBook
|
||||
{
|
||||
internal int dim; // codebook dimensions (elements per vector)
|
||||
internal int entries; // codebook entries
|
||||
internal int[] lengthlist; // codeword lengths in bits
|
||||
|
||||
// mapping
|
||||
internal int maptype; // 0=none
|
||||
// 1=implicitly populated values from map column
|
||||
// 2=listed arbitrary values
|
||||
|
||||
// The below does a linear, single monotonic sequence mapping.
|
||||
internal int q_min; // packed 32 bit float; quant value 0 maps to minval
|
||||
internal int q_delta; // packed 32 bit float; val 1 - val 0 == delta
|
||||
internal int q_quant; // bits: 0 < quant <= 16
|
||||
internal int q_sequencep; // bitflag
|
||||
|
||||
// additional information for log (dB) mapping; the linear mapping
|
||||
// is assumed to actually be values in dB. encodebias is used to
|
||||
// assign an error weight to 0 dB. We have two additional flags:
|
||||
// zeroflag indicates if entry zero is to represent -Inf dB; negflag
|
||||
// indicates if we're to represent negative linear values in a
|
||||
// mirror of the positive mapping.
|
||||
|
||||
internal int[] quantlist; // map == 1: (int)(entries/dim) element column map
|
||||
// map == 2: list of dim*entries quantized entry vals
|
||||
|
||||
// encode helpers
|
||||
internal EncodeAuxNearestMatch nearest_tree;
|
||||
internal EncodeAuxThreshMatch thresh_tree;
|
||||
|
||||
internal StaticCodeBook(){}
|
||||
internal StaticCodeBook(int dim, int entries, int[] lengthlist,
|
||||
int maptype, int q_min, int q_delta,
|
||||
int q_quant, int q_sequencep, int[] quantlist,
|
||||
//EncodeAuxNearestmatch nearest_tree,
|
||||
Object nearest_tree,
|
||||
// EncodeAuxThreshmatch thresh_tree,
|
||||
Object thresh_tree
|
||||
) : this()
|
||||
{
|
||||
this.dim=dim; this.entries=entries; this.lengthlist=lengthlist;
|
||||
this.maptype=maptype; this.q_min=q_min; this.q_delta=q_delta;
|
||||
this.q_quant=q_quant; this.q_sequencep=q_sequencep;
|
||||
this.quantlist=quantlist;
|
||||
}
|
||||
|
||||
internal int pack(csBuffer opb)
|
||||
{
|
||||
int i;
|
||||
bool ordered=false;
|
||||
|
||||
opb.write(0x564342,24);
|
||||
opb.write(dim, 16);
|
||||
opb.write(entries, 24);
|
||||
|
||||
// pack the codewords. There are two packings; length ordered and
|
||||
// length random. Decide between the two now.
|
||||
|
||||
for(i=1;i<entries;i++)
|
||||
{
|
||||
if(lengthlist[i]<lengthlist[i-1])break;
|
||||
}
|
||||
if(i==entries)ordered=true;
|
||||
|
||||
if(ordered)
|
||||
{
|
||||
// length ordered. We only need to say how many codewords of
|
||||
// each length. The actual codewords are generated
|
||||
// deterministically
|
||||
|
||||
int count=0;
|
||||
opb.write(1,1); // ordered
|
||||
opb.write(lengthlist[0]-1,5); // 1 to 32
|
||||
|
||||
for(i=1;i<entries;i++)
|
||||
{
|
||||
int _this=lengthlist[i];
|
||||
int _last=lengthlist[i-1];
|
||||
if(_this>_last)
|
||||
{
|
||||
for(int j=_last;j<_this;j++)
|
||||
{
|
||||
opb.write(i-count,ilog(entries-count));
|
||||
count=i;
|
||||
}
|
||||
}
|
||||
}
|
||||
opb.write(i-count,ilog(entries-count));
|
||||
}
|
||||
else
|
||||
{
|
||||
// length random. Again, we don't code the codeword itself, just
|
||||
// the length. This time, though, we have to encode each length
|
||||
opb.write(0,1); // unordered
|
||||
|
||||
// algortihmic mapping has use for 'unused entries', which we tag
|
||||
// here. The algorithmic mapping happens as usual, but the unused
|
||||
// entry has no codeword.
|
||||
for(i=0;i<entries;i++)
|
||||
{
|
||||
if(lengthlist[i]==0)break;
|
||||
}
|
||||
|
||||
if(i==entries)
|
||||
{
|
||||
opb.write(0,1); // no unused entries
|
||||
for(i=0;i<entries;i++)
|
||||
{
|
||||
opb.write(lengthlist[i]-1,5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
opb.write(1,1); // we have unused entries; thus we tag
|
||||
for(i=0;i<entries;i++)
|
||||
{
|
||||
if(lengthlist[i]==0)
|
||||
{
|
||||
opb.write(0,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
opb.write(1,1);
|
||||
opb.write(lengthlist[i]-1,5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// is the entry number the desired return value, or do we have a
|
||||
// mapping? If we have a mapping, what type?
|
||||
opb.write(maptype,4);
|
||||
switch(maptype)
|
||||
{
|
||||
case 0:
|
||||
// no mapping
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
// implicitly populated value mapping
|
||||
// explicitly populated value mapping
|
||||
if(quantlist==null)
|
||||
{
|
||||
// no quantlist? error
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// values that define the dequantization
|
||||
opb.write(q_min,32);
|
||||
opb.write(q_delta,32);
|
||||
opb.write(q_quant-1,4);
|
||||
opb.write(q_sequencep,1);
|
||||
|
||||
{
|
||||
int quantvals=0;
|
||||
switch(maptype)
|
||||
{
|
||||
case 1:
|
||||
// a single column of (c->entries/c->dim) quantized values for
|
||||
// building a full value list algorithmically (square lattice)
|
||||
quantvals=maptype1_quantvals();
|
||||
break;
|
||||
case 2:
|
||||
// every value (c->entries*c->dim total) specified explicitly
|
||||
quantvals=entries*dim;
|
||||
break;
|
||||
}
|
||||
|
||||
// quantized values
|
||||
for(i=0;i<quantvals;i++)
|
||||
{
|
||||
opb.write(Math.Abs(quantlist[i]),q_quant);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// error case; we don't have any other map types now
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
||||
// unpacks a codebook from the packet buffer into the codebook struct,
|
||||
// readies the codebook auxiliary structures for decode
|
||||
internal int unpack(csBuffer opb)
|
||||
{
|
||||
int i;
|
||||
//memset(s,0,sizeof(static_codebook));
|
||||
|
||||
// make sure alignment is correct
|
||||
if(opb.read(24)!=0x564342)
|
||||
{
|
||||
// goto _eofout;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// first the basic parameters
|
||||
dim=opb.read(16);
|
||||
entries=opb.read(24);
|
||||
if(entries==-1)
|
||||
{
|
||||
// goto _eofout;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// codeword ordering.... length ordered or unordered?
|
||||
switch(opb.read(1))
|
||||
{
|
||||
case 0:
|
||||
// unordered
|
||||
lengthlist=new int[entries];
|
||||
|
||||
// allocated but unused entries?
|
||||
if(opb.read(1)!=0)
|
||||
{
|
||||
// yes, unused entries
|
||||
|
||||
for(i=0;i<entries;i++)
|
||||
{
|
||||
if(opb.read(1)!=0)
|
||||
{
|
||||
int num=opb.read(5);
|
||||
if(num==-1)
|
||||
{
|
||||
// goto _eofout;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
lengthlist[i]=num+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lengthlist[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// all entries used; no tagging
|
||||
for(i=0;i<entries;i++)
|
||||
{
|
||||
int num=opb.read(5);
|
||||
if(num==-1)
|
||||
{
|
||||
// goto _eofout;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
lengthlist[i]=num+1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// ordered
|
||||
{
|
||||
int length=opb.read(5)+1;
|
||||
lengthlist=new int[entries];
|
||||
|
||||
for(i=0;i<entries;)
|
||||
{
|
||||
int num=opb.read(ilog(entries-i));
|
||||
if(num==-1)
|
||||
{
|
||||
// goto _eofout;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
for(int j=0;j<num;j++,i++)
|
||||
{
|
||||
lengthlist[i]=length;
|
||||
}
|
||||
length++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// EOF
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// Do we have a mapping to unpack?
|
||||
switch((maptype=opb.read(4)))
|
||||
{
|
||||
case 0:
|
||||
// no mapping
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
// implicitly populated value mapping
|
||||
// explicitly populated value mapping
|
||||
q_min=opb.read(32);
|
||||
q_delta=opb.read(32);
|
||||
q_quant=opb.read(4)+1;
|
||||
q_sequencep=opb.read(1);
|
||||
|
||||
{
|
||||
int quantvals=0;
|
||||
switch(maptype)
|
||||
{
|
||||
case 1:
|
||||
quantvals=maptype1_quantvals();
|
||||
break;
|
||||
case 2:
|
||||
quantvals=entries*dim;
|
||||
break;
|
||||
}
|
||||
|
||||
// quantized values
|
||||
quantlist=new int[quantvals];
|
||||
for(i=0;i<quantvals;i++)
|
||||
{
|
||||
quantlist[i]=opb.read(q_quant);
|
||||
}
|
||||
if(quantlist[quantvals-1]==-1)
|
||||
{
|
||||
// goto _eofout;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// goto _eofout;
|
||||
clear();
|
||||
return(-1);
|
||||
}
|
||||
// all set
|
||||
return(0);
|
||||
// _errout:
|
||||
// _eofout:
|
||||
// vorbis_staticbook_clear(s);
|
||||
// return(-1);
|
||||
}
|
||||
|
||||
// there might be a straightforward one-line way to do the below
|
||||
// that's portable and totally safe against roundoff, but I haven't
|
||||
// thought of it. Therefore, we opt on the side of caution
|
||||
internal int maptype1_quantvals()
|
||||
{
|
||||
int vals=(int)(Math.Floor(Math.Pow(entries,1.0/dim)));
|
||||
|
||||
// the above *should* be reliable, but we'll not assume that FP is
|
||||
// ever reliable when bitstream sync is at stake; verify via integer
|
||||
// means that vals really is the greatest value of dim for which
|
||||
// vals^b->bim <= b->entries
|
||||
// treat the above as an initial guess
|
||||
while(true)
|
||||
{
|
||||
int acc=1;
|
||||
int acc1=1;
|
||||
for(int i=0;i<dim;i++)
|
||||
{
|
||||
acc*=vals;
|
||||
acc1*=vals+1;
|
||||
}
|
||||
if(acc<=entries && acc1>entries){ return(vals); }
|
||||
else
|
||||
{
|
||||
if(acc>entries){ vals--; }
|
||||
else{ vals++; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void clear()
|
||||
{
|
||||
// if(quantlist!=null)free(b->quantlist);
|
||||
// if(lengthlist!=null)free(b->lengthlist);
|
||||
// if(nearest_tree!=null){
|
||||
// free(b->nearest_tree->ptr0);
|
||||
// free(b->nearest_tree->ptr1);
|
||||
// free(b->nearest_tree->p);
|
||||
// free(b->nearest_tree->q);
|
||||
// memset(b->nearest_tree,0,sizeof(encode_aux_nearestmatch));
|
||||
// free(b->nearest_tree);
|
||||
// }
|
||||
// if(thresh_tree!=null){
|
||||
// free(b->thresh_tree->quantthresh);
|
||||
// free(b->thresh_tree->quantmap);
|
||||
// memset(b->thresh_tree,0,sizeof(encode_aux_threshmatch));
|
||||
// free(b->thresh_tree);
|
||||
// }
|
||||
// memset(b,0,sizeof(static_codebook));
|
||||
}
|
||||
|
||||
// unpack the quantized list of values for encode/decode
|
||||
// we need to deal with two map types: in map type 1, the values are
|
||||
// generated algorithmically (each column of the vector counts through
|
||||
// the values in the quant vector). in map type 2, all the values came
|
||||
// in in an explicit list. Both value lists must be unpacked
|
||||
internal float[] unquantize()
|
||||
{
|
||||
|
||||
if(maptype==1 || maptype==2)
|
||||
{
|
||||
int quantvals;
|
||||
float mindel=float32_unpack(q_min);
|
||||
float delta=float32_unpack(q_delta);
|
||||
float[] r=new float[entries*dim];
|
||||
|
||||
//System.err.println("q_min="+q_min+", mindel="+mindel);
|
||||
|
||||
// maptype 1 and 2 both use a quantized value vector, but
|
||||
// different sizes
|
||||
switch(maptype)
|
||||
{
|
||||
case 1:
|
||||
// most of the time, entries%dimensions == 0, but we need to be
|
||||
// well defined. We define that the possible vales at each
|
||||
// scalar is values == entries/dim. If entries%dim != 0, we'll
|
||||
// have 'too few' values (values*dim<entries), which means that
|
||||
// we'll have 'left over' entries; left over entries use zeroed
|
||||
// values (and are wasted). So don't generate codebooks like that
|
||||
quantvals=maptype1_quantvals();
|
||||
for(int j=0;j<entries;j++)
|
||||
{
|
||||
float last=0.0f;
|
||||
int indexdiv=1;
|
||||
for(int k=0;k<dim;k++)
|
||||
{
|
||||
int index=(j/indexdiv)%quantvals;
|
||||
float val=quantlist[index];
|
||||
val=Math.Abs(val)*delta+mindel+last;
|
||||
if(q_sequencep!=0)last=val;
|
||||
r[j*dim+k]=val;
|
||||
indexdiv*=quantvals;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for(int j=0;j<entries;j++)
|
||||
{
|
||||
float last=0.0f;
|
||||
for(int k=0;k<dim;k++)
|
||||
{
|
||||
float val=quantlist[j*dim+k];
|
||||
//if((j*dim+k)==0){System.err.println(" | 0 -> "+val+" | ");}
|
||||
val=Math.Abs(val)*delta+mindel+last;
|
||||
if(q_sequencep!=0)last=val;
|
||||
r[j*dim+k]=val;
|
||||
//if((j*dim+k)==0){System.err.println(" $ r[0] -> "+r[0]+" | ");}
|
||||
}
|
||||
}
|
||||
//System.err.println("\nr[0]="+r[0]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
return(null);
|
||||
}
|
||||
|
||||
internal static int ilog(int v)
|
||||
{
|
||||
int ret=0;
|
||||
while(v!=0)
|
||||
{
|
||||
ret++;
|
||||
v = (int)((uint)v >> 1);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
// 32 bit float (not IEEE; nonnormalized mantissa +
|
||||
// biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
|
||||
// Why not IEEE? It's just not that important here.
|
||||
|
||||
//static int VQ_FEXP=10;
|
||||
static int VQ_FMAN=21;
|
||||
static int VQ_FEXP_BIAS=768; // bias toward values smaller than 1.
|
||||
|
||||
// doesn't currently guard under/overflow
|
||||
internal static long float32_pack(float val)
|
||||
{
|
||||
uint sign=0;
|
||||
int exp;
|
||||
int mant;
|
||||
if(val<0)
|
||||
{
|
||||
sign = 0x80000000;
|
||||
val = -val;
|
||||
}
|
||||
exp=(int)Math.Floor(Math.Log(val)/Math.Log(2));
|
||||
mant=(int)Math.Round(Math.Pow(val,(VQ_FMAN-1)-exp));
|
||||
exp=(exp+VQ_FEXP_BIAS)<<VQ_FMAN;
|
||||
return((int)sign | exp | mant);
|
||||
}
|
||||
|
||||
internal static float float32_unpack(int val)
|
||||
{
|
||||
float mant=val&0x1fffff;
|
||||
float sign=val&0x80000000;
|
||||
float exp =(uint)(val&0x7fe00000) >> VQ_FMAN;
|
||||
//System.err.println("mant="+mant+", sign="+sign+", exp="+exp);
|
||||
//if(sign!=0.0)mant= -mant;
|
||||
if((val&0x80000000)!=0)mant= -mant;
|
||||
//System.err.println("mant="+mant);
|
||||
return(ldexp(mant,((int)exp)-(VQ_FMAN-1)-VQ_FEXP_BIAS));
|
||||
}
|
||||
|
||||
internal static float ldexp(float foo, int e)
|
||||
{
|
||||
return (float)(foo*Math.Pow(2, e));
|
||||
}
|
||||
}
|
||||
}
|
41
Support/OggUtils/csvorbis/Time0.cs
Normal file
41
Support/OggUtils/csvorbis/Time0.cs
Normal file
@ -0,0 +1,41 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using csogg;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
class Time0 : FuncTime
|
||||
{
|
||||
override public void pack(Object i, csBuffer opb){}
|
||||
override public Object unpack(Info vi , csBuffer opb){return "";}
|
||||
override public Object look(DspState vd, InfoMode mi, Object i){return "";}
|
||||
override public void free_info(Object i){}
|
||||
override public void free_look(Object i){}
|
||||
override public int forward(Block vb, Object i){return 0;}
|
||||
override public int inverse(Block vb, Object i, float[] fin, float[] fout){return 0;}
|
||||
}
|
||||
}
|
1434
Support/OggUtils/csvorbis/VorbisFile.cs
Normal file
1434
Support/OggUtils/csvorbis/VorbisFile.cs
Normal file
File diff suppressed because it is too large
Load Diff
36
Support/OggUtils/csvorbis/csorbisException.cs
Normal file
36
Support/OggUtils/csvorbis/csorbisException.cs
Normal file
@ -0,0 +1,36 @@
|
||||
/* csvorbis
|
||||
* Copyright (C) 2000 ymnk, JCraft,Inc.
|
||||
*
|
||||
* Written by: 2000 ymnk<ymnk@jcraft.com>
|
||||
* Ported to C# from JOrbis by: Mark Crichton <crichton@gimp.org>
|
||||
*
|
||||
* Thanks go to the JOrbis team, for licencing the code under the
|
||||
* LGPL, making my job a lot easier.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace csvorbis
|
||||
{
|
||||
public class csorbisException : Exception
|
||||
{
|
||||
public csorbisException ()
|
||||
:base(){}
|
||||
public csorbisException (String s)
|
||||
:base("csorbis: "+s){}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<OutputPath>..\..\bin\Debug\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -28,7 +28,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<OutputPath>..\..\bin\Release\ModernUI</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -17,15 +17,12 @@ namespace ProjectConverter.Platforms
|
||||
|
||||
private bool isCurrentProjectExecutable;
|
||||
|
||||
public override string Postfix
|
||||
{
|
||||
get
|
||||
{
|
||||
return "WindowsMetro";
|
||||
}
|
||||
}
|
||||
public override string Postfix
|
||||
{
|
||||
get { return "WindowsMetro"; }
|
||||
}
|
||||
|
||||
#region ConvertImport
|
||||
#region ConvertImport
|
||||
protected override void ConvertImport(XElement element, XAttribute projectAttribute)
|
||||
{
|
||||
if (projectAttribute != null)
|
||||
|
5
lib/GetLibraries.cmd
Normal file
5
lib/GetLibraries.cmd
Normal file
@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
|
||||
"./NuGet/NuGet.exe" install packages.config
|
||||
|
||||
pause
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user