CodeSimian (other website: http://sourceforge.net/projects/codesimian) is a great audio synthesis program, but I started it when I was a college student, and now that I have a Masters degree in Computer Science and some work experience, I have started a new open-source program (Audivolv, which means AUDIo eVOLVe) for a similar purpose, and is more advanced at combining Artificial-Intelligence with audio synthesis. CodeSimian is not dead because Audivolv will have a CodeSimian plugin, and/or you can continue its design under GNU GPL 2+ open-source license(s). --Ben Rayfield

Audivolv - where Instruments Play The Musicians

* AI synthesizes music, and learns to control Human's hand on mouse.
* Human moves mouse, and learns to control synthesized music.
* AI translates music problems to programming problems, organizing Humans unconsciously through internet to build AI.

codesimian@audivolv.com

free MP3s recorded of codesimian: fractalSound1.mp3 b.mp3 c.mp3 d.mp3 but its more fun to create your own... Click "sound of your computers screen pixels around your mouse" and any paint program becomes a musical instrument. Every picture sounds different. Draw, blur, push, mutate, etc while the sound of the screen pixels plays like a record needle scraping over a rectangle around the mouse from left to right then top to bottom. Brightness of the pixel is height of the record surface. It repeats approximately 2 times per second, but that may change.

Start CodeSimian NOW (applet)

limited by internet security,
not all parts of CodeSimian work here.
Requires Java 1.5 and 2 ghz CPU
Sound skips on cheap sound cards.

Download CodeSimian NOW (JAR file)

WORKS BEST. click OPEN,
or click SAVE then double-click CodeSimian.jar
Requires Java 1.5 and 2 ghz CPU
Sound skips on cheap sound cards.


CodeSimian.jar

is a programming-language (program that builds programs) for creating advanced sounds from simple equations+MP3s and theoretically designed to build and evolve Strong Artificial-Intelligence and Artificial-Life, thats so easy that ANYBODY (including programs) can use it to build computer-programs.

Intro/Tutorial | SourceCode | FAQ? | ListOfCommands | ~~Sounds/Audio (generated by equations)~~ | Microphone | PlayElectricGuitarWithTheMouse | FREE MP3s (play and modify them with CodeSimian) | Pictures | Javadoc/TechnicalDocuments | CompareToJava | Plans (what to build) | RootClass | 1 Type | SystemReq | Humans | DNA | Bugs/Flaws | WIKI of CodeSimian code | Def | Contact




[skip to the 6 steps]

You might think you will never understand computers without a brain transplant, but ANYONE can build software (computer programs) in 6 easy steps! Or synthesize music in a few more steps, as any combination of: MP3s, equations, mouse, keyboard, microphone, electric guitar (plug into mic hole). Or in less than an hour, you can build your own games (unlimited modifications of existing C.S. games). Anyone can build simple unique software, and it will be on your screen in 2 minutes if you use the summary (1-6) below. Custom software to-go. Your total is $0.00 Please drive around to the second window...

made with pure Java

    (Java vs CodeSimian)




software builds software
faster than Humans can build software...
and when the WIKI of code is created,
it will also build smarter-than-Simian software...


GNU GPL 2+ licenses - FREE (as in free speech) to use, modify, and distribute. The executable file (CodeSimian.jar) is the same file as the source-code (rename it to source.zip) This first CodeSimian costs no money. GPL does not prevent selling, but its rules about keeping code secret usually make it impractical.

Do the 6 steps below to build your own software. CodeSimian has many abilities that you combine by writing short codes.


Summary (1-6): Open CodeSimian.JAR. Replace text with ask("some question?") and click compileCode.
To make it unique, for example, ask(about anything else...) or if( ask("again") ask("ok asking again") )
It can be as simple or complex as you want.

(1) Download CodeSimian.JAR   (What is a JAR file?) (DETAILS of step 1)
(2) Find and double-click CodeSimian.jar (
skip this step if you click OPEN in step 1) (DETAILS of step 2)
(3) A window with title "selfReplicating..." appears. If not, install Java 1.5 and try step 2 again. (DETAILS of step 3)
(4) Click Erase_Text. (If you skip steps 4 and 5, it will instead build another "selfReplicating" window) (DETAILS of step 4)
(5) Type ask("any text here") into the "selfReplicating" window. ask("or for different buttons" try this instead) (DETAILS of step 5)
(6) Click compileCode (in the "selfReplicating" window) then what you built appears on your screen. (DETAILS of step 6)

ask("some question")


CodeSimian is a member of (codesimian.sourceforge.net), the biggest collection of FREE OPEN-SOURCE software ever (159,332 softwares 10/2007), organized by many properties of the softwares. I plan to connect CodeSimian to many softwares, because an artificial-intelligence needs things to play with so it can learn.

(7) Look at these examples() of CodeSimian code and what they build...

ask(type anything here you want...)


window#small_compiler(
	splitPane(
		button#compile_code(do(
			compile#c(0 textarea#t)
			PZ(c 0)
		))
		scroll(t)
	)
	300
	245
)
If you copy/paste that code into the window generated by that code and click compile_code, it will build a copy of itself.

ask('Do you have a small pianist?' 'No' 'Yes' 'Whats a piano?')


code is in file: puyo.cs

ask("What is George W Bush?" "King Bush II" Liar Terrorist)

Of course you can find out which button was clicked. The question is asked again every time you click YES. Click NO to end it...

if#x(ask("repeat this question?") x)

Or do more complicated things. Same as above except plays a.mp3 when it stops repeating... but dont worry, theres more easy examples below... They're not all in order of difficulty...

if#x( ask("repeat?" "play a.mp3" "repeat the question") x sound(mp3("http://codesimian.com/a.mp3")) )

Almost same as above except shorter......

if#x( ask("repeat?") x sound(mp3("http://codesimian.com/a.mp3")) )

This window (and the code() inside it) appears when you double-click the file CodeSimian.jar (or click OPEN). It contains all code needed to build a copy of itself. Click the compileCode button to use whatever code is in the window. Of course, you can modify the code before you click compileCode, and a modified window will appear.


The files_inside_CodeSimian.jar window is built inside the above window. It appears when you click SAVE_and_LOAD_files...


Click any filename in files_inside_CodeSimian.jar and that file is loaded into the selfReplicatingWindow where you can edit and/or use it. Click SAVE and CodeSimian will ask you where to save CodeSimian2.jar, the modified version of CodeSimian you just created...

CodeSimian is a JAR file that creates unique JAR files with unique appearance and behaviors. You can build it into your own program.


This short code creates a button that turns the whole CodeSimian off when you click it, including all open windows and playing sounds.

To turn it off immediately, use this code: method#java.lang.System.exit(0 0 0)

You dont need to know why this works to use it. Just copy it into any of your own programs...


window#X(button#Exit_CodeSimian(method#java.lang.System.exit(0 0 0)) 120 70)


(8) You will see pictures of CodeSimian on this website, often near the code() used to build what is shown in the picture. Learn to use the code you find on this website (not just the short ask code above)... Repeat step 4. Copy (and paste into CodeSimian with keys ctrl+V) some of the more complicated code from this website into the window. Repeat step 6. Then something appears on your screen, plays sound, or whatever the new code tells it to do...

To "copy" code, select it with the mouse, right-click it, and click copy. Or use ctrl+C. Paste is the opposite of copy. Copy to get, paste to put. ctrl+V means hold the ctrl key and push v, when the text cursor is in CodeSimian. In most programs, you can paste with ctrl+V.

window(slidebar(.3) 300 75)     <-- copy and paste this

Play and modify some MP3s...


sound(mp3("http://codesimian.com/a.mp3"))
(plays a.mp3 at normal speed)

sound(mp3("http://codesimian.com/a.mp3" *(-2.2 count)))
(plays a.mp3 backwards at 2.2x speed)

if(ask("play a certain mp3 on your hard-drive?") sound(mp3("C:\\music\\yourfile.mp3")))
(plays yourfile.mp3 only if you click YES)


Plug your microphone or electric-guitar into the microphone hole:



sound(microphone)
(simplest microphone code, plays it on speakers at normal volume)

sound(*(10 microphone))
(plays microphone on speakers at 10x volume)

sound(sine(*(40 microphone)))
(wraps 40x extra volume around a sine wave, adds oscillations to the sound)

sound(+(mp3("http://codesimian.com/a.mp3") microphone))
(plays microphone and a.mp3 together)

Try inserting mp3("http://codesimian.com/a.mp3") and/or microphone in random places in sound codes, and see how it sounds. I've designed CodeSimian to do interesting things even with random code.



Download this sound, or use the code below to generate it.
sound(sine(*( /#div(count#c 44100) +(div 135 *(6 sine(c))) )))
To stop the sound, run this code: sound(0) and if that doesnt work, read How to stop the sound.txt
More example sounds or the sounds page

Play a game (its like Tetris) made with CodeSimian. The code is in file: puyo.cs
To make CodeSimian.jar smaller, the pictures red.jpg blue.jpg yellow.jpg green.jpg and black.jpg have been removed from CodeSimian.jar. If you want the blocks to have pictures, then run CodeSimian.jar in the same folder as any pictures with those names. Whichever pictures it does not find, it displays as a solid color predicted from the file name of that picture.

(9) Learn how ( and ) connect the parts of code together. In the code:
x(y(w) z) , x contains y and z, and y contains w.
if(
     ask( "is your operating system Windows XP?" )
     if(
         ask( "open control-panel?" )
         commandLine#zzz( "control panel" )
     )
     if(
         ask( "then I dont know if it will work. Try anyways?" )
         zzz
     )
)
That code asks a question, and depending on your answer, executes one if() or the other if(). Each if() contains an other question, and if the answer is yes, opens control-panel.
zzz is the name of that commandLine object. zzz is in 2 places at once.
You can put any type of code together with almost any other type.
Each piece of code must contain some number of other other pieces. For example, if() must contain 2 or 3 things, and ask() contains 1 or more. The
list of commands tells how many things each command uses.


window(splitPane(
	horizontal(
		button#someButton
		mousePanel
		splitPane(
			horizontal(slidebar slidebar#x(.37) slidebar)
			horizontal(slidebar slidebar slidebar)
		)
	)
	horizontal(
		+(1 /(x 3) x)
		button
		slidebar
		mousePanel
	)
))
(10) If you want more examples of code, there are hundreds of .cs files inside CodeSimian.jar. To get them, use Winzip to open CodeSimian.jar. Example: CodeSimian.jar/cs/SelfReplicatingWindow10.cs

What can you build with CodeSimian? Many things, the best are sounds built as equations of time vs wave-amplitude, code that lets you play electric-guitar with the mouse, bayesian artificial intelligence, and a game thats like Tetris but color of the blocks matters more than shape. CodeSimian can be as simple or complex as you want.



(11) After you learn by example, build your own software... You will need the list of commands. Build something awesome...



What is code? Code is used to create software.
Code comes in different varieties called programming-languages.
Code is a sequence of letters numbers and other symbols that define computer behavior, like +(2 3 4)
Examples of code below...


01110001011101101? Not unless you want to!
Today most programming-languages allow you to write an entire program without any math!
This is the short code for a Java software: class X{ public static void main(String args[]){ if( args[1].equals("showIt") ) System.out.println("Show this on the screen"); } } Programming-languages are becoming closer to spoken/written languages (like the one you're reading now) every few years. Eventually they will merge, but before that, there must be transition languages between technical and vague. CodeSimian will become such a language...




shortest code
that plays a sound:


sound(sine(count))

plays sound at 30% volume (* is multiply):


sound( *(.3 sine(count)) )

code that skips ahead 1 second of the sound, because there are 22050 sound samples per second, 22 khz:


sound(sine( +(count 22050) ))

code that only starts the sound if you answer yes:


if( ask("play the sound?") sound(sine(count)) )

4 lines of code that plays
a fractal sound on the speakers:


sound( sine( *(
	/#div(count#c 44100)
	+( div 135 *(6 sine(c)) )
) ) )

This code shows what count and # do:

It looks like p divided by p equals 1, but p's value changes as c changes.
/( +#p(count#c 14#num c c num c) p )
is calculated this way:
/( +(0 14 1 2 14 3) +(4 14 5 6 14 7) )
...
/(34 50) equals 0.68, not 1.0


Sounds generated by equations (and sometimes by moving the mouse)


?

download the fractal sound that short code above plays

The most interesting parts of the first sound have low frequency and volume, so listen very closely if you have cheap computer speakers. The next 2 sounds have better frequency distribution, but I dont know if they have any fractal parts.

? Download sound 2   (right-click, save target as)
? Download sound 3

There are many more sounds, but currently they're not on this webpage. They're in equations in files ending with .cs (means Code Simian), which can be found inside CodeSimian.jar when you open it with WinZip.


Go to the
Sound/Audio Section, where sounds are generated by equations of wave-amplitude vs time.

Even if you know NOTHING about computers, you can still build sounds like these.

To start, Download CodeSimian and copy/paste any of the code you see on this website into CodeSimian.

Or with a little more skill, you can build many other things. CodeSimian is a tool for building software. Usually CodeSimian builds software, uses it, then discards it. But you can save the software you or CodeSimian creates.
Each sound is the output of a small software I typed into CodeSimian.
The code for the first sound is the fractal sound above.


Unlike most programming-languages, CodeSimian has no static TYPES or PRIMITIVES (except for JAVA's),
and its RUNTIME TYPES are turing-complete flexible and are FUZZY instead of true or false,
which means you could use artificial-intelligence to generate an object of a certain type.

The last 2 of the 3 sounds above were created by (the old version of) these windows:


The last 2 sounds were created using (an older version of) this code and the window it brings up: x y m1 and m3 are controlled by the mousePanel object because they are in its paranthesis. They are also other places, a graph shape of code. For speed, I turned off the infinite-loop-protection on this equation, so it cant have CYCLES in the graph. Wave amplitude, calculated 44100 (or 22050) times per second, range -1.0 to 1.0, equals the do(...) in the sound(...)

CODE THAT SOUNDS LIKE ELECTRIC-GUITAR DISTORTION AS YOU MOVE THE MOUSE... BUT YOU MIGHT NEED TO ADJUST THE NUMBERS A LITTLE TO GET IT TO SOUND RIGHT ON YOUR SPECIFIC COMPUTER... BEWARE: THIS SOUND IS COMPLEX SO IT RUNS SLOW...

do(
	window#play_electric_guitar_with_mouse(
		mousePanel(.5#x .5#y 0#m1 0#m2 0#m3)
		300 200
	)
	sound#snd(do(
		=D(1#a +(1#d *(5 1#c d x)))
		=D(1#b +(b *(.01 y)))
		=D(c delay( sine(*(a 5)) 7) )
		=D(d delay( sine(*(b 5)) 4) )
		if(m1 =D(d delay( sine(*(d 5)) 8) ) 0)
		=D(c delay( sine(*(c d .5)) 9) )
		=D(c +(c d *(b .037)))
		if(m3 =D(c +(c 2 delay(d 44))) 0)
		=D(1#e sine(  delay( delay(c *(.003 d b x)) 7 )  ) )
		sine(*(e  delay(e 2) delay(e 63)  ))
	))
)

The inner do(...) returns the value of its last object, sine(...), which sound(...) plays.
Play the electric guitar... The code above builds a guitar window.

CodeSimian has a microphone/audio-input ability. Theoretically (until I find one and try this) a real electric-guitar could be plugged into the microphone hole of a computer. The numbers from the microphone hole are mixed with CodeSimian code, and you hear your guitar play ways you've never heard before, adjustable with the mouse and keyboard, evolvable artificially-intelligent audio...

When more code is finished, CodeSimian could easily become the most popular way to do guitar-distortion, because you can mix intelligence with the sounds. For example, you can hear the sound of bayes-nodes learning to predict the sound you're playing.

You could still use normal (EXPENSIVE AND HARD TO SET UP) guitar distortion equipment if you like to play music that way. The outputs from that equipment would be the inputs to codesimian, which outputs an audio signal back to some other equipment. Your computer becomes one of the distortion modules.

Currently CodeSimian only supports mono sound 22 khz for input and output, but that will be fixed. Plug 2 headphone plugs into the microphone and speaker holes in your computer. Get those adapter wires so the other ends are the type that plugs into your guitar distortion equipment.

1/2007 the microphone() command works, but still has a lot of bugs. I'll fix it... Example codesimian code to amplify your microphone 3 times: sound(*(3 microphone))



Parts of CodeSimian's default compiler (not shown in picture) were built with CodeSimian language itsself, and that compiler can be changed and used from inside CodeSimian code at runtime. Its syntax can change at runtime by adding to or replacing some of the standard compiler's parts.

SOME VIRUSES ARE LEGAL
AND YOU MAY WANT TO GET INFECTED

GNU GPL is a virus made of legal text, the same way that "say this sentence to all your friends" is a virus. Also, if a program p is licensed by GNU GPL, and you combine p with program x, then x becomes licensed under GNU GPL, but you may have violated x's license. An example of x is that Jar file being saved in the picture above. GNU GPL is a great virus. Get infected, get your friends infected... add to the GNU GPL gene pool and evolve something... Now 9/2/2007 http://sourceforge.net has 68848 GNU GPL'ed softwares (9/2/07 http://freshmeat.net has 22882),
Its a virus in legal text, not a software virus, but only programs combined with any part of codesimian (or other GNU GPL'ed software) are infected.



CodeSimian is an interpreted-language made with Java, and Java is interpreted too, so its double-interpreted, which gives it incredible flexibility (and slowness). An example of that flexibility is its ability to have many varied compilers and syntaxs. Currently (12/05) theres 3 parts to the compiler and 1 default way to put them together, but you could put them together in combinations with other objects created at runtime to make some strange syntax.

CodeSimian starts with a simple window containing the code to create an identical window. You can modify that workspace before you start programming by changing that code and clicking that compileCode button. New similar windows pop up that you can type code into.



Rapid Application Development (RAD) of the development environment itself


Every GUI object you see in there is a CS (the one root class) object and can be added as numbers or displayed on the screen by the same process.

it can change and replicate:



There is no specific showGUI() call. The window appears when the WindowCS object is EXECUTED. All CSs can be EXECUTED. Executing is their main function. Add.D() returns a double number and Add.F() returns a float, sum of its parameter CSs (abbreviation param or P).

Because there are no TYPES in CodeSimian language, GUI objects like slidebars can be used in equations. A slidebar, when used like a number, equals a value between 0.0 and 1. When you move it with the mouse, the sound changes, assuming that slidebar is in the sound's equation. If code sets the value of that slidebar, you see it move on the screen, assuming its in some object already displayed on the screen. Other code doesnt need to know the screen or sound system exists. It interacts with all other systems through a single file that contains no variables: CS.java.


Every CS has 0 or more params. They are added and moved by list-like functions. They are the function-parameters of a CS when it is EXECUTED. If a CS has 0 params, it works the same as if it had more. CS.minParams() returns 0, and of course, CS.maxParams() might be any nonnegative number.

Bayesian Artificial Intelligence

      (more types of AI coming soon)


This window lets you play with a bayes-node, which is the smallest part of a bayesian network. A bayesNode is to a bayesNet as a neuron is to a brain.

All slidebars here are a chance between 0 and 1.
When you EXECUTE this bayesNode (by clicking the right button), you make the bayesNode look at the 2 inputs and calculate the output.
The first 2 slidebars are the inputs to the bayesNode.
The next 8 slidebars are chances that describe the other 3 slidebars.
The last slidebar is the output of the bayesNode.


Put the following code into CodeSimian (then click the compileCode button) to get the bayes node window:

do(
	list(bayesNode#node(
		list(slidebar#in0 slidebar#in1)
		list(
			slidebar#prob0(.3)
			slidebar#prob1(.22)
			slidebar#prob2
			slidebar#prob3(.7)
			slidebar#prob4(.2)
			slidebar#prob5(.44)
			slidebar#prob6
			slidebar#prob7
		)
		0
	))
	window#moveTheSlidebarsThenClickTheRightButton(
		horizontal(
			in0 in1
			button
			prob0 prob1 prob2 prob3
			prob4 prob5 prob6 prob7
			button#execute( setP(slidebar#out0 0 node) )
			out0
		)
		700
		100
	)
)

The CS object with name node exists in 2 locations. Its defined in the first position, but neither position has priority. In Java, assuming you had CS variables called someList and someSetP, both someList.P(0) and someSetP.P(2) would both return that same bayesNode(). P(0) is the first thing between ( and ), and P(2) is the third thing.

When you click the right button (with name "execute" which might look like "e..."), you will see the middle 8 slidebars decrease their values. A bayes-node requires that its 8 (or other power of 2) numbers SUM TO 1.0 because they represent chances of 8 different combinations of the 3 other numbers (the 2 slidebars on the left and the 1 on the right). If they dont, the bayes-node fixes it by scaling them all proportionally so they sum to 1.




see or download 2 games I made (with source code).


but DNA is a giant base-4 number (with 3 billion digits)... maybe thats a better base

we are all some type of software, if the hardware is a computer or the laws of physics



Privacy Policy