Skip to content

Commit

Permalink
Bring back NAudio - NLayer was kinda buggy.
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyDuchess committed Jun 29, 2024
1 parent 4798f3e commit 4353a8d
Show file tree
Hide file tree
Showing 12 changed files with 22,724 additions and 14 deletions.
8 changes: 8 additions & 0 deletions Assets/Plugins/NAudio.meta

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

Binary file added Assets/Plugins/NAudio/NAudio.dll
Binary file not shown.

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

22,556 changes: 22,556 additions & 0 deletions Assets/Plugins/NAudio/NAudio.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Assets/Plugins/NAudio/NAudio.xml.meta

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

31 changes: 31 additions & 0 deletions Assets/Plugins/NAudio/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Microsoft Public License (Ms-PL)

This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

1. Definitions

The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.

A "contribution" is the original software, or any additions or changes to the software.

A "contributor" is any person that distributes its contribution under this license.

"Licensed patents" are a contributor's patent claims that read directly on its contribution.

2. Grant of Rights

(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.

(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

3. Conditions and Limitations

(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.

(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.

(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.

(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.

(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
7 changes: 7 additions & 0 deletions Assets/Plugins/NAudio/license.txt.meta

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

92 changes: 92 additions & 0 deletions Assets/Plugins/NAudio/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
NAudio is an open source .NET audio library written by Mark Heath (mark.heath@gmail.com)
For more information, visit http://naudio.codeplex.com
NAudio is now being hosted on GitHub http://github.com/naudio/NAudio

THANKS
======
The following list includes some of the people who have contributed in various ways to NAudio, such as code contributions,
bug fixes, documentation, helping out on the forums and even donations. I haven't finished compiling this list yet, so
if your name should be on it but isn't please let me know and I will include it. Also, some people I only know by their forum
id, so if you want me to put your full name here, please also get in touch.

in alphabetical order:
Alan Jordan
Alexandre Mutel
Alexander Binkert
AmandaTarafaMas
balistof
biermeester
borman11
bradb
Brandon Hansen (kg6ypi)
csechet
ChunkWare Music Software
CKing
DaMacc
Dirk Eckhardt
Du10
eejake52
Florian Rosmann (filoe)
Freefall
Giawa
Harald Petrovitsch
Hfuy
Iain McCowan
Idael Cardaso
ioctlLR
Ivan Kochurkin (KvanTTT)
Jamie Michael Ewins
jannera
jbaker8935
jcameron23
JoeGaggler
jonahoffmann
jontdelorme
Jospin Software
Justin Frankel
K24A3
Kamen Lichev
Kassoul
kevinxxx
kzych
LionCash
Lustild
Lucian Wischik (ljw1004)
ManuN
MeelMarcel
Michael Chadwick
Michael Feld
Michael J
Michael Lehenbauer
milligan22963
myrkle
nelsonkidd
Nigel Redmon
Nikolaos Georgiou
Owen Skriloff
owoudenb
painmailer
PPavan
Pygmy
Ray Molenkamp
Roadz
Robert Bristow-Johnson
Scott Fleischman
Simon Clark
Sirish Bajpai
sporn
Steve Underwood
Ted Murphy
Tiny Simple Tools
Tobias Fleming
TomBogle
Tony Cabello
Tony Sistemas
TuneBlade
topher3683
volmart
Vladimir Rokovanov
Ville Koskinen
Wyatt Rice
Yuval Naveh
Zsb
7 changes: 7 additions & 0 deletions Assets/Plugins/NAudio/readme.txt.meta

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

Binary file removed Assets/Plugins/NLayer.dll
Binary file not shown.
26 changes: 14 additions & 12 deletions Assets/Scripts/OpenTS2/Content/DBPF/MP3AudioAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using NLayer;
using System.IO;
using NAudio;
using NAudio.Wave;
using System.Collections;

namespace OpenTS2.Content.DBPF
{
Expand All @@ -20,9 +22,9 @@ public override AudioClip Clip
if (_clip == null)
{
_clip = AudioClip.Create(GlobalTGI.ToString(),
(int)(_mpegFile.Length / sizeof(float) / _mpegFile.Channels),
_mpegFile.Channels,
_mpegFile.SampleRate,
(int)(_mp3Reader.Length / sizeof(float)),
_sampleProvider.WaveFormat.Channels,
_sampleProvider.WaveFormat.SampleRate,
true,
OnMp3Read,
OnClipPositionSet);
Expand All @@ -32,13 +34,14 @@ public override AudioClip Clip
}
public byte[] AudioData;
private AudioClip _clip;
private MpegFile _mpegFile;
private MemoryStream _stream;
private Mp3FileReader _mp3Reader;
private ISampleProvider _sampleProvider;

public MP3AudioAsset(byte[] data) : base(data)
{
_stream = new MemoryStream(data);
_mpegFile = new MpegFile(_stream);
var stream = new MemoryStream(data);
_mp3Reader = new Mp3FileReader(stream);
_sampleProvider = _mp3Reader.ToSampleProvider();
}

public override void FreeUnmanagedResources()
Expand All @@ -48,16 +51,15 @@ public override void FreeUnmanagedResources()
_clip.Free();
}

// PCMReaderCallback will called each time AudioClip reads data.
private void OnMp3Read(float[] data)
{
int actualReadCount = _mpegFile.ReadSamples(data, 0, data.Length);
_sampleProvider.Read(data, 0, data.Length);
}

// PCMSetPositionCallback will called when first loading this audioclip
private void OnClipPositionSet(int position)
{
_mpegFile = new MpegFile(_stream);
// Hallo :3
//_mp3Reader = new Mp3FileReader(_stream);
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Currently a basic main menu with a neighborhood chooser is implemented. Neighbor
* [MoonSharp](https://github.com/moonsharp-devs/moonsharp/)
* [FreeSO](https://github.com/RHY3756547/FreeSO)
* [DBPFSharp](https://github.com/0xC0000054/DBPFSharp/blob/main/src/DBPFSharp)
* [NLayer](https://github.com/naudio/NLayer)
* [NAudio](https://github.com/naudio/NAudio)
* [NSpeex](https://github.com/aijingsun6/NSpeex)

## Similar Projects
Expand Down

0 comments on commit 4353a8d

Please sign in to comment.