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 Mon 24 Nov 2014, 11:33
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 1 [11 Posts]  
Author Message
SFR


Joined: 26 Oct 2011
Posts: 1099

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: 676
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: 6455
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?

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8659

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: 6455
Location: Auckland, New Zealand

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

Why did you want to do that?
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
backi

Joined: 27 Feb 2011
Posts: 458
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: 8659

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: 458
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: 6455
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

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8659

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: 1099

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 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 Posts]  
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.0792s ][ Queries: 11 (0.0030s) ][ GZIP on ]