У меня есть файл WAVE с wFormatTag
, равным 3 (WAVE_FORMAT_IEEE_FLOAT
). Firefox обрабатывает файлы WAVE_FORMAT_IEEE_FLOAT
как WAVE_FORMAT_EXTENSIBLE
, что означает, что он ожидает, что файл WAVE_FORMAT_IEEE_FLOAT
содержит расширенную часть блока fmt.
Мой файл не содержит расширенной части чанка fmt, что приводит к ошибке при декодировании файла в Firefox: The buffer passed to decodeAudioData contains invalid content which cannot be decoded successfully.
Это означает, что я должен добавить wValidBitsPerSample
к байту 38, dwChannelMask
к байту 40 и SubFormat
к байту 44. Какую информацию я должен добавить для этих трех полей заголовка? Что означает эта информация и как я могу добавить их в виде целых чисел 8-16-32 бит?
Спасибо за помощь :).
Вот информация заголовка моего файла:
console.log('ckID', String.fromCharCode(dataView.getUint8(0))); // R
console.log('ckID', String.fromCharCode(dataView.getUint8(1))); // I
console.log('ckID', String.fromCharCode(dataView.getUint8(2))); // F
console.log('ckID', String.fromCharCode(dataView.getUint8(3))); // F
console.log('cksize', dataView.getUint32(4, true)); // 65623058
console.log('WAVEID', String.fromCharCode(dataView.getUint8(8))); // W
console.log('WAVEID', String.fromCharCode(dataView.getUint8(9))); // A
console.log('WAVEID', String.fromCharCode(dataView.getUint8(10))); // V
console.log('WAVEID', String.fromCharCode(dataView.getUint8(11))); // E
console.log('ckID', String.fromCharCode(dataView.getUint8(12))); // f
console.log('ckID', String.fromCharCode(dataView.getUint8(13))); // m
console.log('ckID', String.fromCharCode(dataView.getUint8(14))); // t
console.log('ckID', String.fromCharCode(dataView.getUint8(15))); //
console.log('cksize', (dataView.getUint32(16, true))); // 16
console.log('wFormatTag', (dataView.getUint16(20, true))); // 3
console.log('nChannels', (dataView.getUint16(22, true))); // 2
console.log('nSamplesPerSec', (dataView.getUint32(24, true))); // 44100
console.log('nAvgBytesPerSec', (dataView.getUint32(28, true))); // 352800
console.log('nBlockAlign', (dataView.getUint16(32, true))); // 8
console.log('wBitsPerSample', (dataView.getUint16(34, true))); // 32
console.log('cbSize', (dataView.getUint16(36, true))); // 0
console.log('ckID', String.fromCharCode(dataView.getUint8(38))); // f
console.log('ckID', String.fromCharCode(dataView.getUint8(39))); // a
console.log('ckID', String.fromCharCode(dataView.getUint8(40))); // c
console.log('ckID', String.fromCharCode(dataView.getUint8(41))); // t
console.log('cksize', (dataView.getUint16(42, true))); // 4
console.log('dwSampleLength', (dataView.getUint16(46, true))); // 10876
console.log('ckID', String.fromCharCode(dataView.getUint8(50))); // d
console.log('ckID', String.fromCharCode(dataView.getUint8(51))); // a
console.log('ckID', String.fromCharCode(dataView.getUint8(52))); // t
console.log('ckID', String.fromCharCode(dataView.getUint8(53))); // a