Skip to content

Latest commit

 

History

History
108 lines (83 loc) · 3.44 KB

README-EN.md

File metadata and controls

108 lines (83 loc) · 3.44 KB

Android Wav Recorder

中文 | In English

API Version

download demo.apk

A tool for recording, playing and parsing WAV files.

Features include:

  • Recording
    • Record wav/pcm files. (start, pause, continue, finish)
    • Two modes: normal mode (full recording) and skip silent area mode (recording only the audio part)
  • Play the wav file. (custom playback, system playback)
  • Parsing local wav file information

show_recorder

Quick use

Step 1. Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Add the dependency

    dependencies {
        implementation 'com.github.shaoshuai904:RecordWav:1.2.2'
    }

Sample code

Constructor: [file saving path + parameter configuration + various listening callbacks (audio data block pull listening / silent listening)]
Method:startRecording  pauseRecording  resumeRecording  stopRecording

Get ordinary recorder(java)

    Recorder recorder;
    recorder = MsRecorder.wav(
        new File("savePath"),
        // new AudioRecordConfig(), // use default config
        new AudioRecordConfig(
            MediaRecorder.AudioSource.MIC, // 音频源
            44100, // 采样率,44100、22050、16000、11025 Hz
            AudioFormat.CHANNEL_IN_MONO, // 单声道、双声道/立体声
            AudioFormat.ENCODING_PCM_16BIT // 8/16 bit
        ),
        new PullTransport.Default()
            .setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
                @Override
                public void onAudioChunkPulled(AudioChunk audioChunk) {
                    Log.d("数据监听", "maxValue: " + audioChunk.maxAmplitude());
                }
            })
    );

    recorder.startRecording(); // start
    recorder.pauseRecording(); // pause
    recorder.resumeRecording(); // resume
    recorder.stopRecording(); // stop

Obtain the noise reduction recorder, skip the silence area, and record only the "sound" part(kotlin)

    MsRecorder.wav(
        File("savePath"),
        AudioRecordConfig(),
        PullTransport.Noise().setOnAudioChunkPulledListener { audioChunk ->
            Log.d("maple_log", "maxValue : ${audioChunk.maxAmplitude()} ")
        }.setOnSilenceListener { silenceTime, discardTime ->
            Log.e("NoiseMode", "Silence time:$silenceTime ,Discard time:$discardTime")
        }
    )

License

Copyright 2018 Shuai Shao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.