bitmidi.com | 🎹 Listen to free MIDI songs | Audio Utils library
kandi X-RAY | bitmidi.com Summary
kandi X-RAY | bitmidi.com Summary
Listen to free MIDI songs, download the best MIDI files, and share the best MIDIs on the web
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- add a midi midi to midi
bitmidi.com Key Features
bitmidi.com Examples and Code Snippets
Community Discussions
Trending Discussions on bitmidi.com
QUESTION
I have written a program that takes in a MIDI file, then using Mido, it cleans the data by removing particular types of meta data, repeat messages, etc. It also calculated the cumulative time (as the time in each midi message is in delta time). This is then used to create a new mido file (from scratch) where I append all of these messages into one track (so essentially the tracks are merged)and sort them by cumulative time. The delta time is then adjusted accordingly (keeping in mind that each new midi track starts from cumulative time 0). I realise this may seem pointless (as I am trying to construct the same song just cleaner), however the purpose is to have nicer data to then do other stuff with.
I have split my code into two parts. The first does all the filtering and constructs a big list of lists, where the first item in each sub-list is the message itself and second item in each sub-list is the cumulative time (and this is sorted by cumulative time as stated above). The second part of the code adjusts the delta time of each item in this list and then appends all the messages from the list in order (with the corrected delta times) onto a track created from scratch. It then plays this track using pygame.
The major problem I seem to be encountering is the timing/tempo. The reconstructed tracks either seem to be playing too fast or too slow. In the case of some files (for example the Bohemian Rhapsody file) the instrumental parts also seem to be detached and muddled.
This is the deconstructing and list building code:
...ANSWER
Answered 2020-Jan-03 at 01:30You need to save the ticks_per_beat
. Simply get the ticks_per_beat
of the original file with ticksperbeat = mid.ticks_per_beat
, then set the new file to have mid.ticks_per_beat = ticksperbeat
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install bitmidi.com
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