Compress a WAV file to a SHN archive.
173397
def create_shn (archive, compression, cmd, verbosity, interactive, filenames):
    """"""
    if len(filenames) > 1:
        raise util.PatoolError("multiple filenames for shorten not supported")
    cmdlist = [util.shell_quote(cmd)]
    cmdlist.extend(['-', util.shell_quote(archive), '<',
        util.shell_quote(filenames[0])])
    return (cmdlist, {'shell': True})
1159784
def _compress_obj(obj, level):
    
    return zlib.compress(pickle.dumps(obj, protocol=2), level)
213396
def decompress(compressed_data):
    """"""
    raw_data = []

    index = 0

    while index < len(compressed_data):
        current = compressed_data[index]
        index += 1

        if current == RLE_BYTE:
            directive = compressed_data[index]
            index += 1

            if directive == RLE_BYTE:
                raw_data.append(RLE_BYTE)
            else:
                count = compressed_data[index]
                index += 1

                raw_data.extend([directive] * count)
        elif current == SPECIAL_BYTE:
            directive = compressed_data[index]
            index += 1

            if directive == SPECIAL_BYTE:
                raw_data.append(SPECIAL_BYTE)
            elif directive == DEFAULT_WAVE_BYTE:
                count = compressed_data[index]
                index += 1

                raw_data.extend(DEFAULT_WAVE * count)
            elif directive == DEFAULT_INSTR_BYTE:
                count = compressed_data[index]
                index += 1

                raw_data.extend(DEFAULT_INSTRUMENT_FILEPACK * count)
            elif directive == EOF_BYTE:
                assert False, ("Unexpected EOF command encountered while "
                               "decompressing")
            else:
                assert False, "Countered unexpected sequence 0x%02x 0x%02x" % (
                    current, directive)
        else:
            raw_data.append(current)

    return raw_data
663184
def create_flac (archive, compression, cmd, verbosity, interactive, filenames):
    """"""
    cmdlist = [cmd, filenames[0], '--best', '--output-name', archive]
    return cmdlist
816088
def save(filename)
      speech = bytes_wav
      res = IO.popen(lame_command(filename, command_options), 'r+') do |process|
        process.write(speech)
        process.close_write
        process.read
      end
      res.to_s
    end
245653
def to_wav(mediafile):
    
    if mediafile.endswith(".wav"):
        yield mediafile
    else:
        wavfile = tempfile.mktemp(__name__) + ".wav"
        try:
            extract_wav(mediafile, wavfile)
            yield wavfile
        finally:
            if os.path.exists(wavfile):
                os.remove(wavfile)
132581
function(input_32_bit_buffer) {

		// this method is LOSSY - intended as preliminary step when saving audio into WAV format files
		//                        output is a byte array where the 16 bit output format 
		//						  is spread across two bytes in little endian ordering

	    var size_source_buffer = input_32_bit_buffer.length;

	    var buffer_byte_array = new Int16Array(size_source_buffer * 2); // Int8Array 8-bit twos complement signed integer

	    var value_16_bit_signed_int;
	    var index_byte = 0;


	    for (var index = 0; index < size_source_buffer; index++) {

	        value_16_bit_signed_int = ~~((0 < input_32_bit_buffer[index]) ? input_32_bit_buffer[index] * 0x7FFF : 
	        																input_32_bit_buffer[index] * 0x8000);

	        buffer_byte_array[index_byte] = value_16_bit_signed_int & 0xFF;

	        var byte_two_of_two = (value_16_bit_signed_int >> 8);

	        buffer_byte_array[index_byte + 1] = byte_two_of_two;

	        index_byte += 2;
	    };

	    // ---

	    return buffer_byte_array;
	}
743422
def DecompressionFile(src_fp, algorithm):
    """"""
    if algorithm == "lzma":
        return lzma.open(src_fp, "r")

    if algorithm == "snappy":
        return SnappyFile(src_fp, "rb")

    if algorithm:
        raise InvalidConfigurationError("invalid compression algorithm: {!r}".format(algorithm))

    return src_fp
674442
def recompress_archive(archive, verbosity=0, interactive=True):
    """"""
    util.check_existing_filename(archive)
    util.check_writable_filename(archive)
    if verbosity >= 0:
        util.log_info("Recompressing %s ..." % (archive,))
    res = _recompress_archive(archive, verbosity=verbosity, interactive=interactive)
    if res and verbosity >= 0:
        util.log_info(res)
    return 0
962927
def to_wire(self, file, compress=None, origin=None, **kw):
        """"""

        return super(RRset, self).to_wire(self.name, file, compress, origin,
                                          self.deleting, **kw)
121541
def compress_file(filename, content)
      zip.put_next_entry filename, nil, nil, Zip::Entry::DEFLATED, Zlib::BEST_COMPRESSION
      zip.write content.to_s
    end
794995
def _create(archive, compression, cmd, format, verbosity, filenames):
    """"""
    if len(filenames) > 1:
        raise util.PatoolError('multi-file compression not supported in Python lzma')
    try:
        with lzma.LZMAFile(archive, mode='wb', **_get_lzma_options(format, preset=9)) as lzmafile:
            filename = filenames[0]
            with open(filename, 'rb') as srcfile:
                data = srcfile.read(READ_SIZE_BYTES)
                while data:
                    lzmafile.write(data)
                    data = srcfile.read(READ_SIZE_BYTES)
    except Exception as err:
        msg = "error creating %s: %s" % (archive, err)
        raise util.PatoolError(msg)
    return None
45963
def sfload(self, filename, update_midi_preset=0):
        """"""
        return fluid_synth_sfload(self.synth, filename.encode(), update_midi_preset)
515451
def compress_directory(dir)
      File.open archive_path(dir), 'wb' do |oarchive_path|
        Zlib::GzipWriter.wrap oarchive_path do |gz|
          Gem::Package::TarWriter.new gz do |tar|
            Find.find "#{builds_dir}/"+dir do |f|
              relative_path = f.sub "#{builds_dir}/", ""
              mode = File.stat(f).mode
              size = File.stat(f).size
              
              if File.directory? f
                tar.mkdir relative_path, mode
              else
                tar.add_file_simple relative_path, mode, size do |tio|
                  File.open f, 'rb' do |rio|
                    while buffer = rio.read(BLOCKSIZE_TO_READ)
                      tio.write buffer
                    end
                  end
                end
              end
              
            end
          end
        end
      end
      
    end
1105338
def __shxRecord(self, offset, length):
         """"""
         f = self.__getFileObj(self.shx)
         f.write(pack(">i", offset // 2))
         f.write(pack(">i", length))
1038775
def extract_rar (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    cmdlist = [cmd, 'x']
    if not interactive:
        cmdlist.extend(['-p-', '-y'])
    cmdlist.extend(['--', os.path.abspath(archive)])
    return (cmdlist, {'cwd': outdir})
58260
def convert_to_wav(files):
    ''''''
    converted = []
    for f in files:
        new_name = f + '.temp.wav'
        print(new_name)
        if (os.path.exists(f + '.transcription.txt') is False) and (os.path.exists(new_name) is False):
            subprocess.call(['ffmpeg', '-y', '-i', f, '-acodec', 'pcm_s16le', '-ac', '1', '-ar', '16000', new_name])
        converted.append(new_name)
    return converted