Sub DaoNhac_LoiRuBuon()
Const cnNode = 30
Dim aNode(cnNode) As nNote, aQuang(cnNode) As Long, aDelay(cnNode) As Single
Dim i As Long
i = 0
[COLOR="Green"]'Định nghĩa các nốt nhạc[/COLOR]
aNode(i) = NoteD: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteE: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteF: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteE: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteD: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteA: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteA: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteG: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteG: aQuang(i) = 0 * Quang: aDelay(i) = Den: i = i + 1
aNode(i) = NoteG: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteA: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteA1: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteA: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteG: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteD: aQuang(i) = 1 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteD: aQuang(i) = 1 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteA: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteA: aQuang(i) = 0 * Quang: aDelay(i) = Den: i = i + 1
aNode(i) = NoteE: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteF: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteG: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteF: aQuang(i) = 0 * Quang: aDelay(i) = Kep: i = i + 1
aNode(i) = NoteE: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteF: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteG: aQuang(i) = 0 * Quang: aDelay(i) = Den: i = i + 1
[COLOR="Green"]'Đoạn 1[/COLOR]
aNode(i) = NoteF: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteG: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteA: aQuang(i) = 0 * Quang: aDelay(i) = Den: i = i + 1
[COLOR="Green"]'Ngắt đoạn 2[/COLOR]
aNode(i) = NoteE: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteC: aQuang(i) = 0 * Quang: aDelay(i) = Don: i = i + 1
aNode(i) = NoteD: aQuang(i) = 0 * Quang: aDelay(i) = Den: i = i + 1
[COLOR="Green"]'Kiểm tra và truyền âm thanh cho máy tính[/COLOR]
If hMIDI = 0 Then LoadMIDI
[COLOR="Green"]'Chọn loại nhạc cụ[/COLOR]
Change_Sound hMIDI, Sound_list.[Nylon String Guitar]
K = 0
For K = 0 To 1 [COLOR="Green"]'Chạy 2 lần aNode(i)[/COLOR]
If K = 1 Then Change_Sound hMIDI, Sound_list.[Metal Pad]
For i = 0 To cnNode - 3
If K = 1 And i = cnNode - 6 Then [COLOR="Green"]'Ngắt sang đoạn 2[/COLOR]
Exit For
Else [COLOR="Green"]'Đoạn 1[/COLOR]
NotePlay aNode(i), aQuang(i), aDelay(i)
End If
Next
If K = 1 Then [COLOR="Green"]' Đoạn 2[/COLOR]
For i = cnNode - 3 To cnNode
NotePlay aNode(i), aQuang(i), aDelay(i) [COLOR="Green"]'Phát ra âm thanh[/COLOR]
Next
End If
Next
End Sub