找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 9038|回复: 7
打印 上一主题 下一主题
收起左侧

用易语言写一个电子钢琴软件

[复制链接]
跳转到指定楼层
楼主
ID:56662 发表于 2013-11-25 03:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
     这只是一个窗口程序集,是整个软件的一部分,算是核心吧

   易语言不同于C语言、java,易语言是全中文编写,说实话,我感觉中文编写还不如英文编写顺手。我感觉最简单的还是我当初自己学的Python语言。

    下面是易语言的钢琴软件代码:
.版本 2
.支持库 eMMedia

.程序集 窗口程序集1
.程序集变量 琴键, 图形按钮, , "0"
.程序集变量 黑键, 整数型, , "0"
.程序集变量 白键, 整数型, , "0"
.程序集变量 上次键, 图形按钮
.程序集变量 上次键黑白, 逻辑型
.程序集变量 旧音符, 字节型
.程序集变量 音量钮拖动, 逻辑型
.程序集变量 音量钮位置, 整数型
.程序集变量 乐谱组, 文本型, , "0"
.程序集变量 乐谱位, 整数型
.程序集变量 录音状态, 逻辑型
.程序集变量 录音音长, 文本型, , "255"
.程序集变量 录音文本, 文本型
.程序集变量 停止, 逻辑型
.程序集变量 设置乐器, 逻辑型
.程序集变量 音波值, 整数型, , , 模拟音波用
.程序集变量 音波值历史组, 整数型, , "0", 模拟音波用
.程序集变量 大键码, 整数型, , "0"
.程序集变量 音位, 整数型, , "0"
.程序集变量 重复按键, 逻辑型
.程序集变量 白键码, 整数型, , "0"
.程序集变量 正常音, 文本型
.程序集变量 高一点, 文本型
.程序集变量 高二点, 文本型
.程序集变量 低一点, 文本型
.程序集变量 低二点, 文本型
.程序集变量 按下键, 整数型, , "0"
.程序集变量 存在, 逻辑型
.程序集变量 按键组, 整数型, , "0"
.程序集变量 标记组, 逻辑型, , "0"
.程序集变量 当前弹奏, 整数型
.程序集变量 已执行, 逻辑型
.程序集变量 弹奏码, 整数型
.程序集变量 格式, 整数型
.程序集变量 行结束, 逻辑型
.程序集变量 文件号, 整数型
.程序集变量 临时乐谱, 文本型
.程序集变量 系统播放, 逻辑型
.程序集变量 是否暂停, 逻辑型

.子程序 __启动窗口_创建完毕
.局部变量 黑键位置, 整数型, , "0"
.局部变量 黑键标记, 整数型, , "0"
.局部变量 左声道, 整数型
.局部变量 右声道, 整数型
.局部变量 标记差, 整数型
.局部变量 标记值, 整数型
.局部变量 变量, 整数型

载入 (启动画面, , 假)
置外形图片 (#底图资源, #黑色)
' //初始化
白键码 = { 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 }
重定义数组 (按下键, 假, 取数组成员数 (大键码))
按键组 = 大键码
重定义数组 (标记组, 假, 取数组成员数 (大键码))
.计次循环首 (取数组成员数 (标记组), 变量)
    标记组 [变量] = 假
.计次循环尾 ()
旧音符 = -1
格式 = 2
开始音位 = 0
效果1.选中 = 真
.计次循环首 (MIDI1.取设备数量 (), 变量)
    设备名组合框.加入项目 (MIDI1.取设备名 (变量 - 1), )
.计次循环尾 ()
MIDI1.打开 (0)
设备名组合框.现行选中项 = 0
.计次循环首 (MIDI1.取乐器数量 (), 变量)
    乐器名组合框.加入项目 (MIDI1.取乐器名 (变量), 变量)
.计次循环尾 ()
乐器名组合框.现行选中项 = 4
MIDI1.置乐器 (4, )

' //取音量:
.如果 (系统音量1.打开 (#音量类型.主音量) = 0)
    信息框 (“系统音量打开失败!,您可能听不到声音!”, 48, )
.否则
    系统音量1.取音量 (左声道, 右声道)
    主音量钮.顶边 = 116 - 四舍五入 (取整 ((左声道 + 右声道) ÷ 2 ÷ 1489.43), 0)
.如果结束
系统音量1.关闭 (2)
.如果 (系统音量1.打开 (#音量类型.软件合成器) = 0)
    信息框 (“软件合成器打开失败!,您可能听不到声音!”, 48, )
.否则
    系统音量1.取音量 (左声道, 右声道)
    软件合成器钮.顶边 = 116 - 四舍五入 (取整 ((左声道 + 右声道) ÷ 2 ÷ 1349.81), 0)
.如果结束
系统音量1.关闭 (2)

' //下面生成琴键代码:
重定义数组 (琴键, 假, 71)
.计次循环首 (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)
            加入成员 (白键, 标记值)
        .判断结束

    .如果真结束

.计次循环尾 ()


.子程序 按键发声
.参数 音符, 字节型

MIDI1.奏 (开始音位 + 音符, )
旧音符 = 开始音位 + 音符


.子程序 _琴键1_鼠标左键被按下, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型
.局部变量 当前琴键, 图形按钮

当前琴键 = 取事件组件 ()
.如果真 (MIDI1.是否打开 () = 假)
    MIDI1.打开 (0)
    MIDI1.置乐器 (乐器名组合框.现行选中项, )
.如果真结束
.如果真 (是否已创建 (当前琴键))
    按键发声 (到数值 (当前琴键.标记))
.如果真结束
.如果真 (录音状态 = 真)
    时钟3.时钟周期 = 100
    录音文本 = 录音文本 + 到文本 (到数值 (当前琴键.标记)) + “@”
.如果真结束
当前弹奏 = 到数值 (当前琴键.标记)

.子程序 停奏
.参数 v, 整数型, 可空

.如果 (是否为空 (v))
    MIDI1.停奏 (旧音符, )
.否则
    MIDI1.停奏 (旧音符, v)
.如果结束



.子程序 _琴键1_鼠标左键被放开, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型

停奏 ()
时钟3.时钟周期 = 0
.如果真 (录音状态 = 真 且 存在 = 真)
    .如果真 (弹奏码 ≤ 0)
        返回 ()
    .如果真结束
    .判断开始 (到数值 (录音音长 [弹奏码]) ≤ 2)
        录音音长 [弹奏码] = “8”
    .判断 (到数值 (录音音长 [弹奏码]) = 3)
        录音音长 [弹奏码] = “4.”
    .判断 (到数值 (录音音长 [弹奏码]) = 4)
        录音音长 [弹奏码] = “4”
    .判断 (到数值 (录音音长 [弹奏码]) > 4 且 到数值 (录音音长 [弹奏码]) ≤ 6)
        录音音长 [弹奏码] = “2.”
    .判断 (到数值 (录音音长 [弹奏码]) > 6 且 到数值 (录音音长 [弹奏码]) ≤ 8)
        录音音长 [弹奏码] = “2”
    .判断 (到数值 (录音音长 [弹奏码]) > 10 且 到数值 (录音音长 [弹奏码]) ≤ 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)
        行结束 = 真
        .判断开始 (音轨数 (通用对话框1.文件名) = 1)
            .如果真 (MIDI1.是否打开 () = 假)
                MIDI1.打开 (0)
            .如果真结束
            .如果真 (修复文件 (通用对话框1.文件名))
                转换格式emid (通用对话框1.文件名)
                播放文件 (临时乐谱)
                返回 ()
            .如果真结束

        .默认
            .如果真 (信息框 (“本MIDI音乐暂不支持模拟按键效果,您确定继续播放吗?”, 64 + 1, ) = #确认钮)
                MIDI1.关闭 ()
                媒体播放1.打开 (通用对话框1.文件名)
                媒体播放1.播放 (-1)
                系统播放 = 真
                时钟1.时钟周期 = 350
                时钟5.时钟周期 = 50
            .如果真结束

        .判断结束

    .判断 (格式 = 2)
        .判断开始 (通用对话框1.文件名 ≠ “”)
            .如果真 (MIDI1.是否打开 () = 假)
                MIDI1.打开 (0)
            .如果真结束
            文件乐谱 = 分割文本 (到文本 (读入文件 (通用对话框1.文件名)), #换行符, )
            .如果真 (文件乐谱 [1] ≠ “emid”)
                信息框 (“不是易语言MIDI音乐文本文件!”, 16, )
                播放.选中 = 假
                返回 ()
            .如果真结束
            MIDI1.置乐器 (到数值 (文件乐谱 [2]), )
            播放文件 (文件乐谱 [3])
        .默认
            信息框 (“没有要播放的曲目!”, 48, )
            播放.选中 = 假
            返回 ()
        .判断结束

    .默认

    .判断结束
    音波.选中 = 真
.默认
    连续赋值 (0, 时钟1.时钟周期, 时钟2.时钟周期, 时钟4.时钟周期)
    .如果 (系统播放)
        媒体播放1.暂停 ()
        播放.选中 = 假
        系统播放 = 假
        是否暂停 = 真
        时钟5.时钟周期 = 0
    .否则
        模拟按琴键 (旧音符 - 开始音位, 真)
        停奏 ()

    .如果结束

.判断结束




.子程序 转换格式emid
.参数 文件名, 文本型
.局部变量 变量
.局部变量 临时, 字节集

关闭文件 (文件号)
文件号 = 打开文件 (文件名, #读入, )
移到文件首 (文件号)
临时乐谱 = “”
移动读写位置 (文件号, , 24)
.判断循环首 (是否在文件尾 (文件号, ) = 假)
    临时 = 读入字节集 (文件号, 6)
    .判断开始 (取字节集长度 (临时) < 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) + “ ”
        .判断结束

    .判断结束

.判断循环尾 ()
写到文件 (文件名 + “.txt”, 到字节集 (“emid” + #换行符 + 到文本 (MIDI1.取乐器序号 ()) + #换行符 + 删尾空 (临时乐谱)))
' //上行代码是保存MIDI音乐为易语言文件。
关闭文件 (文件号)

.子程序 修复文件, 逻辑型
.参数 文件名, 文本型
.局部变量 临时1, 字节集, , "8"
.局部变量 临时2, 字节集
.局部变量 音轨数, 整数型
.局部变量 大小, 整数型
.局部变量 变量, 整数型
.局部变量 文件号1, 整数型

.判断开始 (音轨数 (文件名) = 1)
    关闭文件 (文件号)
    文件号 = 打开文件 (文件名, #读入, )
    文件号1 = 打开文件 (文件名 + “.bak”, #重写, )
    移到文件首 (文件号)
    临时1 [1] = 读入字节集 (文件号, 8)
    临时1 [2] = 读入字节集 (文件号, 2)
    临时1 [3] = 读入字节集 (文件号, 2)
    临时1 [4] = 读入字节集 (文件号, 2)
    临时1 [5] = 读入字节集 (文件号, 4)
    临时2 = 读入字节集 (文件号, 4)
    临时1 [6] = 读入字节集 (文件号, 2)
    大小 = 临时2 [1] × 255 × 255 × 255 + 临时2 [2] × 255 × 255 + 临时2 [3] × 255 + 临时2 [4]
    ' 移到文件首 (文件号)
    写出字节集 (文件号1, 取空白字节集 (24))
    .判断循环首 (是否在文件尾 (文件号, ) = 假)
        临时2 = 读入字节集 (文件号, 1)
        .判断开始 (临时2 [1] = 129 或 临时2 [1] = 130 或 临时2 [1] = 131)
            大小 = 大小 - 1
        .默认
            移到文件尾 (文件号1)
            写出字节集 (文件号1, 临时2)
        .判断结束

    .判断循环尾 ()
    移到文件首 (文件号1)
    .计次循环首 (5, 变量)
        写出字节集 (文件号1, 临时1 [变量])
    .计次循环尾 ()
    临时2 = 到字节集 (大小)
    .计次循环首 (4, 变量)
        .判断开始 (临时2 [4 - 变量 + 1] = 0)
            写出字节集 (文件号1, { 0 })
        .默认
            写出字节集 (文件号1, 到字节集 (字符 (临时2 [4 - 变量 + 1])))
        .判断结束

    .计次循环尾 ()
    写出字节集 (文件号1, 临时1 [6])
    关闭文件 (文件号1)
    关闭文件 (文件号)
    .判断开始 (删除文件 (文件名))
        .判断开始 (文件更名 (文件名 + “.bak”, 文件名))
            返回 (真)
        .默认
            返回 (假)
        .判断结束

    .默认
        返回 (假)

    .判断结束
    ' 信息框 (“修理完毕”, 0, )
.默认
    返回 (真)
.判断结束


.子程序 音轨数, 整数型
.参数 文件名, 文本型
.局部变量 临时, 字节集
.局部变量 音轨数, 整数型

关闭文件 (文件号)
文件号 = 打开文件 (文件名, #读入, )
移到文件首 (文件号)
移动读写位置 (文件号, , 10)
临时 = 读入字节集 (文件号, 2)
音轨数 = 临时 [1] × 255 + 临时 [2]
返回 (音轨数)

.子程序 _时钟2_周期事件
.局部变量 当前音, 文本型, , "0"
.局部变量 音符, 图形按钮
.局部变量 变量, 整数型
.局部变量 标识, 整数型

.如果真 (乐谱位 ≠ 0)
    停奏 (旧音符)
.如果真结束
.如果真 (乐谱位 = 取数组成员数 (乐谱组))
    时钟1.时钟周期 = 0
    时钟2.时钟周期 = 0
    时钟4.时钟周期 = 0
    音波画板.可视 = 假
    乐谱位 = 0
    ' 模拟按琴键 (旧音符, 真)
    旧音符 = 0
    播放.选中 = 假
    录音.禁止 = 假
    返回 ()
.如果真结束
乐谱位 = 乐谱位 + 1
.如果真 (乐谱组 [乐谱位] ≠ “|” 且 乐谱组 [乐谱位] ≠ “||”)
    当前音 = 分割文本 (乐谱组 [乐谱位], “@”, )
    .如果 (当前音 [1] = “p”)
        时钟2.时钟周期 = 960 \ 到数值 (当前音 [2])
    .否则
        .如果真 (取数组成员数 (当前音) = 2)
            MIDI1.奏 (到数值 (当前音 [1]), )
            模拟按琴键 (到数值 (当前音 [1]))
            音波值 = 到数值 (当前音 [1])
            旧音符 = 到数值 (当前音 [1])
            .如果 (取文本右边 (当前音 [2], 1) = “.”)
                时钟2.时钟周期 = 960 \ 到数值 (当前音 [2]) + 960 \ 到数值 (当前音 [2]) ÷ 2
            .否则
                时钟2.时钟周期 = 960 \ 到数值 (当前音 [2])
            .如果结束
            .计次循环首 (取数组成员数 (白键码), 变量)
                .如果真 (白键码 [变量] = 到数值 (当前音 [1]))
                    跳出循环 ()
                .如果真结束

            .计次循环尾 ()
            标识 = 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)
                .判断开始 (到数值 (当前音 [1]) ≤ 47)
                    .判断开始 (标识 = 0)
                        低二点 = 低二点 + “ ” + “ ”
                        低一点 = 低一点 + “ ” + “ ”
                    .默认
                        低二点 = 低二点 + “ ” + “.”
                        低一点 = 低一点 + “ ” + “.”
                    .判断结束
                    高一点 = 高一点 + “  ”
                    高二点 = 高二点 + “  ”
                .判断 (到数值 (当前音 [1]) > 47 且 到数值 (当前音 [1]) ≤ 59)
                    .判断开始 (标识 = 0)
                        低一点 = 低一点 + “ ” + “ ”
                    .默认
                        低一点 = 低一点 + “ ” + “.”
                    .判断结束
                    低二点 = 低二点 + “  ”
                    高一点 = 高一点 + “  ”
                    高二点 = 高二点 + “  ”
                .判断 (到数值 (当前音 [1]) > 59 且 到数值 (当前音 [1]) ≤ 71)
                    低二点 = 低二点 + “  ”
                    低一点 = 低一点 + “  ”
                    高一点 = 高一点 + “  ”
                    高二点 = 高二点 + “  ”
                .判断 (到数值 (当前音 [1]) > 71 且 到数值 (当前音 [1]) ≤ 83)
                    低二点 = 低二点 + “  ”
                    低一点 = 低一点 + “  ”
                    .判断开始 (标识 = 0)
                        高一点 = 高一点 + “ ” + “ ”
                    .默认
                        高一点 = 高一点 + “ ” + “.”
                    .判断结束

                    高二点 = 高二点 + “  ”
                .判断 (到数值 (当前音 [1]) > 83 且 到数值 (当前音 [1]) ≤ 95)
                    低二点 = 低二点 + “  ”
                    低一点 = 低一点 + “  ”
                    .判断开始 (标识 = 0)
                        高二点 = 高二点 + “ ” + “ ”
                        高一点 = 高一点 + “ ” + “ ”
                    .默认
                        高二点 = 高二点 + “ ” + “.”
                        高一点 = 高一点 + “ ” + “.”
                    .判断结束

                .默认
                    低二点 = 低二点 + “ ”
                    低一点 = 低一点 + “ ”
                    高一点 = 高一点 + “ ”
                    高二点 = 高二点 + “ ”
                .判断结束

            .默认
                高一点 = “”
                低一点 = “”
                高二点 = “”
                低二点 = “”
            .判断结束
            低1.标题 = 低一点
            低2.标题 = 低二点
            高2.标题 = 高二点
            高1.标题 = 高一点
        .如果真结束

    .如果结束

.如果真结束


.子程序 模拟按琴键
.参数 音符, 字节型
.参数 结束, 逻辑型, 可空
.局部变量 当前键, 图形按钮
.局部变量 当前键黑白, 逻辑型
.局部变量 变量, 整数型

.计次循环首 (取数组成员数 (黑键), 变量)
    .如果真 (黑键 [变量] = 音符)
        当前键黑白 = 真
        跳出循环 ()
    .如果真结束

.计次循环尾 ()
.如果真 (是否已创建 (上次键))
    上次键.正常图片 = 选择 (上次键黑白, #黑正常, #白正常)
.如果真结束
.如果真 (停止)
    返回 ()
.如果真结束
.如果真 (音符 ≠ 255 且 音符 ≠ 0)
    当前键 = 取标记组件 (音符)
.如果真结束
.如果真 (结束 = 真)
    返回 ()
.如果真结束
.如果真 (是否已创建 (当前键))
    当前键.正常图片 = 选择 (当前键黑白, #黑按下, #白按下)
.如果真结束
上次键 = 当前键
上次键黑白 = 当前键黑白

.子程序 播放文件
.参数 内容, 文本型

乐谱组 = 分割文本 (内容, “ ”, )
时钟2.时钟周期 = 50
时钟1.时钟周期 = 350
时钟4.时钟周期 = 150
音波画板.可视 = 真

.子程序 _录音_被单击

.判断开始 (录音.选中 = 真)
    重定义数组 (录音音长, 假, 255)
    录音文本 = “”
    时钟3.时钟周期 = 100
    _启动窗口.获取焦点 ()
    录音状态 = 真
    格式 = 0
    播放.禁止 = 取反 (播放.禁止)
.默认
    时钟3.时钟周期 = 0
    .如果真 (当前弹奏 = 0)
        返回 ()
    .如果真结束
    .判断开始 (到数值 (录音音长 [当前弹奏]) ≤ 2)
        录音音长 [当前弹奏] = “8”
    .判断 (到数值 (录音音长 [当前弹奏]) = 3)
        录音音长 [当前弹奏] = “4.”
    .判断 (到数值 (录音音长 [当前弹奏]) = 4)
        录音音长 [当前弹奏] = “4”
    .判断 (到数值 (录音音长 [当前弹奏]) > 4 且 到数值 (录音音长 [当前弹奏]) ≤ 6)
        录音音长 [当前弹奏] = “2.”
    .判断 (到数值 (录音音长 [当前弹奏]) > 6 且 到数值 (录音音长 [当前弹奏]) ≤ 8)
        录音音长 [当前弹奏] = “2”
    .判断 (到数值 (录音音长 [当前弹奏]) > 10 且 到数值 (录音音长 [当前弹奏]) ≤ 12)
        录音音长 [当前弹奏] = “1”
    .默认
        录音音长 [当前弹奏] = “1.”
    .判断结束
    录音文本 = 录音文本 + 录音音长 [当前弹奏] + “ ”
    录音音长 [当前弹奏] = “”
    录音状态 = 假
    录音状态 = 取反 (取反 (录音.选中))
    播放.禁止 = 取反 (播放.禁止)
.判断结束


.子程序 _时钟3_周期事件

.如果真 (当前弹奏 > 0)
    录音音长 [当前弹奏] = 到文本 (到数值 (录音音长 [当前弹奏]) + 1)
.如果真结束


.子程序 _图形按钮3_被单击

载入 (设置窗口, , 真)

.子程序 _停止播放_被单击

.如果真 (录音.禁止 = 真)
    录音.禁止 = 假
.如果真结束
MIDI1.关闭 ()
连续赋值 (假, 播放.选中, 录音.选中, 音波画板.可视)
连续赋值 (0, 时钟1.时钟周期, 时钟2.时钟周期, 时钟2.时钟周期, 时钟4.时钟周期)
.如果 (系统播放)
    媒体播放1.停止 ()
    系统播放 = 假
.否则
    模拟按琴键 (旧音符, 真)
.如果结束
MIDI1.打开 (0)
MIDI1.置乐器 (乐器名组合框.现行选中项)
乐谱位 = 0
_启动窗口.获取焦点 ()



.子程序 _效果1_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
效果1.选中 = 真
乐器名组合框.现行选中项 = 4
MIDI1.置乐器 (4)

.子程序 _效果2_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
乐器名组合框.现行选中项 = 9
MIDI1.置乐器 (9)
效果2.选中 = 真

.子程序 _效果3_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
乐器名组合框.现行选中项 = 10
MIDI1.置乐器 (10)
效果3.选中 = 真

.子程序 _效果4_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
乐器名组合框.现行选中项 = 11
MIDI1.置乐器 (11)
效果4.选中 = 真

.子程序 _效果5_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
乐器名组合框.现行选中项 = 15
MIDI1.置乐器 (15)
效果5.选中 = 真

.子程序 _效果6_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
乐器名组合框.现行选中项 = 117
MIDI1.置乐器 (117)
效果6.选中 = 真

.子程序 _效果7_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
乐器名组合框.现行选中项 = 17
MIDI1.置乐器 (17)
效果7.选中 = 真

.子程序 _效果8_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
MIDI1.置乐器 (19)
乐器名组合框.现行选中项 = 19
效果8.选中 = 真

.子程序 _效果9_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
MIDI1.置乐器 (113)
乐器名组合框.现行选中项 = 113
效果9.选中 = 真

.子程序 _效果10_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
MIDI1.置乐器 (26)
乐器名组合框.现行选中项 = 26
效果10.选中 = 真

.子程序 _效果11_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
MIDI1.置乐器 (39)
乐器名组合框.现行选中项 = 39
效果11.选中 = 真

.子程序 _效果12_被单击

设置乐器 = 真
连续赋值 (假, 效果1.选中, 效果2.选中, 效果3.选中, 效果4.选中, 效果5.选中, 效果6.选中, 效果7.选中, 效果8.选中, 效果9.选中, 效果10.选中, 效果11.选中, 效果12.选中)
MIDI1.置乐器 (56)
乐器名组合框.现行选中项 = 56
效果12.选中 = 真

.子程序 _保存_被单击
.局部变量 乐器名, 字节型

' 易电子琴格式说明:
' 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.文件名, 到字节集 (“emid” + #换行符 + 到文本 (乐器名) + #换行符 + 删尾空 (录音文本)))
    .判断结束
    信息框 (“保存文件成功”, #信息图标, )
.如果真结束


.子程序 输出midi, 逻辑型
.参数 音源, 文本型
.参数 文件名, 文本型
.局部变量 文本组, 文本型, , "0"
.局部变量 计次变量, 整数型
.局部变量 当前音, 文本型, , "0"
.局部变量 文件号1, 整数型
.局部变量 长度, 整数型
.局部变量 变量, 整数型
.局部变量 临时, 字节集
.局部变量 当前值, 整数型

文件号1 = 打开文件 (文件名, #重写, )
文本组 = 分割文本 (音源, “ ”, )
.计次循环首 (取数组成员数 (文本组), 计次变量)
    当前音 = 分割文本 (文本组 [计次变量], “@”, )
    .如果真 (当前音 [1] ≠ “p”)
        .如果真 (取数组成员数 (当前音) = 2)
            变量 = 变量 + 1
        .如果真结束

    .如果真结束
    处理事件 ()
.计次循环尾 ()
长度 = 变量 × 6 + 5
写出字节集 (文件号1, { 77, 84, 104, 100, 0, 0, 0, 6, 0, 1, 0, 1, 0, 48, 77, 84, 114, 107 })
临时 = 到字节集 (长度)
.计次循环首 (4, 变量)
    .判断开始 (临时 [4 - 变量 + 1] = 0)
        写出字节集 (文件号1, { 0 })
    .默认
        写出字节集 (文件号1, 到字节集 (字符 (临时 [4 - 变量 + 1])))
    .判断结束

.计次循环尾 ()
写出字节集 (文件号1, { 0, 144 })
.计次循环首 (取数组成员数 (文本组), 计次变量)
    当前音 = 分割文本 (文本组 [计次变量], “@”, )
    .如果真 (取数组成员数 (当前音) = 2 且 当前音 [1] ≠ “p”)
        写出字节集 (文件号1, 到字节集 (字符 (到数值 (当前音 [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
        .默认

        .判断结束
        写出字节集 (文件号1, { 64 })
        写出字节集 (文件号1, 到字节集 (字符 (当前值)))
        写出字节集 (文件号1, 到字节集 (字符 (到数值 (当前音 [1]))))
        写出字节集 (文件号1, { 0, 0 })
    .如果真结束
    处理事件 ()
.计次循环尾 ()
写出字节集 (文件号1, { 255, 47, 0 })
关闭文件 (文件号1)
返回 (真)

.子程序 取扩展名, 文本型
.参数 文件, 文本型

返回 (到大写 (取文本右边 (文件, 取文本长度 (文件) - 倒找文本 (文件, “.”, , 假))))

.子程序 _关于_被单击

载入 (关于窗口, , 真)

.子程序 _图形按钮4_被单击

载入 (设置窗口, , 真)

.子程序 _主音量钮_鼠标左键被按下, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型

音量钮位置 = 纵向位置
音量钮拖动 = 真
捕获鼠标 (主音量钮.取窗口句柄 ())

.子程序 _主音量钮_鼠标左键被放开, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型

音量钮拖动 = 假
释放鼠标 ()

.子程序 _主音量钮_鼠标位置被移动, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型

.如果真 (音量钮拖动)
    .如果真 (纵向位置 ≥ 主音量钮.高度 且 纵向位置 ≤ 65535)
        返回 ()
    .如果真结束
    .判断开始 (纵向位置 < 音量钮位置 且 主音量钮.顶边 > 72)
        主音量钮.顶边 = 主音量钮.顶边 - 1
    .判断 (纵向位置 > 音量钮位置 且 主音量钮.顶边 < 116)
        主音量钮.顶边 = 主音量钮.顶边 + 1
    .默认

    .判断结束
    .如果 (系统音量1.打开 (#音量类型.主音量) = 0)
        信息框 (“系统音量打开失败!,您可能听不到声音!”, 48, )
    .否则
        系统音量1.置音量 (四舍五入 ((116 - 主音量钮.顶边) × 1489.43, 0), 四舍五入 ((116 - 主音量钮.顶边) × 1489.43, 0))
        系统音量1.关闭 (2)
    .如果结束

.如果真结束


.子程序 _软件合成器钮_鼠标左键被按下, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型

音量钮位置 = 纵向位置
音量钮拖动 = 真
捕获鼠标 (软件合成器钮.取窗口句柄 ())

.子程序 _软件合成器钮_鼠标左键被放开, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型

音量钮拖动 = 假
释放鼠标 ()

.子程序 _软件合成器钮_鼠标位置被移动, 逻辑型
.参数 横向位置, 整数型
.参数 纵向位置, 整数型
.参数 功能键状态, 整数型

.如果真 (音量钮拖动)
    .如果真 (纵向位置 ≥ 软件合成器钮.高度 且 纵向位置 ≤ 65535)
        返回 ()
    .如果真结束
    .判断开始 (纵向位置 < 音量钮位置 且 软件合成器钮.顶边 > 72)
        软件合成器钮.顶边 = 软件合成器钮.顶边 - 1
    .判断 (纵向位置 > 音量钮位置 且 软件合成器钮.顶边 < 116)
        软件合成器钮.顶边 = 软件合成器钮.顶边 + 1
    .默认

    .判断结束
    .如果 (系统音量1.打开 (#音量类型.软件合成器) = 0)
        信息框 (“系统音量打开失败!,您可能听不到声音!”, 48, )
    .否则
        系统音量1.置音量 (四舍五入 ((116 - 软件合成器钮.顶边) × 1349.81, 0), 四舍五入 ((116 - 软件合成器钮.顶边) × 1349.81, 0))
        系统音量1.关闭 (2)
    .如果结束

.如果真结束


.子程序 _退出_被单击

结束 ()

.子程序 _最小化_被单击

位置 = 2

.子程序 音波模拟
.参数 值, 整数型
.参数 目的画板, 画板
.局部变量 变量

音波画板.清除 (, , , )
置随机数种子 ()
.如果真 (取数组成员数 (音波值历史组) ≥ 16)
    删除成员 (音波值历史组, 17, 取数组成员数 (音波值历史组) - 16)
.如果真结束
.计次循环首 (取数组成员数 (音波值历史组), 变量)
    目的画板.填充矩形 (变量 × 10, 音波值历史组 [变量], 变量 × 10 - 8, 目的画板.高度)
.计次循环尾 ()
插入成员 (音波值历史组, 1, 值)

.子程序 _时钟4_周期事件

音波模拟 (音波值 ÷ 2 - 10, 音波画板)

.子程序 __启动窗口_按下某键, 逻辑型
.参数 键代码, 整数型
.参数 功能键状态, 整数型
.局部变量 变量1, 整数型
.局部变量 变量2, 整数型

存在 = 假
.计次循环首 (取数组成员数 (按键组), 变量2)
    .如果真 (按键组 [变量2] = 键代码)
        存在 = 真
        停奏 ()
        .判断开始 (标记组 [变量2] = 真)
            重复按键 = 真
            跳出循环 ()
        .默认
            标记组 [变量2] = 真
        .判断结束

    .如果真结束

.计次循环尾 ()
.如果真 (重复按键 = 假 且 存在 = 真)
    变量1 = 0
    .计次循环首 (取数组成员数 (大键码), 变量1)
        .如果真 (大键码 [变量1] = 键代码)
            弹奏码 = 音位 [变量1]
            跳出循环 ()
        .如果真结束

    .计次循环尾 ()
    .如果真 (重复按键 = 假)
        模拟按琴键 (弹奏码)
        按键发声 (弹奏码)
        时钟3.时钟周期 = 0
        .如果真 (录音状态 = 真)
            .判断开始 (当前弹奏 > 0)
                .判断开始 (到数值 (录音音长 [当前弹奏]) ≤ 2)
                    录音音长 [当前弹奏] = “8”
                .判断 (到数值 (录音音长 [当前弹奏]) = 3)
                    录音音长 [当前弹奏] = “4.”
                .判断 (到数值 (录音音长 [当前弹奏]) = 4)
                    录音音长 [当前弹奏] = “4”
                .判断 (到数值 (录音音长 [当前弹奏]) > 4 且 到数值 (录音音长 [当前弹奏]) ≤ 6)
                    录音音长 [当前弹奏] = “2.”
                .判断 (到数值 (录音音长 [当前弹奏]) > 6 且 到数值 (录音音长 [当前弹奏]) ≤ 8)
                    录音音长 [当前弹奏] = “2”
                .判断 (到数值 (录音音长 [当前弹奏]) > 10 且 到数值 (录音音长 [当前弹奏]) ≤ 12)
                    录音音长 [当前弹奏] = “1”
                .默认
                    录音音长 [当前弹奏] = “1.”
                .判断结束
                录音文本 = 录音文本 + 录音音长 [当前弹奏] + “ ”
                录音音长 [当前弹奏] = “”
                已执行 = 真
            .默认

            .判断结束
            当前弹奏 = 弹奏码
            时钟3.时钟周期 = 100
            录音文本 = 录音文本 + 到文本 (弹奏码) + “@”
        .如果真结束
        返回 ()
    .如果真结束

.如果真结束


.子程序 __启动窗口_放开某键, 逻辑型
.参数 键代码, 整数型
.参数 功能键状态, 整数型
.局部变量 变量, 整数型

存在 = 假
.计次循环首 (取数组成员数 (按键组), 变量)
    .如果真 (按键组 [变量] = 键代码 且 标记组 [变量] = 真)
        重复按键 = 假
        存在 = 真
        标记组 [变量] = 假
        跳出循环 ()
    .如果真结束

.计次循环尾 ()
.计次循环首 (取数组成员数 (大键码), 变量)
    .如果真 (大键码 [变量] = 键代码)
        弹奏码 = 音位 [变量]
        跳出循环 ()
    .如果真结束

.计次循环尾 ()
停奏 ()
.如果真 (是否已创建 (上次键))
    上次键.正常图片 = 选择 (上次键黑白, #黑正常, #白正常)
.如果真结束

弹奏码 = 当前弹奏
.如果真 (录音状态 = 真 且 存在 = 真)
    .如果真 (弹奏码 > 0 且 已执行 = 假)
        .判断开始 (到数值 (录音音长 [弹奏码]) ≤ 2)
            录音音长 [弹奏码] = “8”
        .判断 (到数值 (录音音长 [弹奏码]) = 3)
            录音音长 [弹奏码] = “4.”
        .判断 (到数值 (录音音长 [弹奏码]) = 4)
            录音音长 [弹奏码] = “4”
        .判断 (到数值 (录音音长 [弹奏码]) > 4 且 到数值 (录音音长 [弹奏码]) ≤ 6)
            录音音长 [弹奏码] = “2.”
        .判断 (到数值 (录音音长 [弹奏码]) > 6 且 到数值 (录音音长 [弹奏码]) ≤ 8)
            录音音长 [弹奏码] = “2”
        .判断 (到数值 (录音音长 [弹奏码]) > 10 且 到数值 (录音音长 [弹奏码]) ≤ 12)
            录音音长 [弹奏码] = “1”
        .默认
            录音音长 [弹奏码] = “1.”
        .判断结束
        录音文本 = 录音文本 + 录音音长 [弹奏码] + “ ”
        已执行 = 真
    .如果真结束

.如果真结束
已执行 = 假


.子程序 _音波_被单击

音值画板.可视 = 假
音波画板.可视 = 真

.子程序 _音值_被单击

音值画板.可视 = 真
音波画板.可视 = 假


.子程序 _时钟5_周期事件

.如果真 (媒体播放1.取位置 () = 媒体播放1.取长度 ())
    时钟1.时钟周期 = 0
    时钟5.时钟周期 = 0
    媒体播放1.关闭 ()
    播放.选中 = 假
    是否暂停 = 假
.如果真结束


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:75246 发表于 2015-3-29 14:06 | 只看该作者
易语言,我也用,多联系!
回复

使用道具 举报

板凳
ID:384821 发表于 2018-8-21 19:45 | 只看该作者
请楼主发一下启动窗口图像
回复

使用道具 举报

地板
ID:384821 发表于 2018-8-21 19:46 | 只看该作者
请楼主发一下启动窗口的图像
回复

使用道具 举报

5#
ID:387700 发表于 2018-8-28 22:59 | 只看该作者
中文的适合新手
回复

使用道具 举报

6#
ID:540398 发表于 2019-5-17 07:24 | 只看该作者
其实还是相对繁琐了。
回复

使用道具 举报

7#
ID:809311 发表于 2020-8-13 12:51 | 只看该作者

RE: 用易语言写一个电子钢琴软件(看起来不对劲)

怎么变成中文了?变成中文程序就用不了了,还要翻译回去。
回复

使用道具 举报

8#
ID:809311 发表于 2020-8-18 16:05 | 只看该作者
Roy-2010 发表于 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)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表