Code Monkey home page Code Monkey logo

midi-parser's Introduction

midi-parser

This repository contains a simple midi parser which is free software. It should be able to parse most .midi files out there. Since the parser returns a stream of events (see the midi dump example), it works without any runtime allocation.

The parser has no dependencies, and supports most platforms due to its simple code and no use of file I/O.

Use in your project

You can build midi-parser via cmake . && make.

Alternatively, to build midi-parser as part of your program, add src/midi-parser.c to your project's object files, and the include/ folder to your include path. (For Visual Studio, you'll find the required fields in your project settings.)

Example using gcc, assuming this repository is at path-to-midi-parser:

$ gcc -o myprogram my_own_code.c path-to-midi-parser/src/midi-parser.c -Ipath-to-midi-parser/include

Demo

Running cmake . && make will also build the example/mini-dump.c demo as midi-dump executable.

You can then use ./midi-dump mymidifile.mid on any midi file to test.

midi-parser's People

Contributors

1480c1 avatar abique avatar cox2 avatar ell1e avatar pbst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

midi-parser's Issues

Is this parser known to work? / Possibly broken file

I'm not fully understanding how to use it maybe. However, I tried basing it on the dump example, and my guesses were as follows: for every track, I'm supposed to get an enum midi_parser_status of MIDI_PARSER_TRACK once, followed by multiple times of MIDI_PARSER_TRACK/MIDI_PARSER_TRACK_META/MIDI_PARSER_TRACK_SYSEX until I reach the end of that particular track. Followed by all that again for every new track. So far, so good.

However, with the following midi file the header reports 14 tracks, but I only get 3 times MIDI_PARSER_TRACK before the end of file, and there are basically almost no note on/offs even though this is clearly a very busy song, and most events are just of status type "unknown" (as per midi_status_name). So something seems to be going wrong here. Or should I be doing something to extract note info from these unknown events? But how?

Here is the midi file:
test.mid.zip

Should be updated for Apple Silicon

~/Desktop/midi-parser-master/src$ gcc midi-parser.c -o midi-parser
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

// same with make

Does not build in MSYS2/MinGW, GCC 13.1: sys/mman.h not found

Hi. I am not an experienced C developer, just a halfwit able to run the media-autobuild suite to build ffmpeg and related linked projects, and interpreting error messages when anything fails.

Here I tried to use an interactive MinGW shell to build your midi-parser. I learned that the file mman.h does not exist by default in an MSYS2 installation, so I installed the package msys2-runtime-devel. Now I have the file /usr/include/sys/mman.h. Yet it seems not to be included by default in the includes paths, which confuses me.

BTW, running cmake . generates a ninja build script in the MSYS2 environment of MABS, but that should be quite equal to a makefile.

$ ninja
[1/2] Building C object CMakeFiles/midi-dump.dir/example/midi-dump.c.obj
FAILED: CMakeFiles/midi-dump.dir/example/midi-dump.c.obj
G:\MABS\msys64\mingw64\bin\ccache.exe  gcc  -IG:/MABS/build/midi-parser-master/include -fstack-protector-strong -mtune=generic -O2 -pipe -mthreads -std=gnu99 -MD -MT CMakeFiles/midi-dump.dir/example/midi-dump.c.obj -MF CMakeFiles\midi-dump.
dir\example\midi-dump.c.obj.d -o CMakeFiles/midi-dump.dir/example/midi-dump.c.obj -c G:/MABS/build/midi-parser-master/example/midi-dump.c
G:/MABS/build/midi-parser-master/example/midi-dump.c:3:10: fatal error: sys/mman.h: No such file or directory
    3 | #include <sys/mman.h>
      |          ^~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.

I wonder if I should help cmake finding include paths by adding parameters, but I have no clue which would be appropriate.

midi-parser-logs.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.