private void AssertAllBuffersHasValue(VstAudioPrecisionBufferManager bufferMgr, float value)
 {
     foreach (VstAudioPrecisionBuffer buffer in bufferMgr.Buffers)
     {
         AssertBufferHasValue(buffer, value);
     }
 }
Exemplo n.º 2
0
        private VstAudioPrecisionBufferManager CreateNew()
        {
            VstAudioPrecisionBufferManager bufferMgr = new VstAudioPrecisionBufferManager(_bufferCount, _bufferSize);

            Assert.AreEqual(_bufferCount, bufferMgr.BufferCount, "Buffer Count was not set correctly.");
            Assert.AreEqual(_bufferSize, bufferMgr.BufferSize, "Buffer Size was not set correctly.");

            return(bufferMgr);
        }
        private VstAudioPrecisionBufferManager CreateNew()
        {
            var bufferMgr = new VstAudioPrecisionBufferManager(_bufferCount, _bufferSize);

            bufferMgr.BufferCount.Should().Be(_bufferCount);
            bufferMgr.BufferSize.Should().Be(_bufferSize);

            return(bufferMgr);
        }
Exemplo n.º 4
0
        public void Test_VstAudioPrecisionBufferManager_ClearAllBuffers()
        {
            VstAudioPrecisionBufferManager bufferMgr = CreateNew(_testValue);

            AssertAllBuffersHasValue(bufferMgr, _testValue);

            bufferMgr.ClearAllBuffers();

            AssertAllBuffersHasValue(bufferMgr, 0);
        }
Exemplo n.º 5
0
        public void Test_VstAudioBufferManager_EnumerateBuffers()
        {
            VstAudioPrecisionBufferManager bufferMgr = CreateNew(_testValue);

            int counter = 0;

            foreach (VstAudioPrecisionBuffer buffer in bufferMgr)
            {
                counter++;
            }

            Assert.AreEqual(_bufferCount, counter, "The number of buffers in the enumerator do not match.");
        }
Exemplo n.º 6
0
        public void Test_VstAudioPrecisionBufferManager_ClearIndividualBuffers()
        {
            VstAudioPrecisionBufferManager bufferMgr = CreateNew(_testValue);

            AssertAllBuffersHasValue(bufferMgr, _testValue);

            foreach (VstAudioPrecisionBuffer buffer in bufferMgr)
            {
                bufferMgr.ClearBuffer(buffer);
            }

            AssertAllBuffersHasValue(bufferMgr, 0);
        }
Exemplo n.º 7
0
        private VstAudioPrecisionBufferManager CreateNew(float value)
        {
            VstAudioPrecisionBufferManager bufferMgr = CreateNew();

            foreach (VstAudioPrecisionBuffer buffer in bufferMgr)
            {
                for (int i = 0; i < buffer.SampleCount; i++)
                {
                    buffer[i] = value;
                }
            }

            return(bufferMgr);
        }
Exemplo n.º 8
0
        public static int ProcessFile(
            string inputFile,
            string outputFile,
            VstPluginContext pluginContext,
            System.Threading.CancellationToken cancellationToken
            )
        {
            var isDoublePrecision = pluginContext.PluginInfo.Flags.HasFlag(VstPluginFlags.CanDoubleReplacing);

            var pcmInput  = new WAVParser(inputFile);
            var pcmOutput = new WAVParser
            {
                ChannelCount = pcmInput.ChannelCount,
                Samples      = new List <List <double> >(),
                SampleRate   = pcmInput.SampleRate,
            };

            for (int i = 0; i < pcmOutput.ChannelCount; i++)
            {
                pcmOutput.Samples.Add(new List <double>());
            }

            pluginContext.PluginCommandStub.SetSampleRate(pcmInput.SampleRate);
            pluginContext.PluginCommandStub.SetProcessPrecision(VstProcessPrecision.Process32);

            // hint: samples per buffer should be equal to pcmInput.SampleRate
            int samplesPerBuffer = (int)pcmInput.SampleRate;

            pluginContext.PluginCommandStub.SetBlockSize(samplesPerBuffer);

            int inputCount  = pluginContext.PluginInfo.AudioInputCount;
            int outputCount = pluginContext.PluginInfo.AudioOutputCount;

            VstAudioBuffer[]          vstBufIn  = null, vstBufOut = null;
            VstAudioPrecisionBuffer[] vstBufIn2 = null, vstBufOut2 = null;

            if (isDoublePrecision)
            {
                var vstBufManIn  = new VstAudioPrecisionBufferManager(inputCount, samplesPerBuffer);
                var vstBufManOut = new VstAudioPrecisionBufferManager(outputCount, samplesPerBuffer);

                vstBufIn2  = NumeratorToArray(vstBufManIn.GetEnumerator());
                vstBufOut2 = NumeratorToArray(vstBufManOut.GetEnumerator());
            }
            else
            {
                var vstBufManIn  = new VstAudioBufferManager(inputCount, samplesPerBuffer);
                var vstBufManOut = new VstAudioBufferManager(outputCount, samplesPerBuffer);

                vstBufIn  = NumeratorToArray(vstBufManIn.GetEnumerator());
                vstBufOut = NumeratorToArray(vstBufManOut.GetEnumerator());
            }

            pluginContext.PluginCommandStub.MainsChanged(true);
            pluginContext.PluginCommandStub.StartProcess();

            for (int samplesOffset = 0;
                 samplesOffset < pcmInput.SamplesCount;
                 samplesOffset += (int)pcmInput.SampleRate)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return(ReturnCodeOffset + 20);
                }

                var result = ProcessSingleBuffer(
                    pluginContext,
                    samplesOffset,
                    vstBufIn,
                    vstBufOut,
                    vstBufIn2,
                    vstBufOut2,
                    isDoublePrecision,
                    pcmInput,
                    pcmOutput,
                    inputCount,
                    outputCount,
                    samplesPerBuffer
                    );

                if (result != 0)
                {
                    return(result);
                }
            }

            // Close VST Context
            pluginContext.PluginCommandStub.StopProcess();
            pluginContext.PluginCommandStub.MainsChanged(false);

            // Save
            pcmOutput.Save(outputFile);

            return(0);
        }
Exemplo n.º 9
0
        public void Test_VstAudioPrecisionBufferManager_Construction()
        {
            VstAudioPrecisionBufferManager bufferMgr = CreateNew(_testValue);

            AssertAllBuffersHasValue(bufferMgr, _testValue);
        }