{
    "content": [
        {
            "type": "text",
            "text": "# MIDI (man)\n\n## NAME\n\nMIDI - read, compose, modify, and write MIDI files\n\n## SYNOPSIS\n\nuse MIDI;\nuse strict;\nuse warnings;\nmy @events = (\n['textevent',0, 'MORE COWBELL'],\n['settempo', 0, 450000], # 1qn = .45 seconds\n);\nfor (1 .. 20) {\npush @events,\n['noteon' , 90,  9, 56, 127],\n['noteoff',  6,  9, 56, 127],\n;\n}\nforeach my $delay (reverse(1..96)) {\npush @events,\n['noteon' ,      0,  9, 56, 127],\n['noteoff', $delay,  9, 56, 127],\n;\n}\nmy $cowbelltrack = MIDI::Track->new({ 'events' => \\@events });\nmy $opus = MIDI::Opus->new(\n{ 'format' => 0, 'ticks' => 96, 'tracks' => [ $cowbelltrack ] } );\n$opus->writetofile( 'cowbell.mid' );\n\n## DESCRIPTION\n\nThis suite of modules provides routines for reading, composing, modifying, and writing MIDI\nfiles.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **COMPONENTS**\n- **INTRODUCTION**\n- **GOODIES**\n- **BRIEF GLOSSARY**\n- **SEE ALSO**\n- **REFERENCES**\n- **COPYRIGHT**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "MIDI",
        "section": "",
        "mode": "man",
        "summary": "MIDI - read, compose, modify, and write MIDI files",
        "synopsis": "use MIDI;\nuse strict;\nuse warnings;\nmy @events = (\n['textevent',0, 'MORE COWBELL'],\n['settempo', 0, 450000], # 1qn = .45 seconds\n);\nfor (1 .. 20) {\npush @events,\n['noteon' , 90,  9, 56, 127],\n['noteoff',  6,  9, 56, 127],\n;\n}\nforeach my $delay (reverse(1..96)) {\npush @events,\n['noteon' ,      0,  9, 56, 127],\n['noteoff', $delay,  9, 56, 127],\n;\n}\nmy $cowbelltrack = MIDI::Track->new({ 'events' => \\@events });\nmy $opus = MIDI::Opus->new(\n{ 'format' => 0, 'ticks' => 96, 'tracks' => [ $cowbelltrack ] } );\n$opus->writetofile( 'cowbell.mid' );",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "COMPONENTS",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "INTRODUCTION",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "GOODIES",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "BRIEF GLOSSARY",
                "lines": 54,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "REFERENCES",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "MIDI - read, compose, modify, and write MIDI files\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use MIDI;\nuse strict;\nuse warnings;\nmy @events = (\n['textevent',0, 'MORE COWBELL'],\n['settempo', 0, 450000], # 1qn = .45 seconds\n);\n\nfor (1 .. 20) {\npush @events,\n['noteon' , 90,  9, 56, 127],\n['noteoff',  6,  9, 56, 127],\n;\n}\nforeach my $delay (reverse(1..96)) {\npush @events,\n['noteon' ,      0,  9, 56, 127],\n['noteoff', $delay,  9, 56, 127],\n;\n}\n\nmy $cowbelltrack = MIDI::Track->new({ 'events' => \\@events });\nmy $opus = MIDI::Opus->new(\n{ 'format' => 0, 'ticks' => 96, 'tracks' => [ $cowbelltrack ] } );\n$opus->writetofile( 'cowbell.mid' );\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This suite of modules provides routines for reading, composing, modifying, and writing MIDI\nfiles.\n\nFrom FOLDOC (\"http://wombat.doc.ic.ac.uk/foldoc/\"):\n\nMIDI, Musical Instrument Digital Interface\n\n<multimedia, file format> (MIDI /mi'-dee/, /mee'-dee/) A hardware specification and\nprotocol used to communicate note and effect information between synthesisers, computers,\nmusic keyboards, controllers and other electronic music devices. [...]\n\nThe basic unit of information is a \"note on/off\" event which includes a note number\n(pitch) and key velocity (loudness). There are many other message types for events such\nas pitch bend, patch changes and synthesizer-specific events for loading new patches etc.\n\nThere is a file format for expressing MIDI data which is like a dump of data sent over a\nMIDI port. [...]\n",
                "subsections": []
            },
            "COMPONENTS": {
                "content": "The MIDI-Perl suite consists of these modules:\n\nMIDI (which you're looking at), MIDI::Opus, MIDI::Track, MIDI::Event, MIDI::Score, and\nMIDI::Simple.  All of these contain documentation in pod format.  You should read all of\nthese pods.\n\nThe order you want to read them in will depend on what you want to do with this suite of\nmodules: if you are focused on manipulating the guts of existing MIDI files, read the pods in\nthe order given above.\n\nBut if you aim to compose music with this suite, read this pod, then MIDI::Score and\nMIDI::Simple, and then skim the rest.\n",
                "subsections": []
            },
            "INTRODUCTION": {
                "content": "This suite of modules is basically object-oriented, with the exception of MIDI::Simple.  MIDI\nopuses (\"songs\") are represented as objects belonging to the class MIDI::Opus.  An opus\ncontains tracks, which are objects belonging to the class MIDI::Track.  A track will\ngenerally contain a list of events, where each event is a list consisting of a command, a\ndelta-time, and some number of parameters.  In other words, opuses and tracks are objects,\nand the events in a track comprise a LoL (and if you don't know what an LoL is, you must read\nperllol).\n\nFurthermore, for some purposes it's useful to analyze the totality of a track's events as a\n\"score\" -- where a score consists of notes where each event is a list consisting of a\ncommand, a time offset from the start of the track, and some number of parameters.  This is\nthe level of abstraction that MIDI::Score and MIDI::Simple deal with.\n\nWhile this suite does provide some functionality accessible only if you're comfortable with\nvarious kinds of references, and while there are some options that deal with the guts of MIDI\nencoding, you can (I hope) get along just fine with just a basic grasp of the MIDI\n\"standard\", and a command of LoLs.  I have tried, at various points in this documentation, to\npoint out what things are not likely to be of use to the casual user.\n",
                "subsections": []
            },
            "GOODIES": {
                "content": "The bare module MIDI.pm doesn't do much more than \"use\" the necessary component submodules\n(i.e., all except MIDI::Simple).  But it does provide some hashes you might find useful:\n\n%MIDI::note2number and %MIDI::number2note\n%MIDI::number2note corresponds MIDI note numbers to a more comprehensible representation\n(e.g., 68 to 'Gs4', for G-sharp, octave 4); %MIDI::note2number is the reverse.  Have a\nlook at the source to see the contents of the hash.\n\n%MIDI::patch2number and %MIDI::number2patch\n%MIDI::number2patch corresponds General MIDI patch numbers (0 to 127) to English names\n(e.g., 79 to 'Ocarina'); %MIDI::patch2number is the reverse.  Have a look at the source\nto see the contents of the hash.\n\n%MIDI::notenum2percussion and %MIDI::percussion2notenum\n%MIDI::notenum2percussion corresponds General MIDI Percussion Keys to English names\n(e.g., 56 to 'Cowbell') -- but note that only numbers 35 to 81 (inclusive) are defined;\n%MIDI::percussion2notenum is the reverse.  Have a look at the source to see the contents\nof the hash.\n",
                "subsections": []
            },
            "BRIEF GLOSSARY": {
                "content": "This glossary defines just a few terms, just enough so you can (hopefully) make some sense of\nthe documentation for this suite of modules.  If you're going to do anything serious with\nthese modules, however, you should really invest in a good book about the MIDI standard --\nsee the References.\n\nchannel: a logical channel to which control changes and patch changes apply, and in which\nMIDI (note-related) events occur.\n\ncontrol: one of the various numeric parameters associated with a given channel.  Like S\nregisters in Hayes-set modems, MIDI controls consist of a few well-known registers, and\nbeyond that, it's patch-specific and/or sequencer-specific.\n\ndelta-time: the time (in ticks) that a sequencer should wait between playing the previous\nevent and playing the current event.\n\nmeta-event: any of a mixed bag of events whose common trait is merely that they are similarly\nencoded.  Most meta-events apply to all channels, unlike events, which mostly apply to just\none channel.\n\nnote: my oversimplistic term for items in a score structure.\n\nopus: the term I prefer for a piece of music, as represented in MIDI.  Most specs use the\nterm \"song\", but I think that this falsely implies that MIDI files represent vocal pieces.\n\npatch: an electronic model of the sound of a given notional instrument.\n\nrunning status: a form of modest compression where an event lacking an event command byte (a\n\"status\" byte) is to be interpreted as having the same event command as the preceding event\n-- which may, in turn, lack a status byte and may have to be interpreted as having the same\nevent command as its previous event, and so on back.\n\nscore: a structure of notes like an event structure, but where notes are represented as\nsingle items, and where timing of items is absolute from the beginning of the track, instead\nof being represented in delta-times.\n\nsong: what some MIDI specs call a song, I call an opus.\n\nsequencer: a device or program that interprets and acts on MIDI data.  This prototypically\nrefers to synthesizers or drum machines, but can also refer to more limited devices, such as\nmixers or even lighting control systems.\n\nstatus: a synonym for \"event\".\n\nsysex: a chunk of binary data encapsulated in the MIDI data stream, for whatever purpose.\n\ntext event: any of the several meta-events (one of which is actually called 'textevent')\nthat conveys text.  Most often used to just label tracks, note the instruments used for a\ntrack, or to provide metainformation about copyright, performer, and piece title and author.\n\ntick: the timing unit in a MIDI opus.\n\nvariable-length encoding: an encoding method identical to what Perl calls the 'w' (BER, Basic\nEncoding Rules) pack/unpack format for integers.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "<http://interglacial.com/~sburke/midi-perl/> -- the MIDI-Perl homepage on the Interwebs!\n\n<http://search.cpan.org/search?m=module&q=MIDI&n=100> -- All the MIDI things in CPAN!\n",
                "subsections": []
            },
            "REFERENCES": {
                "content": "Christian Braut.  The Musician's Guide to Midi.  ISBN 0782112854.  [This one is\nindispensible, but sadly out of print.  Look at abebooks.com for it maybe --SMB]\n\nLangston, Peter S.  1998. \"Little Music Languages\", p.587-656 in: Salus, Peter H,. editor in\nchief, /Handbook of Programming Languages/, vol.  3.  MacMillan Technical, 1998.  [The volume\nit's in is probably not worth the money, but see if you can at least glance at this article\nanyway.  It's not often you see 70 pages written on music languages. --SMB]\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 1998-2005 Sean M. Burke. All rights reserved.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms\nas Perl itself.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Sean M. Burke \"sburke@cpan.org\" (until 2010)\n\nDarrell Conklin \"conklin@cpan.org\" (from 2010)\n\n\n\nperl v5.22.2                                 2016-05-06                                    MIDI(3pm)",
                "subsections": []
            }
        }
    }
}