JF make 282
JF Nav
JF Nav
Creation Date: 2003-08-27
Download Song13b1 It's my new song. You need Winamp or XMMS. You do not need the patented MP3 decoder because Song13b1 (and all songs from now on) is compressed with the superior ogg vorbis format (Redhat users rejoice*).

Tonight, I set about to write a song. It turned out that I did not write a song tonight. My computer did. And it is really decent ambient techno stuff. It's only 2 minutes long, but my computer can mix out tunes like these every second. Really the production of this music is only limited by writing it to disk and compressing it to ogg. That makes very long songs very easy to make. Tonight, I will not only give you a song, but the exact way to reproduce it. In my normal system, I will give you a lesson that I think you should learn which will be helpful no matter if you want to create something like this or something completely different. I will do this not just for you, but for me also. If you want more info and song11, check out the previous MoJF.

* As a funny aside, my good friend and I installed Redhat 9 onto his main machine. He decided to go with Redhat because it's supposed to be easy to use. I installed Slackware on my main machine less than a year ago and it took me a month to go from downloading 8.1 for the first time to everything works well. I believe that the learning curve of Linux is much better than Windows because power-users can customize for a month while simple users can get very basic stuff working easily and perfectly in a day (ask me how). We found out how easy installing Redhat 9 on his machine was. He was using RAID 0 striping with NTFS, the worst combination imaginable because there's no way to resize it correctly that we could find. So after backing up 80 GB of data, he worked on getting software RAID drivers for Linux. This is easier than it sounds. He downloaded the right ones after e-mailing people to make sure that it wouldn't destroy his data. This is definately not Redhat's fault since any other distro would be practically the same. So we install Redhat. Everything is happening, working, hooray for us. It took us an evening to make the install happen. Dual booting XP made it a pain in the ass. But that isn't Redhat's fault. What is Redhat's fault is that when we had finally gotten the NTFS partition to mount (with 40 GB of mp3s), we were aghast to find that Redhat does not come with mp3 support! Not even mpg321, holy shit! I'm angry and stuff, so I decide to download the rpms from the internet. No dice. Everything I download has a dozen unresolved libraries it requires. Pande-fucking-monium. I gave up. And now my friend has to boot into fucking Windows XP just to listen to mp3s! It's fucking undignified! Fuck you Redhat for fucking this shit up all in the name of not being a target of patent violation. Slackware finds it completely agreeable to violate patents to ensure the infinite use of their product. That is why I will support Slackware and produce all my music in ogg format. *phew* rant mode off.

1) Text -- Theory

Do not underestimate the importance of thought, because without it, you would not be reading this. I had to think out my random vectors that my life points me in. Do not confuse vectors with thought. Your observations should not give you an answer as well as your hypotheses. So, the first thing I did was write down unformatted text in my fourth favorite text editor (the first three are Kate, Joe, and Vi in that order) and write an observation onto paper. It starts very vague. First, a title is in order: "What Type of Random". Secondly, an introduction that gathers two thoughts together:
There are many styles of randomness to choose from. For example, a random song might be a choice between Beastie Boys and Space Channel 5. Or a random song could be recorded from a dial tone as such: record, cancel out the dial tone, and amplify whatever is left. This would be quite more entropic than the first example. In fact, it wouldn't be very interesting. In the interest of original music, playing Beastie Boys, Space Channel 5, and 3EB is not interesting at all.
These observations alone mean nothing very specific. It uses my knowledge of The second law of Thermodynamics and physical systems. It also hints at the boundaries of my search: random selection of full songs is too little randomness, completely random noise is just static. It is now time to search between the boundaries into specific topics, namely music.
But there are many ways for random music to be generated. An instrument can be told to fire at random times at random pitches. But that would not be very melodic. It could be narrowed down to a certain octave and a certain number of pitches which work together. Then one could give it a 4/4 beat and give it a probability distribution of hitting whole, half, quarter, eighth, or no note. Of course, a random song with these locked in systems would go all over the place and not accomplish any central theme. Ah, a theme?! Yes, the composer of a random song can propose a theme that the song will start with, use, and evolve from. It is the random song's job to decide what happens.
That is what we want. There are a few specific things that a person can do to make randomness sound like music. Give it a melody, rhythm, and pitch. There you go. How do you use this information? It's not everyone that can use this little bit of information. Most people will simply say: "Fuck, you're nowhere. Picking numbers out of a hat to tell what note to play next?" Well, it so happens that I am a hacker. A week ago I used similar information to create the previous song, song11c4a. Doesn't this make sense? I can simply tell Python to generate random numbers and write out a score to make the song. Then CSound can parse that into wav file which I can compress into ogg!!! WOOHOO!

2) Python Script

So, how does a person go about writing a Python script? Well, I like to start with:

Name Script
by Joel R. Voss

def main():
    """ Either a test function or a default script function."""
#end def main()

# usually we need to do something if we are being called rather than used.
if __name__ == '__main__':
#end if
So that is a useful template in case your text editor has that feature. The next part is an interesting thought. The next step I go through is to copy my last useful code. That is, the code from my previous song11. While none of that code really actually makes it into the end result, it helps me think of what I am going to do. I need:
  • a for loop
  • a time variable
  • a print statement
  • stuff from that paragraph
    • note length
    • pitch
    • theme
    • a comment which explains most of what is above in terms of a hacker
So that's exactly what I do.

def randomSong13(theme=[], iSongLength=120):
    """ randomSong13
    The random song only allows a certain number of random parameters:
        note length
    and a few picked parameters:
        actual idea
        repetitive systems
        song length in seconds
    and thus, it becomes a song generator in a box. The first few versions will be simple.
    import random
    iOctave = 2
    fTime = 0.0              # initialize time
    while fTime < iSongLength:
		# length in inverse powers of 2: whole, half, quarter, eighth
		iNote = int(4 * random.random())
        if iNote > 0:
            fDur = 1.0 / pow(2, iNote)
            iPitch = int(8 * random.random()) # which key
            print 'i2 ', fTime, fDur, '20000', iOctave, '.', iPitch, '0.03'
            fTime += fDur
            fTime += 0.25
        #end if
#end def randomSong13(theme, iSongLength)
You may notice a few things about my code. The first is that I put in comments enough for me in this one. That is because this is a very simple function. There are only two confusing things imho. Another thing is that I use comments as end tags. This is a cool thing for Python because everyone (including me) complains about Python's lack of end tags. Well, like the weather, everyone talks and *I* am the one to do something about it. I have made my style a requirement of my own coding, but it is not enforced. Those who take the pessimistic side of the Roman law: "Where there is no police, there is no speed limit," should take note how my unenforced rule is followed because it helps me. If the speed limit helped me, I would follow it naturally, wouldn't I? So let "Do what thou wilt," be the whole of the law. Anyway, looking at my code, you'll see exactly what I had planned before I even wrote down the title of the essay: "What Kind of Random". When I ran the script, captured the output, and debugged it*, I had the score. * Let me fool you not by leaving out the debugging process. I did not get it right the first, second or tenth time. I code far too fast to be bugfree on the first try. Since no one's life is on the line as I code, I can simply look at the output to ensure that my code is correct. One bug was due to Python assuming that (1 / n) is an integer which it definitely is not (1.0 / n is a float while 1 / n is an integer). Two other bugs were my lack of knowledge of CSound. The first is that the score defines the GEN10 routine that creates the sine wave. I forgot it, so I got an error from CSound and a blank wave file. The second was the key. I am not a musician so if someone asks me for a range of octaves and keys, I will give them 1-8 and 1-16 which are not very normal. However, I like it a bunch. This song reminds me of some of the stuff that I hear on hard days. The way that the sounds are not evenly spaced. You get a weird buzz from something every few seconds. It sounds like techno, but the ins and outs are far too brief to make anything out. I certainly don't expect other people to like this song, but perhaps a hacker (probably myself) can find a way to change my code to make something that is recognized as techno.

3) Orchestra

I decided to explain how to make the orchestra, because this is a hard part of CSound if you don't know how. If you don't know how, I suggest that you go to CSounds and check out the tootorial. But if you have checked that out and don't know where to start, do what I do: copy and paste! Really, I wrote this myself, but with a very clear picture of the code from CSounds tootorial in my mind.

; song13a.orc

; used for song13,
; just a crazy electronic keyboard with nothing to lose..

instr 2
    ; Electric keyboard/flute
    ; p4 = amplitude
    ; p5 = pitch
    ; p6 = wobble

    inote = cpspch(p5)
    k1  oscil 0.2 * p6 * p4, 0.2 * inote, 1

    k2	linen p4 + k1, p3 * 0.05, p3, p3 * 0.1

    a1	oscil k2, inote, 1
	out   a1

This has changed from the previous song11 electronic keyboard because now it uses cpspch. Wtf is that?? That is something that takes stuff like 2.8 (octave.key) and turns it into pitches (in cycles per second) like 440. Also, wobble is an interesting thing that I muted (for all intensive purposes) in song11. It simply increases and decreases the volume at 1/5 the frequency of the frequency. Well, what does that do? It makes a chord with (usually) a much lower volume on the lower frequency. This can hardly be picked out, but it can be recognized as the softening of the sound.

4) Send it to the viewers

Of course, it's not very interesting in text format, is it? No, CSound must be used to create a wave file which can be compressed with ogg to give to the viewer. Simple enough, the command I used was:
consound -Wdo song13b1.wav song13a.orc song13b.sco
I can then listen to it in Winamp. I was so amazed at the song on my first try, that I decided to simply use it. So I opened up OggDropXPd and dropped the wave file onto it. It compressed it, I uploaded it, here it is.

5) Conclusion

I'd like to tell you all that my genius that produced this is capable and willing to do so much more. If it is, why don't I have a job? It only takes a small amount of time to find a job. If a person is really interested in working and has a lot of skills, they can find something. Yet I continually force myself to do anything but look for work. In fact, I've really made a whole career out of not looking for work. I'm writing a video game (a 3D story-based non-violent RPG called Hack Mars), working on this website, and I plan to do more work on Javantea's Fate, the manga (if you remember that far back). If I find work, it will be because I break down and do searching. If I do not, I will hopefully write a successful video game and/or manga. This page ought to explain to you as well as it does to me that I have the skills to pay the bills. Yet on my 22nd birthday, I'll be paying my rent check with a credit card, the same as I did for my 21st birthday. I'll leave the audience with a poem that can be spoken over the track they listen to:

Down but not out,
bustin' my ass doing naught,
got the mind and byte,
but still typing,
sixteen and a half later,
lcd is not getting brighter,
thinking what to do,
knowing that I'm doing it,
not surviving for the future,
allowing the notepads to clutter,
"not by my mind but my environment"
you see space dust rhyming?
"Randomness is a proof for nihilism"
but then wtf is this?
Home Characters Making Of Technical Mail News Links |< First < Prev Next > Latest >|  bandwidth version Goto Scene