public OggVorbisEncodedStream(byte[] buffer)
        {
            //this.buffer = buffer;
            rawStream = new MemoryStream(buffer);

            //Open
            file = new NativeOggVorbisFile();

            NativeCallbacks callbacks = new NativeCallbacks();

            callbacks.ReadFunction = new ReadFunctionDelegate(this.RawStreamRead);
            callbacks.TellFunction = new TellFunctionDelegate(this.RawStreamTell);
            callbacks.SeekFunction = new SeekFunctionDelegate(this.RawStreamSeek);

            int result = 0;

            if ((result = OggVorbisFile.NativeOpenCallbacks(buffer, file, IntPtr.Zero, 0, callbacks)) != 0)
            {
                throw new OggVorbisException(String.Format("Error {0} during open", result));
            }

            //Get info
            info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1));

            //Get lengths of the stream
            pcmLength = OggVorbisFile.NativeGetLength(file, -1);    // -1 to entire bitstream
            rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream
            duration  = OggVorbisFile.NativeGetDuration(file, -1);  // -1 to entire bitstream

            //Update info
            info.Duration = duration;
        }
 public OggVorbisMemoryStream(byte[] buffer, VorbisInfo info, long rawLength, double duration)
     : base(buffer)
 {
     this.buffer = buffer;
     this.info = info;
     this.rawLength = rawLength;
     this.duration = duration;
 }
 public OggVorbisMemoryStream(byte[] buffer, VorbisInfo info, long rawLength, double duration)
     : base(buffer)
 {
     this.buffer    = buffer;
     this.info      = info;
     this.rawLength = rawLength;
     this.duration  = duration;
 }
        public static OggVorbisMemoryStream LoadFromFile(string filename)
        {
            //load from file
            OggVorbisFileStream fileStream = new OggVorbisFileStream(filename);
            VorbisInfo          ninfo      = fileStream.Info;

            //read to memory
            byte[] nbuffer = new byte[fileStream.Length];
            //fileStream.Read(nbuffer, 0, nbuffer.Length);
            nbuffer = ReadWholeArray(fileStream, nbuffer);

            OggVorbisMemoryStream memoryStream = new OggVorbisMemoryStream(nbuffer, ninfo, fileStream.RawLength, fileStream.Duration);

            //clean up
            fileStream.Close();

            return(memoryStream);
        }
        public OggVorbisFileStream(string filename)
        {
            //Open File
            file = new NativeOggVorbisFile();

            //if (ov_open(stream.SafeFileHandle, ref vf, IntPtr.Zero,0) == 0)
            // fopen for Win32!
            if (OggVorbisFile.NativeFOpen(filename, file) != 0)
            {
                throw new OggVorbisException("Error during fopen");
            }

            //Get info
            info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1));

            //Get lengths of the stream
            pcmLength = OggVorbisFile.NativeGetLength(file, -1); // -1 to entire bitstream
            rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream
            duration = OggVorbisFile.NativeGetDuration(file, -1); // -1 to entire bitstream

            //Update info
            info.Duration = duration;
        }
        public OggVorbisFileStream(string filename)
        {
            //Open File
            file = new NativeOggVorbisFile();

            //if (ov_open(stream.SafeFileHandle, ref vf, IntPtr.Zero,0) == 0)
            // fopen for Win32!
            if (OggVorbisFile.NativeFOpen(filename, file) != 0)
            {
                throw new OggVorbisException("Error during fopen");
            }

            //Get info
            info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1));

            //Get lengths of the stream
            pcmLength = OggVorbisFile.NativeGetLength(file, -1);    // -1 to entire bitstream
            rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream
            duration  = OggVorbisFile.NativeGetDuration(file, -1);  // -1 to entire bitstream

            //Update info
            info.Duration = duration;
        }
        public OggVorbisEncodedStream(byte[] buffer)
        {
            //this.buffer = buffer;
            rawStream = new MemoryStream(buffer);

            //Open
            file = new NativeOggVorbisFile();

            NativeCallbacks callbacks = new NativeCallbacks();
            callbacks.ReadFunction = new ReadFunctionDelegate(this.RawStreamRead);
            callbacks.TellFunction = new TellFunctionDelegate(this.RawStreamTell);
            callbacks.SeekFunction = new SeekFunctionDelegate(this.RawStreamSeek);

            int result = 0;
            if ((result = OggVorbisFile.NativeOpenCallbacks(buffer, file, IntPtr.Zero, 0, callbacks)) != 0)
            {
                throw new OggVorbisException(String.Format("Error {0} during open",result));
            }

            //Get info
            info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1));

            //Get lengths of the stream
            pcmLength = OggVorbisFile.NativeGetLength(file, -1); // -1 to entire bitstream
            rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream
            duration = OggVorbisFile.NativeGetDuration(file, -1); // -1 to entire bitstream

            //Update info
            info.Duration = duration;
        }