Sound and recording
Source:alpine/aports/fplinux-audio
Play sound, adjust its volume and record from a microphone with the commands below. Check support status and your phone page for the available outputs, microphones and automatic headphone switching. Run commands in the USB shell or, on an image that includes it, the phone terminal.
The SC9820E Xiaomi Qin 1s+ uses the rear speaker and built-in microphone, with mutually exclusive playback and recording. It uses Master Playback Volume; wired headphones, headset recording and automatic output switching are unsupported. Output selection, per-output volume, equalizer and idle-silence controls below apply to supported UMS9117 targets. The phone page states Qin’s verified uses and limits.
Prepare device data first
Section titled “Prepare device data first”Audio uses device data prepared from the same phone. On UMS9117, it enables the speaker, full volume range and equalizer; without it, headphones still play with a smaller volume range and the speaker controls are missing. Qin requires its prepared sound settings for both playback and recording. Do not reuse another phone’s data. Follow the device-data guide for a source checkout or standalone archive for a downloaded archive.
Play a file
Section titled “Play a file”On Xiaomi Qin 1s+, stop recording before starting playback.
-
Copy a WAV file to the phone, for example with
--upload ./song.wav /tmp/song.wavas shown in Copy files. -
Play it on the phone:
Phone aplay /tmp/song.wav
The default playback device converts files to 48 kHz on UMS9117 and 44.1 kHz on Qin, so you do not need to convert ordinary WAV files yourself. Volume starts low after every boot; see Volume for your phone’s controls and verified levels.
Where the sound goes
Section titled “Where the sound goes”On UMS9117 phones with automatic headphone switching, plugging in headphones moves playback to them; unplugging moves it to the speaker. This also happens during playback, recording and FM radio, which keep running. The socket only detects that a plug is inserted; it cannot tell headphones from a headset or another cable. A plug change made while the phone sleeps is applied when it wakes.
On supported UMS9117 targets with speaker output available, you can also choose the outputs by hand. A manual choice lasts until the next plug or unplug. For example, to play through the speaker as well as the headphones:
amixer -c 0 cset name='Speaker Playback Switch' onKeep an output active during a switch by turning the new output on before turning the old one off. Switching a playing signal can still produce a click:
amixer -c 0 cset name='Speaker Playback Switch' onamixer -c 0 cset name='Headphone Playback Switch' offTo choose outputs only by hand until the next boot, stop automatic switching with rc-service fplinux-jack stop. Starting it again with rc-service fplinux-jack start selects the output that matches the socket.
Volume
Section titled “Volume”Xiaomi Qin 1s+
Section titled “Xiaomi Qin 1s+”Master Playback Volume accepts levels 0 to 7 and starts at 1 after boot. The default level produces audible output, and 0 mutes it. Loudness across the range and playback quality are uncalibrated; see the phone-page limits for simultaneous application use.
amixer -c 0 cget name='Master Playback Volume'amixer -c 0 cset name='Master Playback Volume' 0amixer -c 0 cset name='Master Playback Volume' 1UMS9117 targets
Section titled “UMS9117 targets”Each available output has its own volume from 0 to 9. Both start at 1 after every boot, and 0 mutes. Without device data, the headphone range is 0 to 6. Use the controls for the outputs supported on your phone.
amixer -c 0 cset name='Headphone Playback Volume' 3,3amixer -c 0 cset name='Speaker Playback Volume' 3amixer -c 0 cget name='Headphone Playback Volume'The two headphone numbers are the left and right channels. When headphones and speaker play together, Speaker Playback Volume sets the level of both outputs, and the headphone volume only mutes a channel at 0. The speaker plays both channels mixed together, so the headphones also sound quieter than when they play alone.
With both outputs enabled, speaker level 0 silences only the speaker; the headphones keep playing at the lowest combined-output level.
Volume, output and equalizer settings last until the next boot.
Equalizer and limiter
Section titled “Equalizer and limiter”Qin’s default 44.1 kHz playback uses the equalizer and automatic level control from its saved speaker profile. Direct stereo S16_LE playback through hw:0,0 also accepts 48 kHz, but bypasses that processing: the profile’s coefficients are specific to 44.1 kHz. Qin has no separate equalizer or limiter switches. This does not establish that its loudness or sound quality matches the original system.
On supported UMS9117 targets, device data enables the equalizer and automatic level control, which limits peaks near full volume. Loudness and dynamics have not been matched to stock playback. Both are on by default and apply to FM radio as well. The equalizer makes playback louder, most noticeably on the speaker. To turn them off:
amixer -c 0 cset name='EQ Playback Switch' offamixer -c 0 cset name='ALC Playback Switch' offA change takes effect immediately, so you hear a step in level if you switch during playback. Set them back to on to restore the default.
Silence between files
Section titled “Silence between files”On supported UMS9117 targets, the enabled outputs stay active with silent PCM between files by default. This avoids clicks at playback transitions and uses more power. To let the audio hardware stop while idle:
amixer -c 0 cset name='Idle Silence Playback Switch' offSet it to on to restore the default. It does not alter a file already playing. With it off, starting or stopping the speaker can click. Direct hw:0,0 playback uses stereo S16_LE at 48 kHz; 24 kHz is available only while idle silence is off. The default playback device continues to convert files to 48 kHz.
Record from the microphone
Section titled “Record from the microphone”If built-in microphone recording is supported, record ten seconds of mono audio. On Xiaomi Qin 1s+, stop playback first:
arecord -D hw:0,0 -f S16_LE -c 1 -r 48000 -d 10 /tmp/recording.wavOn a UMS9117 phone with headset recording support, select a wired four-contact headset before recording:
amixer -c 0 cset name='Capture Source' Headsetarecord -D hw:0,0 -f S16_LE -c 1 -r 48000 -d 10 /tmp/headset.wavAfter headset recording ends, select the built-in microphone again:
amixer -c 0 cset name='Capture Source' InternalPlugging in a headset does not change the source, and the source cannot change while a recording runs. The headset input can produce a short noise during the first second, so start recording before the sound you want. There is no automatic gain or noise suppression. Copy the result to your computer with --pull, as shown in Copy files; files in /tmp disappear at power-off.
On supported UMS9117 targets, recording can run while a file plays, as long as playback uses 48 kHz, which the default playback device always does.
Limitations
Section titled “Limitations”- On supported UMS9117 phones, FM radio cannot play while a file plays or a recording runs, and the other way round.
- There are no phone calls and no live monitoring of the microphone.
- For wireless output, see Bluetooth A2DP playback. Check your phone page before choosing a sink or profile.
Applications that use the audio device directly will find the complete list of controls in Device interfaces.