User Tools

Site Tools


doc:appunti:linux:audio:audio_recording

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
doc:appunti:linux:audio:audio_recording [2019/04/09 11:59] – [Electret] niccolodoc:appunti:linux:audio:audio_recording [2020/12/28 17:14] – [Wireless mic on Ugreen USB audio adapter] niccolo
Line 1: Line 1:
-====== Audio Recording With Linux ======+====== Audio Recording With GNU/Linux ======
  
 ===== Choosing the right jack ===== ===== Choosing the right jack =====
Line 44: Line 44:
  
 A small movable **induction coil**, positioned in the **magnetic field** of a permanent magnet, is attached to the diaphragm. The sound wave moves the diaphragm and the coil moves in the magnetic field, producing a varying current in the coil through **electromagnetic induction**. No power is required: the current is carried directly on **two poles** to the mic input. These microphones generally have a **1/4" mono jack**. A small movable **induction coil**, positioned in the **magnetic field** of a permanent magnet, is attached to the diaphragm. The sound wave moves the diaphragm and the coil moves in the magnetic field, producing a varying current in the coil through **electromagnetic induction**. No power is required: the current is carried directly on **two poles** to the mic input. These microphones generally have a **1/4" mono jack**.
 +
 ==== Condenser ==== ==== Condenser ====
  
Line 56: Line 57:
 Unlike capacitor ones, electret microphones **do not require polarizing voltage**, but generally they contain an integrated preamplifier that **does require power**. In this cases a **TRS jack** can be used, where the ring carries power via a resistor from, normally, a 5 V supply in the computer (often incorrectly called //polarizing power// or //bias//). Generally these microphones built to be plugged into computers and electronic audio devices, have a **TRS 3.5 mm jack**, carrying the mic signal and the required current. Unlike capacitor ones, electret microphones **do not require polarizing voltage**, but generally they contain an integrated preamplifier that **does require power**. In this cases a **TRS jack** can be used, where the ring carries power via a resistor from, normally, a 5 V supply in the computer (often incorrectly called //polarizing power// or //bias//). Generally these microphones built to be plugged into computers and electronic audio devices, have a **TRS 3.5 mm jack**, carrying the mic signal and the required current.
  
-===== External mic on the Acer Travelmate B113-E =====+====== Problem: silence gaps using a cheap USB dongle ======
  
-Running **Debian GNU/Linux 9 Stretch**, it seems that the use of the **headphone/microphone split cable** does not abilitate the use of the microphone. In facif you run the **acpi_listen** tool (from the **acpid** Debian package), you can see when you insert the split cable:+I was **unable to use the microphone connector** on my Acer TravelMate, so I tried to use an USB donglemarked **LinQ**. The device was detected by the Linux Kernel 4.9.0:
  
 <code> <code>
-jack/headphone HEADPHONE plug +usb 2-1.3: new full-speed USB device number 9 using ehci-pci 
-jack/headphone HEADPHONE unplug+usb 2-1.3: New USB device found, idVendor=0c76, idProduct=1607 
 +usb 2-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0 
 +usb 2-1.3: Product: USB Headphone Set 
 +input: USB Headphone Set as /devices/pci0000:00/0000:00:1d.0 
 +    /usb2/2-1/2-1.3/2-1.3:1.3/0003:0C76:1607.0004/input/input92 
 +hid-generic 0003:0C76:1607.0004: 
 +    input,hidraw2: USB HID v1.00 Device [USB Headphone Set] 
 +    on usb-0000:00:1d.0-1.3/input3
 </code> </code>
  
-but nothing is reported about the plug of a microphoneBeside thatno bias current appear on the microphone jack. The solution is to run the **hdajackretask** tool (from the **alsa-tools-gui** Debian package), then force the connection of **Pin 0x19**:+{{ linq-usb-audio.png?direct&100|LinQ USB audio dongle}} 
 +The USB audio adapter worked quite nicely at playing audioI use it on a QNAP TS-120 NAS, transformed into a media player installing Debian GNU/Linux on it. The Linux kernel and the **ALSA audio subsystem** works well on setting the levels for **playback**.
  
-  * Enable the **Show unconnected pins** option. +Once started Audacity, I was able to select the microphone line of the USB dongle as a **capture device**:
-  * Click **Pin ID0x19** => **Override** => **Microphone**. +
-  * **Apply now** (it asks for the root password, as it has to run a script with superuser privileges).+
  
-the running **acpi_listen** will print:+{{audacity-select-usb-audio.png?direct&260|}}
  
-<code+Recording a sample track revealed an annoying problem: about **every 0.4 seconds** you can see a **gap of silence** in the audio track of about **two hundredths of a second**. The audio track is unusable! 
-jack/microphone MICROPHONE plug + 
-</code>+{{audacity-track-gaps.png?direct&400|}} 
 + 
 +====== Wireless UHF microphone ====== 
 + 
 +We have purchased an **UHF wireless microphone** on Aliexpress.com for about 25 €. It is composed by: 
 + 
 +  * The **transmitter** powered by **two AA batteries**, featuring: 
 +    * A **[[wp>Lavalier microphone|lavalier microphone]]** on a clip. 
 +    * One small **wire-antenna**. 
 +    * Frequency range: **610-675 MHz** (53 channels spaced by 1.25 MHz each). 
 +    * Modulation system: DQPSK 
 +    * Frequency response: 60-16000 Hz 
 +    * Transmitted power: 10 dBm 
 +    * Working current: %%<=%% 100 mA 
 + 
 +  * The **receiver** powered by **two AAA batteries**, featuring: 
 +    * A 1/4" (6.35 mm) mono jack. 
 +    * One small **telescopic antenna**. 
 +    * Receiving sensitivity: -94 dBm 
 +    * Working current: %%<=%% 100 mA 
 + 
 +{{wireless-mic-trasmitter.jpg?direct&240|}} 
 +{{wireless-mic-receiver.jpg?direct&240|}} 
 + 
 +To connect the **UHF receiver** to the **Ugreen USB audio adapter**, we built an adapter cable with this pinout: 
 + 
 +^ 1/4" TS female jack  ^ Signal         ^ 3.5 mm TRS male jack  ^ 
 +| **Tip**              | Microphone     | **Tip**               | 
 +|                      | Not connected  | **Ring**              | 
 +| **Sleeve**           | Ground         | **Sleeve**            | 
 + 
 +The **2.6 volt** current provided by the USB adapter on th **jack ring** will go nowhere (not connected). The **2.6 volt** current provided on the **jack tip** is probably not required by the UHF receiver, but **it should not harm**. **No infromation** is available about **microphone impedence** expected by the USB adapter, on the other hand no information is available about the **impedence of the mic interface** of the UHF receiver. 
 + 
 +Despite all this empirical approach, the **voice registration is quite satisfying**! See below about connecting the microphone to an Acer TravelMate notebook an to an Android smartphone. 
 + 
 +===== Wireless mic on the Acer Travelmate TMB113-E ===== 
 + 
 +See this article about **[[audio_recording_tmb113_e]]**.
  
-Now you can also measure a **bias current of 2.85 V** between the ground (**sleeve**) and the **ring** or the **tip**.+===== Wireless mic on Android =====
  
-Is not clear **how to disable the external microphone**: even setting **Pin 0x19** to **Not connected** does not generate the ACPI microphone unplug event, and the bias current is not clearedFIXME May be after a reboot? +See this article about **[[audio_recording_android]]**.
-===== Wireless microphone =====+
  
-===== Ugreen USB audio adapter =====+===== Wireless mic on Ugreen USB audio adapter =====
  
 The device is detected by the Linux Kernel 4.9.0 in this way: The device is detected by the Linux Kernel 4.9.0 in this way:
Line 100: Line 143:
  
 {{ ugreen-usb-audio.jpg?direct&220|Ugreen USB Audio Adapter}} {{ ugreen-usb-audio.jpg?direct&220|Ugreen USB Audio Adapter}}
 +
 +The **microphone socket** is a **3.5 mm TRS type** (three poles), it provides a bias current of **2.6 V** on both the **tip** and the **ring**, so it is advisable, as reported in the device manual, to **NOT use a simple two poles mono jack** (TS type), because it will short-circuit the bias current on the ring with the ground on the sleeve.
  
 Launching **alsamixer** and hitting F6 you can select the **USB Advanced Audio Device** sound card. Hit F4 to view the only one capture device, i.e. the microphone input line. Press **Space** to enable/disable the **capture** and **Up/Down arrows** to increase/decrease the **gain**. Launching **alsamixer** and hitting F6 you can select the **USB Advanced Audio Device** sound card. Hit F4 to view the only one capture device, i.e. the microphone input line. Press **Space** to enable/disable the **capture** and **Up/Down arrows** to increase/decrease the **gain**.
  
-The **microphone socket** is a **3.5 mm TRS type** (three poles), it provides a bias current of **2.6 V** on both the **tip** and the **ring**so it is advisable, as reported in the device manual, to **NOT use a simple two poles mono jack** (TS type), because it will short-circuit the bias current on the ring with the ground on the sleeve.+It seems that the best setting for audio recording through the mic, is to keep the **capture mic gain to 100**:
  
 +{{usb-advanced-audio-device-alsamixer.png?direct&300|USB Advenced Audio Device in Alsamixer}}
  
-===== Problem: silence gaps using a cheap USB dongle =====+I use the **PulseAudio** subsystem above the ALSA modules (this is the preferred method in modern GNU/Linux distro). In this case the volume is controlled via the graphics app **pavucontrol** or on the command line using the **pacmd** tool. The PulseAudio recording volume level should be between the **base volume** (value **20724**) and the **100%** (value **65536**).
  
-I was **unable to use the microphone connector** on my Acer TravelMate, so I tried to use an USB dongle, marked **LinQ**. The device was detected by the Linux Kernel 4.9.0:+Here are the commands to start an audio recording using a shell script:
  
-<code> +<code bash
-usb 2-1.3: new full-speed USB device number 9 using ehci-pci +#!/bin/sh 
-usb 2-1.3: New USB device found, idVendor=0c76, idProduct=1607 +SOURCE='alsa_input.usb-C-Media_Electronics_Inc._USB_Advanced_Audio_Device-00.analog-stereo' 
-usb 2-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0 +PORT='analog-input-mic' 
-usb 2-1.3: Product: USB Headphone Set +VOLUME=65536 
-input: USB Headphone Set as /devices/pci0000:00/0000:00:1d.+pacmd set-default-source "$SOURCE" 
-    /usb2/2-1/2-1.3/2-1.3:1.3/0003:0C76:1607.0004/input/input92 +pacmd set-source-port "$SOURCE" "$PORT" 
-hid-generic 0003:0C76:1607.0004: +pacmd set-source-volume "$SOURCE" "$VOLUME" 
-    input,hidraw2: USB HID v1.00 Device [USB Headphone Set] +pacmd set-source-mute "$SOURCE" 
-    on usb-0000:00:1d.0-1.3/input3+parecord --verbose --device="$SOURCE" --channels=1 --fix-rate foobar.wav
 </code> </code>
  
-{{ linq-usb-audio.png?direct&100|LinQ USB audio dongle}} +**WARNING**: The audio files produced by this USB adapter **do not cover the entire 16-bit range**the values returned (converted into float dB) extend from **-0.5** to **+0.5**i.e. exactly **the half of what expected** (-1.0 to +1.0). Above that values, **the audio is clipped**You can view this in the pavucontrol monitorit does not matter how loud you speak into the microphone, the volume meter bar never reaches the full scale. So **it is advisable** eventually to lower the volume (e.g. to **75%** or 50%) to **avoid clipping**, and to proceed with post-processing **software amplification**.
-The USB audio adapter worked quite nicely at playing audio, I use it on a QNAP TS-120 NAS, transformed into a media player installing Debian GNU/Linux on it. The Linux kernel and the **ALSA audio subsystem** works well on setting the levels for **playback**. +
- +
-Once started AudacityI was able to select the microphone line of the USB dongle as a **capture device**+
- +
-{{audacity-select-usb-audio.png?direct&260|}} +
- +
-Recording a sample track revealed an annoying problemabout **every 0.4 seconds** you can see a **gap of silence** in the audio track of about **two hundredths of a second**. The audio track is unusable! +
- +
-{{audacity-track-gaps.png?direct&400|}} +
 ===== Web References ===== ===== Web References =====
  
Line 140: Line 176:
   * [[http://www.shure.com/americas/support/find-an-answer/will-bias-voltage-from-a-computer-effect-a-dynamic-microphone|Will bias voltage from a computer effect a dynamic microphone?]]   * [[http://www.shure.com/americas/support/find-an-answer/will-bias-voltage-from-a-computer-effect-a-dynamic-microphone|Will bias voltage from a computer effect a dynamic microphone?]]
   * [[http://www.epanorama.net/circuits/microphone_powering.html|Powering microphones]]   * [[http://www.epanorama.net/circuits/microphone_powering.html|Powering microphones]]
 +  * [[https://forum.xda-developers.com/showthread.php?t=2072612|External Mic on Galaxy Devices]] 
 +  * [[https://stackoverflow.com/questions/19255908/android-forcing-external-microphone-jack-input-3-5mm-to-stay-on|Android: Forcing external microphone (jack input 3.5mm) to stay on]] 
 +  * [[https://forum.xda-developers.com/showthread.php?t=1042051|App that turns off microphone AGC (Auto-Gain Control)?]] 
 +  * [[https://stackoverflow.com/questions/47394634/difference-between-voice-communication-and-mic-in-mediarecorder-audiosource|Difference between VOICE_COMMUNICATION and MIC in MediaRecorder.AudioSource]] 
 +  * [[https://stackoverflow.com/questions/47359587/what-is-the-best-audiosource-setting-for-calls|What is the best audiosource setting for calls?]] 
 +  * [[https://amp.reddit.com/r/androidapps/comments/4wo8sz/app_to_force_android_to_use_external_microphone/|App to force android to use external microphone when one is plugged in]]
doc/appunti/linux/audio/audio_recording.txt · Last modified: 2020/12/28 18:22 by niccolo