使用经典的基本播放命令和 MML 创建 MIDI 文件

本文档介绍如何利用经典的基本播放命令和MML语言来创建MIDI文件,支持多曲目和在同一语法下播放字符串。示例中展示了创建单个或多个音轨的流程,并提到了可用的FB(VFB)源码资源。
摘要由CSDN通过智能技术生成
此程序是播放例程的变体, 而不是播放软件, 而是使用序列创建 MIDI 文件。

它像正常的编程播放命令一样工作, 但它支持多个曲目 

(使用相同的 GWBasic 和 MSX 基本语法,播放string1 ,string2 ,String3...............)。

注意:可以放在 {} 之间以播放和弦。

该例程创建单个或多轨 midi 文件。

FB源码(VFB源码在勇芳编程群里下载)

FUNCTION WriteVarLen(Value as integer) as string
 dim a as string

 a=chr(Value AND 127)

  DO WHILE (Value > 127)
   Value = Value shr 7
   a=chr((Value AND 127)or 128)+a
  LOOP 
 return a
END FUNCTION

FUNCTION WriteFourBytes(Value as integer) as string
 dim a as string
 a=chr(Value and 255)
 Value shr= 8
 a=chr(Value and 255)+a
 Value shr= 8
 a=chr(Value and 255)+a
 Value shr= 8
 a=chr(Value and 255)+a
 return a
end function




function _fbplay_internal_translateNote(toTranslate as string) as ubyte
   select case toTranslate
   case "c"  : return 0

   case "cs" : return 1
   case "db" : return 1

   case "d"  : return 2

   case "ds" : return 3
   case "eb" : return 3

   case "e"  : return 4
   case "fb" : return 4

   case "f"  : return 5
   case "es" : return 5

   case "fs" : return 6
   case "gb" : return 6

   case "g"  : return 7

   case "gs" : return 8
   case "ab" : return 8

   case "a"  : return 9

   case "as" : return 10
   case "bb" : return 10

   case "b"  : return 11
   case "cb" : return 11
   end select
       
end function



function _fbplay_internal(channel as ubyte, playstr as string) as string
       
   'default tempo is 120 quarter notes per minute
   'default note is a quarter note
   'as default notes play their full length
   'default octave is the 4th
   'default instrument is acoustic grand piano |TODO: Find a instrument closer to QB's PLAY sound.
   'maximum volume is default

   dim Track as string

   dim tempo as uinteger = 120
   dim note_len as ubyte = 4
   dim note_len_mod as double = 1
   dim octave as ubyte = 4
   dim volume as ubyte = 127
   dim note_stack(128) as ubyte

   dim chord as ubyte
   dim next_event as double

       
       
   dim duration as double
   dim idx as ubyte
       
   dim number as string
   dim char as string*1
   dim tChar as string*1
       
   dim toTranslate as string

   dim p as integer=1
       
   do while p < len(playstr)

      char=lcase(mid(playstr, p, 1))
      p+=1

      select case char
       
         'basic playing
       
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值