obiwanjacobi / vst.net

Virtual Studio Technology (VST) for .NET. Plugins and Host applications.
https://obiwanjacobi.github.io/vst.net/index.html
GNU Lesser General Public License v2.1
420 stars 52 forks source link

`Jacobi.Vst.Samples.Host` error. #51

Closed albyho closed 3 years ago

albyho commented 3 years ago

Describe the bug

System.AccessViolationException:“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”

To Reproduce

  1. Run Jacobi.Vst.Samples.Host.
  2. Load VST 2 plugin. (Category: Synth; Flags: HasEditor, CanReplacing, ProgramChunks, IsSynth.)
  3. Click Process Noise.

The Audio Input Count is 0 and the Audio Output Count is 2.

albyho commented 3 years ago

How to create a Jacobi.Vst.Core.VstTimeInfo object?

obiwanjacobi commented 3 years ago

You've closed the issue. Is the problem fixed?

albyho commented 3 years ago

Yes. The reason is :

        public Jacobi.Vst.Core.VstTimeInfo GetTimeInfo(Jacobi.Vst.Core.VstTimeInfoFlags filterFlags)
        {
            RaisePluginCalled("GetTimeInfo(" + filterFlags + ")");
            return null; // Cannot be null here
        }

Create a new VstTimeInfo object to fix it.

obiwanjacobi commented 3 years ago

You could just return an empty object? return new VstTimeInfo();

albyho commented 3 years ago
new VstTimeInfo
                {
                    SamplePosition = 0.0,
                    SampleRate = 44100,
                    NanoSeconds = 0.0,
                    PpqPosition = 0.0,
                    Tempo = 120.0,
                    BarStartPosition = 0.0,
                    CycleStartPosition = 0.0,
                    CycleEndPosition = 0.0,
                    TimeSignatureNumerator = 4,
                    TimeSignatureDenominator = 4,
                    SmpteOffset = 0,
                    SmpteFrameRate = VstSmpteFrameRate.Smpte24fps,
                    SamplesToNearestClock = 0,
                    Flags = 0
                };

Maybe not a good way, but it works.