How to adjust microphone sensitivity while recording audio in android

后端 未结 4 1595
清歌不尽
清歌不尽 2020-12-03 04:11

I\'m working on a voice recording app. In it, I have a Seekbar to change the input voice gain. I couldn\'t find any way to adjust the input voice gain.

I am using th

4条回答
  •  广开言路
    2020-12-03 04:41

    Solution by OP.

    I have done it using

    final int USHORT_MASK = (1 << 16) - 1;
    
    final ByteBuffer buf = ByteBuffer.wrap(data).order(
                            ByteOrder.LITTLE_ENDIAN);
    final ByteBuffer newBuf = ByteBuffer.allocate(
                            data.length).order(ByteOrder.LITTLE_ENDIAN);
    
    int sample;
            while (buf.hasRemaining()) {
                    sample = (int) buf.getShort() & USHORT_MASK;
                    sample *= db_value_global;
                            newBuf.putShort((short) (sample & USHORT_MASK));
                    }
    
                    data = newBuf.array();
    
                    os.write(data);
    

提交回复
热议问题