Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change MIDI Resolution

429 views
Skip to first unread message

Jon Berry

unread,
Dec 11, 2005, 3:05:24 PM12/11/05
to
I'm interested in programatically changing the resolution
of a MIDI file.

For example, say I've got a MIDI file with resolution of 384
and I want to change it to 96.

What procedure is needed to do this?

Would the timing of each event need to be changed?

I assume it's not just a matter of changing one flag. :)

Thanks,

Jon

Leslie Sanford

unread,
Dec 11, 2005, 4:19:48 PM12/11/05
to

"Jon Berry" wrote:
> I'm interested in programatically changing the resolution
> of a MIDI file.
>
> For example, say I've got a MIDI file with resolution of 384
> and I want to change it to 96.
>
> What procedure is needed to do this?
>
> Would the timing of each event need to be changed?

Yes.

If the new resolution is less than the present resolution, divide the
current resolution by the new resolution. Divide the timestamp of each
event by this result.

If the new resolution is more than the present resolution, divide the
new resolution by the current resolution. Multiply the timestamp of each
event by this result.

You will also need to change the "division" value in the MIDI file's
header to reflect the new resolution.


Michael R. Kesti

unread,
Dec 11, 2005, 4:28:46 PM12/11/05
to
Jon Berry wrote:

Yes, you also need to recompute the chunks' delta times. When reducing
the resolution, such as in your example, there will be some "rounding
error" and you want to be careful with the results of your math.

For example, suppose that there is a note on event in the 384 PPQN file
that occurs at delta time 383. A simple algorithm to compute the delta
time for the 96 PPQN file is:

96
383 X --- = 95.75
384

This must be rounded to an integer value. If your algorithm is to simply
discard the fractional part then the converted delta time is 95. The
original event was, however, closer to the quater note boundary than this
and it might make better musical sense to place it at delta time 96. A
better algorithm, then, might be to decide whether to round up or dowm
depending on whether the fractional part is greater than or less than 0.5,
respectively. Other algorithms are also certainly possible.

>Thanks,

Yep.

--
========================================================================
Michael Kesti | "And like, one and one don't make
| two, one and one make one."
mrkesti at comcast dot net | - The Who, Bargain

Gary Rimar

unread,
Dec 11, 2005, 9:54:42 PM12/11/05
to
E-mail me the file if the beats are obvious, and I can change the resolution
for you (or at least I think I can). I bought some software that lets me
redraw the measure lines in MIDI.


"Michael R. Kesti" <mrk...@nospam.net> wrote in message
news:439C9A0E...@nospam.net...

Barry Graham

unread,
Dec 12, 2005, 11:53:47 AM12/12/05
to

"Jon Berry" <j...@berry.jon> wrote in message
news:8E%mf.2272$QQ1...@newsread3.news.pas.earthlink.net...

> I'm interested in programatically changing the resolution
> of a MIDI file.
>
> For example, say I've got a MIDI file with resolution of 384
> and I want to change it to 96.

Are you interested in this as a programming exercise or do you just want to
simply change the resolution of a MIDI file?

Early versions of Cakewalk used the Settings>Timebase option to allow the
change of the number of ticks per quarter note in the file.
I assume that something similar exists in recent sequencers.

-------------------------------------
Barry Graham
Top Brass Events Band
Melbourne, Australia
www.topbrass.com.au
top....@tpg.com.au


Guenter Nagler

unread,
Dec 13, 2005, 2:49:05 AM12/13/05
to
Barry Graham wrote:
> "Jon Berry" <j...@berry.jon> wrote in message
>
> Early versions of Cakewalk used the Settings>Timebase option to allow the
> change of the number of ticks per quarter note in the file.
> I assume that something similar exists in recent sequencers.

GNMIDI (Windows) http://www.gnmidi.com
midires (DOS) http://www.gnmidi.com/gnfreeen.htm
do this too

they recalculate all delta times, so that the result plays same speed as
before.

Guenter

lav...@altavista.com

unread,
Dec 13, 2005, 9:42:28 AM12/13/05
to


Question: Is there any reason for the resolution to be a multiple of
96? If so, what is it?

Michael R. Kesti

unread,
Dec 13, 2005, 11:13:38 AM12/13/05
to
lav...@altavista.com wrote:

>Question: Is there any reason for the resolution to be a multiple of
>96? If so, what is it?

WARNING! The following expresses what I have long thought but about
which I have no actual knowledge.

Very early MIDI sequencers used 48 PPQN. 48, being 16 times 3, is
musically significant, as it allows 64th note triplets to fall on clock
boundaries. As computers became more powerful and users more sophisticated,
higher resolutions were chosen as multiples of 48 to retain this musical
significance.

Does anybody know whether this is correct?

Afoklala

unread,
Dec 14, 2005, 3:34:14 AM12/14/05
to
Op Tue, 13 Dec 2005 08:13:38 -0800 schreef Michael R. Kesti:

> lav...@altavista.com wrote:
>
>>Question: Is there any reason for the resolution to be a multiple of
>>96? If so, what is it?
>
> WARNING! The following expresses what I have long thought but about
> which I have no actual knowledge.
>
> Very early MIDI sequencers used 48 PPQN. 48, being 16 times 3, is
> musically significant, as it allows 64th note triplets to fall on clock
> boundaries. As computers became more powerful and users more sophisticated,
> higher resolutions were chosen as multiples of 48 to retain this musical
> significance.
>
> Does anybody know whether this is correct?

More or less. All resolutions have in common that both dual and triple
subdivisions are possible. But not all of the common ones are multiples of
48. E.g. 120 is often used too.
--
Jan Willem from Odijk, Netherlands

Listen to my music on http://home.hccnet.nl/jw.van.dormolen/gbcomposer.html

e-mail in From-field is wrong, real e-mail is:
jw point van point dormolen on hccnet point nl
(change point into dot, on into at)

And then there's this:
Age is a very high price to pay for maturity.

Guenter Nagler

unread,
Dec 15, 2005, 3:58:27 AM12/15/05
to
Michael R. Kesti wrote:

>>Question: Is there any reason for the resolution to be a multiple of
>>96? If so, what is it?

resolution 96 means that it can be used for smallest note length or
pause 1/384 = 1/(3*128).

Resolution is usually a value 3 * 2 * 2 * .... * 2 * 2 since
music pieces contain trioles (1/3) and 1/1,1/2,1/4,1/8, 1/16 etc. notes.

It is not required that it is a multiple of 96 but midi standard
recommends it. I also saw files using 120, 240, 1920 ...

A song that only consists of exact 1/4 notes and pauses could even live
with a resolution 1 if the players and editors accept it.

But some keyboards or software can only handle certain PPQ values. Some
fail when the value is too high (e.g. 1920), some when the value is not
multiple of 96 or 96 self.

Usually scoresheet cannot display so high precision (e.g. 128th note) as
midi can store and need quantize to printable sizes.

Guenter

lav...@altavista.com

unread,
Dec 20, 2005, 9:11:01 AM12/20/05
to


1920 covers 3, 5, and 128. Are triplets and quintuplets so common at
the 128 level to justify so high a resolution? Practically speaking,
how high can a resolution realistically go?

Michael R. Kesti

unread,
Dec 20, 2005, 1:11:58 PM12/20/05
to
lav...@altavista.com wrote:

>1920 covers 3, 5, and 128. Are triplets and quintuplets so common at
>the 128 level to justify so high a resolution?

Probably not, but it's hard for consumers to avoid thinking that getting
more is better and for vendors to resist giving more if it gives them
a competitive edge.

> Practically speaking,
>how high can a resolution realistically go?

There is no inherent limit but, as is so often the case, greater resolution
comes at the expense of something else. In this case, the something else
is computing power. Greater resolution means that a sequencer needs to
run its timekeeping functions more frequently and therefore consume more
of the processing resources. With today's gigaHertz processors, however,
these resources are abundant.

lav...@altavista.com

unread,
Dec 21, 2005, 10:44:39 AM12/21/05
to

Is there a formula or a rule of thumb relating processor speed and
other resource limitations to the highest resolution available? If so,
what is it?

Michael R. Kesti

unread,
Dec 21, 2005, 12:04:18 PM12/21/05
to
lav...@altavista.com wrote:

>Is there a formula or a rule of thumb relating processor speed and
>other resource limitations to the highest resolution available? If so,
>what is it?

There's no such formula that I am aware of, and coming up with one will
not be an easy matter as there are many variables involved and many of
them are not easily quantified. For example, what operating system is
in use and what, besides running a sequencer is it doing, what other
apps are executing, etc, etc, etc.

Many aspects of computing are like this. As engineers we would like to
be able to determine where the line between guaranteed-to-work and
guaranteed-to-fail lies but, because we cannot know the exact conditions
that even a single system experiences, the best we can do is throw
enough resourses at the problem in the hope that it is enough to suit
most systems.

Leslie Sanford

unread,
Dec 21, 2005, 1:52:11 PM12/21/05
to

<lav...@altavista.com> wrote:
> Michael R. Kesti wrote:
>> lav...@altavista.com wrote:
>>
>>
>> >Practically speaking, how high can a resolution realistically go?
>>
>> There is no inherent limit but, as is so often the case, greater
>> resolution comes at the expense of something else. In this case, the
>> something else is computing power. Greater resolution means that a
>> sequencer needs to run its timekeeping functions more frequently and
>> therefore consume more of the processing resources. With today's
>> gigaHertz processors, however, these resources are abundant.
>
> Is there a formula or a rule of thumb relating processor speed and
> other resource limitations to the highest resolution available? If so,
> what is it?

It's not necessarily processor speed. It has more to do with the
resolution of timing events available to a MIDI programmer. For example,
in Windows the multimedia timer has a max resolution of one timing event
every millisecond.

So that works out to 20.83... timer events for each MIDI tick given a
resolution of 24 ppqn and a tempo of 120 bpm. At a resolution of 360
ppqn and a tempo of 120 bpm, you have 1.38... timer events per MIDI
tick.

As you bump up the ppqn resolution, you reach a point in which the
duration of a MIDI tick is less than the duration of the timer event. So
you have to generate more than just one MIDI tick occasionally for the
timer events to catch things up.

By the way, you don't want to use floating point math for this. You want
to use integer math in such a way as to average out the fractional parts
over time. See the book Maximum MIDI for more information.

So theoretically, you can go as high as you want to with the resolution,
but you have to write your algorithm in such a way so that it works when
you reach a point in which the MIDI ticks have less duration that the
timer events.


0 new messages