Comments (4)
Hi Thomas,
Yes, you need to reduce time divisions of both files to common value. You can take either ticks per quarter note of first file or second one. Or you can set new value that will cause minimum rounding error on delta-times processing.
I have plans on MIDI file merge tool, so thanks for your question. I'll increase priority of this task.
Max
from drywetmidi.
@unitybru Thanks for the code snippet!
Please note that this code will work only for files with the same time division and tempo. I still have plans on MIDI files merger tool, but currently I'm busy with a big task about supporting macOS in Devices API of the library.
Merging MIDI files requires more work in general case than it can be supposed :)
from drywetmidi.
Hi Max,
I realized the functionality this evening in my application- and it works.
Maybe - as you mentioned - you can realize it in the library in the future…..
from drywetmidi.
+1 for the ability to stitch MIDI files more easily.
For those who find this thread, here is how I did it. I had a list of MIDI files that I needed to append one after the other. The trick is to shift things before adding the chunks.
var fileNameOut = "myoutput.mid";
var midiFileOut = new MidiFile()
{
TimeDivision = midiFile.TimeDivision // copied from master file
};
// Add all parts after shifting them
long addedSoFarMicroseconds = 0;
foreach (var midiPart in lsToWrite) // lsToWrite is a list of MidiFile objects
{
var currentDuration = midiPart.GetDuration<MetricTimeSpan>();
midiPart.ShiftEvents(new MetricTimeSpan(addedSoFarMicroseconds));
midiFileOut.Chunks.AddRange(midiPart.Chunks);
addedSoFarMicroseconds += currentDuration.TotalMicroseconds;
}
midiFileOut.Write(fileNameOut);
from drywetmidi.
Related Issues (20)
- How to combin 2 midifile? HOT 4
- Multipacket SysEx is not received correctly on macOS HOT 26
- Simply not working?
- About multi-platform support in unity HOT 3
- iOS support HOT 22
- Native64 dll not found on UWP HOT 2
- How do I know when i have added sufficient notes for a bar using the Pattern Builder Class HOT 14
- Getting instrument by channel HOT 2
- Add time offset for each notes during playback? HOT 2
- Generate drumming patterns HOT 10
- Read multiple MIDI files from stream HOT 17
- Issue in demo-scene in unity. HOT 7
- Anytime I retrieve a device from InputDevice.GetByIndex() it returns a new instance of that device. HOT 4
- Failing to Dispose() of an InputDevice results in never being able to use that device again. Until Unity restart. HOT 3
- Connection issues and how to debug them? HOT 5
- Can't sync midi file notes with audio file HOT 12
- HELP !!! Notes in panel to midi file?? HOT 9
- please help a noob HOT 6
- Remove all notes example from the README not working HOT 9
- Using wetdrymidi in C# project causes error CS0009
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 drywetmidi.