Re: how to record sound to mp3 [wav, for those who can]

2021-03-26 Thread David Wright
On Thu 25 Mar 2021 at 23:22:35 (+0100), Nicolas George wrote:
> David Wright (12021-03-25):
> > > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > > This command does not record the sound being played.
> > … on your machine.
> 
> On no machine, unless specifically configured, which is not trivial at
> all.

I'm afraid it's my PCs that are making a liar of you.

> It would be helpful if people around here learned to read carefully the
> questions before trying to answer them. If they did, they would have
> noticed that the question was not to record the ambient sound but the
> sound BEING PLAYED.

What, you think that I left the speakers running so that the
microphone could record them?

Or did you think that the sound of Thursday evening traffic in
St John's Wood would carry across six timezones?

Or you think that's it's impossible that I should have been able to
record sound the computer is playing (from whatever source, external
or internal) on an OOTB PC for over twenty years?

Is that why you're shouting?

Anyway, back to talking about PCs.

> To achieve it requires either a hardware connection
> between the output and the input of the sound controller

That's my understanding. Using the terminology of the High Definition
Audio Specification (Revision 1.0a June 17, 2010), there is presumably
a link from the § 7.2.3.4 Mixer (Summing Amp) Widget output to the
§ 7.2.3.5 Selector (Multiplexer) Widget. This link in inside the
Widget Interconnection "Cloud" of Figure 49, Module-Based Codec
Architecture.

"The exact number of possible inputs to each widget is determined by
design;" (§ 7.1.1), which is why you can't just conjure up any facility
on any PC.

But the machine is no more "specifically" configured than any PC which
has HDA and a mobo: the vendor (Intel on my old one, Dell on the new)
decides how much of the architecture they will implement. And the
modern way seems to be to go cheap, particularly with consumer-grade.
OK, this one's a decent machine, but it's still a 10-yr old cast off.

Perhaps take a look at the specification and see how much is left open
to the vendor. Hence the need for scripts like alsa-info to tell you
exactly what you've bought with any given "sound card".

This PC was not cheap when it was bought, largely because it's
supposed to be fast: it was bought for students to run geophysics
programs on. You can now pick them up for just over $100. If I ever
have to hand it back, I might just do that. It'll be the first
computer I've ever bought.

> or the
> collaboration of the sound driver.

I assume by this that you're talking about pulseaudio. That's why
I've mentioned it each and every time. (This is the third—should
I put it in my signature?) I can't advise how the OP might use it,
because *I* don't¹. But perhaps that's not expected here—one just
replies   "pulseaudio"   like the people saying   "audacity"
or   "sox"   or whatever.

Finally, who's the audio expert round here? I posted what I think
is a determining factor for just vanilla ALSA and the card to work
with my command line. Presumably there's a definitive answer to
this? Do *you* have it?

¹ self-imposed simplicity: no PA, no OSS.

Cheers,
David.



Re: how to record sound to mp3 [wav, for those who can]

2021-03-26 Thread Michael Lange
On Fri, 26 Mar 2021 09:47:28 +0100
Michael Lange  wrote:

> Plus, I don't know how to switch the OSS capture
> device programmatically (if this is important for the OP's purpose).

uh, got it.

$ aumix -v R

sets "Vol" as capture device.

Regards
Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

A man either lives life as it happens to him, meets it head-on and
licks it, or he turns his back on it and starts to wither away.
-- Dr. Boyce, "The Menagerie" ("The Cage"), stardate
unknown



Re: how to record sound to mp3 [wav, for those who can]

2021-03-26 Thread Michael Lange
Hi,

On Fri, 26 Mar 2021 08:38:02 +0100
 wrote:

> On Thu, Mar 25, 2021 at 11:22:35PM +0100, Nicolas George wrote:
> > David Wright (12021-03-25):
> > > > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > > > This command does not record the sound being played.
> > > … on your machine.
> > 
> > On no machine, unless specifically configured, which is not trivial at
> > all.
> 
> No idea about pulse. For ALSA, there's alsaloop, which comes with a
> man page. Part of alsa-utils. No need of playing with cable loops.

another possibility: when the snd-mixer-oss module is loaded, (at least
here) when using the OSS mixer device there is a "Vol" control which
roughly appears to be the OSS equivalent to Alsa's "Master" control,
however the "Vol" control has an additional "Capture" switch. Now, when I
set "Vol" as capture device, the audio output will be used as input for
recording. Recording level can be adjusted with the "PCM" mixer control.
Of course, the presence of this "Vol" control may depend on the sound
card / driver in use.
Oddly, there seems to be no such easy way to achieve the same result with
alsamixer/amixer. Plus, I don't know how to switch the OSS capture device
programmatically (if this is important for the OP's purpose).

Regards
Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

I thought my people would grow tired of killing.  But you were right,
they see it is easier than trading.  And it has its pleasures.  I feel
it myself.  Like the hunt, but with richer rewards.
-- Apella, "A Private Little War", stardate 4211.8



Re: how to record sound to mp3 [wav, for those who can]

2021-03-26 Thread tomas
On Thu, Mar 25, 2021 at 11:22:35PM +0100, Nicolas George wrote:
> David Wright (12021-03-25):
> > > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > > This command does not record the sound being played.
> > … on your machine.
> 
> On no machine, unless specifically configured, which is not trivial at
> all.

No idea about pulse. For ALSA, there's alsaloop, which comes with a
man page. Part of alsa-utils. No need of playing with cable loops.

> It would be helpful if people around here learned to read carefully the
> questions before trying to answer them [...]

(I was on the verge of making a snarky comment to that, but I'll bite
my tongue).

Cheers
 - t


signature.asc
Description: Digital signature


Re: how to record sound to mp3 [wav, for those who can]

2021-03-25 Thread Linux-Fan

David Wright writes:


On Thu 25 Mar 2021 at 17:40:51 (+0100), Nicolas George wrote:
> David Wright (12021-03-25):


[...]


> > To record, you could type, for example, in another xterm:
> >
> > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
>
> This command does not record the sound being played.

… on your machine. That's why I wrote "If you can't get ALSA to work…".
You're a candidate for pulseaudio, I assume.


Not sure about that command above (no means to try it just now), but _with_  
PulseAudio, I can record the sound that is being played back just fine by  
means of "monitor" audio devices. E.g. I have the following command to  
record my screen (`0:v`), the "monitor" device (`1:a`) and a microphone  
(`2:a`):


exec ffmpeg -video_size 1600x1200 -framerate 12 -f x11grab -i :0.0+0,0 -f pulse -ac 2 -i 
0 -f pulse -i 1 -c:v libvpx-vp9 -deadline realtime -b:v 2M -c:a libvorbis -map 0:v -map 
1:a -map 2:a "recording.webm"

adapted from these two sources:

-> https://trac.ffmpeg.org/wiki/Capture/Desktop
-> 
https://askubuntu.com/questions/682144/capturing-only-desktop-audio-with-ffmpeg

It may of course be true that the hardware _does_ support/accellerate this  
monitoring capability, but it does not seem to be entirely uncommon a  
feature? Here, it even works inside virtual machines :)


Btw. the existence of monitor devices can be checked in `pavucontrol` where  
under "Output" it lists two monitor devices here: One for the HDMI output  
and one for the "Built-in Analog Stereo" Output.



AFAICT, this recording facility is getting harder to find on most
computers, if you're not prepared to fork out for a sound card.
I've been fortunate, in that just as my ancient Pentium III expired,
I have acquired a Dell Precision T3500 which has a well endowed
(integrated) sound card.

I'm still finding my way round it: for example, it also has HDMI
playback, but I haven't yet worked out how to exploit it. The machine
has one DVI output and two DisplayPorts, so I need to find a
DisplayPort/HDMI adapter to see if that would yield anything.


[...]

As far as I can tell, DisplayPort can transport audio without the need for  
an HDMI adapter. Here, a Radeon Pro W5500 graphics card is connected to a  
Dell U2713HM display which has one HDMI, DP, VGA and DVI input each. The  
W5500 is connected to the DisplayPort and if I play sound to the "HDMI"  
output, the display outputs that sound through its headphones socket.


Similar to your case, there are no HDMI ports on the graphics card.
In my case, it is only DisplayPorts.

HTH
Linux-Fan

öö


pgpoa49bihnMC.pgp
Description: PGP signature


Re: how to record sound to mp3 [wav, for those who can]

2021-03-25 Thread Nicolas George
David Wright (12021-03-25):
> > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > This command does not record the sound being played.
> … on your machine.

On no machine, unless specifically configured, which is not trivial at
all.

It would be helpful if people around here learned to read carefully the
questions before trying to answer them. If they did, they would have
noticed that the question was not to record the ambient sound but the
sound BEING PLAYED. To achieve it requires either a hardware connection
between the output and the input of the sound controller or the
collaboration of the sound driver.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature


Re: how to record sound to mp3 [wav, for those who can]

2021-03-25 Thread David Wright
On Thu 25 Mar 2021 at 17:40:51 (+0100), Nicolas George wrote:
> David Wright (12021-03-25):
> > > now i modify my requirement to how to use arecord to record sound being 
> > > played to wav file
> 
> > To record, you could type, for example, in another xterm:
> > 
> > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> 
> This command does not record the sound being played.

… on your machine. That's why I wrote "If you can't get ALSA to work…".
You're a candidate for pulseaudio, I assume.

AFAICT, this recording facility is getting harder to find on most
computers, if you're not prepared to fork out for a sound card.
I've been fortunate, in that just as my ancient Pentium III expired,
I have acquired a Dell Precision T3500 which has a well endowed
(integrated) sound card.

I'm still finding my way round it: for example, it also has HDMI
playback, but I haven't yet worked out how to exploit it. The machine
has one DVI output and two DisplayPorts, so I need to find a
DisplayPort/HDMI adapter to see if that would yield anything.

It also has two Capture devices, and I don't know whether that means
there are two independent sound paths. If so, then I should be able to
record from the browser to one file, and from a TV (my UK one has
headphone output) or the Roku remote control to another file at the
same time.

Anyway, I just recorded a bit of audio from Abbey Road (the live webcam¹,
not the album), and printed the settings of all the controls (attached).
AIUI at present, the critical section is at the end, specifically:

Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Mic' 'Line' 'Stereo Mix'
  Item0: 'Stereo Mix'

IOW, I'm recording from the mixer.

¹ https://www.abbeyroad.com/Crossing

Cheers,
David.
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 31 [100%] [0.00dB] [on]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 39
  Mono:
  Front Left: Playback 0 [0%] [-58.50dB] [on]
  Front Right: Playback 0 [0%] [-58.50dB] [on]
Simple mixer control 'Speaker',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 0 [0%] [-46.50dB] [on]
Simple mixer control 'Line',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [on]
  Front Right: Playback 0 [0%] [-34.50dB] [on]
Simple mixer control 'Line Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Line Out',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-46.50dB] [on]
  Front Right: Playback 0 [0%] [-46.50dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Beep',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 15
  Mono: Playback 0 [0%] [-45.00dB] [off]
Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Speaker Only' 'Line Out+Speaker'
  Item0: 'Disabled'
Simple mixer control 'Independent HP',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'
Simple mixer control 'Loopback Mixing',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 54
  Front Left: Capture 44 [81%] [7.50dB] [on]
  Front Right: Capture 44 [81%] [7.50dB] [on]
Simple mixer control 'Capture',1
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 54
  Front Left: Capture 33 [61%] [-9.00dB] [on]
  Front Right: Capture 33 [61%] [-9.00dB] [on]
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Mic' 'Line' 'Stereo Mix'
  Item0: 'Stereo Mix'
Simple mixer control 'Input Source',1
  Capabilities: cenum
  Items: 'Mic' 'Line' 'Stereo Mix'
  Item0: 'Line'