Exemple #1
0
        public static bool BASSPlayBackEngineRT(Double[] CustomFramerates, ref Int64 pos, ref Int64 es)
        {
            double fpssim = MainWindow.FPSSimulator.NextDouble() * (CustomFramerates[0] - CustomFramerates[1]) + CustomFramerates[1];
            int    length = Convert.ToInt32(Bass.BASS_ChannelSeconds2Bytes(MainWindow.KMCGlobals._recHandle, fpssim));

            byte[] buffer = new byte[length];

            for (int i = 0; i <= 15; i++)
            {
                BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, i, BASSMIDIEvent.MIDI_EVENT_MIXLEVEL, MainWindow.KMCStatus.ChannelsVolume[i]);
            }

            while (es < MainWindow.KMCGlobals.eventc && MainWindow.KMCGlobals.events[es].pos < pos + length)
            {
                BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, MainWindow.KMCGlobals.events[es].chan, MainWindow.KMCGlobals.events[es].eventtype, MainWindow.KMCGlobals.events[es].param);
                es++;
            }

            if (MainWindow.VSTs.VSTInfo[0].isInstrument)
            {
                Bass.BASS_ChannelGetData(MainWindow.VSTs._VSTiHandle, buffer, length);
            }
            int got = Bass.BASS_ChannelGetData(MainWindow.KMCGlobals._recHandle, buffer, length);

            if (got < 0)
            {
                MainWindow.KMCGlobals.CancellationPendingValue = MainWindow.KMCConstants.CONVERSION_ENDED;
                return(false);
            }

            pos += got;
            if (es == MainWindow.KMCGlobals.eventc)
            {
                BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_END, 0);
            }

            float fpsstring = 1 / (float)fpssim;

            IntPtr UnmanagedBuffer = Marshal.AllocHGlobal(buffer.Length);

            Marshal.Copy(buffer, 0, UnmanagedBuffer, buffer.Length);
            BassWasapi.BASS_WASAPI_PutData(UnmanagedBuffer, length);
            Marshal.FreeHGlobal(UnmanagedBuffer);

            return(true);
        }