Recent posts by Metabble on Kongregate

Flag Post

Topic: Game Programming / Free music in 5 seconds.

I’ve built up a collection of several good pieces, and found a way on the Mac to convert the .IT files into MIDI files so I can edit them in GarageBand. First, I import the .IT into MilkyTracker and export it to a .XM. Then, I import the .XM into SunVox and export it as a MIDI.

Now I can use more realistic sounding instruments, and add all sorts of effects and filters. :)

Flag Post

Topic: Game Programming / Free music in 5 seconds.

Originally posted by Senekis93:

@ Metabble: I totally missed yourlast reply. The planned features sound amazing. You may want to drop an email to the author of the other script when you’re done.
I think it must be nice to open source something, forget about it and one day get an e-mail from someone who found your code and improved it.

TBH, I’ve probably only added/modified a few dozen lines. It was easy. For instance, to implement octave/key/tonic shift I just made a few constants which the user punches in before they compile and run. These are used instead of the default values wherever they would’ve been used. The way the user defines them is as other constants (TONIC_A, TONIC_D, OCTAVE_R) which are defined as simple formulas which are evaluate to the desired frequency. I guess I could’ve implemented them as command line arguments, but they aren’t hard to change. Length is at the top with the pre-existing bitrate/sample frequency, while OCTAVE, TONIC and KEY are near the bottom. The guy who made the original script probably could’ve done this in a half hour.

It’ll probably be a while before I smooth out the length constant to make it more precise since I’m learning Objective-C at the moment. Honestly, you probably could’ve implemented these things better than I could’ve, since I’ve only been coding for some months.

Flag Post

Topic: Collaborations / Anyone Need a Composer?

Originally posted by Flameshorts:

Hi Metabble! Thanks for your comments on my music.

If you’re a beginner to music then I’d recommend picking up an instrument that is less technically demanding to start playing, like the guitar or piano, and go from there. If you’re already working with piano then you’re on a good path for working in the MIDI realm seeing as the keyboard is a standard tool for composing in programs like GarageBand. It’s great that you’re so driven to compose your own pieces!

It would definitely benefit you to get a beginner book for piano; that being said there’s probably a decent amount of free material online to help you get started. Learning how to play basic songs like “Mary Had a Little Lamb” and “Twinkle Twinkle Little Star” are how everyone starts! It’s part of the foundation that you will be able to build on later. Learning these melodies in the right hand on piano alone is a great first step. Once you get that down, you can add the chords in the left hand.

Learning to read music will definitely benefit you a lot but of equal importance is the development of your ears. You can work on developing your reading skills and your aural skills at the same time. Learn to recognize the relationship between two notes. Learn to recognize the relationship between the notes and the chord that they are a part of. Learn to recognize rhythmic patterns and things of this sort. These are all things that will help you in the long run.

Don’t think that this all has to come rapidly though! Expect for it to be an ongoing process.

Keep in mind that it takes time to develop your artistic abilities and your ability to use the tools needed to express your art. I’ve been studying music for many years and I’ve been working with GarageBand for the last 4 years. It’s a long process but if you are determined you will see progressive results.

Feel free to message me with any other questions you might have!

Also, a good website to use for training your aural abilities is:

Thanks a lot for the advice. Also, that site does seem pretty good. I’m on “more intervals” and I can get around two thirds of them right (with fixed root off).

Flag Post

Topic: Collaborations / Anyone Need a Composer?

You have talent. I especially enjoyed Village II, and think it could be used even in a commercial RPG. I’m amazed you did most of what I heard in GB. Every time I try to compose anything it ends up sounding terrible.

Do you have any advice on how a completely clueless beginner should break into the musical world? The most I do right now is play piano with one hand (simple melodies), and I can’t even read sheet music. Should I pick up some books on learning to play the piano for beginners and slowly branch out into more general musical theory, or what?

I always end up hearing some amazing piece of music, being blown away and wanting to one day compose my own pieces, but then I never know where to start and run out of steam. I’m also not particularly coordinated, which makes learning an instrument that much harder.

Flag Post

Topic: Collaborations / Artist looking for work

I definitely agree you should step up the variety. If I was given a link to that portfolio and was looking for an artist, I’d probably navigate away after a few minutes and trash the email (unless I was making a horror game). Mix it up, try different artistic styles, draw different things (monsters, common game items, landscapes) and you’ll probably get more work. I think you have enough talent to get a few paying jobs, even if you don’t get much at first. Artistic variety is very important, especially for games.

Flag Post

Topic: Game Programming / Free music in 5 seconds.

EDIT, figured it out, original post below the line: Figured it out. I can alter the patsize as long as the blocksize divides evenly into it 4 times. I had trouble grasping the python syntax… especially having read almost nothing about python.

At first I thought kseq was defined as a random choice between two lists (minor, major), each containing two more lists containing four tuples, each containing two elements. That didn’t make sense. Why pick a random list (major, minor) when major, minor was passed? Then I noticed the whole thing was wrapped in curly braces and the keytype came after. I’m not familiar with the syntax, but it seems it picks either the major or minor list based on the key type (it might be dictionary definition followed by the key), then picks one of the two lists containing four tuples and assigns it to kseq. A tuple, containing a key and keytype, is popped from kseq and assigned to another tuple, k (key) and kt (keytype). The reason why blocksize needs to divide evenly 4 times into patsize is because they are used in a for…in loop which iterates, in essence, as many times as blocksize goes into patsize, popping and using tuples as it goes. After the fourth loop the last tuple has been popped out; there’s no more tuples to pop, and so there’s nothing to assign to the tuple k,kt.

EDIT2: And now there’s a different problem with an index used to access an element of rhythm being out of range once patsize > 160. I give up, for now. Maybe it would help to know some python? >_>

Original, confuzzled, post:
Added the ability to easily change octave along with scale key and tonic just by changing a few constants before running. Ex. SCALE_TONIC = TONIC_A, SCALE_KEY = Key_Minor and OCTAVE = 3 would get A-minor, octave 3. Can use TONIC_R, SCALE_KEY_R, OCTAVE_R to get random values for any of the three.

Also added the ability to control the length, but it isn’t very precise. It just extends the amount of patterns, which is 6 by default, while maintaining the scale change of the last pattern. I was going to make it so it altered the rows per pattern as well as the number of patterns, but the rows per pattern can’t go above 128 without ending up crashing. I change patsize and for some reason it tells me that an int type object isn’t iterable. It pops an object off kseq containing a key and key type and assigns it to a tuple. It works when patsize <= 128, but as soon as patsize is above 128 it freaks. No idea why. I can still get my desired length in rows by lowering the pattern size and raising the number of patterns, but due to the algorithm used, I think it breaks up the flow of the song.

I guess I’m stick with altering the song size in 128 row chunks. :(

Final features when I’m done with this next step should be:

+ Randomly generated instruments.
+ Easy control of scale key. (Not that it wasn’t easy to begin with!)
+ Easy to use control for changing the octave. (Shifting everything up/down an octave by altering the base sample)
+ Easy to use control for the tonic of the scale. (Again, altering the base sample. Essentially shifting everything in frequency in semitones.)
+ Manipulation of the tune length via the amount of patterns, as well as the pattern length.
+ Randomizer for octave, as well as scale tonic and key.

Flag Post

Topic: Game Programming / Free music in 5 seconds.

At first I could only get fast paced songs to sound good (probably due to their inherently more chaotic nature), but lately I’ve gotten quite a few good slow songs. Swapped out one melody sample in a tune with a hollow flute one I made in CFXR and it makes a decent forest tune. The D-minor scale at 90 tempo, 3 speed has given me some more laid back, contemplative tunes.

Flag Post

Topic: Game Programming / New Game

Originally posted by oatlol:

Hey Guys,

I uploaded my 2nd proper game 2 days ago. If you could can you go play it and give me any tips to make it better and also compare it to my first game. My art as gotten a whole lot better :)

Jelly Time

Not bad for your second game. Some advice:

A slowly scrolling background would make it look a bit nicer.

The game runs somewhat slowly, so you should consider re-evaluating your current code’s structure. As you gain knowledge, you should try to find better ways to approach problems and refactor your code.

Having the score leap by 7 every time a jellyfish spawns doesn’t feel right to me; consider increasing it slowly the longer the player survives. The growth rate can be exponential (slow exponential), with a linear growth rate for the jellyfish spawn rate.

From what I’ve seen, the player can get boxed in, with no way out. This is harder to fix. If you store the jellyfish in an array I guess you could compare the x and y values and make sure there are gaps large enough for the player to squeeze through. Someone else could probably give you some ideas.

I know you pointed this out, but a non-rectangular hit box for the fish would be nice. Losing from a hitbox corner collision can be frustrating. It doesn’t need to be the exact shape of the sprite, but something like an oval might work. Hell, even a circle that encompasses his head might work better, since the jellyfish are moving towards his head. His tail is skinny, so the rectangular hitbox makes him collide at the back when he isn’t touching anything. Even though you’ve told the player about the hitbox, they’ll likely not think of that when their game suddenly ends because they hit something behind themselves.

The game over screen appears too abruptly. You could fade out the screen and/or flash the two characters who collided.

I don’t know how you’d implement any of this, of course, since I don’t make flash games myself. :p

@feartehstickman Clever, adding an event listener that calls an empty function. I guess it makes sense, since if a game implements right clicking in its control scheme, it wouldn’t do to have the right click menu pop up every time they clicked it. xD

Flag Post

Topic: Game Programming / Don't be a Pretentious Egotistical Jerk

Originally posted by Senekis93:
Originally posted by alecz127:

I think some people take it too personal and go all defensive at the first chance.

It’s not the same telling you “You’re an incompetent, worthless idiot and you should die.” than telling you that your code sucks.

I remember Skyboy (btw, what happened to him?) telling me that some of my code was stupid or #/( slow or totally unnecessary and indeed it was stupid, effing slow and unnecessary. Of course, now I know that because I replied asking how to do it properly. Had I replied with a “ah, yeah? well, ***k you!” maybe I would keep writing the same stupid, slow code.

Each has his/her own way of helping people. Some (including me) may be harsh with the critics, but they’re directed towards the posted code or whatever the thread is about and it’s the problem of the other person if he wants to take it as an attack or an insult.
(Of course, sometimes I go a bit over the line, but that’s another story).

It’s impossible to please everyone, and trying to do so would only make you have a really bad time. You can’t go around asking yourself how will the other person take that line that you just typed. If they get the message, that’s great. If they go the “how dare you…? you aren’t allowed to say my code is ugly!” way, well, it’s their loss and I won’t be losing any sleep because of it. It’s part of internet communications; if you don’t end your sentence with a smiley, they may think you’re insulting them.

About making fun of newbies, I don’t think that’s common. At least not when they are asking for help and trying to learn.
Making fun of newbies usually takes place when they come and ask for code.

And I agree with Draco. Besides the seasonal troll, this tends to be a nice place.

Hah. So true. “Oh, wait. That sounded too serious. Better slap a smiley on there.”

I think many programmers are very defensive about their programming “style.” When other people start criticizing the way they code, they take it almost as a personal attack. The best thing is to just stand back, take it in the context it was meant to be used in, and think about whether or not they’re right or wrong, in part or whole. We all have something to learn.

I also agree that this is a pretty nice place as a longtime lurker.

Flag Post

Topic: Game Programming / Free music in 5 seconds.

Originally posted by Senekis93:
(ex. the bass, which often comes out sounding like a fart =_=)

Haha, so true.

You can also mess with the speed value at the top. Well, you can mess with pretty much everything, that’s what makes it so beautiful.

Nice job, Metabble.

Thanks. Although, I didn’t do much. Also, if anyone wants to change the key of the scale and octave in code, I think I know how. Observe how the frequency value of the piano and bass are MIDDLE_C. It’s declared as

MIDDLE_C = 220.0 * (2.0 ** (3.0 / 12.0))

in the BOOTSTRAP area. I’m not big on music theory, but I seem to have gotten a grasp of this formula. Correct me if I’m wrong, since before now I didn’t even know an octave was double the Hz of its predecessor. =_=

Simply, the way I see it in my mind, it’s the starting hertz of the octave times the twelfth root of two to the power of the note you want within the octave. Essentially, since an octave is double the hertz of the one below it, we’re splitting this increase into twelve parts (twelfth root of two, 2^[1/12]) and multiplying for every note above A we want. Of course, there’s no need to use powers when we can change the amount that we divide twelve into…

We represent the octave and key we want as:

hZ * (2.0 ** (sT / 12.0))

Let hZ be the starting hertz of the octave, and sT be the number of semitones away from the key belonging to that hertz (A).

220 Hz is the middle octave (that’s why it’s used for middle c) so halve it for every octave down you want to go, and double it for every octave up.

Semitones away from A is self explanatory.

Simple edition with tables to easily change the key and octave, first go to this line:

MIDDLE_C = 220.0 * (2.0 ** (3.0 / 12.0))

Replace it with this line:

MIDDLE_C = Hz * (2.0 ** (sT / 12.0))

where Hz is one of the values below, corresponding to the octave you want…

Middle+2 = 880 Hz
Middle+1 = 440 Hz
Middle = 220 Hz
Middle-1 = 110 Hz
Middle-2 = 55 Hz

..and sT is the number below belonging to the key you want.

A = 0
A#/Bb = 1
B = 2
C = 3
C#/Db = 4
D = 5
D#/Eb = 6
E = 7
F = 8
F#/Gb = 9
G = 10
G#/Ab = 11
A = 12 (octave higher, just double hertz and make it 0)

And you’re done. Keep in mind that this is misleading since MIDDLE_C is, well, no longer middle c. You can always define separate frequencies and change which one is used where the samples are generated (they’re the same lines as the ones I altered in my previous post). Also note that the scale, major or minor, is decided randomly, with a 50% chance of each being chosen, every time a tune is generated. To control that, too, you can change this line:

strat = Strategy_Main(random.randint(50,50+12-1)+12, Key_Minor if random.random() < 0.6 else Key_Major, 128, 32)

by replacing the second argument with Key_Minor or Key_Major.

Whew. That was a lot of work. Again, I’m not much into music theory so if I’ve gotten anything wrong, feel free to correct. :)

Also, to expand on this, you could define multiple octave/key combinations (maybe put them in an array) and then use randint to determine which one to use. That way, you can randomly generate the tune, instruments, base octave and key. xD

Flag Post

Topic: Game Programming / Free music in 5 seconds.

Originally posted by tehdog22:

Thanks Metabble!
Looks like I have something to play around with when I find time again ;)

No problem. Also remember that you can change the tempo and such by altering the values in the IT MODULE HANDLING area (at the top of the ITFile class). If you get a tune you like, you can export it to a WAV or MP3 using VLC’s Export Wizard. Export Wizard → Transcode → pick file → transcode audio → pick codec, format.

I’ve been having bugs with the Mac version of VLC for this, though, (stops halfway through) so I use Schism Tracker. In Schism Tracker you can alter the samples used for each channel to have vibrato, or use a completely different source file.

If you like the melody in one tune, but want the instrument of another, you can load the file in ST, select an empty slot in the Sample List, press enter, select the tune that contains the desired instrument, pick it, and it’ll be on the list. Then use Replace (Alt-R) after selecting the old instrument, and enter the new sample’s number. I do this a lot when I get a good tune but the random instrument isn’t good (ex. the bass, which often comes out sounding like a fart =_=). Schism Tracker itself can export the file as a WAV, which is handy. From there, you can convert it into anything you want.

Flag Post

Topic: Game Programming / Free music in 5 seconds.

Originally posted by tehdog22:
Originally posted by Metabble:

Altered the code to randomly generate the instruments as well with a piano base for the main melody, cranked the tempo up to 180 and got a nice piece that sounds like it uses a banjo.

Mind posting your version of the script? I wanted to do something similar, but I couldn’t get my mind around the python.

Originally posted by tehdog22:
Originally posted by Metabble:

Altered the code to randomly generate the instruments as well with a piano base for the main melody, cranked the tempo up to 180 and got a nice piece that sounds like it uses a banjo.

Mind posting your version of the script? I wanted to do something similar, but I couldn’t get my mind around the python.

I don’t normally use Python, and it wasn’t too hard. It was less of ‘randomly generating’ the instruments (since that implies some complex algorithm) as finding where they are generated and replace the values with randint. If you want to do it yourself, just find where the samples are generated in the BOOTSTRAP area and replace the constant values with randint calls, but remember to divide by 10.0/100.0/1000.0 to get a float, and that both arguments are thus ints, as randint obviously generates integers from an integer range.

I changed the following in the BOOTSTRAP area:

SMP_GUITAR = itf.smp_add(Sample_KS(name = "KS Guitar", freq = MIDDLE_C/2, decay = 0.005, nfrqmul = 1.0, filt0 = 0.1, filtn = 0.6, filtf = 0.0004, length_sec = 1.0))
SMP_BASS = itf.smp_add(Sample_KS(name = "KS Bass", freq = MIDDLE_C/4, decay = 0.005, nfrqmul = 0.5, filt0 = 0.2, filtn = 0.2, filtf = 0.005, length_sec = 0.7))
#SMP_PIANO = itf.smp_add(Sample_KS(name = "KS Piano", freq = MIDDLE_C, decay = 0.07, nfrqmul = 0.02, filtdc = 0.1, filt0 = 0.09, filtn = 0.6, filtf = 0.4, length_sec = 1.0))
#SMP_HOOVER = itf.smp_add(Sample_Hoover(name = "Hoover", freq = MIDDLE_C))

SMP_KICK = itf.smp_add(Sample_Kicker(name = "Kick"))
SMP_HHC = itf.smp_add(Sample_NoiseHit(name = "NH Hihat Closed", gvol = 32, decay = 0.03, filtl = 0.99, filth = 0.20))
SMP_HHO = itf.smp_add(Sample_NoiseHit(name = "NH Hihat Open", gvol = 32, decay = 0.5, filtl = 0.99, filth = 0.20))
SMP_SNARE = itf.smp_add(Sample_NoiseHit(name = "NH Snare", decay = 0.12, filtl = 0.15, filth = 0.149))


# SMP_GUITAR = itf.smp_add(Sample_KS(name = "KS Guitar", freq = MIDDLE_C/2, decay = 0.005, nfrqmul = 1.0, filt0 = 0.1, filtn = 0.6, filtf = 0.0004, length_sec = 1.0))
SMP_BASS = itf.smp_add(Sample_KS(name = "KS Bass", freq = MIDDLE_C/4, decay = random.randint(2, 15)/1000.0, nfrqmul = random.randint(2,15)/10.0, filt0 = random.randint(1,4)/10.0, filtn = random.randint(1,4)/10.0, filtf = random.randint(2,15)/1000.0, length_sec = random.randint(5,12)/10.0))
SMP_PIANO = itf.smp_add(Sample_KS(name = "KS Piano", freq = MIDDLE_C, decay = random.randint(13,39)/100.0, nfrqmul = random.randint(1,9)/100.0, filtdc = random.randint(5,20)/100.0, filt0 = random.randint(4,17)/100.0, filtn = random.randint(3,9)/10.0, filtf = random.randint(2,6)/10.0, length_sec = random.randint(75,150)/100.0))
# SMP_HOOVER = itf.smp_add(Sample_Hoover(name = "Hoover", freq = MIDDLE_C))

SMP_KICK = itf.smp_add(Sample_Kicker(name = "Kick"))
SMP_HHC = itf.smp_add(Sample_NoiseHit(name = "NH Hihat Closed", gvol = random.randint(16,48), decay = random.randint(5,20)/100.0, filtl = random.randint(5,20)/10.0, filth = random.randint(10,40)/100.0))
SMP_HHO = itf.smp_add(Sample_NoiseHit(name = "NH Hihat Open", gvol = random.randint(16,48), decay = random.randint(30,120)/100.0, filtl = random.randint(5,20)/10.0, filth = random.randint(10, 40)/100.0))
SMP_SNARE = itf.smp_add(Sample_NoiseHit(name = "NH Snare", decay = random.randint(6,24)/100.0, filtl = random.randint(9, 27)/100.0, filth = random.randint(1,4)/10.0))

Notice I uncommented piano and commented out guitar. I swapped the melody to piano instead. Not that it really matters much when all the actual values for the sample are random. Still, you’ll need to make that change: just go to this line, right below the others:

strat.gen_add(Generator_AmbientMelody(smp = SMP_GUITAR))

and replace SMP_GUITAR with SMP_PIANO. Because of this I didn’t make a range for a guitar sample. I suggest you make your own. I guess one could have multiple instruments that are generated so that they, you know, actually sound somewhat like that instrument, and then determine what is used randomly.

I’ll be tweaking these ranges quite a bit soon, so that I hopefully get something other than a banjo-esque instrument. The other sounds aren’t too bad (for instance, the snare varies between a clap and a sharper sound), but they need tweaking too; I made the ranges in three minutes later last night at probably 1am, so they kind of suck. As a side note, I have no idea what half the values do to the sound. I can imagine what decay does, but filtdc? I just kind of slapped some values in and saw what came out. If anyone could tell me what some of the numbers actually do to the sound that would be much appreciated. :|

EDIT: I think the ‘piano’ range is skewed too much on a few values, so it’s much more likely to generate a banjo-y sound than anything else. Out of five samples, three sound like a banjo, one sounded like an electric guitar and another sounded a little more like the original piano.

Flag Post

Topic: Game Programming / Free music in 5 seconds.

Altered the code to randomly generate the instruments as well with a piano base for the main melody, cranked the tempo up to 180 and got a nice piece that sounds like it uses a banjo. I turned a piano into a banjo. Sounds great though! Also, when it jumps down an octave it sounds completely different so it’s like I’ve got a second channel supporting it every once in a while. xD

I’m gonna export the sample save a copy of the original IT file so I can use it with other pieces.

Flag Post

Topic: Game Programming / Free music in 5 seconds.

Thanks for posting this, OP. I was tinkering with this (I don’t use Python, but I have used C), changing the instruments, tempo, etc. when this amazing battle theme came out by accident. Seriously carries a tune pretty well, considering everything beforehand sounded chaotic. But then I realized while playing it in VLC that it doesn’t loop cleanly. It says the song is 31~ seconds long but cuts out at 14 seconds in. Anyone else have a similar problem?

EDIT: DL’d Schism Tracker and it plays fine in that.

EDIT2: No idea why it doesn’t work with VLC, maybe I’m just tired, but it doesn’t matter. Can export with Schism as WAV and use that, or convert.

Apparently raising the tempo, swapping the guitar out with a piano and making the bass a bit more subtle makes this thing produce good battle themes. :D

Flag Post

Topic: General Gaming / My 3DS DIED due to Black Screen of DEATH

Title says it all, mostly. My 3DS died recently after being inflicted by a BSoD. Unlike some 3DS users, mine did NOT turn back on after forcing it to power off. I go to start MK7, and the whole thing fries itself. So, my only option was to bring it to Nintendo.

Here’s the blog post for when it originally died.

And here’s for after it was brought to Nintendo’s repair center.

It’s a pretty long read, btw. Anyone else have their 3DSes affected by the Black Screen of Death? Any ideas what causes it?