diff --git a/AudioLib/AudioLib.dll b/AudioLib/AudioLib.dll deleted file mode 100644 index e7e7758..0000000 Binary files a/AudioLib/AudioLib.dll and /dev/null differ diff --git a/AudioLib/AudioLib.pdb b/AudioLib/AudioLib.pdb deleted file mode 100644 index 324d06e..0000000 Binary files a/AudioLib/AudioLib.pdb and /dev/null differ diff --git a/AudioLib/Mp3Sharp.dll b/AudioLib/Mp3Sharp.dll deleted file mode 100644 index 8bea215..0000000 Binary files a/AudioLib/Mp3Sharp.dll and /dev/null differ diff --git a/AudioLib/NAudio.dll b/AudioLib/NAudio.dll deleted file mode 100644 index dc5f986..0000000 Binary files a/AudioLib/NAudio.dll and /dev/null differ diff --git a/AudioLib/NAudio.pdb b/AudioLib/NAudio.pdb deleted file mode 100644 index 5bc348f..0000000 Binary files a/AudioLib/NAudio.pdb and /dev/null differ diff --git a/AudioLib/SharpDX.DirectSound.dll b/AudioLib/SharpDX.DirectSound.dll deleted file mode 100644 index f605583..0000000 Binary files a/AudioLib/SharpDX.DirectSound.dll and /dev/null differ diff --git a/AudioLib/SharpDX.dll b/AudioLib/SharpDX.dll deleted file mode 100644 index ac58975..0000000 Binary files a/AudioLib/SharpDX.dll and /dev/null differ diff --git a/AudioLib/SoundTouch.Net.dll b/AudioLib/SoundTouch.Net.dll deleted file mode 100644 index 04d6fb9..0000000 Binary files a/AudioLib/SoundTouch.Net.dll and /dev/null differ diff --git a/AudioLib/SoundTouch.Net.pdb b/AudioLib/SoundTouch.Net.pdb deleted file mode 100644 index c64047a..0000000 Binary files a/AudioLib/SoundTouch.Net.pdb and /dev/null differ diff --git a/AudioLib/fmpeg_config.xml b/AudioLib/fmpeg_config.xml deleted file mode 100644 index 455b5a4..0000000 --- a/AudioLib/fmpeg_config.xml +++ /dev/null @@ -1,6 +0,0 @@ - - --i {0} -b:a {1} {2} --i {0} -ar 8000 -ab {1} {2} --i {0} -b 400k -acodec aac -strict experimental -ac 1 -ar 16000 -ab {1} {2} - \ No newline at end of file diff --git a/README.md b/README.md index 5649120..fa17e9e 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,3 @@ This application WILL NEVER support any other media type except RIFF files, beca ![](https://cdn.discordapp.com/attachments/568223142724763652/705420220398960650/Home_VSTLogoAlpha92x54.png) VST is a trademark of Steinberg Media Technologies GmbH. - -AudioLib is a intellectual property of Daniel Weck ( https://github.com/danielweck ) and DAISY Consortium. - diff --git a/VSTAudioProcessor/Process/VSTProcessing.cs b/VSTAudioProcessor/Process/VSTProcessing.cs index e242bdd..1e708a8 100644 --- a/VSTAudioProcessor/Process/VSTProcessing.cs +++ b/VSTAudioProcessor/Process/VSTProcessing.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.IO; -using AudioLib; using Jacobi.Vst.Core; using Jacobi.Vst.Core.Host; using Jacobi.Vst.Interop.Host; +using NokitaKaze.WAVParser; using VSTAudioProcessor.General; using VSTAudioProcessor.VstSubClasses; @@ -150,32 +150,23 @@ System.Threading.CancellationToken cancellationToken { var isDoublePrecision = pluginContext.PluginInfo.Flags.HasFlag(VstPluginFlags.CanDoubleReplacing); - MemoryStream inputStream; - MemoryStream outputStream = new MemoryStream(); + var pcmInput = new WAVParser(inputFile); + var pcmOutput = new WAVParser { - inputStream = new MemoryStream(); - var bytes = System.IO.File.ReadAllBytes(inputFile); - inputStream.Write(bytes, 0, bytes.Length); - inputStream.Seek(0, SeekOrigin.Begin); + ChannelCount = pcmInput.ChannelCount, + Samples = new List>(), + SampleRate = pcmInput.SampleRate, + }; + for (int i = 0; i < pcmOutput.ChannelCount; i++) + { + pcmOutput.Samples.Add(new List()); } - var pcmInput = AudioLibPCMFormat.RiffHeaderParse(inputStream, out _); - var pcmOutput = new AudioLibPCMFormat(); - pcmOutput.CopyFrom(pcmInput); - pluginContext.PluginCommandStub.SetSampleRate(pcmInput.SampleRate); pluginContext.PluginCommandStub.SetProcessPrecision(VstProcessPrecision.Process32); - // Write stub header - var audioStreamRiffOffset = pcmOutput.RiffHeaderWrite(outputStream, 0); - - int bytesToTransfer = (int) Math.Min( - inputStream.Length - (long) audioStreamRiffOffset, - pcmOutput.ConvertTimeToBytes(1000 * AudioLibPCMFormat.TIME_UNIT) - ); - // hint: samples per buffer should be equal to pcmInput.SampleRate - int samplesPerBuffer = (int) Math.Round(bytesToTransfer / 2.0 / pcmOutput.NumberOfChannels); + int samplesPerBuffer = (int) pcmInput.SampleRate; pluginContext.PluginCommandStub.SetBlockSize(samplesPerBuffer); int inputCount = pluginContext.PluginInfo.AudioInputCount; @@ -204,9 +195,9 @@ System.Threading.CancellationToken cancellationToken pluginContext.PluginCommandStub.MainsChanged(true); pluginContext.PluginCommandStub.StartProcess(); - int bytesReadFromAudioStream; - byte[] byteBuffer = new byte[bytesToTransfer]; - while ((bytesReadFromAudioStream = inputStream.Read(byteBuffer, 0, bytesToTransfer)) > 0) + for (int samplesOffset = 0; + samplesOffset < pcmInput.SamplesCount; + samplesOffset += (int) pcmInput.SampleRate) { if (cancellationToken.IsCancellationRequested) { @@ -215,13 +206,13 @@ System.Threading.CancellationToken cancellationToken var result = ProcessSingleBuffer( pluginContext, - byteBuffer, - bytesReadFromAudioStream, + samplesOffset, vstBufIn, vstBufOut, vstBufIn2, vstBufOut2, isDoublePrecision, + pcmInput, pcmOutput, inputCount, outputCount, @@ -232,23 +223,14 @@ System.Threading.CancellationToken cancellationToken { return result; } - - outputStream.Write(byteBuffer, 0, bytesReadFromAudioStream); } + // Close VST Context pluginContext.PluginCommandStub.StopProcess(); pluginContext.PluginCommandStub.MainsChanged(false); - { - outputStream.Seek(0, SeekOrigin.Begin); - pcmOutput.RiffHeaderWrite(outputStream, - (uint) (outputStream.Length - (long) audioStreamRiffOffset)); - - inputStream.Dispose(); - var outputBytes = outputStream.ToArray(); - outputStream.Dispose(); - File.WriteAllBytes(outputFile, outputBytes); - } + // Save + pcmOutput.Save(outputFile); return 0; } @@ -256,14 +238,14 @@ System.Threading.CancellationToken cancellationToken private static int ProcessSingleBuffer( IVstPluginContext pluginContext, - byte[] byteBuffer, - int bytesReadFromAudioStream, + int samplesOffset, VstAudioBuffer[] vstBufIn, VstAudioBuffer[] vstBufOut, VstAudioPrecisionBuffer[] vstBufIn2, VstAudioPrecisionBuffer[] vstBufOut2, bool isDoublePrecision, - AudioLibPCMFormat pcmOutput, + WAVParser pcmInput, + WAVParser pcmOutput, int vstInputCount, int vstOutputCount, int samplesPerBuffer @@ -285,11 +267,11 @@ int samplesPerBuffer } result = ProcessSingleBufferFillBufferInput( - byteBuffer, - bytesReadFromAudioStream, + samplesOffset, vstBufIn, vstBufIn2, isDoublePrecision, + pcmInput, pcmOutput, vstOutputCount ); @@ -308,8 +290,6 @@ int samplesPerBuffer } result = ProcessSingleBufferFillByteBuffer( - byteBuffer, - bytesReadFromAudioStream, vstBufOut, vstBufOut2, isDoublePrecision, @@ -367,71 +347,45 @@ int samplesPerBuffer /// /// Read 2-bytes octets from byteBuffer and put them to VstAudioBuffer /// - /// - /// + /// /// /// /// + /// /// /// /// private static int ProcessSingleBufferFillBufferInput( - byte[] byteBuffer, - int bytesReadFromAudioStream, + int samplesOffset, IReadOnlyList vstBufIn, IReadOnlyList vstBufIn2, bool isDoublePrecision, - AudioLibPCMFormat pcmOutput, + WAVParser pcmInput, + WAVParser pcmOutput, int vstOutputCount ) { - var iSample = 0; - for (int i = 0; i < bytesReadFromAudioStream; iSample++) + for (int i = samplesOffset; + i < Math.Min(pcmInput.SamplesCount, samplesOffset + pcmInput.SampleRate); + i++) { - for (int channel = 0; channel < pcmOutput.NumberOfChannels; channel++) + var iSample = i - samplesOffset; + for (int channel = 0; channel < pcmOutput.ChannelCount; channel++) { - if (i + 1 >= bytesReadFromAudioStream) - { - break; - } - - var sample = BitConverter.ToInt16(byteBuffer, i); - i += 2; - if (channel >= vstOutputCount) { continue; } + double sample = pcmInput.Samples[channel][i]; + if (!isDoublePrecision) { - float sampleF = sample / 32768f; - if (sampleF > 1.0f) - { - sampleF = 1.0f; - } - - if (sampleF < -1.0f) - { - sampleF = -1.0f; - } - - vstBufIn[channel][iSample] = sampleF; + vstBufIn[channel][iSample] = (float) sample; } else { - double sampleD = sample / 32768d; - if (sampleD > 1.0d) - { - sampleD = 1.0d; - } - - if (sampleD < -1.0d) - { - sampleD = -1.0d; - } - - vstBufIn2[channel][iSample] = sampleD; + vstBufIn2[channel][iSample] = sample; } } } // int i = 0; i < bytesReadFromAudioStream @@ -440,68 +394,31 @@ int vstOutputCount } private static int ProcessSingleBufferFillByteBuffer( - byte[] byteBuffer, - int bytesReadFromAudioStream, IReadOnlyList vstBufOut, IReadOnlyList vstBufOut2, bool isDoublePrecision, - AudioLibPCMFormat pcmOutput, + WAVParser pcmOutput, int vstOutputCount, int samplesPerBuffer ) { - int iByte = 0; - Array.Clear(byteBuffer, 0, byteBuffer.Length); for (var iSample = 0; iSample < samplesPerBuffer; iSample++) { - for (int channel = 0; channel < pcmOutput.NumberOfChannels; channel++) + for (int channel = 0; channel < pcmOutput.ChannelCount; channel++) { - short sample = 0; - if (channel < vstOutputCount) { if (!isDoublePrecision) { float sampleF = vstBufOut[channel][iSample]; - sampleF *= 32768f; - if (sampleF > short.MaxValue) - { - sampleF = short.MaxValue; - } - - if (sampleF < short.MinValue) - { - sampleF = short.MinValue; - } - - sample = (short) Math.Round(sampleF); + pcmOutput.Samples[channel].Add(sampleF); } else { double sampleD = vstBufOut2[channel][iSample]; - sampleD *= 32768d; - if (sampleD > short.MaxValue) - { - sampleD = short.MaxValue; - } - - if (sampleD < short.MinValue) - { - sampleD = short.MinValue; - } - - sample = (short) Math.Round(sampleD); + pcmOutput.Samples[channel].Add(sampleD); } } - - if (iByte + 1 >= bytesReadFromAudioStream) - { - break; - } - - byte[] sampleBytes = BitConverter.GetBytes(sample); - Array.Copy(sampleBytes, 0, byteBuffer, iByte, 2); - iByte += 2; } } diff --git a/VSTAudioProcessor/VSTAudioProcessor.csproj b/VSTAudioProcessor/VSTAudioProcessor.csproj index f034348..1f4dec8 100644 --- a/VSTAudioProcessor/VSTAudioProcessor.csproj +++ b/VSTAudioProcessor/VSTAudioProcessor.csproj @@ -68,9 +68,6 @@ true - - ..\AudioLib\AudioLib.dll - ..\packages\CommandLineParser.2.7.82\lib\net461\CommandLine.dll True @@ -89,6 +86,10 @@ 4.0 + + ..\packages\NokitaKaze.WAVParser.0.1.0\lib\netstandard2.0\WAVParser.dll + True + diff --git a/VSTAudioProcessor/packages.config b/VSTAudioProcessor/packages.config index ec9a3bd..62683df 100644 --- a/VSTAudioProcessor/packages.config +++ b/VSTAudioProcessor/packages.config @@ -2,6 +2,7 @@ + \ No newline at end of file