Пример #1
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);
        }
Пример #2
0
		public FlakeWriter(string path, Stream IO, AudioPCMConfig pcm)
		{
			_pcm = pcm;

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

			channels = 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(_compressionLevel);
			eparams.padding_size = 8192;

			crc8 = new Crc8();
			crc16 = new Crc16();
			frame = new FlacFrame(channels * 2);
		}
Пример #3
0
		public FLACCLWriter(string path, Stream IO, AudioPCMConfig pcm)
		{
			_pcm = pcm;

			// FIXME: For now, only 16-bit encoding is supported
			if (pcm.BitsPerSample != 16 && pcm.BitsPerSample != 24)
				throw new Exception("Bits per sample must be 16.");
			//if (pcm.ChannelCount != 2)
			//    throw new Exception("ChannelCount must be 2.");

			channels = pcm.ChannelCount;
			sample_rate = pcm.SampleRate;
			bits_per_sample = (uint) pcm.BitsPerSample;

			// flake_validate_params

			_path = path;
			_IO = IO;

			eparams.flake_set_defaults(_compressionLevel);
			eparams.padding_size = 8192;

			crc8 = new Crc8();
			crc16 = new Crc16();
		}
Пример #4
0
		public FlakeWriter(string path, Stream IO, AudioPCMConfig pcm)
		{
			_pcm = pcm;

			channels = pcm.ChannelCount;

			_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(_compressionLevel);
			eparams.padding_size = 8192;

			crc8 = new Crc8();
			crc16 = new Crc16();
			frame = new FlacFrame(channels * 2);
		}
Пример #5
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);
        }
Пример #6
0
		public ALACWriter(string path, Stream IO, AudioPCMConfig pcm)
		{
			_pcm = pcm;

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

			_path = path;
			_IO = IO;
			_pathGiven = _IO == null;
			if (_IO != null && !_IO.CanSeek)
				throw new NotSupportedException("stream doesn't support seeking");

			samplesBuffer = new int[Alac.MAX_BLOCKSIZE * (_pcm.ChannelCount == 2 ? 5 : _pcm.ChannelCount)];
			residualBuffer = new int[Alac.MAX_BLOCKSIZE * (_pcm.ChannelCount == 2 ? 6 : _pcm.ChannelCount + 1)];
			windowBuffer = new float[Alac.MAX_BLOCKSIZE * 2 * Alac.MAX_LPC_WINDOWS];

			eparams.set_defaults(_compressionLevel);
			eparams.padding_size = 4096;

			crc8 = new Crc8();
			crc16 = new Crc16();
			frame = new ALACFrame(_pcm.ChannelCount == 2 ? 5 : _pcm.ChannelCount);
			chunk_pos = new List<int>();
		}
Пример #7
0
		public FlaCudaWriter(string path, Stream IO, AudioPCMConfig pcm)
		{
			_pcm = pcm;

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

			channels = pcm.ChannelCount;
			sample_rate = pcm.SampleRate;
			bits_per_sample = (uint) pcm.BitsPerSample;

			// flake_validate_params

			_path = path;
			_IO = IO;

			windowBuffer = new float[FlaCudaWriter.MAX_BLOCKSIZE * lpc.MAX_LPC_WINDOWS];

			eparams.flake_set_defaults(_compressionLevel, !_settings.GPUOnly);
			eparams.padding_size = 8192;

			crc8 = new Crc8();
			crc16 = new Crc16();
		}