You are on page 1of 10

Sounds and Code

Jonah Franchi 4/10/10


Abstract The goal is to show how to use linear algebra to take a sound matrix, transform it into a square matrix, and randomize it so it is incomprehensible. Once randomized it must be able to be brought back to its original state so that the message can be received.

Introduction

Ok so in nature there are many things that can be described with vectors and matrices. Gravity, light, and sound are among a few of these things. Anything that acts with a magnitude and direction can be expressed as a vector i.e. gravity on earths pulls an object towards the center of the earth with a force of 9.8 Newtons per kilogram, so the vector gravity creates when acting on something with a mass of 10 kilograms would be 98 Newtons(the magnitude) in the direction of the center of the earth(the direction).

1.1

Sound

Sound also creates a vector and depending on the pitch and duration of the sound the vector will have dierent properties. Sound vectors are always nx1 where n can be any length.

Arnolds Catmap

A famous linear algebra equation is called Arnolds Catmap. The formula for this equation is : (x, y ) (x + y, x + 2y )mod(n) By putting this equation into vector form we get x y 1 1 1 2 x y 1 1 0 1 1 0 1 1 x y (1)

mod(n) =

mod(n)

(2)

What this equation does is take a nxn image matrix and stretch the image in a certain manner. Once it has been stretched the image is then sheared and each sheared piece is placed back into the the same nxn matrix. By continuing to run a matrix through this equation and image which begins to look very chaotic and lose all resemblance to the original image will, when ran through enough, return to the original image. The advantage of this could be that a message sent as an image would be able to be skewed beyond recognition and then reassembled only by the people who know how to.

Problem

While this method is a convenient way to hide a message in an image the problem is that it only works on a square matrix. My interest however is that I wish to do the same thing to a sound matrix which is by no means a square matrix. In fact a sound matrix creates a tall skinny matrix. Image Matrix x1 x2 xn y1 . . . . . n1 nn Sound Matrix x1 y1 . . . n1

This poses a problem if Im going to use the Arnolds Catmap equation to try and throw a sound matrix into chaos.

My Solution

The only way I can do it to turn my sound matrix into a square matrix. The way I will do this is to take the square root of the number of rows in my sound matrix and then nd the closest perfect square larger than my number. i.e. Sound matrix with the dimensions 101x1 so the square root of 101 is 10.05 so I round 10.05 up to 11 and then square it so my new number is 112 or 121. Now that I have that number I can add 20 zeros on to the end of my sound matrix so that it is a perfect square. Using Matlab I can cut my sound matrix into 11 sections and place them side by side so that I end up with an 11x11 matrix. Since it is now a square matrix it is now possible to run the matrix through the catmap. Since there is no equation for the relationship between the period and n(the amount of rows and columns) the only person who will know how many times it will take for the catmap to return the sound to normal o hand would be the sender. Therefore unless the sender wants to make it more dicult to crack they should also tell the recipient the period. Once the square matrix is back to its original form I will take that matrix and use Matlab to place each column of the matrix back into a single column and then by removing the zeros at the end of my matrix I will be left with the original sound matrix. By doing this procedure I will be able to produce my original sound matrix which when played will be comprehensible (assuming that the original was).

Example

A sound matrix is a tall and narrow matrix. Because of that I will be unable to display an example of this process in this section, and will only be able to do so on Matlab. To help explain the process a little better though I will give an example with a much smaller matrix. Now with Arnolds catmap what happens is each component of the matrix is shifted to a dierent spot within the same matrix. So suppose I have a matrix with the dimensions of 124x124 (I chose this because I already knew the period) and I want to look at how the component in the 10th row and 56th column moves when irritated. Irritation 1 x y = 1 1 1 2 56 5 mod(124) 56 + 5 56 + 2 5 mod(124) 61 66

That is step by step how the rst irritation is made. What mod does is it divides the number by your mod number and then places the remainder into the new x,y matrix. Irritation 2 Irritation 3 Irritation 4 Irritation 5 Irritation 6 Irritation 7 Irritation 8 x y 53 + 106 53 + 2 106 5 mod(124) 35 17 x y 0 + 53 0 + 2 53 mod(124) 53 106 x y 71 + 53 71 + 2 53 mod(124) 0 53 x y 106 + 89 106 + 2 89 mod(124) 71 53 x y 72 + 17 72 + 2 17 mod(124) 89 106 x y 3 + 69 3 + 2 69 mod(124) 72 17 x y 61 + 66 61 + 2 66 mod(124) 3 69

Irritation 9 Irritation 10 Irritation 11 Irritation 12 Irritation 13 Irritation 14 Irritation 15 x y 107 + 73 107 + 2 73 mod(124) 56 5 x y 17 + 90 17 + 2 90 mod(124) 107 73 x y 68 + 73 68 + 2 73 mod(124) 17 90 x y 63 + 5 63 + 2 5 mod(124) 68 73 x y 121 + 66 121 + 2 66 mod(124) 63 5 x y 52 + 69 52 + 2 69 mod(124) 121 66 x y 35 + 17 35 + 2 17 mod(124) 52 69

So after 15 irritations the component of my matrix will have returned to its original position. That means that for any component of a 124x124 matrix after 15 irritations it will return to its original place in the matrix.

Code

The reason I wont actually show an entire sound transformation is because it is extremely large and would be very dicult to actually t it onto a paper or on a slide. Luckily because of computers I am able to write code to do all of the transformations for me without having to do each by hand. It also allows me to run the same process over and over on any sound matrix without having to redo everything.

6.1

Building a Square Matrix

function b=testbuild(sound) s=size(sound); S=s(:,1); n=ceil(sqrt(size(sound))); k=n(:,1); b=zeros(k,k); z=k^2; x=size(sound); y=x(:,1); a=z-y; q=zeros(a,1); A=[sound;q]; for i=1:(k-1) b(:,i)=A((i-1)*k+1:k*i); end Using this code I create a square matrix of nxn where n=the square root of the size of my sound vector rounded up to the next integer. It then places the rst n amount of terms from my sound vector, with enough extra zeros on the end to make its new size be n2 , and places them in the rst column of the square matrix. It then places the 2nd n amount in the 2nd column, 3rd in the 3rd and so on until it has completely generated a square matrix.

6.2

Using The Catmap Transformation

function A=catmap(X) s=size(X); n=s(:,1); A=[]; for i=1:n for j=1:n

Z=[i;j]; x=Z(2,:); y=Z(1,:); T=mod([1 1;1 2]*[x-1;y-1],n)+[1;1]; a=T(1,:); b=T(2,:); A(b,a)=X(i,j); end end This code takes my newly generated matrix and uses Arnolds Catmap transformation on it. Depending on how large the period of the matrix is I may have to repeat this step quite a few times. For example my sound example austinmail has a period of 200 so in order to return to the original i have to use this function 200 times.

6.3

Returning to a Sound Matrix

function sound=recreate(A) sound=[]; t=size(A); k=t(:,1); for i=1:k sound=[sound;A(:,i)]; end Now that the square matrix is back to its original form I needed a way to take every column and place them on top of each other into a single large column matrix. This is the code that I used to do that, it takes every column in order and places it in the matrix, then it places the next column underneath the rst one.

Conclusion

By using all of these codes any sound can be placed into them to run the transformation. The only problem I have with this is that I have no means of writing a code to tell me the period of the matrix, given my current knowledge of MatLab. Unfortunately this means I must go through the transformation until my transformed matrix minus my original matrix equals a zero matrix with size(n) and then count the number of irritations manually. The rst part could be done with a loop but Im unable to have it spit out the amount of times it goes through the loop. This is, by no means, a idea for advanced codes. It is simply an interesting idea I thought of as something to be entertaining in spare time or to make yourself feel clever and send messages that nobody, except people you chose to tell, would be able to gure out.

References
[1] http://homepages.udayton.edu/ hardierc/ECE203/sound.htm [2] http://www.faqs.org/docs/sp/sp-148.html [3] http://www.freeaudioclips.com/ [4] http://mathworld.wolfram.com/ArnoldsCatMap.html [5] http://en.wikipedia.org/wiki/Arnold [6] http://en.wikipedia.org/wiki/Modulo [7] http://online.redwoods.cc.ca.us/instruct/darnold/LAPROJ/Fall97/Gabe/catmap.pdf

10

You might also like