public FlacReader(Stream input, WavWriter output)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            stream = input;
            writer = output;

            context = _flacStreamDecoderNew();

            if (context == IntPtr.Zero)
            {
                throw new ApplicationException("FLAC: Could not initialize stream decoder!");
            }

            write    = Write;
            metadata = Metadata;
            error    = Error;
            read     = Read;
            seek     = Seek;
            tell     = Tell;
            length   = Length;
            eof      = Eof;

            if (_flacStreamDecoderInitStream(context, read, seek, tell, length, eof, write, metadata,
                                             error, IntPtr.Zero) != 0)
            {
                throw new ApplicationException("FLAC: Could not open stream for reading!");
            }
        }
Esempio n. 2
0
 public void Seek(double NewPossition)
 {
     SeekCallback?.Invoke(this, new SeekEventArgs()
     {
         NewPossition = NewPossition
     });
 }
Esempio n. 3
0
        public FlacWriter(Stream output, int bitDepth, int channels, int sampleRate)
        {
            stream = output;
            writer = new BinaryWriter(stream);

            inputBitDepth   = bitDepth;
            inputChannels   = channels;
            inputSampleRate = sampleRate;

            context = FLAC__stream_encoder_new();

            if (context == IntPtr.Zero)
            {
                throw new ApplicationException("FLAC: Could not initialize stream encoder!");
            }

            Check(
                FLAC__stream_encoder_set_channels(context, channels),
                "set channels");

            Check(
                FLAC__stream_encoder_set_bits_per_sample(context, bitDepth),
                "set bits per sample");

            Check(
                FLAC__stream_encoder_set_sample_rate(context, sampleRate),
                "set sample rate");

            Check(
                FLAC__stream_encoder_set_compression_level(context, 5),
                "set compression level");

            //Check(
            //    FLAC__stream_encoder_set_blocksize(context, 8192),
            //    "set block size");

            write = new WriteCallback(Write);
            seek  = new SeekCallback(Seek);
            tell  = new TellCallback(Tell);

            if (FLAC__stream_encoder_init_stream(context,
                                                 write, seek, tell,
                                                 null, IntPtr.Zero) != 0)
            {
                throw new ApplicationException("FLAC: Could not open stream for writing!");
            }
        }
        public FlacWriter(Stream output, int bitDepth, int channels, int sampleRate)
        {
            stream = output;
            writer = new BinaryWriter(stream);

            inputBitDepth = bitDepth;
            inputChannels = channels;
            inputSampleRate = sampleRate;

            context = FLAC__stream_encoder_new();

            if (context == IntPtr.Zero)
                throw new ApplicationException("FLAC: Could not initialize stream encoder!");

            Check(
                FLAC__stream_encoder_set_channels(context, channels),
                "set channels");

            Check(
                FLAC__stream_encoder_set_bits_per_sample(context, bitDepth),
                "set bits per sample");

            Check(
                FLAC__stream_encoder_set_sample_rate(context, sampleRate),
                "set sample rate");

            Check(
                FLAC__stream_encoder_set_compression_level(context, 5),
                "set compression level");

            //Check(
            //    FLAC__stream_encoder_set_blocksize(context, 8192),
            //    "set block size");

            write = new WriteCallback(Write);
            seek = new SeekCallback(Seek);
            tell = new TellCallback(Tell);

            if (FLAC__stream_encoder_init_stream(context,
                                                 write, seek, tell,
                                                 null, IntPtr.Zero) != 0)
                throw new ApplicationException("FLAC: Could not open stream for writing!");
        }
Esempio n. 5
0
 public static extern void RegisterSeekCallback(
     SafeCurlHandle curl,
     SeekCallback callback,
     IntPtr userPointer,
     ref SafeCallbackHandle callbackHandle);
 static extern int FLAC__stream_encoder_init_stream(IntPtr context, WriteCallback write, SeekCallback seek, TellCallback tell, MetadataCallback metadata, IntPtr userData);
Esempio n. 7
0
 public static extern int init_put_byte(ref ByteIOContext s, [In, Out]byte[] buffer, int buffer_size,
                   int write_flag, IntPtr opaque, ReadPacketCallback read_packet,
                   WritePacketCallback write_packet, SeekCallback seek);
Esempio n. 8
0
 static extern int FLAC__stream_encoder_init_stream(IntPtr context, WriteCallback write, SeekCallback seek, TellCallback tell, MetadataCallback metadata, IntPtr userData);
Esempio n. 9
0
        public FlacWriter(Stream output, int bitDepth, int channels, int sampleRate)
        {
            stream = output;
            writer = new BinaryWriter(stream);

            inputBitDepth = bitDepth;
            inputChannels = channels;
            inputSampleRate = sampleRate;

            context = FLAC__stream_encoder_new();

            if (context == IntPtr.Zero)
                throw new ApplicationException("FLAC: Could not initialize stream encoder!");

            Check(
                FLAC__stream_encoder_set_channels(context, channels),
                "set channels");

            Check(
                FLAC__stream_encoder_set_bits_per_sample(context, bitDepth),
                "set bits per sample");

            Check(
                FLAC__stream_encoder_set_sample_rate(context, sampleRate),
                "set sample rate");

            Check(
                FLAC__stream_encoder_set_verify(context, false),
                "set verify");

            Check(
                FLAC__stream_encoder_set_streamable_subset(context, true),
                "set verify");

            Check(
                FLAC__stream_encoder_set_do_mid_side_stereo(context, true),
                "set verify");

            Check(
                FLAC__stream_encoder_set_loose_mid_side_stereo(context, true),
                "set verify");

            Check(
                FLAC__stream_encoder_set_compression_level(context, 5),
                "set compression level");

            Check(
                FLAC__stream_encoder_set_blocksize(context, 4608),
                "set block size");

            write = new WriteCallback(Write);
            seek = new SeekCallback(Seek);
            tell = new TellCallback(Tell);

            if (FLAC__stream_encoder_init_stream(context,
                                                 write, seek, tell,
                                                 null, IntPtr.Zero) != 0)
                throw new ApplicationException("FLAC: Could not open stream for writing!");

            //if (FLAC__stream_encoder_init_file(context, @"wav\miles_fisher-this_must_be_the_place-iphone2.flac", IntPtr.Zero, IntPtr.Zero) != 0)
            //    throw new ApplicationException("FLAC: Could not open stream for writing!");
        }
Esempio n. 10
0
        public FlacWriter(Stream output, int bitDepth, int channels, int sampleRate)
        {
            stream = output;
            writer = new BinaryWriter(stream);

            inputBitDepth   = bitDepth;
            inputChannels   = channels;
            inputSampleRate = sampleRate;

            context = FLAC__stream_encoder_new();

            if (context == IntPtr.Zero)
            {
                throw new ApplicationException("FLAC: Could not initialize stream encoder!");
            }

            Check(
                FLAC__stream_encoder_set_channels(context, channels),
                "set channels");

            Check(
                FLAC__stream_encoder_set_bits_per_sample(context, bitDepth),
                "set bits per sample");

            Check(
                FLAC__stream_encoder_set_sample_rate(context, sampleRate),
                "set sample rate");

            Check(
                FLAC__stream_encoder_set_verify(context, false),
                "set verify");

            Check(
                FLAC__stream_encoder_set_streamable_subset(context, true),
                "set verify");

            Check(
                FLAC__stream_encoder_set_do_mid_side_stereo(context, true),
                "set verify");

            Check(
                FLAC__stream_encoder_set_loose_mid_side_stereo(context, true),
                "set verify");

            Check(
                FLAC__stream_encoder_set_compression_level(context, 5),
                "set compression level");

            Check(
                FLAC__stream_encoder_set_blocksize(context, 4608),
                "set block size");

            write = new WriteCallback(Write);
            seek  = new SeekCallback(Seek);
            tell  = new TellCallback(Tell);

            if (FLAC__stream_encoder_init_stream(context,
                                                 write, seek, tell,
                                                 null, IntPtr.Zero) != 0)
            {
                throw new ApplicationException("FLAC: Could not open stream for writing!");
            }

            //if (FLAC__stream_encoder_init_file(context, @"wav\miles_fisher-this_must_be_the_place-iphone2.flac", IntPtr.Zero, IntPtr.Zero) != 0)
            //    throw new ApplicationException("FLAC: Could not open stream for writing!");
        }
Esempio n. 11
0
 public static extern int init_put_byte(ref ByteIOContext s, [In, Out] byte[] buffer, int buffer_size,
                                        int write_flag, IntPtr opaque, ReadPacketCallback read_packet,
                                        WritePacketCallback write_packet, SeekCallback seek);
Esempio n. 12
0
 public static extern void RegisterSeekCallback(
     SafeCurlHandle curl,
     SeekCallback callback,
     IntPtr userPointer,
     ref SafeCallbackHandle callbackHandle);
Esempio n. 13
0
        public FlacWriter(Stream output, int bitDepth, int channels, int sampleRate)
        {
            stream = output;

            inputBitDepth = bitDepth;
            inputChannels = channels;

            context = _flacStreamEncoderNew();

            if (context == IntPtr.Zero)
            {
                throw new ApplicationException("FLAC: Could not initialize stream encoder!");
            }

            Check(
                _flacStreamEncoderSetChannels(context, channels),
                "set channels");

            Check(
                _flacStreamEncoderSetBitsPerSample(context, bitDepth),
                "set bits per sample");

            Check(
                _flacStreamEncoderSetSampleRate(context, sampleRate),
                "set sample rate");

            Check(
                _flacStreamEncoderSetVerify(context, false),
                "set verify");

            Check(
                _flacStreamEncoderSetStreamableSubset(context, true),
                "set verify");

            Check(
                _flacStreamEncoderSetDoMidSideStereo(context, true),
                "set verify");

            Check(
                _flacStreamEncoderSetLooseMidSideStereo(context, true),
                "set verify");

            Check(
                _flacStreamEncoderSetQlpCoeffPrecision(context, 10),
                "set qlp coeff precision");

            Check(
                _flacStreamEncoderSetBlockSize(context, 1024),
                "set block size");

            Check(
                _flacStreamEncoderSetDoQlpCoeffPrecSearch(context, true),
                "set do qlp coeff precision search");

            Check(
                _flacStreamEncoderSetCompressionLevel(context, 8),
                "set compression level");

            Check(
                _flacStreamEncoderSetMaxResidualPartitionOrder(context, 5),
                "set max residual partition order");

            Check(
                _flacStreamEncoderSetDoMD5(context, false),
                "set do md5");

            write = Write;
            seek  = Seek;
            tell  = Tell;

            if (_flacStreamEncoderInitStream(context,
                                             write, seek, tell,
                                             null, IntPtr.Zero) != 0)
            {
                throw new ApplicationException("FLAC: Could not open stream for writing!");
            }

            //if (FLAC__stream_encoder_init_file(context, @"wav\miles_fisher-this_must_be_the_place-iphone2.flac", IntPtr.Zero, IntPtr.Zero) != 0)
            //    throw new ApplicationException("FLAC: Could not open stream for writing!");
        }