toxicblobs
  • home
  • programming
  • weblog
  • contact

The Layman's Criteria Of Music

1/25/2013

0 Comments

 
Thus far in human history, critics have used their human intuition to judge whether a work is "good". We have many kinds of critics, then: food critics, art critics, literature critics, programming critics, music critics, mom critics, etc.
However, I believe it is time to usher in a new wave of automated criticism, so creators don't even have to talk to another human to be ridiculed! After all, who knows if the critics really understand their subject matter. They could just be reading off of a standard written by someone else, and probably most of them are. They don't like creativity, innovation, or persistence; character is a foreign word to them. Therefore, I have done my part in automating the criticism of music by developing these standards for a computer to follow when criticizing:


1: The piece of music must have a rhythm that follows one of the standard time signatures: 4/4, 3/4, or 2/2. It must also use only quarter notes/rests, half notes/rests, and whole notes/rests. As little variation as possible is encouraged.


2: The melody must be in whole/semitone increments: no accidentals or intervals!


3: Thusly, the harmony must use only the tonic, subdominant, and dominant notes. Harmony must only use whole notes.


4: No artistic license is allowed, and preferably humans won't even perform music. Computers will! The music must not exhibit creativity of any kind, and should sound exactly like other music, with different notes. No dynamics!


<\sarcasm>


On a serious note, the above criteria, once reversed, become a general way for the layman to judge music.
Obviously, music can follow all the rules above perfectly and sound horrendous!
I have found, however, that all classical music follow these rules, many hymns, much of jazz, and contemporary film scores. Obviously, no rock pieces can ever obey these, nor can hip-hop "music", dance, reggae, or blues. Or RAP, that cacophony of brain-damaging sound.


So here are the actual criteria:


1: The piece of music will have a unique rhythm, that can follow one of the standard time signatures, or a new one. As much rhythmic variety as fits with the piece is preferred.

2: Melody, being the most important part, must be equal parts innovative, reminiscent, emotional, intellectual, complex, and simple. Uses as many intervals, accidentals, and grace notes as fits the song.

3: Contrapuntal harmony is one of the best kinds, and ideally the harmony should be nearly as interesting as the melody. Uses many accidentals, minor-key notes, and intervals.

4: Musicality and artistic preference are to be encouraged. Dynamics are very important.

So, the next time you hear music, try to analyze it and see if these rules label it as good, bad, or something in between. I think you will find, as I did, that only certain types of music are worth listening to.

-Hayden
0 Comments

Monty Hall Problem

9/27/2012

0 Comments

 
I recently came across a paradox known as the Monty Hall problem. It goes like this: imagine you're on a game show, and the host, (Monty) asks you two pick one of three doors. Two of the doors have a goat behind them and one door has a car behind it. When you pick your door, Monty will choose one of the remaining doors for himself. However, Monty's a nice guy, and he ALWAYS chooses a goat. Now you have a choice: keep your door, or take the one Monty left?
Surprisingly, the odds of you winning by taking the last door are 2/3. This is counter-intuitive for most people (myself included!), but this guy provides a nice explanation of the math behind it: http://betterexplained.com/articles/understanding-the-monty-hall-problem/#comment-5738
the commenter DerekSmith gave a very good explanation:

DerekSmith on September 12, 2009 at 1:53 pm said:
We humans have a habit of being acquisitive. Once we choose something, we have a tendency to want to hang on to it. The act of choosing a door, makes it ‘our door’ and so there is a natural reluctance to part with it.

An easier way of intuitively understanding the Monty Hall game is to hold off selection until the ‘door’ has been opened, and to show the higher probability of switching choice.

Take a pack of cards – it contains a single Ace of Diamonds – this is the winning card – pick the Ace of diamonds and you win.

Shuffle the pack and take a single card out – lay it on the table. Put the rest of the pack on the table beside the single card.

Now, the choice is pick the single card or pick the rest of the pack – which do you thinks is most likely to give you the Ace of Diamonds. Clearly, most people would choose the pack with 51 chances that they have chosen the Ace.

Now we add in the ‘opening of the doors’

As before, pick a card and lay it on the table, but before putting the pack down, somebody sorts through the pack and if it contains the Ace of Diamonds, they put it on the top of the pack and then put the pack on the table.

Now you have the choice of taking the single card or the top card off the pack – again, automatically folks will take the top card from the pack.

Now we put it all together – ‘Choose’ a card and put it on the table (we now own it). Next the pack is sorted and if the Ace is present it is put on the top of the pack.

The top card is taken off the pack and placed beside your chosen card and the rest of the pack are turned face up to show that they are not the Ace of Diamonds.

Now you are offered the choice of changing the card you chose for the remaining card from the pack. Even though ‘ownership’ is now involved, most people would not have any doubt about changing, and understand that there is not the remotest chance that the first card has a 50:50 chance of being the Ace.

they will understand that they had a one in 52 chance of picking the Ace first time, and almost dead certainty of it being the other card – they would switch…



-Hayden
0 Comments

Thoughts on 'real' programming languages

9/9/2012

0 Comments

 
We've all seen the guy on the programming forum: "hey gys, i wantz to m4ke a gamez, how do I start?!".
Then, some guy comes and suggests, "Hey, learn you a programming! Python, or Java, or C#! Thoze are goodz!".
Which is a smart answer. The trouble is, these languages aren't considered 'real' game development languages.
So many times people get answers like this:
"Heyz, learn you a C++ and makez games with DirectXes! Itz easy! Don't use a babiez languagez!"
I have one thing to say:
    Any useful programming language can be used to make high-quality games, because no one cares how it was
    made as long as it's fun.

As an example: Spelunky is a popular computer game made by Derek Yu. He made it using GameMaker, a program that lets people make games with little programming. What programming the creators do is in a GameMaker's proprietary scripting language; the farthest thing from C++. Spelunky eventually grew so popular that Derek Yu's company, Mossmouth, is releasing it for XBLA. 

Another example, Minecraft was made in Java. Java isn't considered a major game programming language either, yet Minecraft has been bought by over 7 million people.

-Hayden
</rant>
0 Comments

Multidimensional Python arrays

9/5/2012

0 Comments

 
  You can easily define a semblance of a multidimensional array in python:
>>> my_list = [[0, 1, 2], [2, 3, 4], [4, 5, 6]]

  However, in order to access elements, you must specify the y component first, like so:
>>> my_list[1][2]
4

  This annoys me for some reason, since I prefer passing the x component first, so I went and coded up a hackable solution by overloading __getitem__ and __setitem__. First, I'll explain operator overloading a bit.

  Python's operator overloading is a very powerful tool for constructing data types.
For example, by overloading the __eq__ operator we can specify how two objects are compared.
By default, Python compares the unique identifiers of each object. In this code example I have changed it to compare the value member of each instance of Spam, instead of the identifier.

class Spam():
    def __init__(self, value):
        self.value = value
    def __eq__(self, other):
        return self.value == other.value

>>> eggs1 = Spam(2)
>>> eggs2 = Spam(3)
>>> eggs3 = Spam(2)
>>> eggs1 == eggs2
False
>>> eggs2 == eggs3
True

There are operator overloaders for all bits of syntactic sugar in the Python language. Going back to multidimensional arrays, we can overload the __getitem__ and __setitem__ operators (list[index] and list[index] = spam) to implement a multidimensional array.

Dictionary implementation:
class Grid():
    def __init__(self, widthortuple, height=None):
        self._grid = {}
        self.width = 0
        self.height = 0
        if height == None:
            self.width = widthortuple[0]
            self.height = widthortuple[1]
            for i in range(0, widthortuple[0]):
                self._grid[i] = [0]*widthortuple[1]
        else:
            self.width = widthortuple
            self.height = height
            for i in range(0, widthortuple):
                self._grid[i] = [0]*widthortuple
        self.wrap = True
    def __getitem__(self, *args):
        x, y = args[0]
        if self.wrap:
            if y >= self.height:
                y = y-self.height
            if y < 0:
                y = self.height-y
            if x >= self.width:
                x = x-self.width
            if x < 0:
                x = self.width+x
        return self._grid[x][y]
    def __setitem__(self, *args):
        x, y = args[0]
        item = args[1]
        if self.wrap:
            if y >= self.height:
                y = y-self.height
            if y < 0:
                y = self.height-y
            if x >= self.width:
                x = x-self.width
            if x < 0:
                x = self.width+x
        self._grid[x][y] = item
        return
    def __repr__(self):
        return self._grid.__repr__()
    def __len__(self):
        return self.width*self.height
    def __iter__(self):
        allitems = []
        for column in sorted(self._grid.keys()):
            allitems.extend(self._grid[column])
        return allitems.__iter__()

List implementation:
class Grid_list():
    def __init__(self, widthortuple, height=None):
        self._grid = []
        self.width = 0
        self.height = 0
        if height == None:
            self.width = widthortuple[0]
            self.height = widthortuple[1]
            for i in range(0, widthortuple[1]):
                self._grid.append([0]*widthortuple[0])
        else:
            self.width = widthortuple
            self.height = height
            for i in range(0, height):
                self._grid.append([0]*widthortuple)
        self.wrap = True
    def __getitem__(self, *args):
        x, y = args[0]
        if self.wrap:
            if y >= self.height:
                y = y-self.height
            if y < 0:
                y = self.height-y
            if x >= self.width:
                x = x-self.width
            if x < 0:
                x = self.width+x
        return self._grid[y][x]
    def __setitem__(self, *args):
        x, y = args[0]
        item = args[1]
        if self.wrap:
            if y >= self.height:
                y = y-self.height
            if y < 0:
                y = self.height-y
            if x >= self.width:
                x = x-self.width
            if x < 0:
                x = self.width+x
        self._grid[y][x] = item
        return
    def __repr__(self):
        return self._grid.__repr__()
    def __len__(self):
        return self.width*self.height
    def __iter__(self):
        allitems = []
        for row in self._grid:
            allitems.extend(row)
        return allitems.__iter__()

Using these:
>>> grid = Grid(10, 10):
>>> grid[2, 2]
0
>>> grid[2, 2] = 'hi'
>>> grid[2, 2]
hi

A detailed page on creating types is available at: http://docs.python.org/reference/datamodel.html#objects-values-and-types

-Hayden
(EDIT Sept 7, 2012): Added an __iter__ method to both implementations and linked to a different page in the python docs about type/class creation.
0 Comments

Blog restart

8/17/2012

0 Comments

 
    I've decided to restart this blog for two reasons: 1. The old one had absolutely no useful information and 2. I want a clean slate to begin with.
    As you may have noticed, I've removed all the pages in the navigation menu while I clean them up. I have renamed the 'games'; it is now 'programming'. The other tabs like 'yoyo' and 'animations' have been permanently removed.

    Hopefully this website can be a useful source of information and thoughtful questions. :)

-Hayden
0 Comments

    Author

    I enjoy programming, music, and any form of creative endeavor. I attend Maineville Baptist Church and try to serve Jesus Christ as much as I can there, and everywhere. (look a rhyme!^)

    Archives

    January 2013
    September 2012
    August 2012

    Categories

    All

    RSS Feed

Powered by Create your own unique website with customizable templates.