midi-file | Parse and write MIDI files | Audio Utils library
kandi X-RAY | midi-file Summary
kandi X-RAY | midi-file Summary
Parse and write MIDI files
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Writes a given event .
- Parse a MIDI track
- read event data
- Parse MIDI data .
- Parse a MIDI header
- Writes MIDI data .
- Writes a header chunk
- writes the specified MIDI chunk
- Initialize a new Parser with the given data .
- Initialize a new Writer .
midi-file Key Features
midi-file Examples and Code Snippets
Community Discussions
Trending Discussions on midi-file
QUESTION
Sorry for asking a basic question.
After I've understand the structure of wav file, I move on to understanding the structure of midi file.
While reading this https://github.com/colxi/midi-parser-js/wiki/MIDI-File-Format-Specifications documentation about midi files.
The part of where it showcased a table of "Value" and "Variable-length" is what I couldn't understand.
How did C8
became 8148
in variable-length?
How did the hex 100000
became C08000
in variable-length?
ANSWER
Answered 2020-May-07 at 20:00In the variable-length encoding, 7 bits per byte are used for the actual data. So to encode a value that has more than 7 bits, you have to split it into as many 7-bit parts as necessary, and then add the 1 MSB to all except the last one:
QUESTION
I'm writing a deep learning automatic composer using RNN. Obviously i need to train it and I decided to use MIDI file format as input.
So far i wrote my input code and my model, but i had some problems reading the input MIDI.
This is my "reading" part of code:
...ANSWER
Answered 2020-Apr-27 at 09:45The ticks per quarter note or "resolution" is a variable per file in MIDI, and given in the header of the file. Looks like the library you use is making it available to you as resolution=96
.
The tempo (BPM) itself is embedded in the MIDI stream (along with the notes) as it can change at any point through the track. By default it is assumed to be 120 BPM.
You can find this information and lot more in the MIDI file spec, e.g. here: http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html
QUESTION
Using this thread I have figured out how to use getData(), but instead of getting anything with 0x51, I am getting random values such as [B@37d78d93, [B@29d74462 and [B@1c5ca652
Outputting the meta message itself also results in similar values such as javax.sound.midi.MetaMessage@364d4fca, javax.sound.midi.MetaMessage@5581f86d and javax.sound.midi.MetaMessage@3f011b2b
For example, using
System.out.print ("the meta message is " + mm + ", ");
System.out.print ("the type of meta message is " + mm.getType());
System.out.println(" and the data is " + mm.getData());
outputs
the meta message is javax.sound.midi.MetaMessage@3f011b2b, the type of meta message is 81 and the data is [B@1c5ca652
How can I use the value at the end of the outputted mm
value or the values taken from mm.getData()
to get the tempo of a MIDI file?
ANSWER
Answered 2020-Apr-19 at 11:19Once you get the tempo MetaMessage, you can use this code to get the tempo in beats per minute.
QUESTION
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:05first file:
QUESTION
I want to play an Audio file (A wav file for example) and at specific locations of the track I want to fire events or triggers that will control an external device.
My idea for now is to generate a MIDI track that plays in sync with the Audio Track and when the MIDI track notes are played, some trigger events are generated that we can handle to do whatever we want.
The thing where I am stuck right now is how to play the .mid file and generate events when midi notes are played. I also want to play the wav and the mid file in sync, but that is not what I am solving at this point.
I looked into AudioKit, but the examples seem out of date and the documentation isn't helping a lot.
Is MIDI a right approach to do this? is there an easier way in iOS where I don't have to use AudioKit and just use something from AVFoundation.
I want to understand what tool is best to detect when a midi note from the .mid file is played and handle the event.
My research has pointed me to use AKAppleSequencer. What could help is a simple example that loads a midi file and then basically prints something when a note is played.
I came across these posts,
How to connect AKSequencer to a AKCallbackInstrument?
Play MIDI file together with wav AudioKit
but the AKSequencer is now replaced by AKAppleSequencer.
...ANSWER
Answered 2020-Jan-30 at 17:35So I figured it out. The answer was basically in the posts above just updated the code so it uses AKAppleSequencer.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install midi-file
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page