internal IntPtr AudioMasterCallBackProc(
            IntPtr /*AEffect^*/ aeffectPtr,
            Opcodes opcode,
            int index,
            IntPtr value,
            IntPtr ptr,
            float opt
            )
        {
            /*
             * Logger.LogInformation(
             *  $"AudioMasterCallBackProc " +
             *  $"{nameof(aeffectPtr)}:{aeffectPtr:X} " +
             *  $"{nameof(opcode)}:{opcode:F} " +
             *  $"{nameof(index)}:{index} " +
             *  $"{nameof(value)}:{value:X} " +
             *  $"{nameof(ptr)}:{ptr:X} " +
             *  $"{nameof(opt)}:{opt}"
             * );
             */

            switch (opcode)
            {
            case Opcodes.audioMasterVersion:
            {
                return(new IntPtr(2400));
            }

            case Opcodes.audioMasterGetTime:
            {
                var p = _param.AsSpan(0, 1);
                p[0].vstTimeInfo.nanoSeconds = _counter.NowTicks * 100;
                return(_param.GetIntPtr(0));
            }

            case Opcodes.audioMasterGetSampleRate:
            {
                return(new IntPtr(SamplingRate));
            }

            case Opcodes.audioMasterGetBlockSize:
            {
                return(new IntPtr(BlockSize));
            }

            case Opcodes.audioMasterGetCurrentProcessLevel:
            {
                var p = _param.AsSpan(0, 1);
                return(new IntPtr((int)p[0].vstProcessLevels));
            }

            default:
                //Logger.LogInformation("NOP");
                return(default);
            }
        }
Exemplo n.º 2
0
    public VstHost(
        int samplingRate,
        int blockSize,
        ILoggerFactory loggerFactory
        )
    {
        _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
        _logger        = _loggerFactory.CreateLogger <VstHost>();

        _param = new("vstTimeInfo", 1, _loggerFactory);
        var p = _param.AsSpan(0, 1);

        p[0].vstTimeInfo.samplePos          = 0.0;
        p[0].vstTimeInfo.sampleRate         = samplingRate;
        p[0].vstTimeInfo.nanoSeconds        = 0.0;
        p[0].vstTimeInfo.ppqPos             = 0.0;
        p[0].vstTimeInfo.tempo              = 240.0;
        p[0].vstTimeInfo.barStartPos        = 0.0;
        p[0].vstTimeInfo.cycleStartPos      = 0.0;
        p[0].vstTimeInfo.cycleEndPos        = 0.0;
        p[0].vstTimeInfo.timeSigNumerator   = 4;
        p[0].vstTimeInfo.timeSigDenominator = 4;
        p[0].vstTimeInfo.smpteOffset        = 0;
        p[0].vstTimeInfo.smpteFrameRate     = VstTimeInfo.VstSmpteFrameRate.kVstSmpte24fps;
        p[0].vstTimeInfo.samplesToNextClock = 0;
        p[0].vstTimeInfo.flags              = VstTimeInfo.VstTimeInfoFlags.kVstTempoValid | VstTimeInfo.VstTimeInfoFlags.kVstNanosValid;

        p[0].vstProcessLevels = VstProcessLevels.kVstProcessLevelRealtime;
        p[0].samplingRate     = samplingRate;
        p[0].blockSize        = blockSize;
    }
        public AudioMaster(
            int samplingRate,
            int blockSize,
            ILoggerFactory loggerFactory,
            ElapsedTimeCounter counter,
            IDllManager dllManager
            )
        {
            _loggerFactory = loggerFactory;
            _logger        = _loggerFactory.CreateLogger <AudioMaster <T> >();
            _counter       = counter;
            DllManager     = dllManager;

            _param = new("vstTimeInfo", 1, _loggerFactory);
            var p = _param.AsSpan(0, 1);

            p[0].vstTimeInfo.samplePos          = 0.0;
            p[0].vstTimeInfo.sampleRate         = samplingRate;
            p[0].vstTimeInfo.nanoSeconds        = 0.0;
            p[0].vstTimeInfo.ppqPos             = 0.0;
            p[0].vstTimeInfo.tempo              = 240.0;
            p[0].vstTimeInfo.barStartPos        = 0.0;
            p[0].vstTimeInfo.cycleStartPos      = 0.0;
            p[0].vstTimeInfo.cycleEndPos        = 0.0;
            p[0].vstTimeInfo.timeSigNumerator   = 4;
            p[0].vstTimeInfo.timeSigDenominator = 4;
            p[0].vstTimeInfo.smpteOffset        = 0;
            p[0].vstTimeInfo.smpteFrameRate     = VstTimeInfo.VstSmpteFrameRate.kVstSmpte24fps;
            p[0].vstTimeInfo.samplesToNextClock = 0;
            p[0].vstTimeInfo.flags              = VstTimeInfo.VstTimeInfoFlags.kVstTempoValid | VstTimeInfo.VstTimeInfoFlags.kVstNanosValid;

            p[0].vstProcessLevels = VstProcessLevels.kVstProcessLevelRealtime;
            p[0].samplingRate     = samplingRate;
            p[0].blockSize        = blockSize;
        }
        public void Test1()
        {
            var configuration =
                new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .Build();

            using var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddConfiguration(configuration);
                builder.AddConsole();
                builder.AddDebug();
            });

            using var test = new IPCBuffer <Struct>("test", 2, loggerFactory);
            {
                var s1 = test.AsSpan(0, 2);

                s1[0].a = 10;
                s1[0].b = 20;
                s1[0].c = 30;
                s1[0].d = 40;

                s1[1].a = 50;
                s1[1].b = 60;
                s1[1].c = 70;
                s1[1].d = 80;

                var s2 = test.AsSpan(0, 1);
                Assert.Equal(10, s2[0].a);
                Assert.Equal(20, s2[0].b);
                Assert.Equal(30, s2[0].c);
                Assert.Equal(40, s2[0].d);

                var s3 = test.AsSpan(1, 1);
                Assert.Equal(50, s3[0].a);
                Assert.Equal(60, s3[0].b);
                Assert.Equal(70, s3[0].c);
                Assert.Equal(80, s3[0].d);
            }
        }