(self, initlength)
| 840 | self._convert = self._lin2sowt |
| 841 | |
| 842 | def _write_header(self, initlength): |
| 843 | if self._aifc and self._comptype != b'NONE': |
| 844 | self._init_compression() |
| 845 | self._file.write(b'FORM') |
| 846 | if not self._nframes: |
| 847 | self._nframes = initlength // (self._nchannels * self._sampwidth) |
| 848 | self._datalength = self._nframes * self._nchannels * self._sampwidth |
| 849 | if self._datalength & 1: |
| 850 | self._datalength = self._datalength + 1 |
| 851 | if self._aifc: |
| 852 | if self._comptype in (b'ulaw', b'ULAW', b'alaw', b'ALAW'): |
| 853 | self._datalength = self._datalength // 2 |
| 854 | if self._datalength & 1: |
| 855 | self._datalength = self._datalength + 1 |
| 856 | elif self._comptype == b'G722': |
| 857 | self._datalength = (self._datalength + 3) // 4 |
| 858 | if self._datalength & 1: |
| 859 | self._datalength = self._datalength + 1 |
| 860 | try: |
| 861 | self._form_length_pos = self._file.tell() |
| 862 | except (AttributeError, OSError): |
| 863 | self._form_length_pos = None |
| 864 | commlength = self._write_form_length(self._datalength) |
| 865 | if self._aifc: |
| 866 | self._file.write(b'AIFC') |
| 867 | self._file.write(b'FVER') |
| 868 | _write_ulong(self._file, 4) |
| 869 | _write_ulong(self._file, self._version) |
| 870 | else: |
| 871 | self._file.write(b'AIFF') |
| 872 | self._file.write(b'COMM') |
| 873 | _write_ulong(self._file, commlength) |
| 874 | _write_short(self._file, self._nchannels) |
| 875 | if self._form_length_pos is not None: |
| 876 | self._nframes_pos = self._file.tell() |
| 877 | _write_ulong(self._file, self._nframes) |
| 878 | if self._comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'): |
| 879 | _write_short(self._file, 8) |
| 880 | else: |
| 881 | _write_short(self._file, self._sampwidth * 8) |
| 882 | _write_float(self._file, self._framerate) |
| 883 | if self._aifc: |
| 884 | self._file.write(self._comptype) |
| 885 | _write_string(self._file, self._compname) |
| 886 | self._file.write(b'SSND') |
| 887 | if self._form_length_pos is not None: |
| 888 | self._ssnd_length_pos = self._file.tell() |
| 889 | _write_ulong(self._file, self._datalength + 8) |
| 890 | _write_ulong(self._file, 0) |
| 891 | _write_ulong(self._file, 0) |
| 892 | |
| 893 | def _write_form_length(self, datalength): |
| 894 | if self._aifc: |
no test coverage detected