|
1 | 1 | # MIDI Parser for Garry's Mod Lua
|
2 | 2 |
|
3 |
| -**It is not perfect**! Use it for just experiment. |
| 3 | +**It is not perfect**! Use it for experimental purposes. |
4 | 4 | This is a GLua fork of [Lua_midiParser](https://github.com/FMS-Cat/Lua_midiParser).
|
5 | 5 |
|
6 |
| -## Usage |
| 6 | +## Installation |
| 7 | + |
| 8 | +### Download |
| 9 | + |
| 10 | +You must download the source code first, there are 4 ways to do it, use any way you like: |
| 11 | +* Download the latest release from [here](https://github.com/garrysmodlua/GLua-midi-parser/releases/latest). |
| 12 | +* Download ZIP of this repository [here](https://github.com/garrysmodlua/GLua-midi-parser/archive/master.zip). |
| 13 | +* Clone this repository using [git](https://git-scm.com/downloads): `git clone https://github.com/garrysmodlua/GLua-midi-parser.git midi-parser`. |
| 14 | +* Save the <code><a href="lua/includes/modules/midi-parser.lua">midi-parser.lua</a></code> file (Press <kbd>Ctrl</kbd>+<kbd>S</kbd>; Or, <kbd>Cmd</kbd>+<kbd>S</kbd> on Mac). |
| 15 | + |
| 16 | +### GMod Setup |
| 17 | + |
| 18 | +1. Navigate to your `./Steam/steamapps/common/GarrysMod/garrysmod` folder. |
| 19 | +2. Depending on which download method you have used, make sure you have the following directory structure (create any neccessary folder yourself if it doesn't exist): |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +3. You are done. Have fun! |
| 24 | + |
| 25 | +## Usage / Code Example |
| 26 | + |
| 27 | +1. Must require our `midi-parser` module: |
| 28 | + ```lua |
| 29 | + require( "midi-parser" ) |
| 30 | + ``` |
| 31 | + |
| 32 | +2. Call either of these 2 functions: |
| 33 | + * `[table] = midi.Parse(string midiData)` - To parse MIDI data as string. |
| 34 | + * `[table] = midi.ParseFile(string fileName[, string path="DATA"])` - To parse a given `.mid` file. |
7 | 35 |
|
8 | 36 | ```lua
|
9 |
| --- Will attempt to parse "garrysmod/data/abcdef.mid" file |
10 |
| -myMidi = midiParser( "abcdef.mid" ) -- if path is omitted, it defaults to "DATA" |
| 37 | +-- Notes/Information: |
| 38 | +-- ParseFile function: A fileName argument, if you are dealing with multiple directories, remember to use forward-slash (/) character as directory separator; do NOT use backslash (\) character. |
| 39 | +-- ParseFile function: A path argument is optional, it defaults to "DATA" when omitted; by default it will search relative to "GarrysMod/garrysmod/data" folder. |
| 40 | +-- Both of the Parse functions will throw an error if something goes wrong (e.g. if a given file does not exist, or could not be read, etc). |
| 41 | +-- Moreover, if MIDI file/data is succesfully parsed, a function will return a table as a result. |
11 | 42 |
|
12 |
| --- Will attempt to parse "garrysmod/lua/test.mid" file |
13 |
| -testingMidi = midiParser( "test.mid", "LUA" ) |
| 43 | +local firstMidi = midi.ParseFile( "midis/first.mid" ) -- Will attempt to parse "GarrysMod/garrysmod/data/midis/first.mid" file |
14 | 44 |
|
15 |
| --- Prints the contents of testingMidi table: |
16 |
| -PrintTable( testingMidi ) |
| 45 | +local testingMidi = midi.ParseFile( "test.mid", "LUA" ) -- Will attempt to parse "GarrysMod/garrysmod/lua/test.mid" file |
| 46 | + |
| 47 | +PrintTable( testingMidi ) -- Prints the contents of testingMidi table |
17 | 48 | ```
|
18 | 49 |
|
19 |
| -## Return sample |
| 50 | +### Return Sample |
20 | 51 |
|
21 | 52 | ```lua
|
22 | 53 | {
|
@@ -87,6 +118,37 @@ PrintTable( testingMidi )
|
87 | 118 | }
|
88 | 119 | ```
|
89 | 120 |
|
| 121 | +## Documentation |
| 122 | + |
| 123 | +Sorry, there is no wiki nor docs... |
| 124 | + |
| 125 | +## Contribution |
| 126 | + |
| 127 | +Visit the [Contributor Guidelines](https://github.com/garrysmodlua/GLua-midi-parser/blob/master/.github/CONTRIBUTING.md) for more details. All contributors are expected to follow our [Code of Conduct](https://github.com/garrysmodlua/GLua-midi-parser/master/.github/CODE_OF_CONDUCT.md). |
| 128 | + |
| 129 | +## Support |
| 130 | + |
| 131 | +If you think you have found a bug or have a feature/enhancement request for GLua MIDI parser, use our [issue tracker](https://github.com/garrysmodlua/GLua-midi-parser/issues/new). |
| 132 | + |
| 133 | +Before opening a new issue, please be kind and search to see if your problem has already been reported. Try to be as detailed as possible in your issue reports. |
| 134 | +When creating an issue, clearly explain |
| 135 | + |
| 136 | +* What you were trying to do? |
| 137 | +* What you expected to happen? |
| 138 | +* What actually happened? |
| 139 | +* Steps to reproduce the problem. |
| 140 | + |
| 141 | +Also include any other information you think is relevant to reproduce the problem. |
| 142 | + |
90 | 143 | ## License
|
91 | 144 |
|
92 |
| -This repository is licensed with the [MIT](LICENSE) license. |
| 145 | +[GLua MIDI parser](https://github.com/garrysmodlua/GLua-midi-parser) repository/code is freely distributed under the [MIT](LICENSE) license. See [LICENSE](LICENSE) for more details. |
| 146 | + |
| 147 | +## Credits |
| 148 | + |
| 149 | +[FMS-Cat](https://github.com/FMS-Cat) for the original Lua code. |
| 150 | +[CaptainPRICE](https://github.com/CaptainPRICE) for making it compatible with [Garry's Mod](http://gmod.facepunch.com/) (GLua). |
| 151 | + |
| 152 | +## Related Projects |
| 153 | + |
| 154 | +[GMod-Expression2-midi-parser](https://github.com/garrysmodlua/GMod-Expression2-midi-parser): MIDI Parser (Wire Expression 2 extension). |
0 commit comments