zoukankan      html  css  js  c++  java
  • Overview of MIDI

    东拼西凑的介绍

    MIDI which means Musical Instrument Digital Interface, introduced in 1980's provided a interface for digital music tool to comunicate with each other.The information carried by midi data is some signal like "note on", "note off", "notepitch ", "pitch bend",etc.A midi instrument may be a piece of hardware(electronic keyboard, synthesizer) or software enviroment like ableton, garageband, digital performer, logic.The advantages are:

    compact -an entire song can be stored within a few hundred MIDI messages (compared to audio data which is sampled thousands of times a second)
    easy to modify/manipulate notes -change pitch, duration, and other parameters without having to rerecord
    change instruments -remember, MIDI only describes which notes to play, you can send these notes to any instrument to change the overall sound of the composition.

    MIDI keyboard is the most common instrument to create MIDI(or use your keyboard instead of it).When a key in the board is starting to press ,the message "note on" is send with attributes which key is pressed(note,between the value 0~127,like value 60 means the middel c,c4) and how fast this happens(velocity,value beween 0~127,the higer value means the louder voice).Unfortunately,computer keyboard has no ability to send velocity information,the value of this attribute will be a constant igore your strength of speed of pressing.When a pressed key is released,the message "note off " is created also contains the velocity information. "Aftertouch" is created when a key is in the state of "note on",and you may change the power of pressing.Most times you may use "Pichbend" slider(or other tools) to modify the tone in a distance of a semitone(half-step), this mesage is applied to all the notes played.And all the notes can be send to different "Channel" to compose a multi-track song.

    The most easy way to manage MIDI through python is using the open-source library python-midi,address :https://github.com/vishnubob/python-midi#Installation

    python-midi格式解析:

    首先是head_chunk中

    • format-- midi文件类型,有效值0(所有音符都在1个track中,单轨文件) 1(多轨 同步并行 常用) 2(多轨 独立)
    • resolution --  ticks per quarter note 一个四分音符的ticks,tick是midi中计算时间长短的最小单位。在cakewalk中,默认是1个四分音符等于120tick,根据需要在工程选项里可以将设置改为48、72、96、120、144、168、192、216、240、360、384或480个tick。这里有个例子,可以计算出1个ticks的具体时间:在每个四分音符等于120tick的情况下,拍速120,4/4拍的曲子

          1)4/4拍的曲子是以四分音符为一拍,那么一拍就是120tick;
          2)拍速120也就是说每分钟120拍,即一拍为0.5秒,也就是30毫秒。
          根据1)和2)可知,一拍=120tick=30毫秒,所以1tick=1/4毫秒

    当format为1时,Track0比较特殊,记录了一些meta-events,如 :NameEvent(记录歌名),TextMetaEvent(如歌曲信息 作者),版权,还有:

    SetTempoEvent(重要)----格式为tt tt tt,一分钟多少拍

    TimeSignatureEvent(重要)-----格式为nn dd cc bb nn和dd合起来代表了歌曲拍号nn/dd拍 ,注意dd是记录的是2的指数,如2,代表$2^2$ = 4。cc表示一个四分音符的midi clock数(一般固定为24),bb表示一个四分音符相当于多少个32分音符(这不是傻?),如果没有拍号记录的话,默认为4/4拍

    除开Track0外,其他Track中记录的为<delta_time> <event>的pair对,delta_time记录了上次事件到本次事件发生的时间间隔。event分为midi event,sysex event和meta event。

    Midi Event:

    •   Channel voice message

      主要的就是note on和note off事件了 ,两者成对出现

      

      channel :midi channel

      data:貌似时pitch和velocity的组合数列

      length:?

      pitch:midi音符值

      statusmsg:?

      tick:delta_ticks

      velocity:音符力度,为0的话 不发声

      其他事件还包括AfterTouch(已经on的note的按键力度发生变化)、Controller Change(设备发生变化,如脚踩效果器等)、Program Change(?)、Pitch Bend(从名字猜测是音调变调,推弦?)

    • Channel Mode message

       包括了一些All Sound Off,Reset All Controllers,Local Control,All Notes Off,Omni Mode Off,Omni Mode On,Mono Mode On,Poly Mode On等控制信息

    Sysex Events:

      保留字段用于后续扩展或交由合成器厂商自己实现

    Meta Events:

      track-names, lyrics and cue-points(提示 如演员上场 幕帘拉开之类的),还有上面提到的Track0中的SetTempo event,TimeSignature等都是元事件

     midi文件自行编写参考:http://blog.sina.com.cn/s/blog_622bd1660101aggj.html

                                           http://www.360doc.com/content/17/0205/08/11411827_626609322.shtml

     
  • 相关阅读:
    cocoapods 命令
    开发常用
    ios 定位
    LoadingView
    自定义cell右侧 多按钮
    cocoaPods
    AFNetWorking
    iphone自定义铃声
    升级为iOS9后,默认请求类型为https,如何使用http进行请求会报错(引用他人的)
    理解c语言中的指针
  • 原文地址:https://www.cnblogs.com/punkcure/p/8065852.html
Copyright © 2011-2022 走看看