mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 10:53:50 +02:00
Minor cleanup
This commit is contained in:
@@ -62,26 +62,24 @@ export class WaveMuxer extends Muxer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private writeHeader(track: OutputAudioTrack, config: AudioDecoderConfig) {
|
private writeHeader(track: OutputAudioTrack, config: AudioDecoderConfig) {
|
||||||
const codec = track.source._codec;
|
|
||||||
let format: WaveFormat;
|
let format: WaveFormat;
|
||||||
let sampleSize: number;
|
|
||||||
|
|
||||||
|
const codec = track.source._codec;
|
||||||
const pcmInfo = parsePcmCodec(codec as PcmAudioCodec);
|
const pcmInfo = parsePcmCodec(codec as PcmAudioCodec);
|
||||||
|
|
||||||
if (pcmInfo.dataType === 'ulaw') {
|
if (pcmInfo.dataType === 'ulaw') {
|
||||||
format = WaveFormat.MULAW;
|
format = WaveFormat.MULAW;
|
||||||
sampleSize = 1;
|
|
||||||
} else if (pcmInfo.dataType === 'alaw') {
|
} else if (pcmInfo.dataType === 'alaw') {
|
||||||
format = WaveFormat.ALAW;
|
format = WaveFormat.ALAW;
|
||||||
sampleSize = 1;
|
} else if (pcmInfo.dataType === 'float') {
|
||||||
|
format = WaveFormat.IEEE_FLOAT;
|
||||||
} else {
|
} else {
|
||||||
format = pcmInfo.dataType === 'float' ? WaveFormat.IEEE_FLOAT : WaveFormat.PCM;
|
format = WaveFormat.PCM;
|
||||||
sampleSize = pcmInfo.sampleSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const channels = config.numberOfChannels;
|
const channels = config.numberOfChannels;
|
||||||
const sampleRate = config.sampleRate;
|
const sampleRate = config.sampleRate;
|
||||||
const blockSize = sampleSize * channels;
|
const blockSize = pcmInfo.sampleSize * channels;
|
||||||
|
|
||||||
// RIFF header
|
// RIFF header
|
||||||
this.riffWriter.writeAscii('RIFF');
|
this.riffWriter.writeAscii('RIFF');
|
||||||
@@ -96,7 +94,7 @@ export class WaveMuxer extends Muxer {
|
|||||||
this.riffWriter.writeU32(sampleRate);
|
this.riffWriter.writeU32(sampleRate);
|
||||||
this.riffWriter.writeU32(sampleRate * blockSize); // Bytes per second
|
this.riffWriter.writeU32(sampleRate * blockSize); // Bytes per second
|
||||||
this.riffWriter.writeU16(blockSize);
|
this.riffWriter.writeU16(blockSize);
|
||||||
this.riffWriter.writeU16(8 * sampleSize);
|
this.riffWriter.writeU16(8 * pcmInfo.sampleSize);
|
||||||
|
|
||||||
// data chunk
|
// data chunk
|
||||||
this.riffWriter.writeAscii('data');
|
this.riffWriter.writeAscii('data');
|
||||||
|
|||||||
Reference in New Issue
Block a user