In this tutorial I am going to talk about basics of music programming and music technology. Music programming is an interesting but a very vast area of learning and applying however, jMusic project makes music programmer’s life much easier and makes music programming more effective. jMusic library is an API for Java music programming and provides tools to for music compositional and audio processing.
Today I am going to talk about the fundamentals of music programming using jMusisc library and compose, and process and monitor simple music.
Today's TODO list ...
For those who are not fluent with music notations and western music theory this is how it looks likes in abc format. (More like c,d,e,f,g format :) )
Changing the instrument is easier than creating the song all you need to do is map your phrase to a part and play the part as shown below.
You can try and experiment with different musical instruments such as guitar violin ect. :)
View.notate(phr);
Today I am going to talk about the fundamentals of music programming using jMusisc library and compose, and process and monitor simple music.
Today's TODO list ...
- Create a Simple Song
- Add Instrumentals
- Save and notate
Create Your First Song
Creating your first song is crucial :) If you know the music notation to a particular song you can create almost any song using this technique (make sure you select your favorite song for this task) . Since most people know twinkle twinkle little star and its quite catchy I am going to select that song.
Before we start we need to make sure we have jMusic library, you need to download and import this library to your java class path.
First look at the manuscript notation of our songs.For those who are not fluent with music notations and western music theory this is how it looks likes in abc format. (More like c,d,e,f,g format :) )
Now let's create this song in java.
package mymusicapp;
import jm.JMC;
import jm.music.data.Note;import jm.music.data.Part; import jm.music.data.Phrase; import jm.music.data.Score; import jm.util.Play;import jm.util.Write;public class Main implements JMC {public static void main(String[] args) {
Phrase phr = new Phrase("Twinkle twinkle", 0.0); int[] pitchArray = {C4,C4,G4,G4,A4,A4,G4,F4,F4,E4,E4,D4,D4,C4,G4,G4,F4,F4,E4,E4,D4,G4,G4,F4,F4,E4,E4,D4};double[] rhythmArray = {C, C, C, C, C, C, M, C, C, C, C, C, C, M, C, C, C, C, C, C, M, C, C, C, C, C, C, M}; phr.addNoteList(pitchArray, rhythmArray);Play.midi(phr);}}}
As you can see it is very easy to create music using jMusic library. All you need to do is add the notes and the pitch classes and put them together. If you look at it closely, Notes are given in “pitchArray” int array of pitch classes in C,D,E,F,G manner number 4 represents the fourth octave. And the duration of each pitch classes are given Crochet ( C ), Quaver (Q), Semi Quaver (SQ), Minim (M) ect.
Following table list duration of each note.
Add Instrumentals
Changing the instrument is easier than creating the song all you need to do is map your phrase to a part and play the part as shown below.
phr = new Phrase("Twinkle twinkle", 0.0);
Part p = new Part("FLUTE", FLUTE, 0);phr.addNoteList(pitchArray, rhythmArray);p.add(phr);Play.midi(p);
You can try and experiment with different musical instruments such as guitar violin ect. :)
Save and notate
You can save your creation as a midi file by simply adding the following code.
To view the manuscript notation you can use View.notate method and you can view the manuscript notation of your music creation.
View.notate(phr);
No comments:
Post a Comment