User:Eleanorg/Thematic1.1/11 Oct Terminal Session 2

From XPUB & Lens-Based wiki

sed For substituting one word in a text file for another. You can then write the output to a new text file. For example script see /bin/markov.sh

markov chains For generating probable text using statistical analysis of the input text. A useful program using markov chains is dadadodo, which will do the desired generation for you from a file of your choice.

w3m Simple way of grabbing content from a file or website. See /bin/w3m.sh for an example.

mplayer myfilm.mp3 (opens mplayer and plays myfilm with it) OR mplayer - (reads from std in - ie, it will play whatever comes in. Mplayer no longer controls what is is playing - this data comes from another program (eg cat) which is in control.)

cat myfilm.avi | rawvideo.sh Here myfilm.avi is piped into mplayer by cat. It could be piped in by any program which outputs info through std out (eg 'echo', etc.) - the output will be immediately captured by the pipe. Rawvideo.sh is a script which configures mplayer to accept raw video input, allowing it to 'play' a text file. (see /bin/rawvideo.sh)

dsp what is it?

BITS

1 bit space

0 = 0 1 = 1 You can count up to 1

2 bit space

00 = 0 01 = 1 10 = 2 11 = 3 You can count up to 3

3 bits

000 = 0 001 = 1 010 = 2 001 = 3 100 = 4 101 = 5 110 = 6 111 = 7 You can count up to 7

In 8 bits, you can count up to 256. 8 bit music sounds crunchy, using these 256 options. Modern computers use 32 or 64bits

ASCII TABLE

List of characters understood by the computer.

Each has a binary code and a value (ie name). Not all of them appear on the screen - eg CR (Carriage return).

Original ASCII table was 7-bit - each binary code was 7 digits long, and allowed for 127 characters total. This was replaced with the modern 8-bit table (255 characters). This too was felt to be restrictive as it can't include every symbol. Rather than adding more bits, UTF was introduced.

8-bit ASCII is still used in programming - it's built into C for example. A for loop counting in increments using ++ will go up to 256 before starting again.

BIT-WISE OPERATORS AND OR XOR

BITSHIFTING

You can bit-shift right (>>) or left (<<). For example: 00010111 LEFT-SHIFT = 00101110

00010111 RIGHT-SHIFT

= 00001011

You can make music purely by bit-shifting in this way, if you pipe the output of this program to mplayer (using the rawaudio.sh program written earlier). It's a trend, you can find lots of one-line C programs that make this music - eg at http://pouet.net/topic.php?which=8357

PROGRAMMING IN C

Save with .c extension (but not important) and save anywhere. To make executable run this command as root: gcc myprogram.c -o programname

To run, type the name of the program (if working dir is same as one program is stored in), or ./programname if you're in another directory or logged in as another user.