Algorithm for music imitation? [closed]
Asked Answered
T

5

5

I'm interested in automatic music making. I was thinking about a program that is fed a large number of 1-bar arpeggios (= fixed length sequences of notes, for simplicity) and generates its own sequences, based on what it learnt.

To start with, I know I could use letter (digram? trigram?) frequency analysis, only applied to note pitches, and then generate my sequence based on frequency probabilities.

Are there more advanced algorithms you know of, maybe expressly taught for music sequences?

Tartarus answered 24/7, 2009 at 15:36 Comment(0)
R
6

The Wikipedia article on Algorithmic Composition is an excellent primer. It describes some of the models used for algorithmic music creation, notable composers, book references, and algorithmic composition software.

http://en.wikipedia.org/wiki/Algorithmic_composition

Ribbon answered 24/7, 2009 at 15:46 Comment(1)
Various fractal and sorting algorithms tend to sound musical.Flyn
K
4

Being a musician myself and a Software Engineering major, I htink I can shed some cool light here :P I've done a lot of work on the subject myself and plan on making something big based around this in the future.

When you write an algorithm, your goal is to come up with a solution- fore example, in sorting problems it's to have a sorted list. In algorithmic music composition, the solution is (usually) to have a song, or melody that is pleasing, has structure, etc.

The problem with the solution (hah) is that it is not only objective, but the solution is vastly open ended. With a sorting algorithm, you have only one way to sort a list. With music composition, you have millions of pleasing songs/whatevr your goal is.

So you will need an algorithm that is good for not finding definitive solutions, but OPTIMAL solutions. My suggestion is a genetic algorithm or similar. Genetic algorithms are great because they can create a pool of various optimal solutions.

You'd need to break the composition into parts- have a GA for melody, GA for rhythm, GA for structure, etc. And design your fitness function to fit your needs.

Of course this is only one solution to the problem; there are many and the wikipedia link listed before is a great start.

I recommend checking out: GenJam: an improvisational jazz Genetic Algorithm designed to trade solos- http://www.it.rit.edu/~jab/GenJam.html

And this book is very enlightening: http://www.springer.com/computer/information+systems/book/978-1-84628-599-8

I suppose another fun way would be with neural networks....but giving them sets woud be a bit of an issue probably....it's a lot more work.

Anyways, Good luck in your ventures :P

Knelt answered 31/7, 2009 at 14:52 Comment(1)
Also, studying music composition and harmony will go a long way to help you design fitness functions :DKnelt
D
2

Statistical analysis of existing leads to music that is -- well -- average. There's rarely anything interesting because it tends to reproduce all the common features of whatever you analyzed.

Music is multi-dimensional. You can, clearly, analyze any or all of the dimensions that interest you. Pitch, tempo, sequence of notes, harmonic progressions, volume changes, anything. Everything.

Music is subtle and complex so there's always something more to analyze.

AFAIK (my son is a composer) what's more interesting is to invent your own unique algorithm for generating music that's reasonably distinctive.

Here's something my son specified. It generates a sequence of 48 musical events that the piece is built around.

#!/usr/bin/env python
"""
there are 8, 3-note sets.
each one can occur on 3 different beats.
each pitch of the 3 note set can be in one of 3 octaves and it can either be a harmonic or a fingered note.
"""
import random

noteSetChoices = [ "C-E-G", "C-F-A", "C-E-A", "D-F-A", "D-F-B", "D-G-B", "E-G-B", "F-A-C" ]
beatChoices= [ "1 - - -", "- 2 - -", "- - - 4" ]
octaveChoices= [ 1, 2, 3 ]
techniqueChoices= [ 'Fingered', 'Harmonic' ]

for n in range(48):
    note= random.choice(noteSetChoices)
    beat= random.choice(beatChoices)
    octave= random.choice( octaveChoices )
    technique= random.choice( techniqueChoices )
    print octave, note, technique, beat
Dynasty answered 24/7, 2009 at 15:46 Comment(3)
How is the music on Spore? I'm pretty sure that music is auto generated.Presignify
Mmmmh, this means you already know genre canons, and you don't extract them from other songs.Tartarus
@janesconference: I don't know squat, actually. I'm a bass player, so I understand a little; my son's the composer.Dynasty
J
1

Though it's generally meant to work on longer sequences than one bar, Markov chaining is a simple, effective way of generating music similar to its input. For an example written in Python using RTcmix for audio generation, see my implementation here.

It is based off of the Markov chaining chapter from Notes from the Metalevel, an excellent text on algorithmic composition.

Janellejanene answered 21/1, 2013 at 6:19 Comment(0)
F
0

It really helps if you know conventions of music, so read books and articles written to teach humans how to compose songs. You'll get great ideas.

Throw some pedal point in now and then to build tension. Use the age-old technique of call-response between two different instruments.

Flaring answered 31/7, 2009 at 15:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.