Comments (8)
Hi,
First of all, do you need to change speed of playback using Playback
class of the library or you need to create new file that is faster or slower than original one?
from drywetmidi.
Hi,
Create a new file with faster/slower tempo. Well, I don't need to create a file - just require an object in memory.
from drywetmidi.
Well, you can use this code:
midiFile.GetTrackChunks().First().Events.Insert(0, new SetTempoEvent(SetTempoEvent.DefaultTempo));
foreach (var trackChunk in midiFile.GetTrackChunks())
{
foreach (var setTempoEvent in trackChunk.Events.OfType<SetTempoEvent>())
{
var microsecondsPerQuarterNote = setTempoEvent.MicrosecondsPerQuarterNote;
setTempoEvent.MicrosecondsPerQuarterNote = (long)Math.Round(microsecondsPerQuarterNote * 0.8);
}
}
This code changes all Set Tempo events so playback will be 20% faster (0.8 means quarter note will be 20% shorter in terms of microseconds). To decrease speed use multiplication with values greater than 1.0.
Please let me know if it works.
from drywetmidi.
This works, thank you.
from drywetmidi.
Hi,
This method doesn't seem to work on the midi file below. It doesn't match the tempo of the audio file produced by Ableton.
I increased tempo from 120 to 150 => setTempoEvent.MicrosecondsPerQuarterNote = (long)Math.Round(microsecondsPerQuarterNote * 0.75f);
The only difference I can see from the other files I tried is that Ableton recognizes this midi file as having a 6/8 time signature.
ravel_miroirs_3.zip
from drywetmidi.
Hi,
How did you change tempo with Ableton? Just set 150 instead of 120? And then export to wav? Can you attach audio file produced by Ableton?
from drywetmidi.
Also why you use 0.75
? 120 / 150 = 0.8
. 0.8
should give you the correct result.
from drywetmidi.
Ah. You are right. I was dividing in the wrong order. thanks!
from drywetmidi.
Related Issues (20)
- Remove all notes example from the README not working HOT 9
- Using wetdrymidi in C# project causes error CS0009
- InputDevice event listening crash HOT 2
- Crash when running in Unity on M2 MacBook HOT 3
- MidiDeviceException Internal error HOT 9
- Android Support
- Unity cannot exit after use HOT 10
- MidiClock sync problem HOT 6
- MIDI Tempo changes count returns 1 but the song has 6 tempo changes. HOT 1
- add il2cpp mode HOT 5
- CustomChunk no mididata throw error HOT 4
- CSharp Code Error HOT 2
- MIDI File returns error: InvalidMetaEventParameterValueException HOT 1
- Unable to send Note-On event to device HOT 8
- Cannot get track name to change HOT 10
- How to use DryWetMidi in Visual Basic (VS 2022) ? HOT 20
- Plans for MIDI 2.0 Support? HOT 2
- Skipping notes HOT 5
- Playback Loop=True skips empty steps in the end of a Pattern HOT 2
- Syncing multiple Playbacks HOT 7
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.