Ejemplo n.º 1
0
        public static RevorbStream Jiggle(byte[] raw)
        {
            var handle = GCHandle.Alloc(raw, GCHandleType.Pinned);
            var rawPtr = handle.AddrOfPinnedObject();

            REVORB_FILE input = new REVORB_FILE {
                start = rawPtr,
                size  = raw.Length
            };

            input.cursor = input.start;

            IntPtr ptr = Marshal.AllocHGlobal(4096);

            REVORB_FILE output = new REVORB_FILE
            {
                start = ptr,
                size  = 4096
            };

            output.cursor = output.start;

            int result = revorb(ref input, ref output, _reAlloc);

            handle.Free();
            if (result != REVORB_ERR_SUCCESS)
            {
                Marshal.FreeHGlobal(output.start);
                throw new Exception($"Expected success, got {result} -- refer to RevorbStd.Native");
            }

            // output.start to be freed by the stream
            return(new RevorbStream(output));
        }
Ejemplo n.º 2
0
        public static RevorbStream Jiggle(Stream fi)
        {
            byte[] raw = new byte[fi.Length];
            long   pos = fi.Position;

            fi.Position = 0;
            fi.Read(raw, 0, raw.Length);
            fi.Position = pos;

            IntPtr rawPtr = Marshal.AllocHGlobal(raw.Length);

            Marshal.Copy(raw, 0, rawPtr, raw.Length);

            REVORB_FILE input = new REVORB_FILE {
                start = rawPtr,
                size  = raw.Length
            };

            input.cursor = input.start;

            IntPtr ptr = Marshal.AllocHGlobal(4096);

            REVORB_FILE output = new REVORB_FILE
            {
                start = ptr,
                size  = 4096
            };

            output.cursor = output.start;

            int result = revorb(ref input, ref output);

            Marshal.FreeHGlobal(rawPtr);

            if (result != REVORB_ERR_SUCCESS)
            {
                Marshal.FreeHGlobal(output.start);
                throw new Exception($"Expected success, got {result} -- refer to RevorbStd.Native");
            }

            return(new RevorbStream(output));
        }
Ejemplo n.º 3
0
 public static extern int revorb(ref REVORB_FILE fi, ref REVORB_FILE fo);
Ejemplo n.º 4
0
 public RevorbStream(REVORB_FILE revorbFile) : base((byte *)revorbFile.start.ToPointer(), revorbFile.size)
 {
     this.revorbFile = revorbFile;
 }
Ejemplo n.º 5
0
 internal static extern int revorb(ref REVORB_FILE fi, ref REVORB_FILE fo, ReAlloc reAlloc);