Skip to content

Commit

Permalink
Merge pull request #29 from MineCake147E/feature-WaveCodec
Browse files Browse the repository at this point in the history
Implemented a simple WAVE decoder, and major changes for certain areas
  • Loading branch information
MineCake147E authored Nov 9, 2020
2 parents 0766204 + 8f14a0c commit 3227c35
Show file tree
Hide file tree
Showing 76 changed files with 6,114 additions and 1,033 deletions.
2 changes: 1 addition & 1 deletion MonoAudio.Android/AudioTrackOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void Initialize(IWaveSource source)
AudioAttributes attributes;
AudioFormat format;
int latencyInFrames = (int)(source.Format.SampleRate * Latency.TotalSeconds / 2.0);
bufferSizeInBytes = latencyInFrames * source.Format.GetFrameSize();
bufferSizeInBytes = latencyInFrames * source.Format.GetFrameSizeInBytes();
buffer = new byte[bufferSizeInBytes];
using (var attributesBuilder = new AudioAttributes.Builder())
using (var formatBuilder = new AudioFormat.Builder())
Expand Down
9 changes: 4 additions & 5 deletions MonoAudio.Android/Resources/Resource.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions MonoAudio.CodeGenDependencies/EncodingData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MonoAudio.CodeGenDependencies
{
public struct EncodingData
{
public string Name;
public string Id;
public string Attr;
public string Value;
}
}
13 changes: 13 additions & 0 deletions MonoAudio.CodeGenDependencies/MonoAudio.CodeGenDependencies.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions MonoAudio.CodeGenDependencies/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace MonoAudio.CodeGenDependencies
{
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Span<byte> a;
object h;
}
}
}
22 changes: 22 additions & 0 deletions MonoAudio.sln
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoAudio.BenchmarkRunner",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoAudio.Tests.IO.Droid", "Tests\MonoAudio.Tests.IO.Droid\MonoAudio.Tests.IO.Droid.csproj", "{CBC9C972-F946-484F-9ADF-1BA1906ABF86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoAudio.CodeGenDependencies", "MonoAudio.CodeGenDependencies\MonoAudio.CodeGenDependencies.csproj", "{909B6A2F-D762-469A-9ECD-FCE7653978C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -334,6 +336,26 @@ Global
{CBC9C972-F946-484F-9ADF-1BA1906ABF86}.Release|x86.ActiveCfg = Release|Any CPU
{CBC9C972-F946-484F-9ADF-1BA1906ABF86}.Release|x86.Build.0 = Release|Any CPU
{CBC9C972-F946-484F-9ADF-1BA1906ABF86}.Release|x86.Deploy.0 = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|ARM.ActiveCfg = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|ARM.Build.0 = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|ARM64.Build.0 = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|x64.ActiveCfg = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|x64.Build.0 = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|x86.ActiveCfg = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Debug|x86.Build.0 = Debug|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|Any CPU.Build.0 = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|ARM.ActiveCfg = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|ARM.Build.0 = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|ARM64.ActiveCfg = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|ARM64.Build.0 = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|x64.ActiveCfg = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|x64.Build.0 = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|x86.ActiveCfg = Release|Any CPU
{909B6A2F-D762-469A-9ECD-FCE7653978C6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion MonoAudio/AudioBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ref TSample this[int index]
public AudioBuffer(TFormat format, int sizeInFrames)
{
Format = format;
Memory = new TSample[format.GetFrameSize() / Unsafe.SizeOf<TSample>() * sizeInFrames];
Memory = new TSample[format.GetFrameSizeInBytes() / Unsafe.SizeOf<TSample>() * sizeInFrames];
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions MonoAudio/AudioEncoding.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;

using MonoAudio.Formats;

namespace MonoAudio
Expand Down
106 changes: 106 additions & 0 deletions MonoAudio/CodeGeneration/Formats.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
"Unknown format", "Unknown", "", "0x0000",
"Microsoft PCM Format", "LinearPcm", "FixedBitDepth", "0x0001",
"Microsoft ADPCM Format", "MsAdpcm", "", "0x0002",
"IEEE 754 Single Precision Floating-Point Number", "IeeeFloat", "", "0x0003",
"Vector sum excited linear prediction Compaq Computer Corporation", "Vselp", "", "0x0004",
"IBM Corporation", "IbmCvsd", "", "0x0005",
"A-law format by Microsoft Corporation", "Alaw", "", "0x0006",
"μ-law format by Microsoft Corporation", "Mulaw", "", "0x0007",
"OKI ADPCM", "OkiAdpcm", "", "0x0010",
"Intel Corporation ADPCM", "ImaAdpcm", "", "0x0011",
"Videologic ADPCM", "MediaspaceAdpcm", "", "0x0012",
"Sierra Semiconductor Corp", "SierraAdpcm", "", "0x0013",
"Antex Electronics Corporation", "G723Adpcm", "", "0x0014",
"DSP Solutions, Inc.", "Digistd", "", "0x0015",
"DSP Solutions, Inc.", "Digifix", "", "0x0016",
"Dialogic Corporation", "DialogicOkiAdpcm", "", "0x0017",
"Media Vision, Inc.", "MediavisionAdpcm", "", "0x0018",
"Hewlett-Packard Company", "CuCodec", "", "0x0019",
"Yamaha Corporation of America", "YamahaAdpcm", "", "0x0020",
"Speech Compression", "Sonarc", "", "0x0021",
"DSP Group, Inc", "DspgroupTruespeech", "", "0x0022",
"Echo Speech Corporation", "Echosc1", "", "0x0023",
"Audiofile, Inc.", "AudiofileAf36", "", "0x0024",
"Audio Processing Technology", "Aptx", "", "0x0025",
"Audiofile, Inc.", "AudiofileAf10", "", "0x0026",
"Aculab plc", "Prosody1612", "", "0x0027",
"Merging Technologies S.A.", "Lrc", "", "0x0028",
"Dolby Laboratories", "DolbyAc2", "", "0x0030",
"Microsoft Corporation", "Gsm610", "", "0x0031",
"Microsoft Corporation", "Msnaudio", "", "0x0032",
"Antex Electronics Corporation", "AntexAdpcme", "", "0x0033",
"Control Resources Limited", "ControlResVqlpc", "", "0x0034",
"DSP Solutions, Inc.", "Digireal", "", "0x0035",
"DSP Solutions, Inc.", "Digiadpcm", "", "0x0036",
"Control Resources Limited", "ControlResCr10", "", "0x0037",
"Natural MicroSystems", "NmsVbxadpcm", "", "0x0038",
"Roland", "RolandRdac", "", "0x0039",
"Echo Speech Corporation", "Echosc3", "", "0x003A",
"Rockwell International", "RockwellAdpcm", "", "0x003B",
"Rockwell International", "RockwellDigitalk", "", "0x003C",
"Xebec Multimedia Solutions Limited", "Xebec", "", "0x003D",
"Antex Electronics Corporation", "G721Adpcm", "", "0x0040",
"Antex Electronics Corporation", "G728Celp", "", "0x0041",
"Microsoft Corporation", "Msg723", "", "0x0042",
"Microsoft Corporation", "Mpeg", "", "0x0050",
"InSoft Inc.", "Rt24", "", "0x0052",
"InSoft Inc.", "Pac", "", "0x0053",
"MPEG 3 Layer 1", "Mpeglayer3", "", "0x0055",
"Lucent Technologies", "LucentG723", "", "0x0059",
"Cirrus Logic", "Cirrus", "", "0x0060",
"ESS Technology", "Espcm", "", "0x0061",
"Voxware Inc", "Voxware", "", "0x0062",
"Canopus, Co., Ltd.", "CanopusAtrac", "", "0x0063",
"APICOM", "G726Adpcm", "", "0x0064",
"APICOM", "G722Adpcm", "", "0x0065",
"Microsoft Corporation", "Dsat", "", "0x0066",
"Microsoft Corporation", "DsatDisplay", "", "0x0067",
"Voxware Inc.", "VoxwareByteAligned", "", "0x0069",
"Voxware Inc.", "VoxwareAc8", "", "0x0070",
"Voxware Inc.", "VoxwareAc10", "", "0x0071",
"Voxware Inc.", "VoxwareAc16", "", "0x0072",
"Voxware Inc.", "VoxwareAc20", "", "0x0073",
"Voxware Inc.", "VoxwareRt24", "", "0x0074",
"Voxware Inc.", "VoxwareRt29", "", "0x0075",
"Voxware Inc.", "VoxwareRt29hw", "", "0x0076",
"Voxware Inc.", "VoxwareVr12", "", "0x0077",
"Voxware Inc.", "VoxwareVr18", "", "0x0078",
"Voxware Inc.", "VoxwareTq40", "", "0x0079",
"Softsound, Ltd.", "Softsound", "", "0x0080",
"Voxware Inc.", "VoxareTq60", "", "0x0081",
"Microsoft Corporation", "Msrt24", "", "0x0082",
"AT&amp;T Laboratories", "G729a", "", "0x0083",
"Motion Pixels", "MviMv12", "", "0x0084",
"DataFusion Systems (Pty) (Ltd)", "DfG726", "", "0x0085",
"DataFusion Systems (Pty) (Ltd)", "DfGsm610", "", "0x0086",
"OnLive! Technologies, Inc.", "Onlive", "", "0x0089",
"Siemens Business Communications Systems", "Sbc24", "", "0x0091",
"Sonic Foundry", "DolbyAc3Spdif", "", "0x0092",
"ZyXEL Communications, Inc.", "ZyxelAdpcm", "", "0x0097",
"Philips Speech Processing", "PhilipsLpcbb", "", "0x0098",
"Studer Professional Audio AG", "Packed", "", "0x0099",
"Rhetorex, Inc.", "RhetorexAdpcm", "", "0x0100",
"IBM mu-law format", "IbmMulaw", "", "0x0101",
"IBM a-law format", "IbmAlaw", "", "0x0102",
"IBM AVC Adaptive Differential PCM format", "Adpcm", "", "0x0103",
"Vivo Software", "VivoG723", "", "0x0111",
"Vivo Software", "VivoSiren", "", "0x0112",
"Digital Equipment Corporation", "DigitalG723", "", "0x0123",
"Creative Labs, Inc", "CreativeAdpcm", "", "0x0200",
"Creative Labs, Inc", "CreativeFastspeech8", "", "0x0202",
"Creative Labs, Inc", "CreativeFastspeech10", "", "0x0203",
"Quarterdeck Corporation", "Quarterdeck", "", "0x0220",
"Fujitsu Corporation", "FmTownsSnd", "", "0x0300",
"Brooktree Corporation", "BzvDigital", "", "0x0400",
"AT&amp;T Labs, Inc.", "VmeVmpcm", "", "0x0680",
"Ing C. Olivetti &amp; C., S.p.A.", "Oligsm", "", "0x1000",
"Ing C. Olivetti &amp; C., S.p.A.", "Oliadpcm", "", "0x1001",
"Ing C. Olivetti &amp; C., S.p.A.", "Olicelp", "", "0x1002",
"Ing C. Olivetti &amp; C., S.p.A.", "Olisbc", "", "0x1003",
"Ing C. Olivetti &amp; C., S.p.A.", "Oliopr", "", "0x1004",
"Lernout &amp; Hauspie", "LhCodec", "", "0x1100",
"Norris Communications, Inc.", "Norris", "", "0x1400",
"AT&amp;T Labs, Inc.", "SoundspaceMusicompress", "", "0x1500",
"FAST Multimedia AG", "Dvm", "", "0x2000",
"?????", "InterwavVsc112", "", "0x7150",
"Extensible wave format", "Extensible", "", "0xFFFEu",
23 changes: 23 additions & 0 deletions MonoAudio/CodeGeneration/InfoSubChunkIds.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"The Archival Location subchunk \"IARL\" read in Little Endian.", "ArchivalLocation", "", "IARL"
"The Artist subchunk \"IART\" read in Little Endian.", "Artist", "", "IART"
"The Commissioned subchunk \"ICMS\" read in Little Endian.", "Commissioned", "", "ICMS"
"The Comments subchunk \"ICMT\" read in Little Endian.", "Comments", "", "ICMT"
"The Copyright subchunk \"ICOP\" read in Little Endian.", "Copyright", "", "ICOP"
"The Creation Date subchunk \"ICRD\" read in Little Endian.", "CreationDate", "", "ICRD"
"The Cropped subchunk \"ICRP\" read in Little Endian.", "Cropped", "", "ICRP"
"The Dimensions subchunk \"IDIM\" read in Little Endian.", "Dimensions", "", "IDIM"
"The Dots Per Inch subchunk \"IDPI\" read in Little Endian.", "DotsPerInch", "", "IDPI"
"The Engineer subchunk \"IENG\" read in Little Endian.", "Engineer", "", "IENG"
"The Genre subchunk \"IGNR\" read in Little Endian.", "Genre", "", "IGNR"
"The Keywords subchunk \"IKEY\" read in Little Endian.", "Keywords", "", "IKEY"
"The Lightness subchunk \"ILGT\" read in Little Endian.", "Lightness", "", "ILGT"
"The Medium subchunk \"IMED\" read in Little Endian.", "Medium", "", "IMED"
"The Name subchunk \"INAM\" read in Little Endian.", "Name", "", "INAM"
"The Palette Setting subchunk \"IPLT\" read in Little Endian.", "PaletteSetting", "", "IPLT"
"The Product subchunk \"IPRD\" read in Little Endian.", "Product", "", "IPRD"
"The Subject subchunk \"ISBJ\" read in Little Endian.", "Subject", "", "ISBJ"
"The Software subchunk \"ISFT\" read in Little Endian.", "Software", "", "ISFT"
"The Sharpness subchunk \"ISHP\" read in Little Endian.", "Sharpness", "", "ISHP"
"The Source subchunk \"ISRC\" read in Little Endian.", "Source", "", "ISRC"
"The SourceForm subchunk \"ISRF\" read in Little Endian.", "SourceForm", "", "ISRF"
"The Technician subchunk \"ITCH\" read in Little Endian.", "Technician", "", "ITCH"
9 changes: 5 additions & 4 deletions MonoAudio/Codecs/IDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;

using MonoAudio.Data;

namespace MonoAudio.Codecs
Expand All @@ -16,21 +17,21 @@ public interface IDecoder
/// Determines whether the data from <paramref name="dataSource"/> can be decoded by this decoder asynchronously.<br/>
/// The actual decoding stream must be opened after seeking the source <see cref="Stream"/> to head.
/// </summary>
/// <param name="dataSource">The <see cref="IDataSource"/> to read the data from.</param>
/// <param name="dataSource">The <see cref="IDataSource{TSample}"/> to read the data from.</param>
/// <returns>
/// The whole verification task which returns the value below:<br/>
/// <c>true</c> if the data from <paramref name="dataSource"/> can be supported by this decoder, otherwise, <c>false</c>.
/// </returns>
ValueTask<bool> DetermineDecodabilityAsync(IDataSource dataSource);
ValueTask<bool> DetermineDecodabilityAsync(IDataSource<byte> dataSource);

/// <summary>
/// Tries to create a decoder that asynchronously decodes the data asynchronously read from <paramref name="dataSource"/>.
/// </summary>
/// <param name="dataSource">The <see cref="IDataSource"/> to read the data from.</param>
/// <param name="dataSource">The <see cref="IDataSource{TSample}"/> to read the data from.</param>
/// <returns>
/// success: The value which indicates whether the data is decodable, and the decoder is created.
/// decoder: The decoding <see cref="IWaveSource"/>.
/// </returns>
ValueTask<(bool success, IWaveSource decoder)> TryCreateDecoderAsync(IDataSource dataSource);
ValueTask<(bool success, IWaveSource decoder)> TryCreateDecoderAsync(IDataSource<byte> dataSource);
}
}
Loading

0 comments on commit 3227c35

Please sign in to comment.