Archive for January 14th, 2013

Linux record audio from console / terminal with rec, arecord and ffmpeg

Monday, January 14th, 2013

 

Recording sound input from microphone linux penguin holding microphone

Recording from microphone input on Linux is possible, through multiple programs.

1. Recording microphone input using SoX's rec

 The classical old-school way is through a little proggie called sox. Back in the day I remember we recorded with sox with a friend from the school years necroleak – mirror of his website is on kenamick.www.pc-freak.net, trying to make save vox for one of his Tracked Songs. The experiments was not very succesful as both the PC microphone was low quality one, as well as the the state of recording microphone sound streams on Linux was terrible, but at least I learned about sox.

sox is not so popular and mainstream as it used to be back in the day but for anyone willing to investigate into the roots of GNU / Linux sound capturing make sure you have installed sox, alsa-utils and lame package. The package is available across virtually all main stream Linux distributions, depending on the distro to INSTALL sox do:

 

apt-get install --yes sox alsa-utils lame 
....

 (On Debian, Ubuntu, Arch, Xubuntu … )

yum -y install sox  alsa-utils lame
....

 (on Fedora, CentOS, RHEL …)

 slapt-get install sox ; swaret install sox alsa-utils lame
.....

(on Slackware and derivatives)

Before continuing it is a good idea to check, the microphone is not muted in alsamixer, amixer or aumix

The SoX package provides 4 binaries;

dpkg -L sox|grep -i /usr/bin/
/usr/bin/sox
/usr/bin/rec
/usr/bin/play
/usr/bin/soxi

sox -is tool to apply effects to recorded sound streams

rec – is historically among the first sound recorder tool to make records from microphone (even form the days of OSS – Open Sound System)

play – play is tiny .WAV and some other native classical sounds formats with a beautiful ASCII art (text) equalizer

soxi – gives information on recorded sound stream header (info)

rec -r 8000 -c 1 record_microphone_input.wav

rec is unfortunately made to use the old and now obsolete /dev/dsp sound interface, so on many Linux distributions, recording sound with it might pose problems.

Another problem of rec is it usually records with a lot of noise, thus reducing the noise later with sox cmd is almost necessery, to mitigate the noise you will have to experiment with its options. For some better quality of recording use arg -r 22050.

A little shell script with plenty of example use cases of rec and post sox effect applied as synchronization record_and_normalize_from_mic_with_rec_and_sox_on_linux.sh is here

Generally I mentioned rec for historical reasons, nowadays it is quite obsolete so you probably better stick to the newer alsa native arecord.

2. Recording sound from microphone using alsa-utils arecord

alsa-utils package has bunch of tools to record, play and tune sound;

dpkg -L alsa-utils |grep -i /usr/bin/
/usr/bin/aplaymidi
/usr/bin/aplay
/usr/bin/aconnect
/usr/bin/amixer
/usr/bin/alsamixer
/usr/bin/aseqdump
/usr/bin/arecordmidi
/usr/bin/speaker-test
/usr/bin/iecset
/usr/bin/amidi
/usr/bin/aseqnet
/usr/bin/arecord

One of tools included arecord is able to capture sound from microphone. arecord, can record into .WAV, but as .WAVs are not compressed and most people prefer to save the input to some more wide recognized format as .MP3 it should be invoked in conjunction with lame;

arecord -D plughw:0,0 -f S16_LE -c1 -r22050 -t raw | lame -r -s 22.05 -m m -b 64 - mic-input.mp3


Writting this long and hard to remember command line and arguments is tough, so I created a tiny shell script wrapper which accepts as 1-st argument a file name and saves .WAV and converts it to .MP3. The script linux_record_from_microphone.sh is here

3. Recording from microphone input using ffmpeg

I've earlier blogged on how to use ffmpeg to capture Microphone sound here.

For those lazy to read my previous post the skele syntax is;

ffmpeg -f alsa -ac 2 -i pulse -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 -y myVOICE.wav 

To later convert WAV to MP3 use lame;

 lame -r -s 22.05 -m m -b 64 myVOICE.wav  mic-input.mp3

People Living in 2-nd and 3-rd world country are spiritually blessed – Why we should be thankful to live in a Developing Country

Monday, January 14th, 2013

Orthodox Christian countries blessed, Undeveloped countries more blessed than developed ones, ortodox priest blessing the blessing of the Eastern ex byzantion empire countries

Nowadays, every country under development from the so called 2nd and 3rd world countries is trying to follow after the United States, Japanese and the European Union Western World countries (Germany, France, Holland) developed economies. People in many countries like my motherland Bulgaria are not happy for the life they receive in their home land. There is such situation in so many countries nowadays. Many musicians sung a lot of songs about the prosperity of westerners like for example Jim Morrison – who was singing – "The West is The Best" in The Doors song "THE END". A lot of the modern culture in 2nd and 3rd world countries is singing and following the trend of the Western Art and Songs. But is it really true, that on the West they're more happier or more blessed?  Is the Western life so good and worthy as most people thing?

First thing among western developed countries is the development of technology. Technology use and implementation is in much higher level compared to under-developed countries. Part of technologization is wide use of Internet and connectivity to it as well as all kind of gadgets that somehow use the Internet for their daily operation. In practice Internet is part of the daily life of virtually every Western inhabitant in age 8 to 60. This trend is also spreading in Eastern Europe and is slowly changing the people their too. However still the amount of technology use in East is little compared to West.

From purely spiritual point of view the Internet (though can be used for a spiritual purpose and is now helping people a lot in their life) is changing completely the essence of life, making people dependent on the World Wide Web. Making them less and less attached to the normal relations person to person which used to be main thing in existence since the creation of the world.
In countries where the Internet is slower and they can't watch youtube (India, Pakistan) this simply means less people will spend big chunk of their time consuming youtube videos but likely spend a bit more time with friends and relatives or in best case in Church praying for themselves their relatives and the whole world. Thus from a spiritual standing less developed countries are in more blessed situation.

Also in western world life is so complex, making achieving unity with Christ very hard  – according to Divine Theology God is easier to find in simplicity. For citizens living in Western developed countries nowadays having a touch of true genuine Christian spirituality is harder to achieve and most of people in Western Countries, though possessing humanitarian kindness are lacking any spiritual deepness.

Thus my assertion is, we people from Bulgaria, Romania, Ukraine, Russia and other poorer and even less undeveloped ones like India, Iraq, Syria, Somalia etc. should be thankful to God for being the opportunity to live in a simple countries with less material goods but deeper spirituality. We the poor country inhabitans have much more opportunities to pray and hope on God's mercy and live a humble life in Christ.

Even in business, people are starting to realize "Less is More", the simple the life is the better.
As we Balkan inhabitants has much more worries and concerns and misfortune than westerners means simply we are more likely to look for God's help than our well fed and educated Western fellows.
Here in Western world most people have too many opportunities for entertainment and ways to spend their time good and forget about the bad in the world. Though from one side it is good and easy life, from another (spiritual) angle it is pretty much like closing your eyes for death, suffering and bads that happens in World.

With high degree of Computerization in the West, it is my understanding whether one is behind the Computer Screen / Mobile / Tablet screen you can only help people "Virtually" by speaking to them and can't physically support them. I will not mention about the many health troubles a physical inactivity causes us. Also by having this well developed social system in countries like Holland and France this takes away one's opportunity to meet the poor and suffering beggars. Thus one's heart cannot be touched by the suffering in the way it is touched when you leave in a society with poor, hungry and suffering on streets.

All this means paradoxically, countries, which want to have the blessing of consumerism that has took over developed countries, are now more spiritually blessed and spiritually richer than developed ones. However pithily majority of people in undeveloped countries are un-thankful to God for their blessing, but looking after the imaginary and temporal worldly well being that is now in west. I hope we the Eastern people will realize our mistake and take time, and start enjoying our life in our homelands with thankfulness in our hearts to God for we are wealthy in spirit.