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 Thu 29 Jun 2017, 10:32
All times are UTC - 4
 Forum index » House Training » Beginners Help ( Start Here)
How to record a digital audio stream in Tahr 605? (Solved)
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 5 [68 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
number77

Joined: 22 Oct 2010
Posts: 460

PostPosted: Mon 17 Apr 2017, 05:17    Post subject:  

Hello theru
Terminal commands really tax my brain as I have very little knowledge. arecord -l is usefull but gives the only sound card as analogue and as you seem to be using loopback would that not mean I would be recording an analogue stream and converting to digital in daphile.
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 126
Location: Heers, Belgium

PostPosted: Mon 17 Apr 2017, 11:44    Post subject:  

The command aplay -l gives me this:

Code:
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC888 Digital [ALC888 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: pcsp [pcsp], device 0: pcspeaker [pcsp]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


The card my speakers are connected to is card 0. This will be needed later on.

Now to set up the computer for recording the output.

First I enter the following command:

Code:
modprobe snd-aloop pcm_substreams=1


This will add a virtual soundcard:

Code:
card 3: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


And to "connect" this card to the existing hardware I add the following to /etc/asound.conf

Code:
pcm.multi {
    type route;
    slave.pcm {
        type multi;
        slaves.a.pcm "output";
        slaves.b.pcm "loopin";
        slaves.a.channels 2;
        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;
    }

    ttable.0.0 1;
    ttable.1.1 1;
    ttable.0.2 1;
    ttable.1.3 1;
}

pcm.!default {
   type plug
   slave.pcm "multi"
}

pcm.output {
   type hw
   card <Your Output Device Name>
}

pcm.loopin {
   type plug
   slave.pcm "hw:Loopback,0,0"
}

pcm.loopout {
   type plug
   slave.pcm "hw:Loopback,1,0"
}


However the code is not usable as-is. Let's look at the part that needs to be changed:

Code:
pcm.output {
   type hw
   card <Your Output Device Name>


Remember when I said where my speakers are connected to?

In my case I'll need to change it to this:

Code:
pcm.output {
   type hw
   card 0


At this point save asound.conf. The settings will be applied to any application that's started after this. To revert the settings to the old state just delete the added code from asound.conf and restart the application.

Any application that's already open at this point and is using the soundcard may start experiencing sound issues so it's best to close them before applying the settings.

Now that everything is set up let's start the application you want to record the audio from. Remember at this point only the first application started will be able to output audio. Any other application will be muted unless the first application is closed first.

When you want to record from a flash object it may appear muted. I've discovered that when I start playing something like a youtube video or a soundcloud clip and pause it before opening the flash object in another tab it will play the audio just fine.

When you can hear the audio it's time to open the recorder. I use audacity as that's what I've been testing this setup on.

In the list of recording devices choose the one that has "loopout" in it's name. If there is more then one named like this any of them should work.

At this point when you click on the vu meter in the recording toolbar it should start moving to the beat. When this happens you know that audacity is listening to the output and you can start recording.

Keep in mind that until the changes to asound.conf are reverted and the recorder application is restarted it will be possible to record the audio and save the recorded audio but not to play it back. It may work if you have another card installed or you use another output from the same card but my speakers only have one analog input.

If you still experience audio issues after reverting the changes you can try opening the multiple sound card wizard and switch back and forth between devices (just remember which is the right one). This should reset everything. Worst case scenario a reboot will fix everything.

As to your question about whether the stream is analog or digital, the way I understand it the loopback device listens to the audio buffer which probably means the audio that's about to be sent to the soundcard. Since the soundcard is responsible for the digital to analog conversion I assume that the audio at this point is still digital.
Back to top
View user's profile Send private message 
number77

Joined: 22 Oct 2010
Posts: 460

PostPosted: Tue 18 Apr 2017, 16:26    Post subject:  

theru, I have to admit that this is definitely beyond me. I have learned a lot about the sound on puppy but this is too complicated so probably is the time to give up. I am a beginner at linux and getting audacity working properly is too difficult at least for me and maybe not for a beginner.
But I would like to thank you for all your help and all the help from other members of the forum.
Thanks
number77
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 126
Location: Heers, Belgium

PostPosted: Tue 18 Apr 2017, 20:26    Post subject:  

No thank you for asking your question. Thanks to that I've found the way to some great tutorials.

I've now reduced the complexity to simply replacing /etc/asound.conf with a copy that has the necessary information. This will essentially turn the loopback on or off.

If you haven't really given up on this I can send you a script that does this for you as well as loading/unloading the module just by clicking on it. I can also send you a script that creates a copy of asound.conf with the information already filled in.
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 12546
Location: Arizona USA

PostPosted: Tue 18 Apr 2017, 23:35    Post subject:  

Please post the script here in the forum, unless it's horribly long. Smile
Back to top
View user's profile Send private message 
number77

Joined: 22 Oct 2010
Posts: 460

PostPosted: Wed 19 Apr 2017, 05:58    Post subject:  

theru wrote:
No thank you for asking your question. Thanks to that I've found the way to some great tutorials.

I've now reduced the complexity to simply replacing /etc/asound.conf with a copy that has the necessary information. This will essentially turn the loopback on or off.

If you haven't really given up on this I can send you a script that does this for you as well as loading/unloading the module just by clicking on it. I can also send you a script that creates a copy of asound.conf with the information already filled in.

Yes please. I will give it a try.
Back to top
View user's profile Send private message 
backi

Joined: 27 Feb 2011
Posts: 1111
Location: GERMANY

PostPosted: Wed 19 Apr 2017, 09:30    Post subject:  

Hi !

Quote:
Please post the script here in the forum, unless it's horribly long


Yes .....please post it ......this is exactly what i am looking for ....

Thanks in advance Smile Smile
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 126
Location: Heers, Belgium

PostPosted: Wed 19 Apr 2017, 14:00    Post subject:  

Ok but please keep in mind that I've only tested it on 1 pc.

To keep things simple code-wise I've decided to split it up in 2 scripts, one to create asound-aloop.conf from a template and another one to load/unload the loopback device.

The script to create the file:

Code:

cardnumber=$(cat /etc/asound.conf | grep defaults.pcm.card | cut -f2 -d " ")
cat /etc/asound.conf cat asound-template.conf | sed 's/<number>/'$cardnumber'/' >> asound-aloop.conf


This script does 2 things:

- See which card is used for audio output and assign variable cardnumber to that number.
- Read the original asound.conf and the included asound-template.conf, replace the <number> string in asound-template.conf with whatever value was set for $cardnumber and saves the combined output as asound-aloop.conf

The file asound-aloop.conf needs to be placed into /etc, after that the script aloop-toggle will become functional.

This is aloop-toggle:

Code:

#!/bin/sh

if
[ ! -t 1 ] ; then rxvt -e "$0" && exit
fi

if [[ -e /etc/asound-aloop.conf ]] ; then modprobe snd-aloop pcm_substreams=1 ; mv /etc/asound.conf /etc/asound-aloop-orig.conf && mv /etc/asound-aloop.conf /etc/asound.conf ; echo "aloop entries enabled"
elif [[ -e /etc/asound-aloop-orig.conf ]] ; then mv /etc/asound.conf /etc/asound-aloop.conf && mv /etc/asound-aloop-orig.conf /etc/asound.conf ; rmmod snd-aloop ; echo "aloop entries disabled"
fi
sleep 2


When the script is run it loads the module snd-aloop and swaps out asound.conf and asound-aloop.conf by renaming them. Click on it again and it swaps the modified script with the original one and unloads the module snd-aloop.

Using the script is fairly straightforward:

- Close all applications that access the sound card so the correct values can be read at application startup once the loopback device is turned on.
- Click on it once to load the loopback device and record audio from a single application
- Click on it again to restore normal functionality

Some things to keep in mind:

- Close alll applications that play audio before you turn the loop device on or off. That way the config file currently in use will be read when you start the application you want to play audio on.

- When you turn the loop device on the first application accessing the sound card will get exclusive use of the sound card. All other applications will be muted. This means it's important that no applications are using the sound card when you turn the loop device on.

- When you have confirmed you have sound you can start any application you prefer for capturing audio. In the list of recording devices select any device that has "loopout" in it's name. That should be enough to start recording.

- When you want to turn the loop device off don't forget to close all applications capable of outputting audio. Just like other modules the module snd-aloop can't be unloaded when it's still in use. For applications started after this the soundcard's normal performance will be restored anyway as the original asound.conf has no information about the loopback device so it would no longer be used.

So far the only application I wasn't able to record audio from is vlc but that player has capture functionality on it's own.
aloop.tar.gz
Description  Click on aloop-create to create asound-aloop.conf. Place this file in /etc
Once asound-aloop.conf is in place aloop-toggle will be functional.
gz

 Download 
Filename  aloop.tar.gz 
Filesize  686 Bytes 
Downloaded  15 Time(s) 
Back to top
View user's profile Send private message 
number77

Joined: 22 Oct 2010
Posts: 460

PostPosted: Thu 20 Apr 2017, 03:00    Post subject:  

Thanks theru
Nice explanation, I very nearly understand it. I will give it a try tonight.
Back to top
View user's profile Send private message 
number77

Joined: 22 Oct 2010
Posts: 460

PostPosted: Thu 20 Apr 2017, 13:30    Post subject:  

theru that is realy impressive.
Audacity now records. Speaker working on loopout, input on loopback: PCM hw:2,1 stereo. The volume being recorded is quite low and all inputs in alsamixer are set to max. Any ideas.
I like the aloop-toggle.
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 126
Location: Heers, Belgium

PostPosted: Thu 20 Apr 2017, 20:15    Post subject:  

You say you have the inputs set to maximum. Does that mean the capture sliders, playback sliders or both?

When I tried to switch to the loopback device in alsamixer I got the message that there were no sliders to adjust. This makes sense since the loopback device is a virtual passthrough device, not an actual card.

About the lower volume I don't know what the actual cause is. Are you sure the playback sliders are all the way up? I have tried recording at a lower output volume but when I played it back at normal volume levels it didn't sound any quiter.
Back to top
View user's profile Send private message 
number77

Joined: 22 Oct 2010
Posts: 460

PostPosted: Fri 21 Apr 2017, 02:49    Post subject:  

theru wrote:
You say you have the inputs set to maximum. Does that mean the capture sliders, playback sliders or both?

When I tried to switch to the loopback device in alsamixer I got the message that there were no sliders to adjust. This makes sense since the loopback device is a virtual passthrough device, not an actual card.

About the lower volume I don't know what the actual cause is. Are you sure the playback sliders are all the way up? I have tried recording at a lower output volume but when I played it back at normal volume levels it didn't sound any quiter.

The capture sliders, capture and digital are set to max 100
The playback sliders are set to master, headphone, speaker, pcm 15, auto mut and loopback to enabled.
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 126
Location: Heers, Belgium

PostPosted: Fri 21 Apr 2017, 15:21    Post subject:  

You said the volume was a bit low. Do you mean it's low compared to input from a microphone?

I've noticed in alsamixer that there is a slider named "mic boost". This is used to enhance the volume of less powerful microphones.

When you capture the output it doesn't go through the sound card before going to audacity so I don't think the volume is boosted.

Also if you only use audacity for recording and saving the output and nothing in between I may have a script that saves the output using ffmpeg. The only thing you need to do is start the script and stop ffmpeg when you're done recording. FFmpeg will run in a terminal, you just press q when you're done.The files will have the same name followed by the current date and time unless you start the script in a terminal followed by the name of the file, like this: <scriptname> <filename>

What do you think?

edit: Here is what I have in mind:

- click on script: capture audio, filename output_date_time.wav (simple)
- execute in terminal with <name of script> <name of file> Additional ffmpeg options can be added in between (advanced)
Back to top
View user's profile Send private message 
number77

Joined: 22 Oct 2010
Posts: 460

PostPosted: Sat 22 Apr 2017, 09:55    Post subject:  

The volume is low compared with equivalent tracks recorded on the same laptop but in xp, Neither uses microphone at all.
I will have a look at FFmpeg.
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 126
Location: Heers, Belgium

PostPosted: Sat 22 Apr 2017, 14:52    Post subject:  

FFmpeg is a command line program. It's used to convert media files and capture streams.

Since you're not comfortable with the command line I've created a script that allows you to record the stream with a single click:

Code:
#!/bin/sh
if
[ ! -t 1 ] ; then rxvt -e "$0" && exit
fi

capture="ffmpeg -f alsa -i loopout"
output=output_$(date +%F_%R:%S).wav

if [[ -e $1 ]] ; then $capture $*
else $capture $output
fi


If you just want to record the stream, feel free to skip to the attachment. If you prefer to change the name or output volume, these things are explained further down.

A quick breakdown of the script:

Code:
if
[ ! -t 1 ] ; then rxvt -e "$0" && exit
fi


If the script isn't started from a terminal, restart it in a terminal.

Code:
capture="ffmpeg -f alsa -i loopout"


Tells ffmpeg to process a stream that has the alsa format (-f alsa) from an input stream named loopout (-i loopout)


Code:
output=output_$(date +%F_%R:%S).wav


The source and format that were defined on the previous line will be stored in the script's directory as a file named output_yyyy-mm-dd_hh:mm:ss.wav

When you simply click the script it will use the defaults:

Code:
$capture $output


These variables are defined in the script and will be translated as:

Code:
ffmpeg -f alsa -i loopout output_$(date +%F_%R:%S).wav


The part between $( ) is a separate command that will run first, the final line is:

Code:
ffmpeg -f alsa -i loopout output_yyyy-mm-dd_hh:mm:ss.wav


But what if you want to give it another name? Then you'll need to open a terminal at the directory where the script is and run it like this:

Code:
./aloop-record custom-name.wav


Then the script will run this code:

Code:
$capture custom-name.wav


Which will translate to:

Code:
ffmpeg -f alsa -i loopout custom-name.wav


In a nutshell, ./aloop by itself (or just clicking on the script) will run like this:

Code:
ffmpeg -f alsa -i loopout output_yyyy-mm-dd_hh:mm:ss.wav


While ./aloop other options will be run like this:

Code:
ffmpeg -f alsa -i loopout other options


I've found a way to let ffmpeg increase the volume of the output. In case of the script you'll need to run it like this:

Code:
./aloop-record -af "volume=1.5" custom-name.wav


This will increase the volume with 1.5.

If you need to add extra options but want to keep the default name:

Code:
./aloop-record -af "volume=1.5" $output


edit: I've made a mistake in the script. Look at line

Code:
if [[ -e $1 ]] ; then $capture $*


Should be -n instead of -e

I've re-tested and updated the script
aloop-record.gz
Description  Remove fake gz extension
Click on the script to start recording to the current directory
Press q to stop recording
gz

 Download 
Filename  aloop-record.gz 
Filesize  191 Bytes 
Downloaded  20 Time(s) 

Last edited by theru on Fri 28 Apr 2017, 18:59; edited 1 time in total
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 5 [68 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Beginners Help ( Start Here)
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.1015s ][ Queries: 15 (0.0124s) ][ GZIP on ]