How to record sound from built in microphone

  • Hello, Luckfox Ultra uses a patch microphone with a small radio range. When receiving, you need to put the sound source close to the microphone. You can use ffmpeg -f alsa -i default -f alsa default command to record and playback the test. Compared with recording and then playing, the effect will be more intuitive.
    If you are prompted that ffmpeg is not working, remove/oem/usr/lib/libfreetype* to ensure that you do not incorrectly link to Rockchip libraries.
  • Thanks for the reply. I've tried moving right above the microphone and speaking loudly but still the recorded file is just silent. Could the issue be the settings in amixer/alsamixer? There are many options, it's not clear to me which ones necessarily relate to the microphone:

    Code: Select all

    [root@luckfox root]# amixer 
    Simple mixer control 'I2STDM Digital Loopback Mode',0
      Capabilities: enum
      Items: 'Disabled' 'Mode1' 'Mode2' 'Mode2 Swap'
      Item0: 'Mode2'
    Simple mixer control 'ADC ALC Left',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 31
      Mono: 6 [19%] [0.00dB]
    Simple mixer control 'ADC ALC Right',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 31
      Mono: 10 [32%] [6.00dB]
    Simple mixer control 'ADC Digital Left',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 255
      Mono: 245 [96%] [25.00dB]
    Simple mixer control 'ADC Digital Right',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 255
      Mono: 244 [96%] [24.50dB]
    Simple mixer control 'ADC HPF Cut-off',0
      Capabilities: enum
      Items: 'Off' 'On'
      Item0: 'Off'
    Simple mixer control 'ADC MIC Left',0
      Capabilities: enum
      Items: 'Work' 'Mute'
      Item0: 'Work'
    Simple mixer control 'ADC MIC Left Gain',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 3
      Mono: 2 [67%]
    Simple mixer control 'ADC MIC Right',0
      Capabilities: enum
      Items: 'Work' 'Mute'
      Item0: 'Work'
    Simple mixer control 'ADC MIC Right Gain',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 3
      Mono: 2 [67%]
    Simple mixer control 'ADC MICBIAS Voltage',0
      Capabilities: enum
      Items: 'VREFx0_8' 'VREFx0_825' 'VREFx0_85' 'VREFx0_875' 'VREFx0_9' 'VREFx0_925' 'VREFx0_95' 'VREFx0_975'
      Item0: 'VREFx0_9'
    Simple mixer control 'ADC Main MICBIAS',0
      Capabilities: enum
      Items: 'Off' 'On'
      Item0: 'On'
    Simple mixer control 'ADC Mode',0
      Capabilities: enum
      Items: 'DiffadcL' 'SingadcL' 'DiffadcR' 'SingadcR' 'SingadcLR' 'DiffadcLR'
      Item0: 'DiffadcL'
    Simple mixer control 'AGC Left Approximate Sample Rate',0
      Capabilities: enum
      Items: '96KHz' '48KHz' '44.1KHz' '32KHz' '24KHz' '16KHz' '12KHz' '8KHz'
      Item0: '96KHz'
    Simple mixer control 'AGC Right Approximate Sample Rate',0
      Capabilities: enum
      Items: '96KHz' '48KHz' '44.1KHz' '32KHz' '24KHz' '16KHz' '12KHz' '8KHz'
      Item0: '96KHz'
    Simple mixer control 'ALC AGC Left',0
      Capabilities: volume volume-joined enum
      Items: 'Off' 'On'
      Item0: 'On'
    Simple mixer control 'ALC AGC Left Max',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 7 [100%] [28.50dB]
    Simple mixer control 'ALC AGC Left Min',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 0 [0%] [-99999.99dB]
    Simple mixer control 'ALC AGC Right',0
      Capabilities: volume volume-joined enum
      Items: 'Off' 'On'
      Item0: 'On'
    Simple mixer control 'ALC AGC Right Max',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 7 [100%] [28.50dB]
    Simple mixer control 'ALC AGC Right Min',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 0 [0%] [-99999.99dB]
    Simple mixer control 'DAC HPMIX',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 2
      Mono: 1 [50%] [0.00dB]
    Simple mixer control 'DAC LINEOUT',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 30
      Mono: 30 [100%] [6.00dB]
    
  • Have you tried to use the echo test command first to determine whether it works properly?

    Code: Select all

    ffmpeg -f alsa -i default -f alsa default
    
    tried to execute the record audio command you provided, using Audacity is able to see the waveform

    Code: Select all

    arecord -f S16_LE -c 2 -r 16000 -D hw:0 -d 30 test.wav
    
    audio_record.png
    The system default mixer control settings can be recorded, you can refer to it

    Code: Select all

    [root@luckfox root]# amixer 
    Simple mixer control 'I2STDM Digital Loopback Mode',0
      Capabilities: enum
      Items: 'Disabled' 'Mode1' 'Mode2' 'Mode2 Swap'
      Item0: 'Disabled'
    Simple mixer control 'ADC ALC Left',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 31
      Mono: 6 [19%] [0.00dB]
    Simple mixer control 'ADC ALC Right',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 31
      Mono: 6 [19%] [0.00dB]
    Simple mixer control 'ADC Digital Left',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 255
      Mono: 195 [76%] [0.00dB]
    Simple mixer control 'ADC Digital Right',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 255
      Mono: 195 [76%] [0.00dB]
    Simple mixer control 'ADC HPF Cut-off',0
      Capabilities: enum
      Items: 'Off' 'On'
      Item0: 'Off'
    Simple mixer control 'ADC MIC Left',0
      Capabilities: enum
      Items: 'Work' 'Mute'
      Item0: 'Work'
    Simple mixer control 'ADC MIC Left Gain',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 3
      Mono: 2 [67%]
    Simple mixer control 'ADC MIC Right',0
      Capabilities: enum
      Items: 'Work' 'Mute'
      Item0: 'Work'
    Simple mixer control 'ADC MIC Right Gain',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 3
      Mono: 2 [67%]
    Simple mixer control 'ADC MICBIAS Voltage',0
      Capabilities: enum
      Items: 'VREFx0_8' 'VREFx0_825' 'VREFx0_85' 'VREFx0_875' 'VREFx0_9' 'VREFx0_925' 'VREFx0_95' 'VREFx0_975'
      Item0: 'VREFx0_9'
    Simple mixer control 'ADC Main MICBIAS',0
      Capabilities: enum
      Items: 'Off' 'On'
      Item0: 'On'
    Simple mixer control 'ADC Mode',0
      Capabilities: enum
      Items: 'DiffadcL' 'SingadcL' 'DiffadcR' 'SingadcR' 'SingadcLR' 'DiffadcLR'
      Item0: 'DiffadcL'
    Simple mixer control 'AGC Left Approximate Sample Rate',0
      Capabilities: enum
      Items: '96KHz' '48KHz' '44.1KHz' '32KHz' '24KHz' '16KHz' '12KHz' '8KHz'
      Item0: '96KHz'
    Simple mixer control 'AGC Right Approximate Sample Rate',0
      Capabilities: enum
      Items: '96KHz' '48KHz' '44.1KHz' '32KHz' '24KHz' '16KHz' '12KHz' '8KHz'
      Item0: '96KHz'
    Simple mixer control 'ALC AGC Left',0
      Capabilities: volume volume-joined enum
      Items: 'Off' 'On'
      Item0: 'Off'
    Simple mixer control 'ALC AGC Left Max',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 7 [100%] [28.50dB]
    Simple mixer control 'ALC AGC Left Min',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 0 [0%] [-99999.99dB]
    Simple mixer control 'ALC AGC Right',0
      Capabilities: volume volume-joined enum
      Items: 'Off' 'On'
      Item0: 'Off'
    Simple mixer control 'ALC AGC Right Max',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 7 [100%] [28.50dB]
    Simple mixer control 'ALC AGC Right Min',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 7
      Mono: 0 [0%] [-99999.99dB]
    Simple mixer control 'DAC Control Manually',0
      Capabilities: enum
      Items: 'None' 'Off' 'On'
      Item0: 'None'
    Simple mixer control 'DAC HPMIX',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 2
      Mono: 1 [50%] [0.00dB]
    Simple mixer control 'DAC LINEOUT',0
      Capabilities: volume volume-joined
      Playback channels: Mono
      Capture channels: Mono
      Limits: 0 - 30
      Mono: 26 [87%] [0.00dB]