Skip to content

MIDIシーケンサー

Reputeless edited this page Mar 14, 2017 · 3 revisions
MIDIシーケンサー
# include <Siv3D.hpp>

void Main()
{
    Window::Resize(480, 480);
    Graphics::SetBackground(Palette::White);
    Midi::SendMessage(MidiMessage::SetInstrument(0, GMInstrument::MusicBox));

    const Array<uint8> midis{ 86, 84, 83, 81, 79, 77, 76, 74, 72, 71, 69, 67, 65, 64, 62, 60 };
    const int32 dotSize = 30;

    Grid<bool> dots(16, 16);
    int32 previousLine = 0;

    while (System::Update())
    {
        const int32 currentLine = Time::MillisecSince1601() / 160 % 16;

        if (currentLine != previousLine)
        {
            for (auto i : step(dots.height))
            {
                Midi::SendMessage(dots[i][currentLine] ?
                    MidiMessage::NoteOn(0, midis[i]) : MidiMessage::NoteOff(0, midis[i]));
            }

            previousLine = currentLine;
        }

        for (auto p : step({ dots.width, dots.height }))
        {
            Rect rect(p * dotSize, dotSize, dotSize);

            if (rect.leftClicked)
            {
                dots[p.y][p.x] = !dots[p.y][p.x];
            }

            const Color color = HSV(40, 0.2 + dots[p.y][p.x] * 0.8 - (p.x == currentLine) * 0.2, 0.9 + dots[p.y][p.x] * 0.1);

            rect.stretched(-1).draw(color);
        }
    }
}

Siv3D について

  1. Siv3D の基本
  2. 図形を描く
  3. テクスチャを描く
  4. テキストを描く
  5. 文字列と数値の変換
  6. キーボード入力
  7. マウス入力
  8. サウンドの再生
  9. MIDI の再生
  10. ウィンドウと背景
  11. 図形のあたり判定
  12. 乱数
  13. ダイアログ
  14. ドラッグ & ドロップ
  15. アプリの状態
  16. テキストファイル
  17. INI, CSV, JSON
  18. バイナリファイル
  19. GUI
  20. アセット管理
  21. 画像編集
  22. Web カメラ
  23. マイク入力
  24. 経過時間の測定
  25. HSV カラー
  26. ファイルダウンロード
  27. 3D 描画
  28. 2D のレンダーステート
  29. 3D のレンダーステート
  30. パーティクル
  31. スクリーンショット
  32. アプリケーションの公開
  33. さらに学ぶには

表現テクニック集

入出力デバイス

開発のヒント

Clone this wiki locally