Exemple #1
0
        int Read(object Buffer, int Length)
        {
            GCHandle gch = GCHandle.Alloc(Buffer, GCHandleType.Pinned);

            int Return = Bass.ChannelGetData(Handle, gch.AddrOfPinnedObject(), Length);

            gch.Free();

            return(Return);
        }
Exemple #2
0
        /// <summary>
        /// Writes all the Data in the decoder to a file
        /// </summary>
        /// <param name="Writer">Audio File Writer to write to</param>
        /// <param name="Offset">+ve for forward, -ve for backward</param>
        public void Write(IAudioFileWriter Writer, int Offset = 0)
        {
            long InitialPosition = Position;

            Position += Offset;

            int BlockLength = (int)Seconds2Bytes(2);

            byte[] Buffer = new byte[BlockLength];

            var gch = GCHandle.Alloc(Buffer, GCHandleType.Pinned);

            while (HasData)
            {
                Bass.ChannelGetData(Handle, gch.AddrOfPinnedObject(), BlockLength);
                Writer.Write(Buffer, BlockLength);
            }

            gch.Free();

            Writer.Dispose();

            Position = InitialPosition;
        }