Skip to content

Commit

Permalink
增加8000的采样率
Browse files Browse the repository at this point in the history
  • Loading branch information
2fps committed Apr 15, 2020
1 parent bb75cf5 commit 8e80c7c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.6] 2020-04-15
### Added
+ 增加8000采样率。

## [1.0.5] 2020-04-13
### Added
+ 增加`getChannelData`用于获取左右声道的数据,使用[lamejs](https://github.com/zhuker/lamejs)支持mp3音频格式的转化。

Expand Down
4 changes: 2 additions & 2 deletions dist/recorder.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/recorder.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let pCtx = null;
let drawPlayId = null;

const sampleRateOptions = [
{ text: '8000', value: 8000 },
{ text: '16000', value: 16000 },
{ text: '22050', value: 22050 },
{ text: '24000', value: 24000 },
Expand Down Expand Up @@ -551,6 +552,7 @@ function convertToMp3(wavDataView) {
// 获取wav头信息
const wav = lamejs.WavHeader.readHeader(wavDataView); // 此处其实可以不用去读wav头信息,毕竟有对应的config配置
const { channels, sampleRate } = wav;
console.log('wav', wav)
const mp3enc = new lamejs.Mp3Encoder(channels, sampleRate, 128);
// 获取左右通道数据
const result = recorder.getChannelData()
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-audio-recorder",
"version": "1.0.5",
"version": "1.0.6",
"description": "js audio recorder plugin",
"main": "./index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/recorder/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class Recorder {
// 采样数位 8, 16
sampleBits: ~[8, 16].indexOf(options.sampleBits) ? options.sampleBits : 16,
// 采样率
sampleRate: ~[11025, 16000, 22050, 24000, 44100, 48000].indexOf(options.sampleRate) ? options.sampleRate : this.inputSampleRate,
sampleRate: ~[8000, 11025, 16000, 22050, 24000, 44100, 48000].indexOf(options.sampleRate) ? options.sampleRate : this.inputSampleRate,
// 声道数,1或2
numChannels: ~[1, 2].indexOf(options.numChannels) ? options.numChannels : 1,
// 是否需要边录边转,默认关闭,后期使用web worker
Expand Down

0 comments on commit 8e80c7c

Please sign in to comment.