Free music in 5 seconds. page 3

66 posts

Flag Post

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

 
Flag Post
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
(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.

 
Flag Post
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

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

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

just on a similar note, I found a similar python script by some guy, called Pythoven

I made this awesome song with it:
http://soundcloud.com/tehdog/pythoven-awesome-loop-1

 
Flag Post

@ 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.

@Tehdog: Nice find, I’ll give it a try later.
The soundcloud file sounds really suitable for some games. Thanks for sharing. (:

 
Flag Post

I’m unfamiliar with python, what would be the easiest way to run/compile this script?

 
Flag Post

Assuming you are on Windows (Mac too I think), and assuming you mean the script from the OP, you download Python (http://www.python.org/download/releases/2.7.3/), download the script file, remove the .txt so it’s just called atrk-bu.py, and double click it.
If you don’t plan to change it see here:

Originally posted by tehdog22:

Just for people who can’t easily run python or open .it files:
Here are 54 songs in .it and .ogg (128kbps audio) file format generated by this:
http://j.mp/OiP1eD

 
Flag Post

Thanks :)

 
Flag Post
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

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

I wanted to download the Python file in the OP but I can’t access the webpage. Could someone please post the code into pastebin or somewhere else where I can get it. Thanks.

 
Flag Post

http://pastie.org/5104625

 
Flag Post
Originally posted by Senekis93:

http://pastie.org/5104625

Thank you. I have been sitting at the computer for about an hour playing with this.