Research->Music Softtware Development->Preparation
This page introduces MIDI software development.
SMF Edit Engine
If the final output is SMF (MIDI file), you will need to prepare class that has function of loading, writing, playing, and editing of SMF. You will need to have some knowledge of MIDI and SMF, I refer to books entitled "MIDI Bible I" and "MIDI Bible II" (both in Japanese). I think no other books will be necessary since these books cover all what you need. In addition, the book entitled "Windows Sound Programming" (in Japanese) would be a good reference. For your information, I have listed some useful books here.
Event Management
There are some choices how you set class that deals with MIDI. A minimum unit of MIDI is a message. It would be more understandable for you to consider a message as an order sucha as "play the sound", "stop the sound", or "change the tone". These are defined as "Note On Message", "Note Off Message" and "Program Change" according to MIDI standard. When it comes to SMF file, time data will be added and these become "Note On Event", "Note Off Event", and "Program Change Event". Therefore, a minimum unit of SMF is an event.
Since SMF is made up of group of events, how you manage the events becomes very important. Please click here for more information about message and event.
Tips
SMF is made up of group of events.
Strictly speaking, each event has different data inside such as "Note On Message", "Note Off Message", and "Program Change". However, it would be easy to manage by sorting them according to the same data type because there are a lot of common features, too. There are 2 choices in managing the set of all events sorting by the same type. One is a method of using array and another one is using the list structure.
Because how many the total of the event included in the file becomes beforehand cannot be understood, the memory will be extra secured though it is easy to understand from the head imaging it at the array, and the operation ends almost because of the copy of the memory between arrays.
The list structure manages the chain of the event as a list by maintaining the pointer and the pointer of the following event to the previous event. There is no problem here even if the total of the event is not understood beforehand. However, it is necessary to add the event to the list structure, and to make the processing deleted. It thinks it is changed to the list structure now though the program was being written at first for me in the array structure.
Tips
List structure is better choice for event management.
Consideration Regarding Form
It is understood that the note input to open SMF with the sequence software has four information on the pronunciation timing, the number of notes, the velocity, and the gate time. Pronunciation timing, for instance, is data of 240 tick ofsecond beat of the first bar. Note number is a number that indicates sound level such as 60. Sometimes it is indicated by name such as C4 and octave. Velocity is the strength of the sound. Gate time is the length of the sound.
Data is maintained in actual SMF though an individual sound is managed by data like the above-mentioned, and displayed in the sequence software by a quite different form. In SMF, there is no "Note Event", instead, there are "Note On Event" and "Note Off Event". In sequcence software, "Gate time" is calculated by the length between "Note On Event" and "Note Off Event".
We call it "Q1 type" that has data like sequence software and "Q2 type" that has data like SMF. When creating a process that edits event within SMF, it is variously easy with data in the "Q2 type". However, you will need to define both Q1 and Q2 and prepare process that enables you to come and go between them since final output would be "Q1 type".
Tips
Process is easier to manage as "Note Event" rather than "Note On Event" or "Note Off Event".
Consideration Regarding Time Data
In the sequence software, the timing of the event is displayed at intervals from the first position of the tune such as 240 tick of second beat of first bar. "Delta time" is the data that maintains the time data in SMF, and maintains the interval from the previous event. (This data is maintained as variable length data.) It is necessary to examine whether to have the time data absolutely in the class that treats SMF at time or to have it at relative time thoroughly. When it is made to come and go mutually, the programming becomes easy.
Create Base Class In Preparation For Transplant
Ringtone data for mobile phones have structural similarity with MIDI data. Although the ringtone data of DoCoMo, SoftBank, and au are a litte bit different structurely, all of them are made from SMF (MIDI) basically.
For example, individual sound is maintained as a note event of the Q2 form though the ring tone melody file is thought to be sets of events such as the program changes and the note events. In addition to that, one mass of data in SMF including the event is managed by the concept named chunk. In a word, some chunks are contained in SMF, and the event that is a minimum unit is included in either chunk such as track chunk. This structure is basically the same also in the ringtone file.
From what I have mentioned above, you can see that it is easy to transplant from SMF edit engine to ringtone edit engine if you create MIDI and parts that are common in each ringtone carrier as base class and develop the class that treats MIDI or ringtone to be derived. However, this is based on the fact that you know the format of ringtone file, and this format is not open to the public as SMF is open to the public.