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 revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
doc:appunti:linux:audio:audio_recording [2019/04/19 15:34]
niccolo [Ugreen USB audio adapter]
doc:appunti:linux:audio:audio_recording [2019/04/23 12:50]
niccolo [Web References]
Line 1: Line 1:
-====== Audio Recording With Linux ======+====== Audio Recording With GNU/Linux ======
  
 ===== Choosing the right jack ===== ===== Choosing the right jack =====
Line 82: Line 82:
  
 Is not clear **how to disable the external microphone**:​ re-setting **Pin 0x19** to **Not connected** does not generate the ACPI microphone unplug event, and the bias current is not cleared. The bias power disappears from the jack after a poweroff or an hybernation,​ so the external microphone seems to be "​unplugged"​ after these events. Is not clear **how to disable the external microphone**:​ re-setting **Pin 0x19** to **Not connected** does not generate the ACPI microphone unplug event, and the bias current is not cleared. The bias power disappears from the jack after a poweroff or an hybernation,​ so the external microphone seems to be "​unplugged"​ after these events.
-===== Wireless ​microphone =====+ 
 +===== Problem: silence gaps using a cheap USB dongle ===== 
 + 
 +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: 
 + 
 +<​code>​ 
 +usb 2-1.3: new full-speed USB device number 9 using ehci-pci 
 +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=
 +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>​ 
 + 
 +{{ linq-usb-audio.png?​direct&​100|LinQ USB audio dongle}} 
 +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 Audacity, I 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 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! 
 + 
 +{{audacity-track-gaps.png?​direct&​400|}}
  
 ===== Ugreen USB audio adapter ===== ===== Ugreen USB audio adapter =====
Line 111: Line 137:
 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. 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.
  
 +===== Wireless UHF microphone =====
  
-===== Problemsilence gaps using a cheap USB dongle =====+We have purchased an **UHF wireless microphone** on Aliexpress.com for about 25 €. It is composed by:
  
-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:+  * 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
  
-<​code>​ +  * The **receiver** powered by **two AAA batteries**featuring
-usb 2-1.3: new full-speed USB device number 9 using ehci-pci +    ​* A 1/4" (6.35 mm) mono jack
-usb 2-1.3: New USB device foundidVendor=0c76,​ idProduct=1607 +    * One small **telescopic antenna**
-usb 2-1.3New USB device strings: Mfr=0, Product=1, SerialNumber=0 +    ​* Receiving sensitivity-94 dBm 
-usb 2-1.3: Product: USB Headphone Set +    ​* Working current%%<=%% 100 mA
-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,​hidraw2USB HID v1.00 Device [USB Headphone Set] +
-    ​on usb-0000:00:​1d.0-1.3/​input3 +
-</code>+
  
-{{ linq-usb-audio.png?​direct&​100|LinQ USB audio dongle}} +{{wireless-mic-trasmitter.jpg?​direct&​240|}} 
-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**.+{{wireless-mic-receiver.jpg?​direct&​240|}}
  
-Once started Audacity, I was able to select ​the microphone line of the USB dongle as a **capture device**:+To connect the **UHF receiver** ​to the **Ugreen USB audio adapter**, we built an adapter cable with this pinout:
  
-{{audacity-select-usb-audio.png?​direct&​260|}}+^ 1/4" TS female jack  ^ Signal ​        ^ 3.5 mm TRS male jack  ^ 
 +| **Tip** ​             | Microphone ​    | **Tip** ​              | 
 +|                      | Not connected ​ | **Ring** ​             | 
 +| **Sleeve** ​          | Ground ​        | **Sleeve** ​           ​|
  
-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!+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.
  
-{{audacity-track-gaps.png?direct&​400|}}+Despite all this empirical approach, the **voice registration is quite satisfying**! 
 +====== Audio Recording With Android ====== 
 + 
 +Recording audio using an **external microphone** connected to an **Android device** can be a real nightmare. We tried the hard way using a Chinese, no-brand, **wireless UHF microphone**! 
 + 
 +We can group the problems you can face in three main categories:​ 
 + 
 +  * Physical connection 
 +  * Electrical compatibility and hardware autodetection 
 +  * Software capabilities and settings 
 + 
 +===== Physical connection ===== 
 + 
 +Most Android devices have a **3.5 mm jack** accepting a **TRRS connector in CTIA standard** and every brand of mobile phones produces **headsets** with their own standard. The vast majority of solutions uses **electret microphones** requiring a **bias current**, but use **some combinations of impedence** to detect the insertion of the microphone and to **handle the headset button** (or buttons). 
 + 
 +So, connecting an external microphone, can be as simple as making a cable that connects the **ring** and the **sleve** of the **CTIA connector** to (respectively) the **ground** and the **microphone line** of the microphone. The hard part is to guess, or empirically try, if the microphone **requires a bias current**, if the Android device is provinding such a current and if the microphone produces a sufficient **output level** (actually a voltage in the order of the millivolts) that can be used by the device. 
 + 
 +===== Electrical compatibility and hardware autodetection ===== 
 + 
 +As stated above, the first problem is **powering the microphone** itself, because generally we will use an **electret** one. It is a **common practice** to provide the power on the same line of the microphone signal, so **requiring just two wires** for both power (from the device to the mic) and for signal (from the mic to the device). The power, also called //bias current//, is generally in the range of **2.5** to **5.0 volt**. 
 + 
 +FIXME: How much current is provided in our testIs the current always present or switched-on only at jack insertion?​ 
 + 
 +Another parameter which should be considered is the **impedence** FIXME 
 + 
 +===== Software capabilities and settings ===== 
 + 
 +FIXME Complete the article! 
 + 
 +Wishing to connect the **UHF microphone** to an **Android smartphone**,​ we prepared an **adapter cable**. From 3.5 mm jack TRRS male to 1/4" jack TS female, with this pinout: 
 + 
 +^ 1/4" TS female jack  ^ Signal ​        ^ 3.5 mm TRRS male jack (CTIA) ​ ^ 
 +|                      | Not connected ​ | **Tip** ​                      | 
 +|                      | Not connected ​ | **Ring** ​                     | 
 +| **Sleeve** ​          | Ground ​        | **Ring** ​                     | 
 +| **Tip** ​             | Microphone ​    | **Sleeve** ​                   ​|
  
 +The smartphone **did not sensed the microphone**,​ there is not much documentation about it, but it seems that the **autodetection** of the microphone is **based upon the impedence** of the mic itself, if it is too low, it is not detected.
 ===== Web References ===== ===== Web References =====
  
Line 146: Line 213:
   * [[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?]]
doc/appunti/linux/audio/audio_recording.txt · Last modified: 2019/05/22 15:51 by niccolo