Part 1
요약·해설
PDM→PCM 변환, LED 상태, 16 kHz mono 형식, ttyUSB0 raw capture 절차를 설명합니다.
MP34DT05 · PDM
16 kHz · 16-bit · Mono
Binary · ASCII
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
107791505E69E77114C907558AB73B9C945B742358C0C298B7EF260566D93F5D
.. _ArgonKey_Microphone:
ArgonKey Board Microphone
#########################
Overview
********
This sample provides an example of how to acquire audio through
the on-board MP34DT05 microphone. The microphone generates a PDM
stream which is acquired through I2S. The PDM stream is then
converted to PCM using the OpenPDMFilter library, which is available
in source code in this sample.
Requirements
************
This sample requires the ArgonKey board plus a USB to TTL 1V8 serial
cable to get the output audio stream. The board can be powered
in either one of the following two ways:
- mezzanine mode, plugging the ArgonKey to HiKey board through its 96Board
low-speed connector
- standalone mode, supplying 5V directly on P1 connector
References
**********
- :ref:`96b_argonkey`
Building and Running
********************
.. zephyr-app-commands::
:zephyr-app: samples/boards/96b_argonkey/microphone
:host-os: unix
:board: 96b_argonkey
:goals: run
:compact:
Sample Output
=============
The example acquires 5s of audio and prints out the PCM stream on COM port.
A USB to TTL 1V8 serial cable may be attached to the low speed connector on
the back of the board on P3.5 (TX) and P3.7 (RX).
As soon as the acquisition starts the green LED glows. At the end of the
acquisition both the green and red LEDs go on and the PCM stream is sent
on COM port. When the output is completed the green LED goes off and the red
LED stays on. The process can be reiterated by pressing the RST button.
- audio acquisition starts: GRN on - RED off
- audio acquisition ends: GRN on - RED on
- audio output ends: GRN off - RED on
The characteristics of the PCM audio are hardcoded in the example:
- 16KHz sample rate
- 16 bits per sample
- 1 channel (mono), as only 1 microphone is available
Five seconds of acquisition at a 16KHz sampling rate yields 80,000 16-bit samples.
The microphone PDM requested clock should lead the MP34DT05 driver to select an
oversampling/decimation factor equal to 128, resulting in a 2.048MHz bit clock.
See pcm and pdm configuration in file :zephyr_file:`samples/boards/96b_argonkey/microphone/src/main.c`.
.. note:: It is possible to change the AUDIO_FREQ to 32000 acquiring only 2500 ms. In this
case the oversampling/decimation factor will be 64.
At the end of the acquisition the PCM data will be printed on the terminal
emulator in either binary or ASCII format. The output is controlled by
following macro, off by default, in :zephyr_file:`samples/boards/96b_argonkey/microphone/src/main.c`:
* :c:macro:`PCM_OUTPUT_IN_ASCII`
Binary PCM Output
-----------------
The ttyUSB0 port must be configured in raw mode to avoid having
characters 'cooked' out.
.. code-block:: console
stty -F /dev/ttyUSB0 115200 raw
cat /dev/ttyUSB0 > /tmp/sound.raw
.. note:: The "cat /dev/ttyUSB0 > /tmp/sound.raw" command should be launched after the audio
acquisition starts (after green led glows) to avoid initial boot messages to enter in the file,
and before audio acquisition ends (before red led glows).
.. note:: In case the character 0x0a is interpreted as NL and an 0x0d (CR) is added,
you may need to remove it::
dos2unix -f /tmp/sound.raw
ASCII PCM Output
----------------
It is also possible to recompile and to have PCM output in ASCII, which needs
to be converted to binary later on. The output format is the following:
.. code-block:: console
ArgonKey test!!
-- start
0xfbe0,
0xfbf0,
0xfc0c,
0xfc24,
0xfc3c,
0xfc4c,
0xfc68,
0xfc48,
[...]
0xfb98,
0xfb98,
0xfbb8,
0xfbac,
0xfbc4,
0xfbe8,
0xfbf4,
-- end
Play PCM Audio
--------------
Now that we have a binary PCM file (say sound.raw), you can use,
for example, the audacity open source editor/player to load and play it.
Use the 'Import->Raw Data' menu to load the sound.raw file as
signed 16 bit PCM, Little Endian, mono format @16KHz.
Part 3
한국어 전문 번역
개요
이 sample은 board에 내장된 MP34DT05 microphone으로 audio를 수집하는 방법을 보여줍니다. Microphone이 생성한 PDM stream은 I2S를 통해 수집됩니다. 그런 다음 이 sample에 source code로 포함된 OpenPDMFilter library를 사용해 PDM stream을 PCM으로 변환합니다.
요구사항
이 sample에는 ArgonKey board와 출력 audio stream을 받기 위한 USB-to-TTL 1.8 V serial cable이 필요합니다. Board에는 다음 두 방법 가운데 하나로 전원을 공급할 수 있습니다.
- Mezzanine mode: ArgonKey를 96Boards low-speed connector로 HiKey board에 연결합니다.
- Standalone mode: P1 connector에 5 V를 직접 공급합니다.
참고 자료
- 96Boards ArgonKey board 문서
Build와 실행
west build -b 96b_argonkey samples/boards/96b_argonkey/microphone
west build -t run
Sample 출력
예제는 5초 분량의 audio를 수집한 뒤 PCM stream을 COM port로 출력합니다. USB-to-TTL 1.8 V serial cable은 board 뒷면 low-speed connector의 P3.5(TX)와 P3.7(RX)에 연결할 수 있습니다.
수집이 시작되면 green LED가 켜집니다. 수집이 끝나면 green LED와 red LED가 모두 켜지고 PCM stream이 COM port로 전송됩니다. 출력이 끝나면 green LED는 꺼지고 red LED는 켜진 채로 남습니다. RST button을 누르면 이 과정을 다시 실행할 수 있습니다.
- Audio 수집 시작: GRN on, RED off
- Audio 수집 종료: GRN on, RED on
- Audio 출력 종료: GRN off, RED on
PCM audio 특성은 예제에 다음 값으로 고정되어 있습니다.
- Sample rate: 16 kHz
- Sample당 16 bit
- Channel 1개(mono): microphone이 하나만 있기 때문입니다.
16 kHz sample rate로 5초를 수집하면 16-bit sample 80,000개가 생성됩니다. 요청된 microphone PDM clock에 따라 MP34DT05 driver는 oversampling/decimation factor 128을 선택하며, 그 결과 bit clock은 2.048 MHz가 됩니다.
PCM과 PDM 설정은 samples/boards/96b_argonkey/microphone/src/main.c에서 확인할 수 있습니다.
수집이 끝나면 PCM data가 terminal emulator에 binary 또는 ASCII 형식으로 출력됩니다. 출력 형식은 같은 main.c의 다음 macro가 제어하며 기본값은 off입니다.
PCM_OUTPUT_IN_ASCII
Binary PCM 출력
문자가 임의로 변환되는 cooked 처리를 피하려면 ttyUSB0 port를 raw mode로 설정해야 합니다.
stty -F /dev/ttyUSB0 115200 raw
cat /dev/ttyUSB0 > /tmp/sound.raw
dos2unix -f /tmp/sound.raw
ASCII PCM 출력
다시 compile해 PCM을 ASCII로 출력할 수도 있습니다. 이 data는 나중에 binary로 변환해야 합니다. 출력 형식은 다음과 같습니다.
ArgonKey test!!
-- start
0xfbe0,
0xfbf0,
0xfc0c,
0xfc24,
0xfc3c,
0xfc4c,
0xfc68,
0xfc48,
[...]
0xfb98,
0xfb98,
0xfbb8,
0xfbac,
0xfbc4,
0xfbe8,
0xfbf4,
-- end
PCM audio 재생
Binary PCM file(예: sound.raw)을 얻었으면 open-source editor/player인 Audacity 등으로 불러와 재생할 수 있습니다. Import → Raw Data menu에서 sound.raw를 signed 16-bit PCM, little-endian, mono, 16 kHz 형식으로 불러오십시오.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.