マイペースなプログラミング日記

DTMやプログラミングにお熱なd-kamiがマイペースに書くブログ

とりあえずJavaでMIDI編 その1

現在以下のようなXMLを読み込ませるとピアノがドレミファソラシドと8分で鳴らし、ベースはドを8分で鳴らし続け、ドラムは8ビートの基本的なパターンでバスドラムとスネアのみが鳴る。適当にSMF形式のファイル読み込めるようにして鳴らしてみようかな

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MidiMusic>
    <Tracks>
        <Track number="1" program="0">
            <NoteList>
                <Note pitch="60" position="0" type="144" velocity="100"/>
                <Note pitch="60" position="250" type="128" velocity="100"/>
                
                <Note pitch="62" position="250" type="144" velocity="100"/>
                <Note pitch="62" position="500" type="128" velocity="100"/>
                
                <Note pitch="64" position="500" type="144" velocity="100"/>
                <Note pitch="64" position="750" type="128" velocity="100"/>
                
                <Note pitch="65" position="750" type="144" velocity="100"/>
                <Note pitch="65" position="1000" type="128" velocity="100"/>
                
                <Note pitch="67" position="1000" type="144" velocity="100"/>
                <Note pitch="67" position="1250" type="128" velocity="100"/>
                
                <Note pitch="69" position="1250" type="144" velocity="100"/>
                <Note pitch="69" position="1500" type="128" velocity="100"/>
                
                <Note pitch="71" position="1500" type="144" velocity="100"/>
                <Note pitch="71" position="1750" type="128" velocity="100"/>
                
                <Note pitch="72" position="1750" type="144" velocity="100"/>
                <Note pitch="72" position="2000" type="128" velocity="100"/>
            </NoteList>
        </Track>
    
        <Track number="1" program="34">
            <NoteList>
                <Note pitch="36" position="0" type="144" velocity="100"/>
                <Note pitch="36" position="250" type="128" velocity="100"/>
                
                <Note pitch="36" position="250" type="144" velocity="100"/>
                <Note pitch="36" position="500" type="128" velocity="100"/>
                
                <Note pitch="36" position="500" type="144" velocity="100"/>
                <Note pitch="36" position="750" type="128" velocity="100"/>
                
                <Note pitch="36" position="750" type="144" velocity="100"/>
                <Note pitch="36" position="1000" type="128" velocity="100"/>
                
                <Note pitch="36" position="1000" type="144" velocity="100"/>
                <Note pitch="36" position="1250" type="128" velocity="100"/>
                
                <Note pitch="36" position="1250" type="144" velocity="100"/>
                <Note pitch="36" position="1500" type="128" velocity="100"/>
                
                <Note pitch="36" position="1500" type="144" velocity="100"/>
                <Note pitch="36" position="1750" type="128" velocity="100"/>
                
                <Note pitch="36" position="1750" type="144" velocity="100"/>
                <Note pitch="36" position="2000" type="128" velocity="100"/>
            </NoteList>
        </Track>

        <Track number="9" program="0">
            <NoteList>
                <Note pitch="36" position="0" type="144" velocity="100"/>
                <Note pitch="38" position="500" type="144" velocity="100"/>
                <Note pitch="36" position="1000" type="144" velocity="100"/>
                <Note pitch="36" position="1250" type="144" velocity="100"/>
                <Note pitch="38" position="1500" type="144" velocity="100"/>
            </NoteList>
        </Track>
    </Tracks>
</MidiMusic>