<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Next MIDI Project &#187; Tips</title>
	<atom:link href="http://starway.s234.xrea.com/wordpress/?cat=7&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://starway.s234.xrea.com/wordpress</link>
	<description>C# / IronPython 上で利用可能な MIDI ライブラリ Next MIDI を公開しています。</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:22:36 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6</generator>
		<item>
		<title>MIDI ファイルを４キー上げて再生する</title>
		<link>http://starway.s234.xrea.com/wordpress/?p=33</link>
		<comments>http://starway.s234.xrea.com/wordpress/?p=33#comments</comments>
		<pubDate>Wed, 04 Jan 2012 15:21:05 +0000</pubDate>
		<dc:creator>yokaze</dc:creator>
				<category><![CDATA[Next MIDI]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://starway.s234.xrea.com/wordpress/?p=33</guid>
		<description><![CDATA[<a href="http://starway.s234.xrea.com/wordpress/?p=33" title="MIDI ファイルを４キー上げて再生する"></a>次の例では、Next MIDI を用いて、MIDI ファイルのキーを +4 した &#8230;<p class="read-more"><a href="http://starway.s234.xrea.com/wordpress/?p=33">Continue reading</a></p>]]></description>
	<a href="http://starway.s234.xrea.com/wordpress/?p=33" title="MIDI ファイルを４キー上げて再生する"></a>			<content:encoded><![CDATA[<p>次の例では、Next MIDI を用いて、MIDI ファイルのキーを +4 した後、再生しています。</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.IO;
using System.Text;
using NextMidi.Data.Domain;
using NextMidi.DataElement;
using NextMidi.Filing.Midi;
using NextMidi.MidiPort.Output;
using NextMidi.Time;

/* ... */

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // 引数チェック
            if (args.Length != 2)
            {
                Console.WriteLine(&quot;1 port name and 1 file name required&quot;);
                return;
            }

            // MIDI ファイルを読み込み
            string fname = args[1];
            if (!File.Exists(fname))
            {
                Console.WriteLine(&quot;File does not exist&quot;);
                return;
            }
            var midiData = MidiReader.ReadFrom(fname, Encoding.GetEncoding(&quot;shift-jis&quot;));

            // 全ての MIDI ノートを 4 半音上げる
            foreach (var track in midiData.Tracks)
            {
                foreach (var note in track.GetData&lt;NoteEvent&gt;())
                {
                    note.Note += 4;
                }
            }

            // テンポマップを作成
            var domain = new MidiFileDomain(midiData);

            // MIDI ポートを作成
            var port = new MidiOutPort(args[0]);
            try
            {
                port.Open();
            }
            catch
            {
                Console.WriteLine(&quot;no such port exists&quot;);
                return;
            }

            // MIDI プレーヤーを作成
            var player = new MidiPlayer(port);

            // MIDI ファイルを再生
            player.Play(domain);
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://starway.s234.xrea.com/wordpress/?feed=rss2&#038;p=33</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MIDI 信号を再生する</title>
		<link>http://starway.s234.xrea.com/wordpress/?p=25</link>
		<comments>http://starway.s234.xrea.com/wordpress/?p=25#comments</comments>
		<pubDate>Wed, 04 Jan 2012 14:54:27 +0000</pubDate>
		<dc:creator>yokaze</dc:creator>
				<category><![CDATA[Next MIDI]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://starway.s234.xrea.com/wordpress/?p=25</guid>
		<description><![CDATA[<a href="http://starway.s234.xrea.com/wordpress/?p=25" title="MIDI 信号を再生する"></a>次の例では、Next MIDI を用いて、簡単な MIDI 信号を再生します。]]></description>
	<a href="http://starway.s234.xrea.com/wordpress/?p=25" title="MIDI 信号を再生する"></a>			<content:encoded><![CDATA[<p>次の例では、Next MIDI を用いて、簡単な MIDI 信号を再生します。</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Threading;
using NextMidi.DataElement;
using NextMidi.MidiPort.Output;

/* ... */

static void Main(string[] args)
{
    // MIDI ポート名を指定して MIDI ポートを開く
    if (args.Length != 1)
    {
        Console.WriteLine(&quot;1 port name required&quot;);
        return;
    }
    var port = new MidiOutPort(args[0]);
    try
    {
        port.Open();
    }
    catch
    {
        Console.WriteLine(&quot;no such port exists&quot;);
        return;
    }

    // Program No.5 に切り替え
    port.Send(new ProgramEvent(4));

    // 500 ミリ秒待つ
    Thread.Sleep(500);

    // ドレミファソラシド
    foreach (byte n in new byte[8] { 60, 62, 64, 65, 67, 69, 71, 72 })
    {
        // ベロシティ 112 でノートオンを送信
        port.Send(new NoteOnEvent(n, 112));
        Thread.Sleep(n != 72 ? 500 : 1500);
        port.Send(new NoteOffEvent(n));
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://starway.s234.xrea.com/wordpress/?feed=rss2&#038;p=25</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MIDI ポートを列挙する</title>
		<link>http://starway.s234.xrea.com/wordpress/?p=19</link>
		<comments>http://starway.s234.xrea.com/wordpress/?p=19#comments</comments>
		<pubDate>Wed, 04 Jan 2012 14:47:10 +0000</pubDate>
		<dc:creator>yokaze</dc:creator>
				<category><![CDATA[Next MIDI]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://starway.s234.xrea.com/wordpress/?p=19</guid>
		<description><![CDATA[<a href="http://starway.s234.xrea.com/wordpress/?p=19" title="MIDI ポートを列挙する"></a>次の例では、Next MIDI を用いて、MIDI 入力ポートと MIDI 出力 &#8230;<p class="read-more"><a href="http://starway.s234.xrea.com/wordpress/?p=19">Continue reading</a></p>]]></description>
	<a href="http://starway.s234.xrea.com/wordpress/?p=19" title="MIDI ポートを列挙する"></a>			<content:encoded><![CDATA[<p>次の例では、Next MIDI を用いて、MIDI 入力ポートと MIDI 出力ポートの一覧を取得します。</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using NextMidi.MidiPort.Input.Core;
using NextMidi.MidiPort.Output.Core;

/* ... */

static void EnumInput()
{
    int count = MidiInPortHandle.PortCount;
    for (int i = 0; i &lt; count; i++)
    {
        Console.WriteLine(MidiInPortHandle.GetPortInformation(i).szPname);
    }
}

static void EnumOutput()
{
    int count = MidiOutPortHandle.PortCount;
    for (int i = 0; i &lt; count; i++)
    {
        Console.WriteLine(MidiOutPortHandle.GetPortInformation(i).szPname);
    }
}

static void Main(string[] args)
{
    EnumInput();
    Console.WriteLine();
    EnumOutput();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://starway.s234.xrea.com/wordpress/?feed=rss2&#038;p=19</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>トラックごとのイベント数を数える</title>
		<link>http://starway.s234.xrea.com/wordpress/?p=1</link>
		<comments>http://starway.s234.xrea.com/wordpress/?p=1#comments</comments>
		<pubDate>Wed, 04 Jan 2012 05:01:50 +0000</pubDate>
		<dc:creator>yokaze</dc:creator>
				<category><![CDATA[Next MIDI]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://starway.s234.xrea.com/wordpress/?p=1</guid>
		<description><![CDATA[<a href="http://starway.s234.xrea.com/wordpress/?p=1" title="トラックごとのイベント数を数える"></a>次の例では、Next MIDI を用いて、MIDI ファイルの各トラックに含まれ &#8230;<p class="read-more"><a href="http://starway.s234.xrea.com/wordpress/?p=1">Continue reading</a></p>]]></description>
	<a href="http://starway.s234.xrea.com/wordpress/?p=1" title="トラックごとのイベント数を数える"></a>			<content:encoded><![CDATA[<p>次の例では、Next MIDI を用いて、MIDI ファイルの各トラックに含まれる MIDI イベント数、ノート数、プログラムチェンジの数、コントロールチェンジの数、メタイベント数、エクスクルーシブイベント数を表示します。</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.IO;
using System.Text;
using NextMidi.Data.Track;
using NextMidi.DataElement;
using NextMidi.DataElement.MetaData;
using NextMidi.Filing.Midi;

/* ... */

static void Main(string[] args)
{
    // MIDI ファイルを指定する
    if (args.Length != 1)
    {
        Console.WriteLine(&quot;1 source file required&quot;);
        return;
    }
    string fname = args[0];
    if (!File.Exists(fname))
    {
        Console.WriteLine(&quot;File does not exist&quot;);
        return;
    }

    // MIDI ファイルを読み込む
    var midiData = MidiReader.ReadFrom(fname, Encoding.GetEncoding(&quot;shift-jis&quot;));

    Console.WriteLine();
    Console.WriteLine(&quot;Track Evnt Note Prog Cont Meta Excl  Title&quot;);
    Console.WriteLine(&quot;----- ---- ---- ---- ---- ---- ----  ----------------&quot;);

    for (int i = 0; i &lt; midiData.Tracks.Count; i++)
    {
        var track = midiData.Tracks[i];

        Console.WriteLine(&quot;{0} {1} {2} {3} {4} {5} {6}  {7}&quot;,
        i.ToString().PadLeft(5),
        track.GetData&lt;MidiEvent&gt;().Count.ToString().PadLeft(4),
        track.GetData&lt;NoteEvent&gt;().Count.ToString().PadLeft(4),
        track.GetData&lt;ProgramEvent&gt;().Count.ToString().PadLeft(4),
        track.GetData&lt;ControlEvent&gt;().Count.ToString().PadLeft(4),
        track.GetData&lt;MetaEvent&gt;().Count.ToString().PadLeft(4),
        track.GetData&lt;ExclusiveEvent&gt;().Count.ToString().PadLeft(4),
        track.GetTitle(i == 0));
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://starway.s234.xrea.com/wordpress/?feed=rss2&#038;p=1</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
