midiutil | It 's a pure Python MIDI library

 by   TheLongRunSmoke Python Version: Current License: Non-SPDX

kandi X-RAY | midiutil Summary

kandi X-RAY | midiutil Summary

midiutil is a Python library. midiutil has no bugs, it has no vulnerabilities, it has build file available and it has low support. However midiutil has a Non-SPDX License. You can download it from GitHub.

MIDIUtil is a pure Python library that allows one to write multi-track Musical Instrument Digital Interface (MIDI) files from within Python programs. It is object-oriented and allows one to create and write these files with a minimum of fuss. MIDIUtil isn't a full implementation of the MIDI specification. The actual specification is a large, sprawling document which has organically grown over the course of decades. I have selectively implemented some of the more useful and common aspects of the specification. The choices have been somewhat idiosyncratic; I largely implemented what I needed. When I decided that it could be of use to other people I fleshed it out a bit, but there are still things missing. Regardless, the code is fairly easy to understand and well structured. Additions can be made to the library by anyone with a good working knowledge of the MIDI file format and a good, working knowledge of Python. Documentation for extending the library is provided. This software was originally developed with Python 2.5.2 and it makes use of some features that were introduced in 2.5. I have used it extensively in Python 2.6.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              midiutil has a low active ecosystem.
              It has 0 star(s) with 0 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 3 have been closed. On average issues are closed in 1 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of midiutil is current.

            kandi-Quality Quality

              midiutil has 0 bugs and 0 code smells.

            kandi-Security Security

              midiutil has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              midiutil code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              midiutil has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              midiutil releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              It has 1287 lines of code, 107 functions and 6 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed midiutil and discovered the below as its top functions. This is intended to give you an instant insight into midiutil implemented functionality, and help decide if they suit your requirements.
            • Write MIDI events to stream .
            • Compute equality of two objects .
            • Add Universal System System .
            • Calculate the length of the variable length
            • Calculate the length of a variable .
            • Convert a float to a decimal frequency .
            • Convert a floating point number to a decimal value .
            • Read a variable length from a buffer .
            • Read variable length from buffer .
            • Compare two time series .
            Get all kandi verified functions for this library.

            midiutil Key Features

            No Key Features are available at this moment for midiutil.

            midiutil Examples and Code Snippets

            No Code Snippets are available at this moment for midiutil.

            Community Discussions

            QUESTION

            midiutil with python doesnt write drumset sounds in channel 10?
            Asked 2021-May-16 at 18:07

            Im trying to write a complete music using midiutil library with python. So far, i have been able to add any instrument i've wanted via

            MIDIFile.addProgramChange(track, channel, time, program)

            and taking the program number from the table at https://www.midi.org/specifications-old/item/gm-level-1-sound-set

            However, i cant add any drumset sounds the way i want. I know channel 10 is reserved for percussion, but whenever i write anything via

            MyMIDI.addNote(track, 10, pitch, time + i, duration, volume)

            the sound played by musescore is played in the piano voice or in the voice defined by the ProgramChange method. I know there is drumset sounds somewhere in my computer because i have been able to manually add drumset sounds in musescore. Am i doing something wrong?

            ...

            ANSWER

            Answered 2021-May-16 at 18:07

            Humans begin counting at one, so you have channels 1 … 16.
            Computers begin couting at zero, so they have channels 0 … 15.

            The addNote() documentation says that the channel parameter is an integer from 0 to 15, so you must use 9 for the percussion channel.

            Source https://stackoverflow.com/questions/67559607

            QUESTION

            Python Write MIDI file
            Asked 2020-Nov-14 at 23:21

            I want to write a MIDI file with the inputs I receive from the digital piano I have connected. I am using pygame.midi to open an input port and midiutil to write the MIDI file. What I can't wrap my head around is the timing. For example, in addNote(track, channel, pitch, time, duration, volume), how do I know what time and duration of a note is? When reading a note, I get pitch and volume just fine, but the others I have no idea... I tried using the timestamp but to no avail, it places the note really far away in the MIDI file.

            So, how do I compute the 'time' and 'duration' of a note?

            ...

            ANSWER

            Answered 2020-Nov-14 at 23:21

            time dictates the position in musical time the note should be played. Exactly what the parameter should be depends in part how the Midi file object was constructed (more on that soon)

            In practice, MIDI asks for two messages per note: a NOTE On message and a NOTE Off message. The duration will indicate when the Note Off message should be sent, relative to the start of the note. Again, how the parameter should be formed depends on how the file object is constructed.

            From the MIDIUtil docs:

            • time – the time at which the note sounds. The value can be either quarter notes [Float], or ticks [Integer]. Ticks may be specified by passing eventtime_is_ticks=True to the MIDIFile constructor. The default is quarter notes.
            • duration – the duration of the note. Like the time argument, the value can be either quarter notes [Float], or ticks [Integer]

            A complete example that plays the C major scale

            Source https://stackoverflow.com/questions/64838592

            QUESTION

            Accidentally edited a windows header, now nothing compiles
            Asked 2020-Oct-11 at 20:26

            I was writing a program that used the windows midi interface, and at some point I was following the definition of a symbol and ended up in one of the windows headers. I must have accidentally edited it before closing it because now when I try to compile my code, I get literally hundreds of errors like:

            ...

            ANSWER

            Answered 2020-Oct-11 at 18:51

            Q: Is there a way to revert the standard windows headers?

            A: Yes. Restore from backup, or reinstall your SDK.

            It sounds like you probably don't take backups ;)

            If you got the SDK from Visual Studio, one option might be to simply reinstall MSVS.

            The files you mention, C:\Program Files (x86)\Windows Kits\10\Include, are part of the Windows 10 SDK. It's installed when you install MSVS. You can also download it separately from here:

            https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/

            Source https://stackoverflow.com/questions/64307772

            QUESTION

            Write Note at specific time in Midi via Python
            Asked 2020-Mar-30 at 22:25

            I want to convert a sequence of notes (defined by time, duration, pitch) to a audio-file. For doing so, I thought creating a midi first and then compile it to wav is the way to go.

            I'm quite new to audio processing and MIDI-Files, so even though I read several tutorials, it can be, that I didn't get the point.

            Edit: I found the problem, see solution below.

            What's the problem

            Writing notes at a specific time with a specific duration via python's MIDIUtil doesn't work as expected. In fact, the time in seconds, where a note is placed heavily depends on the track's bpm, even though I think I took the bpm into account, when converting the note time to MIDI's time measure in quarter notes.

            What I've tried

            I'm creating a MIDI track with a given bpm. Then I'm converting a note's event time via t_{quarter} = t_{seconds} * bpm/60

            Example

            I'm writing with the following code two notes, the last at t=5 seconds with a duration of 1s; i.e. I'm expecting a midi-file with lasts 6seconds. But at a bpm=600, the file is 14s long. At a bpm=100 it's almost the expected 6s.

            Here's my code

            ...

            ANSWER

            Answered 2020-Mar-30 at 16:05

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install midiutil

            To use the library one can either install it on one's system or copy the midiutil directory of the source distribution to your project's directory (or to any directory pointed to  by the PYTHONPATH environment variable). For the Windows platforms an executable installer is provided. Alternately the source distribution can be downloaded, un-zipped (or un-tarred), and installed in the standard way:. On non-Windows platforms (Linux, MacOS, etc.) the software should be installed in this way. MIDIUtil is pure Python and should work on any platform to which Python has been ported. If you do not wish to install in on your system, just copy the src/midiutil directory to your project's directory or elsewhere on your PYTHONPATH. If you're using this software in your own projects you may want to consider distributing the library bundled with yours; the library is small and self-contained, and such bundling makes things more convenient for your users. The best way of doing this is probably to copy the midiutil directory directly to your package directory and then refer to it with a fully qualified name. This will prevent it from conflicting with any version of the software that may be installed on the target system.
            Using the software is easy:. Detailed documentation is provided; what follows is a simple example to get you going quickly. In this example we'll create a one track MIDI File, assign a name and tempo to the track, add a one beat middle-C to the track, and write it to disk. There are several additional event types that can be added and there are various options available for creating the MIDIFile object, but the above is sufficient to begin using the library and creating note sequences. The above code is found in machine-readable form in the examples directory. A detailed class reference and documentation describing how to extend the library is provided in the documentation directory.
            The package must be imported into your namespace
            A MIDIFile object is created
            Events (notes, tempo-changes, etc.) are added to the object
            The MIDI file is written to disk.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/TheLongRunSmoke/midiutil.git

          • CLI

            gh repo clone TheLongRunSmoke/midiutil

          • sshUrl

            git@github.com:TheLongRunSmoke/midiutil.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link