Research
My perfect format would be: plain text format which store series of music notes with duration, similar to (C#,whole),(D,half) ... format and which is really simple. I didn't find exactly what I need, so I have 2 option:
- make my own format, but in this case I should write a small editor tool too
- find a not perfect, but good enough format, e.g.: music XML. This can be edit with popular music softwares (Finale, Sibelius etc.)
My feelings suggest the second option, but I didn't develop anything in this way at the moment. Even more, later I made my own, simple format.
Coding
I'm ready with basics (~simple sound notes). If I want to play quarter C note, I should write:
Sound snd = new Sound();
snd.play(Sound.Tone.C2,Sound.Duration.Quarter);
I should make an Sound object and call the play method with tone and duration. These are enum types so you can choose them from a "list". C2 means C in the second octave. Naturally you can play half notes (D# or B etc.) too.
I made a Song class for more complex operations. Possible to load a song from file, like this:
Song exampleSong = new Song("example_song.txt");
exampleSong.repeat = false;
exampleSong.play(); //in case of repeat, there is a stop method
As you can see it needs a song file. My plain text music file format is like this:
F3,Q,
F3,TQ,
B3,TQ
It means F in 3. octave will sounds with quarter length, then F in 3. octave will sounds for 3 quarter and B in 3. octave for 3 quarter and so on.
Current sound features
- play beep sound with music tone and duration, forget about frequencies
- my own format can be played from plain text file
- playing sound on another thread (possible to play music in background)
- repeatable
- nothing for awhile
Nincsenek megjegyzések:
Megjegyzés küldése