Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 26 May 2018, 10:22
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to capture audio output
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [21 Posts]   Goto page: 1, 2 Next
Author Message
SFR


Joined: 26 Oct 2011
Posts: 1657

PostPosted: Mon 25 Aug 2014, 11:07    Post subject:  How to capture audio output
Subject description: A workaround for lack of 'mix' device
 

This "how-to" describes one of the methods of recording audio output in case of lack of 'mix' capture device.
This is especially true for laptops/netbooks with snd_hda_intel driver.
___________

1. First, we need to load snd-aloop kernel module. Open terminal window and type:
Code:
modprobe snd-aloop

If the above command returns 'FATAL: Module snd-aloop not found.' you're out of luck.
In such a case you could either try to compile the missing module by yourself or consult developer(s) of your distro for additional info/help.

To make this module load at system boot:
Menu -> System -> Boot Manager -> Modules -> Add new module

NOTE: if the module is already loaded it won't be listed in BootManager!
To remove it:
Code:
rmmod snd-aloop

Then add it in BootManager and load back using modprobe.



2. Create (if doesn't exist) /etc/asound.conf and append the following content to it:
Code:
pcm.!default {
  type asym
  playback.pcm "LoopAndReal"
  #capture.pcm "looprec"
  capture.pcm "hw:0,0"
}

pcm.looprec {
    type hw
    card "Loopback"
    device 1
    subdevice 0
}


pcm.LoopAndReal {
  type plug
  slave.pcm mdev
  route_policy "duplicate"
}


pcm.mdev {
  type multi
  slaves.a.pcm pcm.MixReale
  slaves.a.channels 2
  slaves.b.pcm pcm.MixLoopback
  slaves.b.channels 2
  bindings.0.slave a
  bindings.0.channel 0
  bindings.1.slave a
  bindings.1.channel 1
  bindings.2.slave b
  bindings.2.channel 0
  bindings.3.slave b
  bindings.3.channel 1
}


pcm.MixReale {
  type dmix
  ipc_key 1024
  ipc_perm 0666
  slave {
    pcm "hw:0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}

pcm.MixLoopback {
  type dmix
  ipc_key 1025
  ipc_perm 0666
  slave {
    pcm "hw:Loopback,0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}


This will create a new device named looprec, which is kinda substitute for the absent 'mix' device.

NOTE 1: In some cases sound card's index may be different from 0, e.g. in Acer AO 722 I had to replace all occurences of 'hw:0,0' with 'hw:1,0'.

NOTE 2: Multiple-Sound-Card-Wizard creates its own /etc/asound.conf file, so if you need to use it, do it before setting up looprec. Then you can append the stuff from above to it.



3. Perform a quick test. Turn on some music and type:
Code:
arecord -f dat -D looprec > /root/test.wav

Keep recording for a few seconds, then Ctrl+C and type:
Code:
aplay /root/test.wav

to check if the recording went well.



In order to enable recording in mhWaveEdit:
In 'Edit -> Preferences -> Sound -> (Driver: ALSA) Settings -> Recording device' enter looprec.
Also, sample format ('Play -> Record -> Sample format -> Other format') has to be:
- Channels: Stereo
- Sample type: 16 bit PCM
- Signedness: Signed
- Endianness: Little endian
- Sample rate: 48000


In order to enable recording in Audacity:
In 'Edit -> Preferences -> Devices -> Recording -> Device' choose looprec
In 'Edit -> Preferences -> Quality -> Sampling -> Default Sample Rate' choose 48000



KNOWN ISSUES:
- PCM slider in Alsamixer/Retrovol no longer works
- you can't record from microphone using looprec device
- nor from pMusic (may be not true for older versions though, haven't checked), because it uses its own, custom ~/.asoundrc config file (probably needed by equalizer), but if you delete this file after starting PMusic and restart a track, it becomes recordable
- nor from apps that use OSS, unless they have an option to set output to ALSA (or unless you have alsa-oss installed and you'll use aoss script to launch such an application)
___________

DISCLAIMER: I only tranplanted the info provided by kokoko3k on Archlinux forum into Puppy's ground, taking into account some specific quirks of the latter.
I do not understand why and how the stuff in asound.conf works.

Thanks to all in this thread for the feedback.

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.

Last edited by SFR on Mon 17 Nov 2014, 12:02; edited 1 time in total
Back to top
View user's profile Send private message 
mister_electronico


Joined: 20 Jan 2008
Posts: 960
Location: Asturias_ España

PostPosted: Sat 15 Nov 2014, 06:35    Post subject: very interesting this post  

very interesting this post.

If you want to record sound from microphone

cat /dev/audio > sample.au

or

dd bs=8k count=4 < /dev/audio > sample.au

Only make file 8 K


to play it

cat sample.au > /dev/audio

Thanks
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
disciple

Joined: 20 May 2006
Posts: 6796
Location: Auckland, New Zealand

PostPosted: Sat 15 Nov 2014, 07:49    Post subject:  

Quote:
- nor from apps that use OSS, unless they have an option to set output to alsa

it would work if you used aoss, wouldn't it?

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 11124

PostPosted: Sat 15 Nov 2014, 08:06    Post subject:  

I managed to compile an audacity to have the choice of OSS and ALSA.... the compromise is to drop their built in mixer controls since the reason they don't support both is because they never bothered to make the mixer/portaudio work with both...hence version 1.2.x. is OSS only and version 1.3.x./ 2.x.x is ALSA only.

Felt the urge to mention that ..it seemed related...and this recording of audio is an interest of mine.

mike
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6796
Location: Auckland, New Zealand

PostPosted: Sat 15 Nov 2014, 08:41    Post subject:  

Why did you want to do that?
_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
backi

Joined: 27 Feb 2011
Posts: 1472
Location: GERMANY

PostPosted: Sat 15 Nov 2014, 10:08    Post subject:  

Thanks !!!! very much
Helped me a lot ......
could not get Audacity working in Quirky Unicorn and in Tahrpup ....
but now.......problem solved .
Thanks a lot !!
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 11124

PostPosted: Sat 15 Nov 2014, 10:23    Post subject:  

Quote:
Why did you want to do that?


If thats directed at me the motivation was audacity 1.3 overhead is 4 times that of 1.2 due to it insisting on rendering the waveform in real time as it records...in gtk2 thats a cpu killer and can result in jerky recordings...not good...but the gtk1/1.2 version had no Alsa support so the problem of sound card hogging. I dug in and found out why and got both working on both versions... for the sheer usefulness of it. (sp/dif option was a bonus on 1.2)


mike
Back to top
View user's profile Send private message 
backi

Joined: 27 Feb 2011
Posts: 1472
Location: GERMANY

PostPosted: Sat 15 Nov 2014, 11:36    Post subject:  

Sorry i was wrong on Tahrpup .
Did not work !
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6796
Location: Auckland, New Zealand

PostPosted: Sat 15 Nov 2014, 16:42    Post subject:  

Quote:
had no Alsa support so the problem of sound card hogging

Again, aoss would be a good work around in that situation. But well done on solving it proproperly Smile

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 11124

PostPosted: Sat 15 Nov 2014, 16:54    Post subject:  

It was a challenge to myself... IIRC newer releases of portaudio makes it extremely difficult to do it now and the loss of built in level controls would be unpopular anyway.

Sorry if that was a bit of a sidetrack on the topic.... my usual method is arecord anyway which also works nicely with sp/dif input..... that in itself usually requires control outside of such as audacity can provide anyway..or did. eg switching digital in on and so on...

mike
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1657

PostPosted: Mon 17 Nov 2014, 12:04    Post subject:  

disciple wrote:
Quote:
- nor from apps that use OSS, unless they have an option to set output to alsa

it would work if you used aoss, wouldn't it?

Hmm, I didn't know about the existence of that "thing" 'till you mentioned it.
Slacko doesn't have alsa-oss installed by default, but just grabbed one from pkgs.org and yes, I can confirm - it does work.
Thanks for the info!

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
gcmartin

Joined: 14 Oct 2005
Posts: 6730
Location: Earth

PostPosted: Tue 31 May 2016, 23:07    Post subject:  

This solution in this thread or this solution here should be included in PUP distros. Often times we need to record audio over the desktop without having to read for a "redirect" cable for Line-out to line-in use.

Hope this gets to PUP developers.

_________________
Get ACTIVE Create Circles; Do those good things which benefit people's needs!
We are all related ... Its time to show that we know this!
3 Different Puppy Search Engines or use DogPile
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6796
Location: Auckland, New Zealand

PostPosted: Tue 31 May 2016, 23:27    Post subject:  

What sound related wizards are in Puppies these days? And how is the software equaliser that is in them provided?
Since soundcards typically have a "mix" control I think this would be more appropriate as (part of?) a wizard than set up by default. I'd say the same for setting up a software volume control when the sound card doesn't provide one.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
greengeek


Joined: 20 Jul 2010
Posts: 5007
Location: Republic of Novo Zelande

PostPosted: Thu 02 Jun 2016, 04:31    Post subject:  

gcmartin wrote:
This solution in this thread or this solution here should be included in PUP distros. Often times we need to record audio over the desktop without having to read for a "redirect" cable for Line-out to line-in use.
Thanks SFR for the methodology - seems to work well for me on a Slacko 5.6 derivative.
I have made a pet which adds a default /etc/asound.conf file, loads the snd-aloop module, adds a loopbackrecorder script into /usr/bin, and also adds start and stop scripts into /root.

Just click "startloopback" in /root, then start your audio stream playing, and the test.wav file will be accumulated in /root.

When you have finished playing the audio just click "stoploopback" in /root and the recording phase will stop.

EDIT : if you do not have enough RAM to accumulate the final size of the .wav file you record into /root then it will be necessary to modify the /usr/bin/loopbackrecord file to select a different location that has more space to store the recording. (Roughly speaking it uses around 10MB of RAM per minute of recording)

EDITED : The only problem I have experienced is that after the recording is made pMusic cannot be used to play any music - it gives a "playback error". I guess it can't access some part of the audio subsystem. Turns out this only occurs if I have not yet closed the program that was producing the original audio - eg browser or other music player etc.. However, I find this problem does not occur if I play a music track with pmusic before I make the recording. If I do that it has no trouble playing any track afterwards.

EDIT : Once the recording is done I use mhwaveedit to open the test.wav file for the purpose of trimming unwanted extra stuff from the beginning and end of the track, then save as .mp3 if i want a smaller file.

EDIT : Added an sfs for those who dont want to take the risk of installing a pet. Please remove the false .gz suffix.

CAUTION : Never install any pets unless you have first taken a backup of your savefile. I recommend testing pets first in a "fresh" boot of the generic version of your puppy - so that your savefile is not permanently affected. Use the sfs version instead if you are concerned about this issue.
.
loopbackrecorder_gg-0.0.sfs.gz
Description  False gz suffix. REMOVE THE gz SUFFIX
gz

 Download 
Filename  loopbackrecorder_gg-0.0.sfs.gz 
Filesize  4 KB 
Downloaded  142 Time(s) 
loopbackrecorder_gg-0.0.pet
Description 
pet

 Download 
Filename  loopbackrecorder_gg-0.0.pet 
Filesize  1.04 KB 
Downloaded  147 Time(s) 

Last edited by greengeek on Thu 02 Jun 2016, 21:39; edited 7 times in total
Back to top
View user's profile Send private message 
Pelo

Joined: 10 Sep 2011
Posts: 12591
Location: Mer méditerrannée (1 kms°)

PostPosted: Thu 02 Jun 2016, 12:20    Post subject: how to record your tapes to mp3  

how to record your tapes to mp3 with audacity French topic here (English how-to)
For concerned people.

_________________
Passenger Pelo ! don't ask him to repair the aircraft. Don't use him as a demining dog .... pleeease.
Back to top
View user's profile Send private message Yahoo Messenger 
Display posts from previous:   Sort by:   
Page 1 of 2 [21 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0649s ][ Queries: 12 (0.0088s) ][ GZIP on ]