Comments (6)
It's certainly possible. A few different approaches are possible. You'd probably want to reuse the low-level methods in MIDI::IO::SeqWriter such as write_var_len
and write16
but override/replace functions like write_to
, write_header
, and write_track
.
To keep the public interface the same, you might want to add an optional argument to SeqWriter#initialize
for the MIDI file format that defaults to 1 but can accept 0 as well. In that case you would probably end up rewriting write_to
so that it calls something like write_format_0
or write_format_1
depending on the requested format.
The trick bit would be merging all of the tracks' events into one list of properly time-ordered events first so that you can write that out. Actually, it's not that tricky --- Track
already has the merge
function so you could create a new temporary track and merge all of the events from those tracks into that one so you can write it out.
I'm not sure what other differences there are in a MIDI file format 0, so I have probably missed something.
Does tha tall make sense?
from midilib.
@jimm Yes this does make sense. Thanks for taking the time to write that up.
from midilib.
As a side note, I just realized that reading a type 0 file is already supported! A type 0 file is just a type 1 file with a format byte of 0
and a track count of 1
.
from midilib.
@jimm thats great! so if the tracks are merged, and writing with a format byte of 0, that should solve it correct?
from midilib.
Yes, I think that's it.
from midilib.
@rhelsing implemented this feature in #17 which has been merged.
from midilib.
Related Issues (17)
- should length to delta round? HOT 1
- undefined method `note' for nil:NilClass HOT 1
- How would I modify an events time_from_start and save to new midi file? HOT 3
- Avoid monkey patching core classes HOT 6
- delta_time needs a descriptive comment HOT 1
- General Purpose CC codes are off HOT 2
- Any plan to release 3.x to rubygems? HOT 5
- Feature suggestion: determine track duration in SeqReader#eot for META_TRACK_END events HOT 8
- Notes get moved forward in time HOT 21
- Incorrect handling of pitchbend lsb and msb HOT 4
- Force into Format Type 0 possible? HOT 21
- @curr_ticks looks haywire HOT 1
- sequence.format is ignored when writing files HOT 1
- Docu example: how to play a midi file from within ruby? HOT 2
- Song tempo incorrectly calculated HOT 1
- Broken link in README HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from midilib.