久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 10416|回復: 7
打印 上一主題 下一主題
收起左側

用易語言寫一個電子鋼琴軟件

[復制鏈接]
跳轉到指定樓層
樓主
ID:56662 發(fā)表于 2013-11-25 03:29 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
     這只是一個窗口程序集,是整個軟件的一部分,算是核心吧

   易語言不同于C語言、java,易語言是全中文編寫,說實話,我感覺中文編寫還不如英文編寫順手。我感覺最簡單的還是我當初自己學的Python語言。

    下面是易語言的鋼琴軟件代碼:
.版本 2
.支持庫 eMMedia

.程序集 窗口程序集1
.程序集變量 琴鍵, 圖形按鈕, , "0"
.程序集變量 黑鍵, 整數(shù)型, , "0"
.程序集變量 白鍵, 整數(shù)型, , "0"
.程序集變量 上次鍵, 圖形按鈕
.程序集變量 上次鍵黑白, 邏輯型
.程序集變量 舊音符, 字節(jié)型
.程序集變量 音量鈕拖動, 邏輯型
.程序集變量 音量鈕位置, 整數(shù)型
.程序集變量 樂譜組, 文本型, , "0"
.程序集變量 樂譜位, 整數(shù)型
.程序集變量 錄音狀態(tài), 邏輯型
.程序集變量 錄音音長, 文本型, , "255"
.程序集變量 錄音文本, 文本型
.程序集變量 停止, 邏輯型
.程序集變量 設置樂器, 邏輯型
.程序集變量 音波值, 整數(shù)型, , , 模擬音波用
.程序集變量 音波值歷史組, 整數(shù)型, , "0", 模擬音波用
.程序集變量 大鍵碼, 整數(shù)型, , "0"
.程序集變量 音位, 整數(shù)型, , "0"
.程序集變量 重復按鍵, 邏輯型
.程序集變量 白鍵碼, 整數(shù)型, , "0"
.程序集變量 正常音, 文本型
.程序集變量 高一點, 文本型
.程序集變量 高二點, 文本型
.程序集變量 低一點, 文本型
.程序集變量 低二點, 文本型
.程序集變量 按下鍵, 整數(shù)型, , "0"
.程序集變量 存在, 邏輯型
.程序集變量 按鍵組, 整數(shù)型, , "0"
.程序集變量 標記組, 邏輯型, , "0"
.程序集變量 當前彈奏, 整數(shù)型
.程序集變量 已執(zhí)行, 邏輯型
.程序集變量 彈奏碼, 整數(shù)型
.程序集變量 格式, 整數(shù)型
.程序集變量 行結束, 邏輯型
.程序集變量 文件號, 整數(shù)型
.程序集變量 臨時樂譜, 文本型
.程序集變量 系統(tǒng)播放, 邏輯型
.程序集變量 是否暫停, 邏輯型

.子程序 __啟動窗口_創(chuàng)建完畢
.局部變量 黑鍵位置, 整數(shù)型, , "0"
.局部變量 黑鍵標記, 整數(shù)型, , "0"
.局部變量 左聲道, 整數(shù)型
.局部變量 右聲道, 整數(shù)型
.局部變量 標記差, 整數(shù)型
.局部變量 標記值, 整數(shù)型
.局部變量 變量, 整數(shù)型

載入 (啟動畫面, , 假)
置外形圖片 (#底圖資源, #黑色)
' //初始化
白鍵碼 = { 36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 53, 55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72, 74, 76, 77, 79, 81, 83, 84, 86, 88, 89, 91, 93, 95 }
大鍵碼 = { 90, 88, 67, 86, 66, 78, 77, 65, 83, 68, 70, 71, 72, 74, 81, 87, 69, 82, 84, 89, 85, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 189, 187, 220, 8, 46, 35, 34, 45, 36, 33, 8, 73, 79, 80, 219, 221, 188, 190, 191, 75, 76, 186, 222 }
音位 = { 36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 53, 55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72, 74, 76, 77, 79, 81, 83, 84, 86, 88, 89, 91, 93, 95, 84, 86, 88, 89, 91, 93, 95, 72, 74, 76, 77, 79, 48, 50, 52, 60, 62, 64, 65 }
重定義數(shù)組 (按下鍵, 假, 取數(shù)組成員數(shù) (大鍵碼))
按鍵組 = 大鍵碼
重定義數(shù)組 (標記組, 假, 取數(shù)組成員數(shù) (大鍵碼))
.計次循環(huán)首 (取數(shù)組成員數(shù) (標記組), 變量)
    標記組 [變量] = 假
.計次循環(huán)尾 ()
舊音符 = -1
格式 = 2
開始音位 = 0
效果1.選中 = 真
.計次循環(huán)首 (MIDI1.取設備數(shù)量 (), 變量)
    設備名組合框.加入項目 (MIDI1.取設備名 (變量 - 1), )
.計次循環(huán)尾 ()
MIDI1.打開 (0)
設備名組合框.現(xiàn)行選中項 = 0
.計次循環(huán)首 (MIDI1.取樂器數(shù)量 (), 變量)
    樂器名組合框.加入項目 (MIDI1.取樂器名 (變量), 變量)
.計次循環(huán)尾 ()
樂器名組合框.現(xiàn)行選中項 = 4
MIDI1.置樂器 (4, )

' //取音量:
.如果 (系統(tǒng)音量1.打開 (#音量類型.主音量) = 0)
    信息框 (“系統(tǒng)音量打開失敗!,您可能聽不到聲音!”, 48, )
.否則
    系統(tǒng)音量1.取音量 (左聲道, 右聲道)
    主音量鈕.頂邊 = 116 - 四舍五入 (取整 ((左聲道 + 右聲道) ÷ 2 ÷ 1489.43), 0)
.如果結束
系統(tǒng)音量1.關閉 (2)
.如果 (系統(tǒng)音量1.打開 (#音量類型.軟件合成器) = 0)
    信息框 (“軟件合成器打開失敗!,您可能聽不到聲音!”, 48, )
.否則
    系統(tǒng)音量1.取音量 (左聲道, 右聲道)
    軟件合成器鈕.頂邊 = 116 - 四舍五入 (取整 ((左聲道 + 右聲道) ÷ 2 ÷ 1349.81), 0)
.如果結束
系統(tǒng)音量1.關閉 (2)

' //下面生成琴鍵代碼:
重定義數(shù)組 (琴鍵, 假, 71)
.計次循環(huán)首 (71, 變量)
    .如果真 (變量 ≠ 6 且 變量 ≠ 14 且 變量 ≠ 20 且 變量 ≠ 28 且 變量 ≠ 34 且 變量 ≠ 42 且 變量 ≠ 48 且 變量 ≠ 56 且 變量 ≠ 62 且 變量 ≠ 70 且 變量 ≠ 76 且 變量 ≠ 84)
        標記差 = 標記差 + 1
        復制窗口組件 (琴鍵1, 琴鍵 [變量])
        標記值 = 35 + 標記差
        .判斷開始 (變量 % 2 = 0)
            琴鍵 [變量].寬度 = 12
            琴鍵 [變量].寬度 = 70
            琴鍵 [變量].頂邊 = 0
            琴鍵 [變量].正常圖片 = 琴鍵2.正常圖片
            琴鍵 [變量].按下圖片 = 琴鍵2.按下圖片
            琴鍵 [變量].透明顏色 = #白色
            琴鍵 [變量].調整層次 (#頂層)
            琴鍵 [變量].可視 = 真
            琴鍵 [變量].標記 = 到文本 (標記值)
            加入成員 (黑鍵, 標記值)
            琴鍵 [變量].左邊 = 琴鍵2.左邊 + 琴鍵1.寬度 × (絕對取整 (變量 ÷ 2) - 1)
        .默認
            琴鍵 [變量].可視 = 真
            琴鍵 [變量].標記 = 到文本 (標記值)
            琴鍵 [變量].左邊 = 琴鍵1.左邊 + 琴鍵1.寬度 × 絕對取整 (變量 ÷ 2)
            加入成員 (白鍵, 標記值)
        .判斷結束

    .如果真結束

.計次循環(huán)尾 ()


.子程序 按鍵發(fā)聲
.參數(shù) 音符, 字節(jié)型

MIDI1.奏 (開始音位 + 音符, )
舊音符 = 開始音位 + 音符


.子程序 _琴鍵1_鼠標左鍵被按下, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型
.局部變量 當前琴鍵, 圖形按鈕

當前琴鍵 = 取事件組件 ()
.如果真 (MIDI1.是否打開 () = 假)
    MIDI1.打開 (0)
    MIDI1.置樂器 (樂器名組合框.現(xiàn)行選中項, )
.如果真結束
.如果真 (是否已創(chuàng)建 (當前琴鍵))
    按鍵發(fā)聲 (到數(shù)值 (當前琴鍵.標記))
.如果真結束
.如果真 (錄音狀態(tài) = 真)
    時鐘3.時鐘周期 = 100
    錄音文本 = 錄音文本 + 到文本 (到數(shù)值 (當前琴鍵.標記)) + “@”
.如果真結束
當前彈奏 = 到數(shù)值 (當前琴鍵.標記)

.子程序 停奏
.參數(shù) v, 整數(shù)型, 可空

.如果 (是否為空 (v))
    MIDI1.停奏 (舊音符, )
.否則
    MIDI1.停奏 (舊音符, v)
.如果結束



.子程序 _琴鍵1_鼠標左鍵被放開, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型

停奏 ()
時鐘3.時鐘周期 = 0
.如果真 (錄音狀態(tài) = 真 且 存在 = 真)
    .如果真 (彈奏碼 ≤ 0)
        返回 ()
    .如果真結束
    .判斷開始 (到數(shù)值 (錄音音長 [彈奏碼]) ≤ 2)
        錄音音長 [彈奏碼] = “8”
    .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) = 3)
        錄音音長 [彈奏碼] = “4.”
    .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) = 4)
        錄音音長 [彈奏碼] = “4”
    .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) > 4 且 到數(shù)值 (錄音音長 [彈奏碼]) ≤ 6)
        錄音音長 [彈奏碼] = “2.”
    .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) > 6 且 到數(shù)值 (錄音音長 [彈奏碼]) ≤ 8)
        錄音音長 [彈奏碼] = “2”
    .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) > 10 且 到數(shù)值 (錄音音長 [彈奏碼]) ≤ 12)
        錄音音長 [彈奏碼] = “1”
    .默認
        錄音音長 [彈奏碼] = “1.”
    .判斷結束
    錄音文本 = 錄音文本 + 錄音音長 [彈奏碼] + “ ”
.如果真結束
_啟動窗口.標記 = “2”

.子程序 _時鐘1_周期事件

.如果 (圖形按鈕1.可視 = 真)
    圖形按鈕1.可視 = 假
    圖形按鈕2.可視 = 假
.否則
    圖形按鈕1.可視 = 真
    圖形按鈕2.可視 = 真
.如果結束


.子程序 _打開_被單擊

設置樂器 = 假
通用對話框1.類型 = 0
.如果真 (通用對話框1.打開 ())
    錄音文本 = “”
.如果真結束
.判斷開始 (取擴展名 (通用對話框1.文件名) = “MIDI” 或 取擴展名 (通用對話框1.文件名) = “MID”)
    格式 = 1
.默認
    格式 = 2
.判斷結束


.子程序 _播放_被單擊
.局部變量 文件樂譜, 文本型, , "0"

_啟動窗口.獲取焦點 ()
.如果真 (是否暫停)
    媒體播放1.播放 (-1)
    時鐘5.時鐘周期 = 50
    返回 ()
.如果真結束
.判斷開始 (播放.選中 = 真)
    正常音 = “”
    高一點 = “”
    高二點 = “”
    低二點 = “”
    低一點 = “”
    .判斷開始 (格式 = 0)
        .如果真 (錄音文本 ≠ “”)
            .如果真 (MIDI1.是否打開 () = 假)
                MIDI1.打開 (0)
            .如果真結束
            播放文件 (錄音文本 + “p@2”)
        .如果真結束

    .判斷 (格式 = 1)
        行結束 = 真
        .判斷開始 (音軌數(shù) (通用對話框1.文件名) = 1)
            .如果真 (MIDI1.是否打開 () = 假)
                MIDI1.打開 (0)
            .如果真結束
            .如果真 (修復文件 (通用對話框1.文件名))
                轉換格式emid (通用對話框1.文件名)
                播放文件 (臨時樂譜)
                返回 ()
            .如果真結束

        .默認
            .如果真 (信息框 (“本MIDI音樂暫不支持模擬按鍵效果,您確定繼續(xù)播放嗎?”, 64 + 1, ) = #確認鈕)
                MIDI1.關閉 ()
                媒體播放1.打開 (通用對話框1.文件名)
                媒體播放1.播放 (-1)
                系統(tǒng)播放 = 真
                時鐘1.時鐘周期 = 350
                時鐘5.時鐘周期 = 50
            .如果真結束

        .判斷結束

    .判斷 (格式 = 2)
        .判斷開始 (通用對話框1.文件名 ≠ “”)
            .如果真 (MIDI1.是否打開 () = 假)
                MIDI1.打開 (0)
            .如果真結束
            文件樂譜 = 分割文本 (到文本 (讀入文件 (通用對話框1.文件名)), #換行符, )
            .如果真 (文件樂譜 [1] ≠ “emid”)
                信息框 (“不是易語言MIDI音樂文本文件!”, 16, )
                播放.選中 = 假
                返回 ()
            .如果真結束
            MIDI1.置樂器 (到數(shù)值 (文件樂譜 [2]), )
            播放文件 (文件樂譜 [3])
        .默認
            信息框 (“沒有要播放的曲目!”, 48, )
            播放.選中 = 假
            返回 ()
        .判斷結束

    .默認

    .判斷結束
    音波.選中 = 真
.默認
    連續(xù)賦值 (0, 時鐘1.時鐘周期, 時鐘2.時鐘周期, 時鐘4.時鐘周期)
    .如果 (系統(tǒng)播放)
        媒體播放1.暫停 ()
        播放.選中 = 假
        系統(tǒng)播放 = 假
        是否暫停 = 真
        時鐘5.時鐘周期 = 0
    .否則
        模擬按琴鍵 (舊音符 - 開始音位, 真)
        停奏 ()

    .如果結束

.判斷結束




.子程序 轉換格式emid
.參數(shù) 文件名, 文本型
.局部變量 變量
.局部變量 臨時, 字節(jié)集

關閉文件 (文件號)
文件號 = 打開文件 (文件名, #讀入, )
移到文件首 (文件號)
臨時樂譜 = “”
移動讀寫位置 (文件號, , 24)
.判斷循環(huán)首 (是否在文件尾 (文件號, ) = 假)
    臨時 = 讀入字節(jié)集 (文件號, 6)
    .判斷開始 (取字節(jié)集長度 (臨時) < 6)
        臨時樂譜 = 臨時樂譜 + “p@2”
    .默認
        .判斷開始 (臨時 [3] = 3)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (32) + “ ”
        .判斷 (臨時 [3] = 6)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (16) + “ ”
        .判斷 (臨時 [3] = 12)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (8) + “ ”
        .判斷 (臨時 [3] = 18)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (8) + “. ”
        .判斷 (臨時 [3] = 24)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (4) + “ ”
        .判斷 (臨時 [3] = 36)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (4) + “. ”
        .判斷 (臨時 [3] = 48)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (2) + “ ”
        .判斷 (臨時 [3] = 64)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (2) + “. ”
        .判斷 (臨時 [3] = 72)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (1) + “ ”
        .判斷 (臨時 [3] = 96)
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (1) + “. ”
        .默認
            臨時樂譜 = 臨時樂譜 + 到文本 (臨時 [1]) + “@” + 到文本 (4) + “ ”
        .判斷結束

    .判斷結束

.判斷循環(huán)尾 ()
寫到文件 (文件名 + “.txt”, 到字節(jié)集 (“emid” + #換行符 + 到文本 (MIDI1.取樂器序號 ()) + #換行符 + 刪尾空 (臨時樂譜)))
' //上行代碼是保存MIDI音樂為易語言文件。
關閉文件 (文件號)

.子程序 修復文件, 邏輯型
.參數(shù) 文件名, 文本型
.局部變量 臨時1, 字節(jié)集, , "8"
.局部變量 臨時2, 字節(jié)集
.局部變量 音軌數(shù), 整數(shù)型
.局部變量 大小, 整數(shù)型
.局部變量 變量, 整數(shù)型
.局部變量 文件號1, 整數(shù)型

.判斷開始 (音軌數(shù) (文件名) = 1)
    關閉文件 (文件號)
    文件號 = 打開文件 (文件名, #讀入, )
    文件號1 = 打開文件 (文件名 + “.bak”, #重寫, )
    移到文件首 (文件號)
    臨時1 [1] = 讀入字節(jié)集 (文件號, 8)
    臨時1 [2] = 讀入字節(jié)集 (文件號, 2)
    臨時1 [3] = 讀入字節(jié)集 (文件號, 2)
    臨時1 [4] = 讀入字節(jié)集 (文件號, 2)
    臨時1 [5] = 讀入字節(jié)集 (文件號, 4)
    臨時2 = 讀入字節(jié)集 (文件號, 4)
    臨時1 [6] = 讀入字節(jié)集 (文件號, 2)
    大小 = 臨時2 [1] × 255 × 255 × 255 + 臨時2 [2] × 255 × 255 + 臨時2 [3] × 255 + 臨時2 [4]
    ' 移到文件首 (文件號)
    寫出字節(jié)集 (文件號1, 取空白字節(jié)集 (24))
    .判斷循環(huán)首 (是否在文件尾 (文件號, ) = 假)
        臨時2 = 讀入字節(jié)集 (文件號, 1)
        .判斷開始 (臨時2 [1] = 129 或 臨時2 [1] = 130 或 臨時2 [1] = 131)
            大小 = 大小 - 1
        .默認
            移到文件尾 (文件號1)
            寫出字節(jié)集 (文件號1, 臨時2)
        .判斷結束

    .判斷循環(huán)尾 ()
    移到文件首 (文件號1)
    .計次循環(huán)首 (5, 變量)
        寫出字節(jié)集 (文件號1, 臨時1 [變量])
    .計次循環(huán)尾 ()
    臨時2 = 到字節(jié)集 (大小)
    .計次循環(huán)首 (4, 變量)
        .判斷開始 (臨時2 [4 - 變量 + 1] = 0)
            寫出字節(jié)集 (文件號1, { 0 })
        .默認
            寫出字節(jié)集 (文件號1, 到字節(jié)集 (字符 (臨時2 [4 - 變量 + 1])))
        .判斷結束

    .計次循環(huán)尾 ()
    寫出字節(jié)集 (文件號1, 臨時1 [6])
    關閉文件 (文件號1)
    關閉文件 (文件號)
    .判斷開始 (刪除文件 (文件名))
        .判斷開始 (文件更名 (文件名 + “.bak”, 文件名))
            返回 (真)
        .默認
            返回 (假)
        .判斷結束

    .默認
        返回 (假)

    .判斷結束
    ' 信息框 (“修理完畢”, 0, )
.默認
    返回 (真)
.判斷結束


.子程序 音軌數(shù), 整數(shù)型
.參數(shù) 文件名, 文本型
.局部變量 臨時, 字節(jié)集
.局部變量 音軌數(shù), 整數(shù)型

關閉文件 (文件號)
文件號 = 打開文件 (文件名, #讀入, )
移到文件首 (文件號)
移動讀寫位置 (文件號, , 10)
臨時 = 讀入字節(jié)集 (文件號, 2)
音軌數(shù) = 臨時 [1] × 255 + 臨時 [2]
返回 (音軌數(shù))

.子程序 _時鐘2_周期事件
.局部變量 當前音, 文本型, , "0"
.局部變量 音符, 圖形按鈕
.局部變量 變量, 整數(shù)型
.局部變量 標識, 整數(shù)型

.如果真 (樂譜位 ≠ 0)
    停奏 (舊音符)
.如果真結束
.如果真 (樂譜位 = 取數(shù)組成員數(shù) (樂譜組))
    時鐘1.時鐘周期 = 0
    時鐘2.時鐘周期 = 0
    時鐘4.時鐘周期 = 0
    音波畫板.可視 = 假
    樂譜位 = 0
    ' 模擬按琴鍵 (舊音符, 真)
    舊音符 = 0
    播放.選中 = 假
    錄音.禁止 = 假
    返回 ()
.如果真結束
樂譜位 = 樂譜位 + 1
.如果真 (樂譜組 [樂譜位] ≠ “|” 且 樂譜組 [樂譜位] ≠ “||”)
    當前音 = 分割文本 (樂譜組 [樂譜位], “@”, )
    .如果 (當前音 [1] = “p”)
        時鐘2.時鐘周期 = 960 \ 到數(shù)值 (當前音 [2])
    .否則
        .如果真 (取數(shù)組成員數(shù) (當前音) = 2)
            MIDI1.奏 (到數(shù)值 (當前音 [1]), )
            模擬按琴鍵 (到數(shù)值 (當前音 [1]))
            音波值 = 到數(shù)值 (當前音 [1])
            舊音符 = 到數(shù)值 (當前音 [1])
            .如果 (取文本右邊 (當前音 [2], 1) = “.”)
                時鐘2.時鐘周期 = 960 \ 到數(shù)值 (當前音 [2]) + 960 \ 到數(shù)值 (當前音 [2]) ÷ 2
            .否則
                時鐘2.時鐘周期 = 960 \ 到數(shù)值 (當前音 [2])
            .如果結束
            .計次循環(huán)首 (取數(shù)組成員數(shù) (白鍵碼), 變量)
                .如果真 (白鍵碼 [變量] = 到數(shù)值 (當前音 [1]))
                    跳出循環(huán) ()
                .如果真結束

            .計次循環(huán)尾 ()
            標識 = 1
            .判斷開始 (取文本長度 (正常音) < 22)
                .判斷開始 (變量 % 7 = 0)
                    .判斷開始 (取整 (變量 ÷ 7) ≠ 0)
                        .判斷開始 (變量 % 7 = 0)
                            正常音 = 正常音 + “ 7”
                        .默認
                            正常音 = 正常音 + “ ” + 到文本 (變量 % 7)
                        .判斷結束

                    .判斷 (變量 % 7 = 0)
                        正常音 = 正常音 + “ 0”
                        標識 = 0
                    .默認
                        正常音 = 正常音 + “ ” + 到文本 (變量 % 7)
                    .判斷結束

                .默認
                    正常音 = 正常音 + “ ” + 到文本 (變量 % 7)
                .判斷結束

            .判斷 (變量 % 7 = 0)
                .判斷開始 (取整 (變量 ÷ 7) ≠ 0)
                    .判斷開始 (變量 % 7 = 0)
                        正常音 = “ 7”
                    .默認
                        正常音 = “ ” + 到文本 (變量 % 7)
                    .判斷結束

                .判斷 (變量 % 7 = 0)
                    正常音 = “ 0”
                    標識 = 0
                .默認
                    正常音 = “ ” + 到文本 (變量 % 7)
                .判斷結束

            .默認
                正常音 = “ ” + 到文本 (變量 % 7)
            .判斷結束
            樂譜.標題 = 正常音
            低1.標題 = “”
            低2.標題 = “”
            高2.標題 = “”
            高1.標題 = “”
            .判斷開始 (取文本長度 (正常音) < 22)
                .判斷開始 (到數(shù)值 (當前音 [1]) ≤ 47)
                    .判斷開始 (標識 = 0)
                        低二點 = 低二點 + “ ” + “ ”
                        低一點 = 低一點 + “ ” + “ ”
                    .默認
                        低二點 = 低二點 + “ ” + “.”
                        低一點 = 低一點 + “ ” + “.”
                    .判斷結束
                    高一點 = 高一點 + “  ”
                    高二點 = 高二點 + “  ”
                .判斷 (到數(shù)值 (當前音 [1]) > 47 且 到數(shù)值 (當前音 [1]) ≤ 59)
                    .判斷開始 (標識 = 0)
                        低一點 = 低一點 + “ ” + “ ”
                    .默認
                        低一點 = 低一點 + “ ” + “.”
                    .判斷結束
                    低二點 = 低二點 + “  ”
                    高一點 = 高一點 + “  ”
                    高二點 = 高二點 + “  ”
                .判斷 (到數(shù)值 (當前音 [1]) > 59 且 到數(shù)值 (當前音 [1]) ≤ 71)
                    低二點 = 低二點 + “  ”
                    低一點 = 低一點 + “  ”
                    高一點 = 高一點 + “  ”
                    高二點 = 高二點 + “  ”
                .判斷 (到數(shù)值 (當前音 [1]) > 71 且 到數(shù)值 (當前音 [1]) ≤ 83)
                    低二點 = 低二點 + “  ”
                    低一點 = 低一點 + “  ”
                    .判斷開始 (標識 = 0)
                        高一點 = 高一點 + “ ” + “ ”
                    .默認
                        高一點 = 高一點 + “ ” + “.”
                    .判斷結束

                    高二點 = 高二點 + “  ”
                .判斷 (到數(shù)值 (當前音 [1]) > 83 且 到數(shù)值 (當前音 [1]) ≤ 95)
                    低二點 = 低二點 + “  ”
                    低一點 = 低一點 + “  ”
                    .判斷開始 (標識 = 0)
                        高二點 = 高二點 + “ ” + “ ”
                        高一點 = 高一點 + “ ” + “ ”
                    .默認
                        高二點 = 高二點 + “ ” + “.”
                        高一點 = 高一點 + “ ” + “.”
                    .判斷結束

                .默認
                    低二點 = 低二點 + “ ”
                    低一點 = 低一點 + “ ”
                    高一點 = 高一點 + “ ”
                    高二點 = 高二點 + “ ”
                .判斷結束

            .默認
                高一點 = “”
                低一點 = “”
                高二點 = “”
                低二點 = “”
            .判斷結束
            低1.標題 = 低一點
            低2.標題 = 低二點
            高2.標題 = 高二點
            高1.標題 = 高一點
        .如果真結束

    .如果結束

.如果真結束


.子程序 模擬按琴鍵
.參數(shù) 音符, 字節(jié)型
.參數(shù) 結束, 邏輯型, 可空
.局部變量 當前鍵, 圖形按鈕
.局部變量 當前鍵黑白, 邏輯型
.局部變量 變量, 整數(shù)型

.計次循環(huán)首 (取數(shù)組成員數(shù) (黑鍵), 變量)
    .如果真 (黑鍵 [變量] = 音符)
        當前鍵黑白 = 真
        跳出循環(huán) ()
    .如果真結束

.計次循環(huán)尾 ()
.如果真 (是否已創(chuàng)建 (上次鍵))
    上次鍵.正常圖片 = 選擇 (上次鍵黑白, #黑正常, #白正常)
.如果真結束
.如果真 (停止)
    返回 ()
.如果真結束
.如果真 (音符 ≠ 255 且 音符 ≠ 0)
    當前鍵 = 取標記組件 (音符)
.如果真結束
.如果真 (結束 = 真)
    返回 ()
.如果真結束
.如果真 (是否已創(chuàng)建 (當前鍵))
    當前鍵.正常圖片 = 選擇 (當前鍵黑白, #黑按下, #白按下)
.如果真結束
上次鍵 = 當前鍵
上次鍵黑白 = 當前鍵黑白

.子程序 播放文件
.參數(shù) 內容, 文本型

樂譜組 = 分割文本 (內容, “ ”, )
時鐘2.時鐘周期 = 50
時鐘1.時鐘周期 = 350
時鐘4.時鐘周期 = 150
音波畫板.可視 = 真

.子程序 _錄音_被單擊

.判斷開始 (錄音.選中 = 真)
    重定義數(shù)組 (錄音音長, 假, 255)
    錄音文本 = “”
    時鐘3.時鐘周期 = 100
    _啟動窗口.獲取焦點 ()
    錄音狀態(tài) = 真
    格式 = 0
    播放.禁止 = 取反 (播放.禁止)
.默認
    時鐘3.時鐘周期 = 0
    .如果真 (當前彈奏 = 0)
        返回 ()
    .如果真結束
    .判斷開始 (到數(shù)值 (錄音音長 [當前彈奏]) ≤ 2)
        錄音音長 [當前彈奏] = “8”
    .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) = 3)
        錄音音長 [當前彈奏] = “4.”
    .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) = 4)
        錄音音長 [當前彈奏] = “4”
    .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) > 4 且 到數(shù)值 (錄音音長 [當前彈奏]) ≤ 6)
        錄音音長 [當前彈奏] = “2.”
    .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) > 6 且 到數(shù)值 (錄音音長 [當前彈奏]) ≤ 8)
        錄音音長 [當前彈奏] = “2”
    .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) > 10 且 到數(shù)值 (錄音音長 [當前彈奏]) ≤ 12)
        錄音音長 [當前彈奏] = “1”
    .默認
        錄音音長 [當前彈奏] = “1.”
    .判斷結束
    錄音文本 = 錄音文本 + 錄音音長 [當前彈奏] + “ ”
    錄音音長 [當前彈奏] = “”
    錄音狀態(tài) = 假
    錄音狀態(tài) = 取反 (取反 (錄音.選中))
    播放.禁止 = 取反 (播放.禁止)
.判斷結束


.子程序 _時鐘3_周期事件

.如果真 (當前彈奏 > 0)
    錄音音長 [當前彈奏] = 到文本 (到數(shù)值 (錄音音長 [當前彈奏]) + 1)
.如果真結束


.子程序 _圖形按鈕3_被單擊

載入 (設置窗口, , 真)

.子程序 _停止播放_被單擊

.如果真 (錄音.禁止 = 真)
    錄音.禁止 = 假
.如果真結束
MIDI1.關閉 ()
連續(xù)賦值 (假, 播放.選中, 錄音.選中, 音波畫板.可視)
連續(xù)賦值 (0, 時鐘1.時鐘周期, 時鐘2.時鐘周期, 時鐘2.時鐘周期, 時鐘4.時鐘周期)
.如果 (系統(tǒng)播放)
    媒體播放1.停止 ()
    系統(tǒng)播放 = 假
.否則
    模擬按琴鍵 (舊音符, 真)
.如果結束
MIDI1.打開 (0)
MIDI1.置樂器 (樂器名組合框.現(xiàn)行選中項)
樂譜位 = 0
_啟動窗口.獲取焦點 ()



.子程序 _效果1_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
效果1.選中 = 真
樂器名組合框.現(xiàn)行選中項 = 4
MIDI1.置樂器 (4)

.子程序 _效果2_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
樂器名組合框.現(xiàn)行選中項 = 9
MIDI1.置樂器 (9)
效果2.選中 = 真

.子程序 _效果3_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
樂器名組合框.現(xiàn)行選中項 = 10
MIDI1.置樂器 (10)
效果3.選中 = 真

.子程序 _效果4_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
樂器名組合框.現(xiàn)行選中項 = 11
MIDI1.置樂器 (11)
效果4.選中 = 真

.子程序 _效果5_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
樂器名組合框.現(xiàn)行選中項 = 15
MIDI1.置樂器 (15)
效果5.選中 = 真

.子程序 _效果6_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
樂器名組合框.現(xiàn)行選中項 = 117
MIDI1.置樂器 (117)
效果6.選中 = 真

.子程序 _效果7_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
樂器名組合框.現(xiàn)行選中項 = 17
MIDI1.置樂器 (17)
效果7.選中 = 真

.子程序 _效果8_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
MIDI1.置樂器 (19)
樂器名組合框.現(xiàn)行選中項 = 19
效果8.選中 = 真

.子程序 _效果9_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
MIDI1.置樂器 (113)
樂器名組合框.現(xiàn)行選中項 = 113
效果9.選中 = 真

.子程序 _效果10_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
MIDI1.置樂器 (26)
樂器名組合框.現(xiàn)行選中項 = 26
效果10.選中 = 真

.子程序 _效果11_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
MIDI1.置樂器 (39)
樂器名組合框.現(xiàn)行選中項 = 39
效果11.選中 = 真

.子程序 _效果12_被單擊

設置樂器 = 真
連續(xù)賦值 (假, 效果1.選中, 效果2.選中, 效果3.選中, 效果4.選中, 效果5.選中, 效果6.選中, 效果7.選中, 效果8.選中, 效果9.選中, 效果10.選中, 效果11.選中, 效果12.選中)
MIDI1.置樂器 (56)
樂器名組合框.現(xiàn)行選中項 = 56
效果12.選中 = 真

.子程序 _保存_被單擊
.局部變量 樂器名, 字節(jié)型

' 易電子琴格式說明:
' emid  ------------------- 是易電子琴文件標記;
' 4  ---------------------- 是樂器號,對應每個樂器的值;
' 48@4 71@4 69@4....p@2 --- 樂譜組,其排列方式是:樂譜值@音長,中間空格分開,以p@2結束。

.如果真 (錄音文本 = “”)
    返回 ()
.如果真結束
通用對話框1.類型 = 1
.如果真 (通用對話框1.打開 ())
    樂器名 = MIDI1.取樂器序號 ()
    .判斷開始 (取擴展名 (通用對話框1.文件名) = “MIDI” 或 取擴展名 (通用對話框1.文件名) = “MID”)
        輸出midi (錄音文本 + “p@2”, 通用對話框1.文件名)
    .默認
        寫到文件 (通用對話框1.文件名, 到字節(jié)集 (“emid” + #換行符 + 到文本 (樂器名) + #換行符 + 刪尾空 (錄音文本)))
    .判斷結束
    信息框 (“保存文件成功”, #信息圖標, )
.如果真結束


.子程序 輸出midi, 邏輯型
.參數(shù) 音源, 文本型
.參數(shù) 文件名, 文本型
.局部變量 文本組, 文本型, , "0"
.局部變量 計次變量, 整數(shù)型
.局部變量 當前音, 文本型, , "0"
.局部變量 文件號1, 整數(shù)型
.局部變量 長度, 整數(shù)型
.局部變量 變量, 整數(shù)型
.局部變量 臨時, 字節(jié)集
.局部變量 當前值, 整數(shù)型

文件號1 = 打開文件 (文件名, #重寫, )
文本組 = 分割文本 (音源, “ ”, )
.計次循環(huán)首 (取數(shù)組成員數(shù) (文本組), 計次變量)
    當前音 = 分割文本 (文本組 [計次變量], “@”, )
    .如果真 (當前音 [1] ≠ “p”)
        .如果真 (取數(shù)組成員數(shù) (當前音) = 2)
            變量 = 變量 + 1
        .如果真結束

    .如果真結束
    處理事件 ()
.計次循環(huán)尾 ()
長度 = 變量 × 6 + 5
寫出字節(jié)集 (文件號1, { 77, 84, 104, 100, 0, 0, 0, 6, 0, 1, 0, 1, 0, 48, 77, 84, 114, 107 })
臨時 = 到字節(jié)集 (長度)
.計次循環(huán)首 (4, 變量)
    .判斷開始 (臨時 [4 - 變量 + 1] = 0)
        寫出字節(jié)集 (文件號1, { 0 })
    .默認
        寫出字節(jié)集 (文件號1, 到字節(jié)集 (字符 (臨時 [4 - 變量 + 1])))
    .判斷結束

.計次循環(huán)尾 ()
寫出字節(jié)集 (文件號1, { 0, 144 })
.計次循環(huán)首 (取數(shù)組成員數(shù) (文本組), 計次變量)
    當前音 = 分割文本 (文本組 [計次變量], “@”, )
    .如果真 (取數(shù)組成員數(shù) (當前音) = 2 且 當前音 [1] ≠ “p”)
        寫出字節(jié)集 (文件號1, 到字節(jié)集 (字符 (到數(shù)值 (當前音 [1]))))
        .判斷開始 (當前音 [2] = “1.”)
            當前值 = 96
        .判斷 (當前音 [2] = “1”)
            當前值 = 72
        .判斷 (當前音 [2] = “2.”)
            當前值 = 64
        .判斷 (當前音 [2] = “2”)
            當前值 = 48
        .判斷 (當前音 [2] = “4.”)
            當前值 = 36
        .判斷 (當前音 [2] = “4”)
            當前值 = 24
        .判斷 (當前音 [2] = “8.”)
            當前值 = 18
        .判斷 (當前音 [2] = “8”)
            當前值 = 12
        .判斷 (當前音 [2] = “16”)
            當前值 = 6
        .判斷 (當前音 [2] = “32”)
            當前值 = 3
        .默認

        .判斷結束
        寫出字節(jié)集 (文件號1, { 64 })
        寫出字節(jié)集 (文件號1, 到字節(jié)集 (字符 (當前值)))
        寫出字節(jié)集 (文件號1, 到字節(jié)集 (字符 (到數(shù)值 (當前音 [1]))))
        寫出字節(jié)集 (文件號1, { 0, 0 })
    .如果真結束
    處理事件 ()
.計次循環(huán)尾 ()
寫出字節(jié)集 (文件號1, { 255, 47, 0 })
關閉文件 (文件號1)
返回 (真)

.子程序 取擴展名, 文本型
.參數(shù) 文件, 文本型

返回 (到大寫 (取文本右邊 (文件, 取文本長度 (文件) - 倒找文本 (文件, “.”, , 假))))

.子程序 _關于_被單擊

載入 (關于窗口, , 真)

.子程序 _圖形按鈕4_被單擊

載入 (設置窗口, , 真)

.子程序 _主音量鈕_鼠標左鍵被按下, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型

音量鈕位置 = 縱向位置
音量鈕拖動 = 真
捕獲鼠標 (主音量鈕.取窗口句柄 ())

.子程序 _主音量鈕_鼠標左鍵被放開, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型

音量鈕拖動 = 假
釋放鼠標 ()

.子程序 _主音量鈕_鼠標位置被移動, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型

.如果真 (音量鈕拖動)
    .如果真 (縱向位置 ≥ 主音量鈕.高度 且 縱向位置 ≤ 65535)
        返回 ()
    .如果真結束
    .判斷開始 (縱向位置 < 音量鈕位置 且 主音量鈕.頂邊 > 72)
        主音量鈕.頂邊 = 主音量鈕.頂邊 - 1
    .判斷 (縱向位置 > 音量鈕位置 且 主音量鈕.頂邊 < 116)
        主音量鈕.頂邊 = 主音量鈕.頂邊 + 1
    .默認

    .判斷結束
    .如果 (系統(tǒng)音量1.打開 (#音量類型.主音量) = 0)
        信息框 (“系統(tǒng)音量打開失敗!,您可能聽不到聲音!”, 48, )
    .否則
        系統(tǒng)音量1.置音量 (四舍五入 ((116 - 主音量鈕.頂邊) × 1489.43, 0), 四舍五入 ((116 - 主音量鈕.頂邊) × 1489.43, 0))
        系統(tǒng)音量1.關閉 (2)
    .如果結束

.如果真結束


.子程序 _軟件合成器鈕_鼠標左鍵被按下, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型

音量鈕位置 = 縱向位置
音量鈕拖動 = 真
捕獲鼠標 (軟件合成器鈕.取窗口句柄 ())

.子程序 _軟件合成器鈕_鼠標左鍵被放開, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型

音量鈕拖動 = 假
釋放鼠標 ()

.子程序 _軟件合成器鈕_鼠標位置被移動, 邏輯型
.參數(shù) 橫向位置, 整數(shù)型
.參數(shù) 縱向位置, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型

.如果真 (音量鈕拖動)
    .如果真 (縱向位置 ≥ 軟件合成器鈕.高度 且 縱向位置 ≤ 65535)
        返回 ()
    .如果真結束
    .判斷開始 (縱向位置 < 音量鈕位置 且 軟件合成器鈕.頂邊 > 72)
        軟件合成器鈕.頂邊 = 軟件合成器鈕.頂邊 - 1
    .判斷 (縱向位置 > 音量鈕位置 且 軟件合成器鈕.頂邊 < 116)
        軟件合成器鈕.頂邊 = 軟件合成器鈕.頂邊 + 1
    .默認

    .判斷結束
    .如果 (系統(tǒng)音量1.打開 (#音量類型.軟件合成器) = 0)
        信息框 (“系統(tǒng)音量打開失敗!,您可能聽不到聲音!”, 48, )
    .否則
        系統(tǒng)音量1.置音量 (四舍五入 ((116 - 軟件合成器鈕.頂邊) × 1349.81, 0), 四舍五入 ((116 - 軟件合成器鈕.頂邊) × 1349.81, 0))
        系統(tǒng)音量1.關閉 (2)
    .如果結束

.如果真結束


.子程序 _退出_被單擊

結束 ()

.子程序 _最小化_被單擊

位置 = 2

.子程序 音波模擬
.參數(shù) 值, 整數(shù)型
.參數(shù) 目的畫板, 畫板
.局部變量 變量

音波畫板.清除 (, , , )
置隨機數(shù)種子 ()
.如果真 (取數(shù)組成員數(shù) (音波值歷史組) ≥ 16)
    刪除成員 (音波值歷史組, 17, 取數(shù)組成員數(shù) (音波值歷史組) - 16)
.如果真結束
.計次循環(huán)首 (取數(shù)組成員數(shù) (音波值歷史組), 變量)
    目的畫板.填充矩形 (變量 × 10, 音波值歷史組 [變量], 變量 × 10 - 8, 目的畫板.高度)
.計次循環(huán)尾 ()
插入成員 (音波值歷史組, 1, 值)

.子程序 _時鐘4_周期事件

音波模擬 (音波值 ÷ 2 - 10, 音波畫板)

.子程序 __啟動窗口_按下某鍵, 邏輯型
.參數(shù) 鍵代碼, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型
.局部變量 變量1, 整數(shù)型
.局部變量 變量2, 整數(shù)型

存在 = 假
.計次循環(huán)首 (取數(shù)組成員數(shù) (按鍵組), 變量2)
    .如果真 (按鍵組 [變量2] = 鍵代碼)
        存在 = 真
        停奏 ()
        .判斷開始 (標記組 [變量2] = 真)
            重復按鍵 = 真
            跳出循環(huán) ()
        .默認
            標記組 [變量2] = 真
        .判斷結束

    .如果真結束

.計次循環(huán)尾 ()
.如果真 (重復按鍵 = 假 且 存在 = 真)
    變量1 = 0
    .計次循環(huán)首 (取數(shù)組成員數(shù) (大鍵碼), 變量1)
        .如果真 (大鍵碼 [變量1] = 鍵代碼)
            彈奏碼 = 音位 [變量1]
            跳出循環(huán) ()
        .如果真結束

    .計次循環(huán)尾 ()
    .如果真 (重復按鍵 = 假)
        模擬按琴鍵 (彈奏碼)
        按鍵發(fā)聲 (彈奏碼)
        時鐘3.時鐘周期 = 0
        .如果真 (錄音狀態(tài) = 真)
            .判斷開始 (當前彈奏 > 0)
                .判斷開始 (到數(shù)值 (錄音音長 [當前彈奏]) ≤ 2)
                    錄音音長 [當前彈奏] = “8”
                .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) = 3)
                    錄音音長 [當前彈奏] = “4.”
                .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) = 4)
                    錄音音長 [當前彈奏] = “4”
                .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) > 4 且 到數(shù)值 (錄音音長 [當前彈奏]) ≤ 6)
                    錄音音長 [當前彈奏] = “2.”
                .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) > 6 且 到數(shù)值 (錄音音長 [當前彈奏]) ≤ 8)
                    錄音音長 [當前彈奏] = “2”
                .判斷 (到數(shù)值 (錄音音長 [當前彈奏]) > 10 且 到數(shù)值 (錄音音長 [當前彈奏]) ≤ 12)
                    錄音音長 [當前彈奏] = “1”
                .默認
                    錄音音長 [當前彈奏] = “1.”
                .判斷結束
                錄音文本 = 錄音文本 + 錄音音長 [當前彈奏] + “ ”
                錄音音長 [當前彈奏] = “”
                已執(zhí)行 = 真
            .默認

            .判斷結束
            當前彈奏 = 彈奏碼
            時鐘3.時鐘周期 = 100
            錄音文本 = 錄音文本 + 到文本 (彈奏碼) + “@”
        .如果真結束
        返回 ()
    .如果真結束

.如果真結束


.子程序 __啟動窗口_放開某鍵, 邏輯型
.參數(shù) 鍵代碼, 整數(shù)型
.參數(shù) 功能鍵狀態(tài), 整數(shù)型
.局部變量 變量, 整數(shù)型

存在 = 假
.計次循環(huán)首 (取數(shù)組成員數(shù) (按鍵組), 變量)
    .如果真 (按鍵組 [變量] = 鍵代碼 且 標記組 [變量] = 真)
        重復按鍵 = 假
        存在 = 真
        標記組 [變量] = 假
        跳出循環(huán) ()
    .如果真結束

.計次循環(huán)尾 ()
.計次循環(huán)首 (取數(shù)組成員數(shù) (大鍵碼), 變量)
    .如果真 (大鍵碼 [變量] = 鍵代碼)
        彈奏碼 = 音位 [變量]
        跳出循環(huán) ()
    .如果真結束

.計次循環(huán)尾 ()
停奏 ()
.如果真 (是否已創(chuàng)建 (上次鍵))
    上次鍵.正常圖片 = 選擇 (上次鍵黑白, #黑正常, #白正常)
.如果真結束

彈奏碼 = 當前彈奏
.如果真 (錄音狀態(tài) = 真 且 存在 = 真)
    .如果真 (彈奏碼 > 0 且 已執(zhí)行 = 假)
        .判斷開始 (到數(shù)值 (錄音音長 [彈奏碼]) ≤ 2)
            錄音音長 [彈奏碼] = “8”
        .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) = 3)
            錄音音長 [彈奏碼] = “4.”
        .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) = 4)
            錄音音長 [彈奏碼] = “4”
        .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) > 4 且 到數(shù)值 (錄音音長 [彈奏碼]) ≤ 6)
            錄音音長 [彈奏碼] = “2.”
        .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) > 6 且 到數(shù)值 (錄音音長 [彈奏碼]) ≤ 8)
            錄音音長 [彈奏碼] = “2”
        .判斷 (到數(shù)值 (錄音音長 [彈奏碼]) > 10 且 到數(shù)值 (錄音音長 [彈奏碼]) ≤ 12)
            錄音音長 [彈奏碼] = “1”
        .默認
            錄音音長 [彈奏碼] = “1.”
        .判斷結束
        錄音文本 = 錄音文本 + 錄音音長 [彈奏碼] + “ ”
        已執(zhí)行 = 真
    .如果真結束

.如果真結束
已執(zhí)行 = 假


.子程序 _音波_被單擊

音值畫板.可視 = 假
音波畫板.可視 = 真

.子程序 _音值_被單擊

音值畫板.可視 = 真
音波畫板.可視 = 假


.子程序 _時鐘5_周期事件

.如果真 (媒體播放1.取位置 () = 媒體播放1.取長度 ())
    時鐘1.時鐘周期 = 0
    時鐘5.時鐘周期 = 0
    媒體播放1.關閉 ()
    播放.選中 = 假
    是否暫停 = 假
.如果真結束


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:75246 發(fā)表于 2015-3-29 14:06 | 只看該作者
易語言,我也用,多聯(lián)系!
回復

使用道具 舉報

板凳
ID:384821 發(fā)表于 2018-8-21 19:45 | 只看該作者
請樓主發(fā)一下啟動窗口圖像
回復

使用道具 舉報

地板
ID:384821 發(fā)表于 2018-8-21 19:46 | 只看該作者
請樓主發(fā)一下啟動窗口的圖像
回復

使用道具 舉報

5#
ID:387700 發(fā)表于 2018-8-28 22:59 | 只看該作者
中文的適合新手
回復

使用道具 舉報

6#
ID:540398 發(fā)表于 2019-5-17 07:24 | 只看該作者
其實還是相對繁瑣了。
回復

使用道具 舉報

7#
ID:809311 發(fā)表于 2020-8-13 12:51 | 只看該作者

RE: 用易語言寫一個電子鋼琴軟件(看起來不對勁)

怎么變成中文了?變成中文程序就用不了了,還要翻譯回去。
回復

使用道具 舉報

8#
ID:809311 發(fā)表于 2020-8-18 16:05 | 只看該作者
Roy-2010 發(fā)表于 2020-8-13 12:51
怎么變成中文了?變成中文程序就用不了了,還要翻譯回去。

別把別人帶進坑了,正確代碼:.Version 2
.Support library eMMedia

.Assembly Window Assembly 1
.Assembly variables piano keys, graphic buttons,, "0"
.Assembly variable black key, integer type,, "0"
.Assembly variable white key, integer type,, "0"
.Assembly variable last key, graphic button
.Assembly variable last key black and white, logic type
.Assembly variables old notes, byte type
.Assembly variable volume knob drag, logic type
.Assembly variable volume knob position, integer type
.Assembly variable score group, text type,, "0"
.Assembly variable Music score position, integer type
.Assembly variable recording status, logic type
.Assembly variable recording length, text type,, "255"
.Assembly variable recording text, text type
.Assembly variable stop, logic type
.Assembly variables set instruments, logic type
.Assembly variable, sound wave value, integer type,,, for analog sound wave
.Assembly variable Sound wave value history group, integer type,, "0", used for analog sound wave
.Assembly variable big key code, integer type,, "0"
.Assembly variable phoneme, integer type,, "0"
.Assembly variables Repeated keystrokes, logic type
.Assembly variable white key code, integer type,, "0"
.Assembly variable Normal tone, text type
.Assembly variables higher, text type
.Assembly variable high two points, text type
.Assembly variables lower, text type
.Assembly variable low two points, text type
.Assembly variables press key, integer type,, "0"
.Assembly variables exist, logical type
.Assembly variable key group, integer type,, "0"
.Assembly variable mark group, logical type,, "0"
.Assembly variable Current playing, integer type
.Assembly variables have been executed, logic type
.Assembly variable playing code, integer type
.Assembly variable format, integer
.Assembly variable End of line, logical type
.Assembly variable file number, integer
.Assembly variable Temporary score, text type
.Assembly variable system play, logic type
.Assembly variables are paused, logic type

.Subroutine __start window_created
.Local variable Black key position, integer type,, "0"
.Local variable black key mark, integer type,, "0"
.Local variable left channel, integer type
.Local variable right channel, integer type
.Local variables, marked difference, integer type
.Local Variables Tagged Value, Integer Type
.Local Variable Variable, Integer Type

Load (splash screen,, false)
Set the shape picture (#底圖資源, #黑)
'//Initialization
White key code = {36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 53, 55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72, 74  , 76, 77, 79, 81, 83, 84, 86, 88, 89, 91, 93, 95}
Big key code = {90, 88, 67, 86, 66, 78, 77, 65, 83, 68, 70, 71, 72, 74, 81, 87, 69, 82, 84, 89, 85, 49, 50  , 51, 52, 53, 54, 55, 56, 57, 48, 189, 187, 220, 8, 46, 35, 34, 45, 36, 33, 8, 73, 79, 80, 219, 221, 188  , 190, 191, 75, 76, 186, 222}
Phoneme = {36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 53, 55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72, 74,  76, 77, 79, 81, 83, 84, 86, 88, 89, 91, 93, 95, 84, 86, 88, 89, 91, 93, 95, 72, 74, 76, 77, 79, 48,  50, 52, 60, 62, 64, 65}
Redefine the array (press key, false, take the number of array members (large key code))
Key group = big key code
Redefine the array (mark group, false, take the number of array members (large key code))
.Counting cycle first (take the number of array members (tag group), variable)
     Tag group [variable] = false
.Counting cycle end ()
Old note = -1
Format = 2
Start phoneme = 0
Effect 1. Selected = true
.Counting cycle first (MIDI1. Take the number of devices (), variable)
     Device name combo box. Add item (MIDI1. Take device name (variable-1),)
.Counting cycle end ()
MIDI1. Open (0)
Device name combo box. Currently selected item = 0
.Counting cycle first (MIDI1. Take the number of instruments (), variable)
     Instrument name combo box. Add item (MIDI1. Take instrument name (variable), variable)
.Counting cycle end ()
Instrument name combo box. Currently selected item = 4
MIDI1. Set the instrument (4,)

'//Take the volume:
.If (system volume 1. turn on (#volume type. master volume) = 0)
     Message box ("System volume failed to open!, you may not hear the sound!", 48,)
.otherwise
     System volume 1. Take the volume (left channel, right channel)
     Master volume button. Top edge = 116-rounded (rounded up ((left channel + right channel) ÷ 2 ÷ 1489.43), 0)
If it ends
System volume 1. Off (2)
.If (system volume 1. open (#volume type. software synthesizer) = 0)
     Message box ("Software synthesizer failed to open!, you may not hear the sound!", 48,)
.otherwise
     System volume 1. Take volume (left channel, right channel)
     Software synthesizer button. Top edge = 116-rounded (rounded up ((left channel + right channel) ÷ 2 ÷ 1349.81), 0)
If it ends
System volume 1. Off (2)

'//The key code is generated below:
Redefine the array (key, false, 71)
.Counting cycle first (71, variable)
     If true (variable ≠ 6 and variable ≠ 14 and variable ≠ 20 and variable ≠ 28 and variable ≠ 34 and variable ≠ 42 and variable ≠ 48 and variable ≠ 56 and variable ≠ 62 and variable ≠ 70 and variable ≠ 76 and variable ≠  84)
         Mark difference = Mark difference + 1
         Copy widget (key1, key [variable])
         Marked value = 35 + mark difference
         .Judgment start (variable% 2 = 0)
             Key [variable]. Width = 12
             Key [variable]. Width = 70
             Key [variable]. Top side = 0
             Key [variable]. Normal picture = Piano key 2. Normal picture
             Key [variable]. Press the picture = Piano 2. Press the picture
             Key [variable]. Transparent color = #white
             Key [variable]. Adjust level (#Top level)
             Key [variable]. visible = true
             Key [variable]. Mark = to text (mark value)
             Join members (black key, marked value)
             Key [Variable]. Left = Key 2. Left + Key 1. Width × (Absolute rounding (variable ÷ 2) - 1)
         .default
             Key [variable]. visible = true
             Key [variable]. Mark = to text (mark value)
             Key [Variable]. Left = Key 1. Left + Key 1. Width × Absolute rounding (variable ÷ 2)
             Join members (white key, mark value)
         .The end of judgment

     .If it really ends

.Counting cycle end ()


.Subroutine button sound
.Parameters note, byte type

MIDI1. Play (starting pitch + note,)
Old note = start phoneme + note


.Subroutine _Key1_The left mouse button is pressed, logic type
.Parameters horizontal position, integer type
.Parameters longitudinal position, integer type
.Parameter Function key status, integer
.Local variable Current key, graphic button

Current key = take event component ()
.If true (MIDI1. Open () = false)
     MIDI1. Open (0)
     MIDI1. Set the instrument (instrument name combo box. The currently selected item,)
.If it really ends
.If true (whether it has been created (current key))
     Button sound (to value (current key.mark))
.If it really ends
.If true (recording status = true)
     Clock 3. Clock period = 100
     Recording text = recording text + to text (to value (current key. mark)) + "@"
.If it really ends
Current play = to value (current key. mark)

.Subroutine stop
.Parameter v, integer, nullable

.If (is it empty (v))
     MIDI1. Stop (old note,)
.otherwise
     MIDI1. Stop (old note, v)
If it ends



.Subroutine _Key1_Left mouse button is released, logic type
.Parameters horizontal position, integer
.Parameters longitudinal position, integer type
.Parameter Function key status, integer type

Stop play ()
Clock 3. Clock period = 0
.If true (recording status = true and exists = true)
     .If true (playing code ≤ 0)
         Return ()
     .If it really ends
     .Judgment start (to value (recording tone length [playing code]) ≤ 2)
         Recording Tone Length [Playing Code] = "8"
     .Judgment (to the value (recording tone length [playing code]) = 3)
         Recording length [playing code] = "4."
     .Judgment (to the value (recording tone length [playing code]) = 4)
         Recording Tone Length [Playing Code] = "4"
     .Judgment (to the value (recording pitch [playing code]) > 4 and to the value (recording pitch [playing code]) ≤ 6)
         Recording Tone Length [Playing Code] = "2."
     .Judgment (to the value (recording tone length [playing code]) > 6 and to the value (recording tone length [playing code]) ≤ 8)
         Recording Tone Length [Playing Code] = "2"
     .Judgment (to the value (recording tone length [playing code]) > 10 and to the value (recording tone length [playing code]) ≤ 12)
         Recording Tone Length [Playing Code] = "1"
     .default
         Recording length [playing code] = "1."
     .The end of judgment
     Recording text = recording text + recording tone length [playing code] + ""
.If it really ends
_Start window. Flag = "2"

.Subroutine _clock 1_period event

.If (graphic button 1. visible = true)
     Graphic button 1. Visible = False
     Graphic button 2. Visible = False
.otherwise
     Graphic button 1. Visible = true
     Graphic button 2. Visible = true
If it ends


.Subroutine _open_clicked

Set instrument = false
Common dialog 1. Type = 0
.If true (common dialog 1. open ())
     Recording text = ""
.If it really ends
.Judgment start (take the extension (common dialog 1. file name) = "MIDI" or take the extension (common dialog 1. file name) = "MID")
     Format = 1
.default
     Format = 2
.The end of judgment


.Subroutine _play_clicked
.Local variable file score, text type,, "0"

_Start window. Get focus ()
.If true (whether to pause)
     Media playback 1. Play (-1)
     Clock 5. Clock period = 50
     Return ()
.If it really ends
.Judgment to start (Play. Select = True)
     Normal tone = ""
     Higher = ""
     High two point = ""
     Two points lower = ""
     Lower = ""
     .Judgment start (format = 0)
         .If true (recorded text ≠ “”)
             .If true (MIDI1. Open () = false)
                 MIDI1. Open (0)
             .If it really ends
             Play file (recorded text + "p@2")
         .If it really ends

     .Judgment (format = 1)
         End of line = true
         .Judgment start (number of tracks (common dialog 1. file name) = 1)
             .If true (MIDI1. Open () = false)
                 MIDI1. Open (0)
             .If it really ends
             .If true (repair file (common dialog box 1. file name))
                 Conversion format emid (common dialog box 1. file name)
                 Play file (temporary score)
                 Return ()
             .If it really ends

         .default
             .If true (message box ("This MIDI music does not currently support analog key effects, are you sure to continue playing?", 64 + 1,) = #Confirm button)
                 MIDI1.Close ()
                 Media player 1. Open (Common dialog 1. File name)
                 Media playback 1. Play (-1)
                 System play = true
                 Clock 1. Clock period = 350
                 Clock 5. Clock period = 50
             .If it really ends

         .The end of judgment

     .Judgment (format = 2)
         .Judgment start (Common dialog box 1. File name ≠ "")
             .If true (MIDI1. Open () = false)
                 MIDI1. Open (0)
             .If it really ends
             File score = Split text (to text (import file (common dialog box 1. file name)), # line break,)
             .If true (file sheet music [1] ≠ "emid")
                 Message box ("Not easy language MIDI music text file!", 16,)
                 Play. Selected = False
                 Return ()
             .If it really ends
             MIDI1. Set the instrument (to value (file score [2]),)
             Play file (file score [3])
         .default
             Message box ("There is no track to play!", 48,)
             Play. Selected = False
             Return ()
         .The end of judgment

     .default

     .The end of judgment
     Sound wave. Selected = true
.default
     Continuous assignment (0, clock 1. clock period, clock 2. clock period, clock 4. clock period)
     .If (system play)
         Media playback 1. Pause ()
         Play. Selected = False
         System play = false
         Whether to pause = true
         Clock 5. Clock period = 0
     .otherwise
         Simulate pressing a key (old note-start pitch, true)
         Stop play ()

     If it ends

.The end of judgment




.Subroutine conversion format emid
.Parameter File name, text type
.Local Variables Variables
.Local Variable Temporary, Byte Set

Close file (file number)
File number = open file (file name, #read in,)
Move to the beginning of the file (file number)
Temporary score = ""
Move the reading and writing position (file number,, 24)
.Judging the beginning of the loop (whether it is at the end of the file (file number,) = false)
     Temporary = read in byte set (file number, 6)
     .Judgment start (take byte set length (temporary) <6)
         Temporary score = Temporary score + "p@2"
     .default
         .Judgment start (temporary [3] = 3)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (32) + ""
         .Judgment (temporary [3] = 6)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (16) + ""
         .Judgment (temporary [3] = 12)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (8) + ""
         .Judgment (temporary [3] = 18)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (8) + ". "
         .Judgment (temporary [3] = 24)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (4) + ""
         .Judgment (temporary [3] = 36)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (4) + ". "
         .Judgment (temporary [3] = 48)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (2) + ""
         .Judgment (temporary [3] = 64)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (2) + ". "
         .Judgment (temporary [3] = 72)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (1) + ""
         .Judgment (temporary [3] = 96)
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (1) + ". "
         .default
             Temporary score = Temporary score + to text (temporary [1]) + "@" + to text (4) + ""
         .The end of judgment

     .The end of judgment

.Determine the end of the loop ()
Write to file (file name + ".txt", to byte set ("emid" + #newline character + to text (MIDI1. Take the instrument number ())) + #newline character + delete tail empty (temporary score)))
'//Upstream code is to save MIDI music as easy language files.
Close file (file number)

.Subroutine repair file, logical type
.Parameter File name, text type
.Local variable temporary 1, byte set,, "8"
.Local Variable Temporary 2, Byte Set
.Local variable Number of tracks, integer type
.Local variable size, integer type
.Local Variable Variable, Integer Type
.Local Variable File No. 1, Integer Type

.Judgment start (number of tracks (file name) = 1)
     Close file (file number)
     File number = open file (file name, #read in,)
     File number 1 = open file (file name + ".bak", #rewrite,)
     Move to the beginning of the file (file number)
     Temporary 1 [1] = read byte set (file number, 8)
     Temporary 1 [2] = read byte set (file number, 2)
     Temporary 1 [3] = read byte set (file number, 2)
     Temporary 1 [4] = read byte set (file number, 2)
     Temporary 1 [5] = read byte set (file number, 4)
     Temporary 2 = read byte set (file number, 4)
     Temporary 1 [6] = read byte set (file number, 2)
     Size = Temporary 2 [1] × 255 × 255 × 255 + Temporary 2 [2] × 255 × 255 + Temporary 2 [3] × 255 + Temporary 2 [4]
     'Move to the beginning of the file (file number)
     Write out byte set (file number 1, take blank byte set (24))
     .Judging the beginning of the loop (whether at the end of the file (file number,) = false)
         Temporary 2 = read byte set (file number, 1)
         .Judgment start (temporary 2 [1] = 129 or temporary 2 [1] = 130 or temporary 2 [1] = 131)
             Size = size-1
         .default
             Move to the end of the file (file number 1)
             Write out byte set (file number 1, temporary 2)
         .The end of judgment

     .Determine the end of the loop ()
     Move to the beginning of the file (file number 1)
     .Counting cycle first (5, variable)
         Write out the byte set (file number 1, temporary 1 [variable])
     .Counting cycle end ()
     Temporary 2 = to byte set (size)
     .Counting cycle first (4, variable)
         .Judgment start (temporary 2 [4-variable + 1] = 0)
             Write out byte set (file number 1, {0 })
         .default
             Write out byte set (file number 1, to byte set (character (temporary 2 [4-variable + 1])))
         .The end of judgment

     .Counting cycle end ()
     Write out the byte set (file number 1, temporary 1 [6])
     Close file (file number 1)
     Close file (file number)
     .Judgment start (delete file (file name))
         .Judgment start (file rename (file name + ".bak", file name))
             Return (true)
         .default
             Return (false)
         .The end of judgment

     .default
         Return (false)

     .The end of judgment
     'Message box ("repair completed", 0,)
.default
     Return (true)
.The end of judgment


.Subroutine Number of tracks, integer
.Parameter File name, text type
.Local Variable Temporary, Byte Set
.Local variable Number of tracks, integer type

Close file (file number)
File number = open file (file name, #read in,)
Move to the beginning of the file (file number)
Move the reading and writing position (file number,, 10)
Temporary = read byte set (file number, 2)
Number of tracks = Temporary [1] × 255 + Temporary [2]
Return (number of tracks)

.Subroutine _clock 2_period event
.Local variable Current sound, text type,, "0"
.Local variables, musical notes, graphic buttons
.Local Variable Variable, Integer Type
.Local variable identification, integer type

.If true (music score position ≠ 0)
     Stop (old note)
.If it really ends
.If true (musical score position = take the number of array members (music score group))
     Clock 1. Clock period = 0
     Clock 2. Clock period = 0
     Clock 4. Clock period = 0
     Sonic drawing board. Visible = false
     Score position = 0
     'Simulate pressing a key (old note, true)
     Old note = 0
     Play. Selected = False
     Recording. Prohibited = False
     Return ()
.If it really ends
Music score position = music score position +1
.If true (musical score group [musical score position] ≠ "|" and score group [musical score position] ≠ “||”)
     Current note = Split text (Music score group [Music score position], “@”,)
     .If (current tone [1] = "p")
         Clock 2. Clock period = 960 \ to value (current tone [2])
     .otherwise
         .If true (take the number of array members (current tone) = 2)
             MIDI1. Play (to value (current note [1]),)
             Simulate pressing a key (to value (current note [1]))
             Sound wave value = to value (current tone [1])
             Old note = to value (current note [1])
             .If (take the right side of the text (current tone [2], 1) = ".")
                 Clock 2. Clock period = 960 \ to value (current tone [2]) + 960 \ to value (current tone [2]) ÷ 2
             .otherwise
                 Clock 2. Clock period = 960 \ to value (current tone [2])
             If it ends
             .Counting cycle first (take the number of array members (white key code), variable)
                 .If true (white key code [variable] = to value (current tone [1]))
                     Out of loop ()
                 .If it really ends

             .Counting cycle end ()
             Logo =1
             .Judgment start (take the text length (normal tone) <22)
                 .Judgment start (variable% 7 = 0)
                     .Judgment start (round (variable ÷ 7) ≠ 0)
                         .Judgment start (variable% 7 = 0)
                             Normal tone = normal tone + "7"
                         .default
                             Normal tone = normal tone + "" + to text (variable% 7)
                         .The end of judgment

                     .Judgment (variable% 7 = 0)
                         Normal tone = normal tone + "0"
                         Logo = 0
                     .default
                         Normal tone = normal tone + "" + to text (variable% 7)
                     .The end of judgment

                 .default
                     Normal tone = normal tone + "" + to text (variable% 7)
                 .The end of judgment

             .Judgment (variable% 7 = 0)
                 .Judgment start (round (variable ÷ 7) ≠ 0)
                     .Judgment start (variable% 7 = 0)
                         Normal tone = "7"
                     .default
                         Normal tone = "" + to text (variable% 7)
                     .The end of judgment

                 .Judgment (variable% 7 = 0)
                     Normal tone = "0"
                     Logo = 0
                 .default
                     Normal tone = "" + to text (variable% 7)
                 .The end of judgment

             .default
                 Normal tone = "" + to text (variable% 7)
             .The end of judgment
             Music score. Title = normal tone
             Low 1. Title = ""
             Low 2. Title = ""
             High 2. Title = ""
             High 1. Title = ""
             .Judgment start (take the text length (normal tone) < 22)
                 .Judgment start (to value (current tone [1]) ≤ 47)
                     .Judgment Start (Identification = 0)
                         Low two points = low two points + "" + ""
                         A little lower = a little lower + "" + ""
                     .default
                         Low two points = low two points + "" + "."
                         A little lower = a little lower + "" + "."
                     .The end of judgment
                     Higher = Higher + ""
                     High two point = high two point + ""
                 .Judgment (to the value (current tone [1]) > 47 and to the value (current tone [1]) ≤ 59)
                     .Judgment Start (Identification = 0)
                         A little bit lower = a little bit lower + "" + ""
                     .default
                         A little lower = a little lower + "" + "."
                     .The end of judgment
                     Low two points = low two points + ""
                     Higher = Higher + ""
                     High two point = high two point + ""
                 .Judgment (to the value (current tone [1]) > 59 and to the value (current tone [1]) ≤ 71)
                     Low two points = low two points + ""
                     A little lower = a little lower + ""
                     Higher = Higher + ""
                     High two point = high two point + ""
                 .Judgment (to the value (current tone [1]) > 71 and to the value (current tone [1]) ≤ 83)
                     Low two points = low two points + ""
                     A little lower = a little lower + ""
                     .Judgment Start (Identification = 0)
                         A little higher = a little higher + "" + ""
                     .default
                         A little higher = a little higher + "" + "."
                     .The end of judgment

                     High two point = high two point + ""
                 .Judgment (to the value (current tone [1]) > 83 and to the value (current tone [1]) ≤ 95)
                     Low two points = low two points + ""
                     A little bit lower = a little bit lower + ""
                     .Judgment Start (Identification = 0)
                         High two points = high two points + "" + ""
                         A little higher = a little higher + "" + ""
                     .default
                         High two points = high two points + "" + "."
                         A little higher = a little higher + "" + "."
                     .The end of judgment

                 .default
                     Low two points = low two points + ""
                     A little bit lower = a little bit lower + ""
                     Higher = Higher + ""
                     High two point = high two point + ""
                 .The end of judgment

             .default
                 Higher = ""
                 Lower = ""
                 Senior two points = ""
                 Two points lower = ""
             .The end of judgment
             1. Title = lower
             Low 2. Title = Low two points
             High 2. Title = High two points
             1. Title = higher
         .If it really ends

     If it ends

.If it really ends


.Subroutine Simulate pressing the keys
.Parameters note, byte type
.Parameter end, logical, nullable
.Local variables Current key, graphic button
.Local variable Current key black and white, logic type
.Local Variable Variable, Integer Type

.Counting cycle first (take the number of array members (black key), variable)
     .If true (black key [variable] = note)
         Current key black and white = true
         Out of loop ()
     .If it really ends

.Counting cycle end ()
.If true (whether created (last key))
     Last key. Normal picture = select (last key black and white, #黑normal, #白normal)
.If it really ends
.If true (stop)
     Return ()
.If it really ends
.If true (note ≠ 255 and note ≠ 0)
     Current key = take mark component (note)
.If it really ends
.If true (end = true)
     Return ()
.If it really ends
.If true (whether it has been created (current key))
     Current key. Normal picture =Select (current key black and white, #black press, #white press)
.If it really ends
Last key = current key
Last key black and white = current key black and white

.Subroutine Play file
.Parameter content, text type

Music score group = split text (content, "",)
Clock 2. Clock period = 50
Clock 1. Clock period = 350
Clock 4. Clock period = 150
Sonic drawing board. Visual = true

.Subroutine _Recording_ Clicked

.Judgment Start (Recording. Selected = True)
     Redefine the array (recording sound length, false, 255)
     Recording text = ""
     Clock 3. Clock period = 100
     _Start window. Get focus ()
     Recording status = true
     Format = 0
     Play. Prohibit = Invert (Play. Prohibit)
.default
     Clock 3. Clock period = 0
     .If true (currently playing =0)
         Return ()
     .If it really ends
     .Judgment start (to the value (recording length [current playing]) ≤ 2)
         Recording length [current playing] = "8"
     .Judgment (to the value (recorded tone length [current playing]) = 3)
         Recording length [current playing] = "4."
     .Judgment (to the value (recording tone length [current playing]) = 4)
         Recording Tone Length [Current Playing] = "4"
     .Judgment (to the value (recorded pitch [current playing]) > 4 and to the value (recorded pitch [current playing]) ≤ 6)
         Recording length [current playing] = "2."
     .Judgment (to the value (recording sound length [current playing])> 6 and to the value (recording sound length [current playing]) ≤ 8)
         Recording length [current playing] = "2"
     .Judgment (to the value (recording sound length [current playing]) > 10 and to the value (recording sound length [current playing]) ≤ 12)
         Recording length [current playing] = "1"
     .default
         Recording Tone Length [Currently Playing] = "1."
     .The end of judgment
     Recording text = recording text + recording tone length [current playing] + “”
     Recording Tone Length [Current Playing] =""
     Recording status = false
     Recording status = inverted (inverted (recording. selected))
     Play. Prohibit = Invert (Play. Prohibit)
.The end of judgment


.Subroutine _clock 3_period event

.If true (current play > 0)
     Recording tone length [current playing] = to text (to value (recording tone length [current playing]) + 1)
.If it really ends


.Subroutine _graphic button 3_ clicked

Load (setting window,, true)

.Subroutine _stop playing_clicked

.If true (recording.prohibited = true)
     Recording. Prohibited = False
.If it really ends
MIDI1.Close ()
Continuous assignment (false, play. selected, record. selected, sound wave drawing board. visible)
Continuous assignment (0, clock 1. clock period, clock 2. clock period, clock 2. clock period, clock 4. clock period)
.If (system play)
     Media playback 1. Stop ()
     System play = false
.otherwise
     Simulate pressing a key (old note, true)
If it ends
MIDI1. Open (0)
MIDI1. Set the instrument (instrument name combo box. Currently selected item)
Score position = 0
_Start window. Get focus ()



.Subroutine _Effect 1_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
Effect 1. Selected = true
Instrument name combo box. Currently selected item = 4
MIDI1. Set the instrument (4)

.Subroutine _Effect 2_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
Instrument name combo box. Currently selected item = 9
MIDI1. Set the instrument (9)
Effect 2. Selected = true

.Subroutine _Effect 3_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
Instrument name combo box. Currently selected item = 10
MIDI1. Set the instrument (10)
Effect 3. Selected = true

.Subroutine _Effect 4_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
Instrument name combo box. Currently selected item = 11
MIDI1. Set the instrument (11)
Effect 4. Selected = true

.Subroutine _Effect 5_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
Instrument name combo box. Currently selected item = 15
MIDI1. Set the instrument (15)
Effect 5. Selected = true

.Subroutine _Effect 6_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
Instrument name combo box. Currently selected item = 117
MIDI1. Set the instrument (117)
Effect 6. Selected = true

.Subroutine _Effect 7_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
Instrument name combo box. Currently selected item = 17
MIDI1. Set the instrument (17)
Effect 7. Selected = true

.Subroutine _Effect 8_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
MIDI1. Set the instrument (19)
Instrument name combo box. Currently selected item = 19
Effect 8. Selected = true

.Subroutine _Effect 9_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
MIDI1. Set the instrument (113)
Instrument name combo box. Currently selected item = 113
Effect 9. Selected = true

.Subroutine _Effect 10_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
MIDI1. Set the instrument (26)
Instrument name combo box. Currently selected item = 26
Effect 10. Selected = true

.Subroutine _Effect 11_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
MIDI1. Set the instrument (39)
Instrument name combo box. Currently selected item = 39
Effect 11. Selected = true

.Subroutine _Effect 12_ is clicked

Set instrument = true
Continuous assignment (false, effect 1. selected, effect 2. selected, effect 3. selected, effect 4. selected, effect 5. selected, effect 6. selected, effect 7. selected, effect 8. selected, effect 9. selected,  Effect 10. selected, effect 11. selected, effect 12. selected)
MIDI1. Set the instrument (56)
Instrument name combo box. Currently selected item = 56
Effect 12. Selected = true

.Subroutine _save_ clicked
.Local variable Instrument name, byte type

'Easy keyboard format description:
'emid ------------------- is an easy electronic keyboard file mark;
'4 ---------------------- is the instrument number, corresponding to the value of each instrument;
'48@4 71@4 69@4....p@2 --- sheet music group, its arrangement is: sheet music value @音長, separated by a space, ending with p@2.

.If true (recording text = "")
     Return ()
.If it really ends
Common dialog 1. Type =1
.If true (common dialog 1. open ())
     Instrument name = MIDI1. Take the instrument number ()
     .Judgment start (take the extension (common dialog 1. file name) = "MIDI" or take the extension (common dialog 1. file name) = "MID")
         Output midi (recording text + "p@2", common dialog 1. File name)
     .default
         Write to file (Common dialog 1. File name, to byte set ("emid" + #newline character + to text (instrument name) + #newline character + trailing blank (recording text)))
     .The end of judgment
     Message box ("Save file successfully", #Info icon,)
.If it really ends


.Subroutine output midi, logic type
.Parameter Sound source, text type
.Parameter File name, text type
.Local variable text group, text type,, "0"
.Local Variables Counting Variables, Integer Type
.Local variable current tone, text type,, "0"
.Local Variable File No. 1, Integer Type
.Local variable length, integer type
.Local Variable Variable, Integer Type
.Local Variable Temporary, Byte Set
.Local variable current value, integer type

File number 1 = open file (file name, #rewrite,)
Text group = split text (audio source, "",)
.Counting cycle first (take the number of array members (text group), counting variable)
     Current tone = split text (text group [counting variable], “@”,)
     .If true (current tone [1] ≠ “p”)
         .If true (take the number of array members (current tone) = 2)
             Variable = variable + 1
         .If it really ends

     .If it really ends
     Handle event ()
.Counting cycle end ()
Length = variable × 6 + 5
Write out the byte set (file number 1, {77, 84, 104, 100, 0, 0, 0, 6, 0, 1, 0, 1, 0, 48, 77, 84, 114, 107 })
Temporary = to byte set (length)
.Counting cycle first (4, variable)
     .Judgment start (temporary [4-variable + 1] = 0)
         Write out byte set (file number 1, {0 })
     .default
         Write out byte set (file number 1, to byte set (character (temporary [4-variable + 1])))
     .The end of judgment

.Counting cycle end ()
Write out the byte set (file number 1, {0, 144 })
.Counting cycle first (take the number of array members (text group), counting variable)
     Current tone = split text (text group [counting variable], “@”,)
     .If true (take the number of array members (current tone) = 2 and current tone [1] ≠ "p")
         Write out byte set (file number 1, to byte set (character (to value (current sound [1]))))
         .Judgment start (current tone [2] = "1.")
             Current value = 96
         .Judgment (current tone [2] = "1")
             Current value = 72
         .Judgment (current tone [2] = "2.")
             Current value = 64
         .Judgment (current tone [2] = "2")
             Current value = 48
         .Judgment (current tone [2] = "4.")
             Current value = 36
         .Judgment (current tone [2] = "4")
             Current value = 24
         .Judgment (current tone [2] = "8.")
             Current value = 18
         .Judgment (current tone [2] = "8")
             Current value = 12
         .Judgment (current tone [2] = "16")
             Current value = 6
         .Judgment (current tone [2] = "32")
             Current value = 3
         .default

         .The end of judgment
         Write out byte set (file number 1, {64 })
         Write out byte set (file number 1, to byte set (character (current value)))
         Write out byte set (file number 1, to byte set (character (to value (current sound [1]))))
         Write out the byte set (file number 1, {0, 0 })
     .If it really ends
     Handle event ()
.Counting cycle end ()
Write out the byte set (file number 1, {255, 47, 0 })
Close file (file number 1)
Return (true)

.Subroutine extension, text type
.Parameter file, text type

Back (to uppercase (take the right side of the text (file, take the length of the text (file)-find the text backwards (file, ".",, false))))

.Subroutine _About_ was clicked

Load (about window,, true)

.Subroutine _Graphic button 4_ is clicked

Load (setting window,, true)

.Subroutine _Master Volume Button_The left mouse button is pressed, logic type
.Parameters horizontal position, integer
.Parameters longitudinal position, integer
.Parameter Function key status, integer

Volume knob position = vertical position
Volume button drag = true
Capture the mouse (master volume button. take window handle ())

.Subroutine _Master volume button_The left mouse button is released, logic type
.Parameters horizontal position, integer type
.Parameters longitudinal position, integer type
.Parameter Function key status, integer type

Volume button drag = false
Release the mouse ()

.Subroutine _Master Volume Button_Mouse position is moved, logic type
.Parameters horizontal position, integer type
.Parameters longitudinal position, integer type
.Parameter Function key status, integer

.If true (volume button drag)
     .If true (vertical position ≥ master volume button. height and vertical position ≤ 65535)
         Return ()
     .If it really ends
     .Judgment start (vertical position <volume button position and master volume button. top edge> 72)
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 三区在线 | 999久久久 | 午夜久久| 国产精品久久av | av大片在线观看 | 免费观看成人性生生活片 | 黄色大片免费播放 | 成人精品网 | 久久美女视频 | 伊人久久综合 | 国产欧美日韩在线 | 亚洲国产欧美91 | 日韩欧美国产一区二区三区 | 中国美女av | 久久精品亚洲欧美日韩久久 | 国产精品久久久久久久久免费相片 | 伊人久久免费视频 | 天天综合国产 | 欧美最猛黑人 | 日韩视频在线一区 | 免费一看一级毛片 | 国产欧美日韩综合精品一区二区 | 日韩成人一区二区 | 波多野吉衣在线播放 | 成人在线国产 | 日韩精品视频一区二区三区 | 成人不卡视频 | 亚洲午夜视频 | 中文字幕高清 | 一区精品视频在线观看 | 亚洲毛片网站 | 国产精品一区二区在线播放 | 91精品麻豆日日躁夜夜躁 | 国产精品视频一区二区三区 | 国产精品久久久久久 | 成人网址在线观看 | 日本久久久久久久久 | 中文字幕成人网 | 中文字幕精品一区 | 日日操夜夜操天天操 | 国产一二区在线 |