tagCANDY CGI VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
[ツリー表示へ]  [ワード検索]  [Home]

タイトル Re: VB.NETによるMIDI作曲支援ソフト〜
投稿日: 2005/11/12(Sat) 14:45
投稿者なおこ(・∀・)
お世話になります。

おもしろそうだったんで、ちょっと調べてみました。
で、音を鳴らすだけだったら出来ました。
ただ私もあまり詳しい事は解らないので、質問されても回答できないかもしれません(汗
使っているAPIの関数名などでGoogle検索してみると、色々情報が得られるかと思います。

参考にした所を書いときます。
[MIDI の基本]
hhttp://wisdom.sakura.ne.jp/system/winapi/media/mm11.html
[43.MIDI音源を使用して音を鳴らす]
hhttp://homepage1.nifty.com/MADIA/vb/API/MidiOutShortMsg.htm
[midiOutShortMsg]
hhttp://www.microsoft.com/japan/msdn/library/default.asp?
url=/japan/msdn/library/ja/jpmltimd/html/_win32_midioutshortmsg.asp
hhttp://yokohama.cool.ne.jp/chokuto/urawaza/api/midiOutShortMsg.html
[MIDIデバイスを直接鳴らす]
hhttp://www.skai.co.jp/arufonsu/vb/VB-002-07-003.htm
[MIDI外部機器をVBでコントロールする]
hhttp://www.cs.k.tsukuba-tech.ac.jp/labo/koba/software/midi.html
[Programming with MIDI in VB.Net]
hhttp://tomgroves.net/projects/vbmidi/

===============================================================
Form には NumericUpDown コントロール 1 個と
Button を 1 個、配置しています。
===============================================================
Imports System.Runtime.InteropServices

Public Class Form2
    Inherits System.Windows.Forms.Form

    'MIDIデバイスをOpen
    <DllImport("winmm.dll", CharSet:=CharSet.Auto)> _
    Private Shared Function midiOutOpen( _
                            ByRef hMidiOut As Integer, _
                            ByVal uDeviceID As Integer, _
                            ByVal dwCallback As Integer, _
                            ByVal dwInstance As Integer, _
                            ByVal dwFlags As Integer) As Integer
    End Function

    'MIDIデバイスをClose
    <DllImport("winmm.dll", CharSet:=CharSet.Auto)> _
    Private Shared Function midiOutClose( _
                            ByRef hMidiOut As Integer) _
                            As Boolean
    End Function

    <DllImport("winmm.dll", CharSet:=CharSet.Auto)> _
    Private Shared Function midiOutShortMsg( _
                        ByVal hMidiOut As Integer, _
                        ByVal dwMsg As Integer) _
                        As Integer
    End Function

    'MIDIデバイスハンドル
    Private m_hMidiDevice As Integer

    Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
MyBase.Load
        Dim ret As Integer = midiOutOpen(Me.m_hMidiDevice, -1, 0, 0, 0)
        If ret <> 0 Then
            MessageBox.Show("Device の Openに失敗")
        End If
        Me.NumericUpDown1.Minimum = 0
        Me.NumericUpDown1.Maximum = 127
        Me.NumericUpDown1.Value = 60 '60がドの音かな?
    End Sub

    '音を鳴らす
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
        Dim dwMsg As Integer = &H90 + 1 + (Decimal.ToInt32(Me.NumericUpDown1.Value) * &H100)
+ 100 * &H10000
        midiOutShortMsg(Me.m_hMidiDevice, dwMsg)
    End Sub

    Private Sub Form2_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        If Not midiOutClose(Me.m_hMidiDevice) Then
            MessageBox.Show("Device の Closeに失敗")
        End If
    End Sub
End Class

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)

古いスレッドにレスはつけられません。