我正在接收16位无符号整数形式的音频剪辑。我想添加一个WAV标头并将其保存到文件中。我使用this作为对标题进行硬编码的参考。 (嗯,那些固定的部分)
这是构造WAVE标头的代码:
import React, { Component, Fragment } from 'react';
import { Link } from 'react-router-dom';
import { AuthUserContext } from '../../../providers/authUser';
import { withFirebase } from '../../../providers/firebase';
import * as ROUTES from '../../../../constants/routes';
import { PrimaryBtn, Errors } from '../../../templates';
interface InterfaceProps {
initialError: any;
firebase?: any;
}
interface InterfaceState {
error: any;
}
const isCurrentUser = (authUser: any) => authUser !== null;
class VerifyEmailError extends Component<InterfaceProps, InterfaceState> {
private static INITIAL_STATE = {
error: null
};
public constructor(props: InterfaceProps) {
super(props);
this.state = { ...VerifyEmailError.INITIAL_STATE };
}
public onSendEmailVerification = () => {
const { firebase } = this.props;
firebase.doSendEmailVerification().catch((error: any) => {
this.setState({
error
});
});
};
public render() {
const { error } = this.state;
const { initialError } = this.props;
return (
<Fragment>
<AuthUserContext.Consumer>
{(authUser: any) =>
isCurrentUser(authUser) ? (
<PrimaryBtn type="button" onClick={this.onSendEmailVerification}>
E-mail resend
</PrimaryBtn>
) : (
<Link to={ROUTES.INDEX}>Login to resend confirmation e-mail</Link>
)
}
</AuthUserContext.Consumer>
{initialError && <Errors error={initialError} />}
{error && <Errors error={error} />}
</Fragment>
);
}
}
export default withFirebase(VerifyEmailError);
我将标头放在接收到的字节数组之前,并将其保存到文件中。保存的输出文件的标题中似乎没有正确的元信息,我想知道我是否为案例使用了正确的标题和参数。
我的参考:http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html