Here is the musicgen program in java (as an applet embedded in this webpage). Your browser likely doesn't start it automatically (you should see a button below). If you want to still run it, it is a bit complicated but:
- you need to have java installed on your computer
- download musicgen to your disk
- create a simple html file (let's say
music.html
) in the same directory as the jar file you downloaded, with the following contents: <html> <applet code="JavaSoundApplet.class" archive="MusicGen.jar" width="760" height="480"> </applet> </html>
- use "appletviewer" (a program from java distribution) to run this html file: in system console window, type:
appletviewer music.html
A new version that works perfectly well in a web browser is here.
User's manual
Menu
Evolution
- Nowa – restarts evolution process. Warning! All data from previous evolution will be lost.
- Dodaj nową frazę – enables adding a new phrase saved in MusicGen format.
- Zapisz frazę – enables saving a phrase in MusicGen format.
- Zapisz frazę jako midi – enables saving a phrase as midi.
Options
- Ustawienia procesu ewolucji – calls evolution process parameters window.
- Applet Info – shows which settings in .java.policy file are required to use all program possibilities.
Main window objects
- Field "liczba pokoleń" and "start" button – clicking the button starts evolution process executed by number of generations equal to field value.
- "Lista fraz" – all described below buttons from this window operate on a phrase chosen from the list.
Phrase description on individuals list:
[Ranking
] w:Wiek
M=_evalMelo
->evalMelo
V=_evalVelo
->evalVelo
I=_evalInter
->evalInter
R=_evalRthm
->evalRthm
[l_Nut
:l_Taktów
*Metrum
@Tempo
] Komentarz
- "Zagraj" i "Stop" buttons – enable to start and stop playback of chosen phrase.
- Field and "Button Ustaw czas ochronny (liczbę pokoleń) na" – enables to set period of time in which phrase regardless of its quality won't be removed from population.
- "Ustaw ocenę", "Ustaw ocenę zgodną z rankingiem" and "Ocena" slidebar – Slide-bar "Ocena" ("Estimation") shows estimation of actual phrase. This estimation may be modified by user due to his/hers preferences, by changing bar's position and pressing button "Ustaw ocenę" ("Set estimation"). Also return to estimation determined by program is possible by clicking "Ustaw ocenę zgodną z rankingiem" ("Set estimation accord with ranking") button..
Objects in evolution parameters window
To exactly understand influence of settings that this window provides, to musical phrases evolution process it's is a must to read the part treating about musical phrases evolution.
- Field "Prawdopodobieństwo mutacji" ("Mutation probability") – sets mutation probability for each population gene.
- Field "Prawdopodobieństwo krzyżowania" ("Crossing probability") – sets crossing probability of musical phrases.
- Field "Wielkość populacji" ("Population size") – sets musical phrases population size.
- Field "Maksymalna liczba nut we frazie" ("Maximum notes number in phrase") – sets phrase notes number- it should not be large (greater than 30).
- "krzyżowanie muzyczne", "krzyżowanie zwykłe" buttons – set way of musical phrases crossing.
Evaluation of musical phrases
In this project an attempt has been undertaken of automatic musical phrases evaluation. Estimation of aesthetic values using strictly mathematical formulas doesn't really seem to be easy (if it's possible at all), that's why poor effects of this experiment should not surprise. From the same reason, that aim function is not strictly defined we felt eligible to use solutions (in some cases it were even "tricks"), which validity is hard to prove but which (probably) were leading to some approximated way of phrase estimation, taking on account particular properties.
4 functions of melody estimation were used:
- Melo – task of this function is to estimate sound pitch in whole phrase using Fourier transform (DFT)
- Velo – this function estimates amplitude of sound volume in whole phrase using DFT
- Inter - simplifying – this is average size of intervals between successive sounds
- Rthm - function estimates "richness" of rhythm
Last stage is computation of user's preference function (eval) on basis of given feature estimation (eval_index).
Phrase estimation functions
"Richness" of melody(Melo)
Function computes Discrete Fourier Transform (DFT); set of input samples is a vector of notes pitches, transformed in a way that sequence of successive, identical values is proportional to note's length which this sequence suits. Additional stage of computation fills gaps with neighbor values. Value eval_index_Melo is in approximation a sum of amplitudes of positive successive DFT constituents divided by constituent number. Additionally function Melo is only estimation function that takes melody tempo on account.
This function in its assumption was about to increase its value due to appearance of larger intervals or/and faster fragments of melody.
Differentiation of dynamics (Velo)
Function computes Discrete Fourier Transform (DFT); set of input samples is a vector of note pitches values prepared using the same method as above.
eval_index_Velo = (S_{k = (1, fmax)} (|F|_{k} / k) + 0.25 * max_{k = (1, fmax)}|F|_{k} ) / f_{max}
, where
|F|_{k} is an amplitude of k-th DFT constituent.
Mean interval (Inter)
eval_index_Inter = sumeval / sumdiv
sumeval = S_{k} intereval (n_{k}-n_{k+1}) * div_{k,k+1}
sumdiv = S_{k} div_{k,k+1}
div_{k,k+1} = min {(d_{k} + d_{k+1}) / (d_{k} + d_{k+1} + p_{k,k+1}), (d_{k} + p_{k,k+1}) / (d_{k+1} + p_{k,k+1})}
, where
n_{k} - is k-th note pitch C),
d_{k} – is k-th note length ,
p_{k,k+1} – gap (pause) between k-th and successive note.
Weight div_{k,k+1} introduction is justified because large interval between successive notes is less perceptible while these sounds are separated by large pause or first of them is a short pre-note (ornament) of second.
intereval (k) = 0.8 * log (|k| + 3)
+ 1.0 * log (8 – ||k| mod 12 – 6|)
+ 1.0 * tabeval _{|k| mod 12}
+ 1.0 * [(|k| - 1) / 12]
Value of above function is a sum of four constituents. Two of them depend on logarithm from size of interval and distance of interval from size of 6 halftones. tabeval vector contains (arbitrary chosen) values dependent (in approximation) from degree of interval's dissonance. Last ingredient is equal zero only when interval is greater than octave.
"Richness" of rhythm(Rthm)
set of input samples is a vector of values increasing by 1 which each note.
eval_index_Rthm = S_{k = (1, fmax)} (avg_{k} + std_dev_{k}) / f_{max}
, where
avg_{k} – is average value |F_{k, j}| computed by j (bars),
std_dev_{k} – is standard deviation among values F_{k, j} computed by j (bars),
F_{k, j} – is value of k-th cosine constituent computed for j-th bar.
Both replacing Fourier transform with cosine transform and its computation separately for each bar (together with taking into consideration variety of these values) is justified by willingness to pull out not only the richness' of rhythmic division among whole melody but also differences of local division.
Phrases estimation on basis of characteristics estimation.
For each inspected characteristic value of preference function equals:
eval = min {a/b, b/a}
, where
a = eval_index + add
,
b = best + add
.
It is quotient scaling to range [0,1]. Usage of constantadd (except of quotient scaling) prevents from incorrect arithmetical operations if best oreval_indexwas equal 0. Constant Best i add values were set arbitrarily.
Program and text: Jerzy Blaszczynski, Marcin Szymanski |
Mentor: Maciej Komosinski |
Translation: Piotr Ceglowski |