banana pi BPI-M1 A20 dual core single board comput
  • Initial page
  • LANGS
  • banana pi BPI-M1
    • banana pi BPI-M1 26 PIN GPIO define
    • BPI-M1 HDMI interface
    • BPI-M1 hardware interface
    • All Banana Pi SBC Comparison
    • BPI-M1 Hardware
    • OpenSuse
    • Linux mainlining effort
    • linuxmainlinekernelimage
    • BPI-M1 SATA interface
    • How to build OpenWRT image from github
    • Officeal OpenWRT
    • CentOS 7 Linux for BPI
    • Summary
    • Armbian Linux
    • OpenMediaVault for BPI-M1
    • How to booting from SSD using Lubuntu / Raspbian
    • BPI-M1 WiringPi
    • BPI-M1 schematic diagram
    • WiringPi python for BPI-M1
    • BPI-M1 GigE RJ45 LAN
    • BPI-M1 SD card slot
    • BPI-M1 Audio
    • Building the cluster on BPI
    • bpi-m1-software
    • BPI-M1 Camera interface
    • Arch linux wiki for BPI-M1
    • freebsdnetbsd
    • All banana pi product
    • Lamobo Openwrt image
    • Lamobo Openwrt image
    • BPI-M1 CE FCC RoHS Certification
    • RaspBSD on BPI-M1
    • bpi40customizedserver
    • Linux software
    • bananian_linux
    • BPI-M1 DXF and 3D design
    • BPI-M1 IR interface
    • BPI-M1 OTG interface
    • DietPi | Minimal image at its core
    • Reference documents
    • NetBSD/evbarm on Allwinner Technology SoCs
    • Allwinner chip documents
    • Arch Linux
    • Asterisk for VOIP
    • BPI-M1 RGB DSI interface
    • Android software
    • BPI-M1 DC Power interface
    • BPI-M1 UART interface
    • Pi4J Project
    • linux-sunxi wiki
    • BPI-M1 quick start
    • BPI-M1 CAN Bus
    • linuxkernel34
    • Nas for BPI
    • BPI-M1 MIC
    • chapter1
    • Gentoo Linux
    • Compulsive modification of HDMI output resolution
    • OpenWRT
    • lakka.tv for banana pi
    • Android Mattrix XBMC/KODI Image - V3.1
    • banana pi books
    • BPI-M 3.7V lithium battery interface
  • 香蕉派Banana Pi M1 (BPI-M1)
    • chapter1
    • Summary
    • Armbian Linux
    • Compulsive modification of HDMI output resolution
    • How to booting from SSD using Lubuntu / Raspbian
    • BPI-M1 WiringPi
    • 香蕉派 Banana Pi (BPI-M1) 千兆RJ45接口
    • Banana Pi M1 (BPI-M1) 单节锂电池接口(额定电压4.2V)
    • Android Mattrix XBMC/KODI Image - V3.1
    • Banana Pi M1 (BPI-M1) 音频接口
    • Banana Pi 对比 选型
    • BPI-M1 硬件设计
    • OpenSuse
    • Building the cluster on BPI
    • 如何从Github上下载镜像并且编译出OpenWRT
    • BPI-M1 摄像头接口
    • bpi-m1-software
    • CentOS 7 Linux for BPI
    • Banana Pi M1 RaspBSD 镜像
    • Linux 软件
    • 用于 Banana Pi M1 的 OpenMediaVault 镜像
    • bpi-m1irinterface
    • BPI-M1 原理图设计文档
    • WiringPi python for BPI-M1
    • NetBSD/evbarm on Allwinner Technology SoCs
    • 香蕉派 Banana Pi (BPI-M1) SD卡槽
    • Asterisk for VOIP
    • BPI-M1 RGB 显示接口
    • Android 软件
    • BPI-M1 UART interface
    • linux-sunxi wiki
    • Arch linux wiki for BPI-M1
    • Nas for BPI
    • Lamobo Openwrt 镜像
    • Lamobo Openwrt image
    • Linux kernel 3.4
    • BPI-M1 CE FCC RoHS 认证
    • Banana Pi M1 (BPI-M1) MIC 接口
    • bananian_linux
    • Gentoo Linux
    • BPI-M1 DXF and 3D design
    • BPI-M1 OTG 接口
    • OpenWRT
    • Reference documents
    • lakka.tv for banana pi
    • Allwinner chip documents
    • Arch Linux
    • banana pi books
    • 香蕉派 Banana Pi (BPI-M1) HDMI interface
    • BPI-M1 硬件接口介绍
    • 香蕉派 Banana Pi M1 (BPI-M1) 扩展GPIO 定义:
    • BPI-M1 DC 电源接口
    • Pi4J Project
    • Linux mainlining effort
    • BPI-M1 快速上手
    • BPI-M1 CAN Bus
    • 官方 OpenWRT
    • BPI-M1 SATA interface
Powered by GitBook
On this page

Was this helpful?

  1. 香蕉派Banana Pi M1 (BPI-M1)

Banana Pi M1 (BPI-M1) MIC 接口

感谢chaos.dennis做这个测试:

i write about this, because i found very few sources and had to tumble a lot around to get it working. This is a quick walk through to give you a hint where to start. I asume for simplicity that you stay always in /root directory as root user. If something fails, look if the files are written and paths are right. It is adressed for more advanced users who know what they are basically doing.

This is done with bananian 15.08 on Kernel 3.4. Other kernels < 4.4 do not work. It is a headless server with no HDMI pluged in.

A. 基本设置

  • Install alsa (renove pulseaudio if present):

    # apt-get install alsa-base alsa-utils

  • Configure asound.conf

    # nano /etc/asound.conf

  • Should look like:

    pcm.!default {
          type hw
          card 0 # for headphone, turn 1 to 0
          device 0
    }
    ctl.!default {
          type hw
          card 0 # for headphone, turn 1 to 0
    }
  • Shutdown, make a cold boot

  • Call the alsamixer

    # alsamixer

    Press F5. Your channels should be setup like the attached file at the bottom of this post, or compare it to amixer output:

    # amixer
    Simple mixer control 'Master',0
    Capabilities: pvolume pvolume-joined
    Playback channels: Mono
    Limits: Playback 0 - 63
    Mono: Playback 45 [71%]
    Simple mixer control 'Master Capture Mute',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [off]
    Simple mixer control 'LineL',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'LineR',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Linein Pre-AMP',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 7
    Mono: 7 [100%]
    Simple mixer control 'Mic Input Mux',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 15
    Mono: 15 [100%]
    Simple mixer control 'Mic Power',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Mic1 Boost',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Mic1 gain',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 3
    Mono: 3 [100%]
    Simple mixer control 'Mic2 Boost',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Mic2 gain',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 7
    Mono: 0 [0%]
    Simple mixer control 'MicL',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 3
    Mono: 1 [33%]
    Simple mixer control 'MicR',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 3
    Mono: 3 [100%]
    Simple mixer control 'Playback',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Capture',0
    Capabilities: cvolume cvolume-joined
    Capture channels: Mono
    Limits: Capture 0 - 7
    Mono: Capture 7 [100%]
    Simple mixer control 'ADC Input Mux',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 7
    Mono: 7 [100%]
    Simple mixer control 'Fm output',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 7
    Mono: 7 [100%]
    Simple mixer control 'FmL',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'FmR',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'LINEIN APM',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 7
    Mono: 7 [100%]
    Simple mixer control 'Ldac Left Mixer',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Ldac Right Mixer',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Left Capture Mute',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'MIC output volume',0
    Capabilities: volume volume-joined
    Playback channels: Mono
    Capture channels: Mono
    Limits: 0 - 7
    Mono: 7 [100%]
    Simple mixer control 'Rdac Right Mixer',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]
    Simple mixer control 'Right Capture Mute',0
    Capabilities: pswitch pswitch-joined
    Playback channels: Mono
    Mono: Playback [on]

    This step is critical. One false muted channel and you are out of the game.

  • Test recording.

    # arecord -L

    Should show a device.

    # arecord -f S16_LE -r 44100 -t wav test.wav

    Should make kind of Sound. Stop it with ctr-c and check the file.

B. SoX Recording / Streaming

  • Install SoX

    # apt-get install sox libsox-fmt-all Sox gives you tools like: sox, rec and play. I would suggest you install it on the client pc too.

  • Record striaght to mp3

    # rec -c 2 -C 64 test.mp3

    -c 2 two channels

    -C 64 tell the encoder to produce a 64kbit/s mp3

    Stop it with ctr-c, check the output.

  • Listen to it live over LAN

    Banana:

    # rec -c 2 -C 64 -t mp3 - | netcat -l -p 9000

    -t mp3 - produce mp3 stream to stdout

    Client:

    # netcat <banana ip> 9000 | vlc

    Works? Great! Live listening is important to play around and test the mic.

  • Listen and record at same time

    # rec -c 2 -C 64 -t mp3 - | tee test.mp3 | netcat -l -p 9000

  • Poor man's streaming server

    # apt-get install openbsd-inetd tcpd

    Edit config file:

    # nano /etc/inetd.conf

    Insert this at the end:

    9000            stream  tcp     nowait  nobody  /usr/bin/tail       tail -f /test.mp3

    Restart service

    # service openbsd-inetd restart

    Start recording on banana:

    # rec -c 2 -C 64 /test.mp3

    Connect via client:

    # netcat <banana ip> 9000 | vlc -

C. Advanced Recording

  • Devide recording and postprocessing in two parts

    # rec -t raw - remix - | sox -t raw -r 48000 -c 1 -b 16 -e signed-integer - -t mp3 -c 1 -C 32 test.mp3

Recording:

-t raw - forward raw input to pipe

remix - Mix the two channels to one

Encoding:

-t raw -r 48000 -c 1 -b 16 -e signed-integer - tell sox what kind of strean comes from stdin

-t mp3 -c 1 -C 32 test.mp3 and what goes out

Note that it is switched to mono from here with -c 1 and the mp3 bitrate is cut in half. Live listening to the strean does not work anymore, i asume it is because of the non regulare output from pipeing and processing in a second step.

  • Reduce noise

    The mic input is pretty bad, lot of white noise. Sox can deal with it.

    Make a sample "silent" file:

    # rec -t raw test.raw remix - trim 0 10

    trim 0 10 record 10 seconds

    Test it at client pc:

    # play -r 48000 -c 1 -b 16 -e signed-integer test.raw

    Create profile file:

    # sox -r 48000 -c 1 -b 16 -e signed-integer test.raw -n trim 0 2 noiseprof raw-profile

    Record with noise canceld

    # rec -t raw - remix - noisered raw-profile 0.2 | sox -t raw -r 48000 -c 1 -b 16 -e signed-integer - -t mp3 -c 1 -C 32 test.mp3

    Play with the factor of 0.2 to regulate the intensity of cancellation.

D. Record 24/7

My goal of this....

Create a script:

 # nano /root/record.sh

Insert the following:

 #!/bin/bash

# send sigterm and wait for exit of the process
function stop() { kill $@; while kill -0 $@; do sleep 1; done; }
function log() { echo $(date +%T) $@; }

log "Stopping previus recording"
stop `pidof rec` &> /dev/null

DATE=`date "+%Y.%m.%d"`
log "Recording $DATE.mp3"
rec -q -t raw - remix - noisered /root/raw-profile 0.2 | \
        sox -v 2.0 -t raw -r 48000 -c 1 -b 16 -e signed-integer -   \
                   -t mp3 -r 22050 -c 1 -C -9.2 /root/$DATE.mp3
log "Done $DATE.mp3"

Recording:

-q less output

Encoding: -v 2.0 Make the input stream louder

-r 22050 encode to a lower sample rate

-C -9.2 Create a low quality VBR mp3

Fileszie ~100mb per day. If you want smaller files, a 8000 sanple rate gives you a gsm grade quality.

编译此可执行文件

 # chmod +x record.sh

编辑 crontab:

 # env EDITOR=nano crontab -e

Insert at the end the following:

 PATH=/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin
0 0 * * * /root/record.sh >> /root/record-mic.log

A new recording should start every day at midnight.

PreviousBPI-M1 CE FCC RoHS 认证Nextbananian_linux

Last updated 5 years ago

Was this helpful?

A very good article to sample rate:

http://wiki.audacityteam.org/wiki/Sample_Rates