Editor's Note: Tip Top Tips is a new monthly column in The PCLinuxOS Magazine. Each month, we will feature – and possibly even expand upon – one tip from the PCLinuxOS forum. The magazine will not accept independent tip submissions specifically intended for inclusion in the Tip Top Tips column. Rather, if you have a tip, share it in the PCLinuxOS forum's "Tips & Tricks" section. Your tip just may be selected for publication in The PCLinuxOS Magazine.
This month's tip comes from PCLinuxOS forum member i14.
This tip will try to describe what is needed to set up mixing two sound streams, through Pulseaudio, and what setup is required to record the mixed output.
This is a description of doing things manually so that you know what is required.
There is now no need to actually use the manual method as this mixer has been included in
PulseAudio Control Panel, which provides a button which, when depressed, creates the required environment. When clicked again the mixer settings are destroyed, so the setup does not interfere with anything else you might wish to do. References to 'Null' will be named Mixer#1 in the Control Panel application.
***
You must have Pulseaudio installed and working, as well as Pulseaudio Volume Control installed. You should get familiar with PA Volume Control and its various tabs, etc.
Tip: When viewing a tab, enable viewing of ALL streams, by selecting the option from the drop-down box on the bottom of the tab.
Manual Method:
To set up your system for mixing and recording you must first setup the output location for the mixed sound stream. This is done by loading the 'null-sink' PA module.
Then you set up two loopback sinks, one each for the two sound sources to be mixed ... the song being played, and the MIC for your voice.
Here are the three commands to be input in a terminal as user:
# Set up the mixed sound sink
pactl load-module module-null-sink sink_name=MySink
# Set up the first loopback sink
pactl load-module module-loopback sink=MySink
# Set up the second loopback sink
pactl load-module module-loopback sink=MySink
If you wish to mix more than two sound streams, just create extra loopbacks using the last command.
*Important: Take note of the number returned for each command. They will be needed later.*
As can be seen from the name used in the above commands, they are all related; that is the loopbacks will connect to the null-sink of the same name.
That is it. The system is now set up for mixing two sound sources and recording it.
To record from the correct sound sources, a little set up is needed in PA Volume Control, to specify the correct streams. This is done on the Recording tab.
With 'All Streams' selected on the bottom of the page, the two Loopback streams become visible.
Using the buttons to the right of the Loopback entries, select the MIC for one of them, and
select 'Monitor of .. ' the built in Audio for the other.
You can, of course, mix different sound streams if you wish by selecting them here.
In general, an entry without 'Monitor' in its name is an input device, such as a MIC. Those with 'Monitor' in their names are 'taps into' the sound stream going to a sink, such as speakers or headset.
Now launch your preferred recording application. If necessary, ensure it uses Pulse Audio and 'default' source. It too will appear on the Recording tab when a recording is started. It is useful to start a recording and pause it, while the correct settings are applied on the Recording tab.
Set it to record from "Monitor of Null Output." That is the mixed sound stream.
The three streams are now set up.
Un-pause the recording application. It starts to record. Play the song with your player application. Sing/speak into the MIC.
You will most likely need to do a few 'dry runs' first to get the balance between the MIC and song to your liking.
To alter the volume of the MIC use the Input Device tab of PA Vol Control.
To alter the volume of the played song, use the Output Devices tab of PA Vol Control.
Alter the sliders on the "Null Input" and "Null Output" devices until you have the required balance.
Hours of fun!
The setup described above is not permanent. It will be lost on a reboot.
I thought about setting this up permanently, but decided against it, as it seems to cause PA to use an extra couple of % of CPU.
Balanced against that, issuing three commands to do the setup, and three more to dismantle it, is not a difficult task, but is now incorporated into PulseAudio Control Panel which is in the repository, if you prefer to use that.
Should you wish to delete the setup without rebooting the following command will do it. Do the command for each of the three numbers returned when doing the setup commands (you do remember them don't you?).
pactl unload-module <module number>
Hopefully some will find this useful.
|