User talk:Balsa: Difference between revisions

From SlackWiki
Jump to navigation Jump to search
Line 164: Line 164:


Once local mail delivery works, you can setup cron jobs (see cron page on slackwiki, and man cron) and the output (if any) will be mailed to you.
Once local mail delivery works, you can setup cron jobs (see cron page on slackwiki, and man cron) and the output (if any) will be mailed to you.
== Octave: simple functions ==
Find the Octave tutorial by typing doc at the Octave command line.<br>
Navigate to * Introduction::                A brief introduction to Octave.<br>
Then go to * Simple Examples::<br>
The tutorial is quite brief, and gives few examples of functions.<br>
This page will demo how to make simple functions, and how to call one function from another.<br>
octave:11> function fn = fn ( p )<br>
> fn = p*20<br>
> endfunction<br>
octave:10> function sn = sn ( a )<br>
> sn = a * (1/2)<br>
> endfunction<br>
octave:12> function tn = tn( p, a )<br>
> tn = sn(a)+fn(p)<br>
> endfunction<br>
octave:17> function excess = excess( p, a, bs )<br>
> excess = bs - tn(p,a)<br>
> endfunction<br>
octave:18> excess(p,a,bs)<br>
sn =  517.50<br>
fn =  2140<br>
tn =  2657.5<br>
excess = -1452.5<br>
ans = -1452.5<br>
octave:28> function trade = trade ( p, a, bs, lt )<br>
> trade = excess(p,a,bs)/lt<br>
> endfunction<br>
octave:26> function newacres = newacres (p, a, bs, lt, na )<br>
> newacres = a+trade(p,a,bs,lt)<br>
> endfunction<br>
octave:36> p=107; a=1013; bs=3017; lt=25;<br>
octave:37> newacres(p,a,bs,lt,na)<br>
sn =  506.50<br>
fn =  2140<br>
tn =  2646.5<br>
excess =  370.50<br>
trade =  14.820<br>
newacres =  1027.8<br>
ans =  1027.8<br>
octave:38> p=114; a=1027; bs=3095; lt=23;<br>
octave:39> newacres(p,a,bs,lt,na)<br>
sn =  513.50<br>
fn =  2280<br>
tn =  2793.5<br>
excess =  301.50<br>
trade =  13.109<br>
newacres =  1040.1<br>
ans =  1040.1<br>
--[[User:Balsa|Balsa]] 13:17, 21 February 2011 (EST)

Revision as of 18:17, 21 February 2011

Hi.

Balsa 03:28, 3 February 2011 (EST)


ALSA

/etc/asound.names
Gives names and descriptions for ALSA hardware devices. Very useful when using arecord and its '-D, --device=NAME' command line options.

/etc/asound.conf
I do not know what this is currently.

/etc/asound.state
Ditto.

strace - handy utility to see what programs are doing. strace -e file [some program and its args if relevant] - only shows file related stuff.

arecord - ALSA utility to record sound. It's what I'm having trouble with, and is the subject of most of this page.

sox - "Sound eXchange, the Swiss Army knife of audio manipulation" - (man sox; GNU General Public License)

strace -e file arecord -v -d 5 -t au test4.au ----> <snip>
Recording Sparc Audio 'test4.au' : Unsigned 8 bit, Rate 8000 Hz, Mono <snip>
Very interesting, indeed. This gives us the default ALSA device used by arecord, in my case it was /dev/snd/pcmC0D0c. Cross referencing with /etc/asound.names doesn't get us far, because I still don't know the mappings between that file and the stuff in /dev/snd. Some speculation may be in order.

grep -i capture -B 1 /etc/asound.names -->
name 'hw:0,4'
comment 'Physical Device - ALC268 Analog (Capture)'
--
name 'plughw:0,4'
comment 'Physical Device With Conversions - ALC268 Analog (Capture)'

Hmm.

Lets try: strace -e file arecord -v -d 5 -t au -D hw:0,4 test5.au
This opens /dev/snd/pcmC0D4c, and says "Recording Sparc Audio 'test5.au' : Unsigned 8 bit, Rate 8000 Hz, Mono" but exits with "arecord: set_params:954: Sample format non available".

strace -e file arecord -v -d 5 -t au -D hw:0,0 test5.au
Same deal, but opens /dev/snd/pcmC0D0c instead. Strange, since that is the same as the default.

TODO: Look at source code. Edit: nevermind.

Let's try one more thing - that /etc/asound.names gave me an idea...
strace -e file arecord -v -d 5 -t au -D plughw:0,0 test5.au
Hot dog it worked!
open("/dev/snd/pcmC0D0c", O_RDWR|O_NONBLOCK) = 4
open("test5.au", O_WRONLY|O_CREAT|O_LARGEFILE, 0644) = 3

sox test5.au -d --> Lots of clipping, noisy.
sox au: header size 24 is too small

Input File  : 'test5.au'
Channels  : 1
Sample Rate  : 8000
Precision  : 8-bit
Duration  : 00:05.00 = 40000 samples ~ 375 CDDA sectors
Sample Encoding: 8-bit Signed Integer PCM

100% 00:05.00 [00:00.00] of 00:05.00 Out:240k [!=====|=====!]Hd:0.0 Clip:182k
sox effects: rate clipped 120593 samples; decrease volume?
sox sox: alsa: output clipped 61507 samples; decrease volume?
Done.

Aha! The recording is unsigned 8bit, but the playback was signed 8bit. How does one change this?

man sox

sox -u test5.au -d
sox formats_i: `test5.au': overriding encoding type
Sample Encoding: 8-bit Unsigned Integer PCM
OK, it plays as unsigned 8bit. Success.

Simple tests from command line

netstat - man netstat

look for services that you don't know, read their manual pages. See if the service would be better listening to fewer interfaces [like localhost]. Use the ps command to figure out what's running. Try the netstat flags "--inet -anp" and read what they mean in the netstat manual.

look at /etc/fstab

man fstab man mount

Read a security article [fixme] about this file and the options. Skim the LVM and partitions pages here on slackwiki. Read about the noexec option (don't use this without understanding the consequences)

Try "hostname --fqdn" and see what it does. Check the exim page or qmail page to see about local mail delivery. Some security tools (and other stuff too) will email you when important events occur.

Read about the sudo and su commands.

--Balsa 16:15, 20 February 2011 (EST)

Exim - local mail only - setup and testing

Setup: not written yet.


Testing / Debugging:

The following are draft quality only. ps -efw | grep -i -e exim | grep -v grep

  1. Lists running exim processes.

netstat --inet -anp | grep -i -e exim -e 25 -e mail

  1. See if anything is listening on port 25.


ls -l /var/log look for mail or exim4 directory, and mail.??? and mail.???? files.

ls -l /var/ look for mail, queue, or spool. Do a ls -l in any directories found above.

Mail might be in ~/Mail

Read the Mutt HOWTO on slackwiki.org.

Read the qmail HOWTO as well.

tail -f /var/log/exim4/mainlog (if it exists) The -f flag makes tail follow the file, so its best used on another virtual console or with screen. There are numerous guides for screen. My suggestion is to printout the most common commands on paper and keep it near your monitor.


Try the mail command out. man mail

echo "Testing local mail, sent on `date` to the local system" \ | mail -s "Test of Local Mail" username@localhost.localdomain

Note that username@localhost.localdomain may not work.

Try hostname --fqdn

look in /etc/hosts


Testing the MTA with telnet on a certain port:

telnet localhost 25

HELO localhost

MAIL FROM: username@localhost.localdomain

RCPT TO: username@localhost.localdomain

DATA

SUBJECT: Testing mail via telnet

This is the message body.

Check if it worked with your favorite mail reader or by looking in the files listed above. End message body with a "." on a line by itself. .

QUIT


Once local mail delivery works, you can setup cron jobs (see cron page on slackwiki, and man cron) and the output (if any) will be mailed to you.

Octave: simple functions

Find the Octave tutorial by typing doc at the Octave command line.
Navigate to * Introduction:: A brief introduction to Octave.
Then go to * Simple Examples::
The tutorial is quite brief, and gives few examples of functions.
This page will demo how to make simple functions, and how to call one function from another.

octave:11> function fn = fn ( p )
> fn = p*20
> endfunction

octave:10> function sn = sn ( a )
> sn = a * (1/2)
> endfunction

octave:12> function tn = tn( p, a )
> tn = sn(a)+fn(p)
> endfunction

octave:17> function excess = excess( p, a, bs )
> excess = bs - tn(p,a)
> endfunction

octave:18> excess(p,a,bs)
sn = 517.50
fn = 2140
tn = 2657.5
excess = -1452.5
ans = -1452.5

octave:28> function trade = trade ( p, a, bs, lt )
> trade = excess(p,a,bs)/lt
> endfunction

octave:26> function newacres = newacres (p, a, bs, lt, na )
> newacres = a+trade(p,a,bs,lt)
> endfunction

octave:36> p=107; a=1013; bs=3017; lt=25;
octave:37> newacres(p,a,bs,lt,na)
sn = 506.50
fn = 2140
tn = 2646.5
excess = 370.50
trade = 14.820
newacres = 1027.8
ans = 1027.8
octave:38> p=114; a=1027; bs=3095; lt=23;
octave:39> newacres(p,a,bs,lt,na)
sn = 513.50
fn = 2280
tn = 2793.5
excess = 301.50
trade = 13.109
newacres = 1040.1
ans = 1040.1

--Balsa 13:17, 21 February 2011 (EST)