Inheritance: CUETools.Codecs.AudioEncoderSettings
 private static Tuple<int, string> WavToFlacHelper(WAVReader audioSource, string targetFlacPath)
 {
     int sampleRate;
     AudioBuffer buffer = new AudioBuffer(audioSource, 0x10000);
     FlakeWriterSettings settings = new FlakeWriterSettings();
     settings.PCM = audioSource.PCM;
     FlakeWriter audioDestination = new FlakeWriter(targetFlacPath, settings);
     while (audioSource.Read(buffer, -1) != 0)
     {
         audioDestination.Write(buffer);
     }
     sampleRate = settings.PCM.SampleRate;
     audioDestination.Close();
     audioSource.Close();
     return new Tuple<int, string>(sampleRate, targetFlacPath);
 }
Exemplo n.º 2
0
        public FlakeWriter(Stream IO, FlakeWriterSettings settings)
        {
            m_settings = settings;

            //if (Settings.PCM.BitsPerSample != 16)
            //    throw new Exception("Bits per sample must be 16.");
            //if (Settings.PCM.ChannelCount != 2)
            //    throw new Exception("ChannelCount must be 2.");

            channels = Settings.PCM.ChannelCount;

            // flake_validate_params

            //_path = path;

            if (IO == null)
            {
                throw new ArgumentNullException("IO");

            }

            _IO = IO;

            samplesBuffer = new int[Flake.MAX_BLOCKSIZE * (channels == 2 ? 4 : channels)];
            residualBuffer = new int[Flake.MAX_BLOCKSIZE * (channels == 2 ? 10 : channels + 1)];
            windowBuffer = new float[Flake.MAX_BLOCKSIZE * 2 * lpc.MAX_LPC_WINDOWS];
            windowScale = new double[lpc.MAX_LPC_WINDOWS];

            var _compressionLevel = Settings.EncoderModeIndex;
            eparams.flake_set_defaults(_compressionLevel);

            crc8 = new Crc8();
            frame = new FlacFrame(channels * 2);
        }
Exemplo n.º 3
0
        public FlakeWriter(string path, Stream IO, FlakeWriterSettings settings)
        {
            m_settings = settings.Clone() as FlakeWriterSettings;
            m_settings.Validate();

            //if (Settings.PCM.BitsPerSample != 16)
            //    throw new Exception("Bits per sample must be 16.");
            //if (Settings.PCM.ChannelCount != 2)
            //    throw new Exception("ChannelCount must be 2.");

            channels = Settings.PCM.ChannelCount;

            // flake_validate_params

            _path = path;
            _IO = IO;

            samplesBuffer = new int[Flake.MAX_BLOCKSIZE * (channels == 2 ? 4 : channels)];
            residualBuffer = new int[Flake.MAX_BLOCKSIZE * (channels == 2 ? 10 : channels + 1)];
            windowBuffer = new float[Flake.MAX_BLOCKSIZE * 2 * lpc.MAX_LPC_WINDOWS];
            windowScale = new double[lpc.MAX_LPC_WINDOWS];

            eparams.flake_set_defaults(m_settings);

            crc8 = new Crc8();
            frame = new FlacFrame(channels * 2);
        }
Exemplo n.º 4
0
 public FlakeWriter(string path, FlakeWriterSettings settings)
     : this(path, null, settings)
 {
 }
Exemplo n.º 5
0
        public int flake_set_defaults(FlakeWriterSettings settings)
        {
            // default to level 7 params
            window_function = WindowFunction.Flattop | WindowFunction.Tukey;
            order_method = OrderMethod.Akaike;
            stereo_method = StereoMethod.Evaluate;
            window_method = WindowMethod.Evaluate;
            block_time_ms = 105;			
            prediction_type = PredictionType.Search;
            estimation_depth = 1;
            variable_block_size = 0;
            lpc_min_precision_search = 1;
            lpc_max_precision_search = 1;
            do_seektable = true;
            development_mode = -1;

            // differences from level 7
            switch (settings.EncoderModeIndex)
            {
                case 0:
                    block_time_ms = 53;
                    prediction_type = PredictionType.Fixed;
                    stereo_method = StereoMethod.Independent;
                    break;
                case 1:
                    prediction_type = PredictionType.Levinson;
                    stereo_method = StereoMethod.Independent;
                    window_function = WindowFunction.Bartlett;
                    break;
                case 2:
                    stereo_method = StereoMethod.Independent;
                    window_function = WindowFunction.Bartlett;
                    break;
                case 3:
                    stereo_method = StereoMethod.Estimate;
                    window_function = WindowFunction.Bartlett;
                    break;
                case 4:
                    stereo_method = StereoMethod.Estimate;
                    window_function = WindowFunction.Bartlett;
                    break;
                case 5:
                    stereo_method = StereoMethod.Estimate;
                    window_method = WindowMethod.Estimate;
                    break;
                case 6:
                    stereo_method = StereoMethod.Estimate;
                    break;
                case 7:
                    break;
                case 8:
                    estimation_depth = 2;
                    lpc_min_precision_search = 0;
                    break;
                case 9:
                    window_function = WindowFunction.Bartlett;
                    break;
                case 10:
                    //lpc_max_precision_search = 2;
                    break;
                case 11:
                    estimation_depth = 5;
                    //lpc_max_precision_search = 2;
                    variable_block_size = 4;
                    break;
            }

            return 0;
        }