Re: [PD] MIDIFILE read Tempo

2013-09-06 Thread Dan Wilcox
mrpeach = my favorite externals

On Sep 6, 2013, at 2:54 AM, pd-list-requ...@iem.at wrote:

> From: Martin Peach 
> Subject: Re: [PD] MIDIFILE read Tempo
> Date: September 5, 2013 12:36:41 PM EDT
> To: Maciej Sledziecki 
> Cc: pd-list@iem.at
> 
> 
> On 2013-09-05 09:29, Martin Peach wrote:
>> On 2013-09-05 07:04, Maciej Sledziecki wrote:
>>> Hello,
>>> 
>>> ist there any way to read the tempo information contained in a midi file?
>>> Or do I really have to set up a metro for mrpeach/midifile everytime ?
>> 
>> 
>> It's been a while since I worked on that but I think you can dump the
>> info and use that to set up a metro. I could probably add a message to
>> get it to play automatically.
>> 
> 
> If you bang the [midifile] after opening the file, the right outlet will emit 
> ticks_per_quarternote and microsec_per_quarternote messages.
> 
> So the millisecond rate for the [metro] would be = 
> (microsec_per_quarternote/ticks_per_quarternote)/1000
> 
> See attached patch.
> 
> Martin


Dan Wilcox
@danomatika
danomatika.com
robotcowboy.com





___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] MIDIFILE read Tempo

2013-09-05 Thread Martin Peach

On 2013-09-05 09:29, Martin Peach wrote:

On 2013-09-05 07:04, Maciej Sledziecki wrote:

Hello,

ist there any way to read the tempo information contained in a midi file?
Or do I really have to set up a metro for mrpeach/midifile everytime ?



It's been a while since I worked on that but I think you can dump the
info and use that to set up a metro. I could probably add a message to
get it to play automatically.



If you bang the [midifile] after opening the file, the right outlet will 
emit ticks_per_quarternote and microsec_per_quarternote messages.


So the millisecond rate for the [metro] would be = 
(microsec_per_quarternote/ticks_per_quarternote)/1000


See attached patch.

Martin
#N canvas 421 249 558 483 10;
#X declare -lib mrpeach;
#X obj 320 12 import mrpeach;
#X obj 155 164 midifile;
#X obj 200 340 /;
#X obj 200 366 / 1000;
#X obj 155 135 metro 2;
#X obj 200 394 s ms_tempo;
#X obj 194 108 r ms_tempo;
#X obj 155 109 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X floatatom 213 214 7 0 0 0 - - -;
#X floatatom 367 214 7 0 0 0 - - -;
#X floatatom 204 135 7 0 0 0 - - -;
#X msg 64 147 rewind;
#X obj 60 54 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X text 122 29 Read the midi file and bang it once to get the tempo
into the metro;
#X text 14 29 1>;
#X text 39 55 2>;
#X text 133 106 3>;
#X text 157 74 or just start the metro and it will adjust after the
first tick;
#X obj 39 0 openpanel;
#X msg 39 31 read \$1;
#X obj 39 -18 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 200 184 route microsec_per_quarternote ticks_per_quarternote
;
#X connect 1 2 21 0;
#X connect 2 0 3 0;
#X connect 3 0 5 0;
#X connect 4 0 1 0;
#X connect 6 0 4 1;
#X connect 6 0 10 0;
#X connect 7 0 4 0;
#X connect 11 0 1 0;
#X connect 12 0 1 0;
#X connect 18 0 19 0;
#X connect 19 0 1 0;
#X connect 20 0 18 0;
#X connect 21 0 8 0;
#X connect 21 0 2 0;
#X connect 21 1 9 0;
#X connect 21 1 2 1;
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] MIDIFILE read Tempo

2013-09-05 Thread Maciej Sledziecki
That works great ! 
Even tempo changes within the file are updated.
Thank you very much.
Maciej

Am 05.09.2013 um 18:36 schrieb Martin Peach:

> On 2013-09-05 09:29, Martin Peach wrote:
>> On 2013-09-05 07:04, Maciej Sledziecki wrote:
>>> Hello,
>>> 
>>> ist there any way to read the tempo information contained in a midi file?
>>> Or do I really have to set up a metro for mrpeach/midifile everytime ?
>> 
>> 
>> It's been a while since I worked on that but I think you can dump the
>> info and use that to set up a metro. I could probably add a message to
>> get it to play automatically.
>> 
> 
> If you bang the [midifile] after opening the file, the right outlet will emit 
> ticks_per_quarternote and microsec_per_quarternote messages.
> 
> So the millisecond rate for the [metro] would be = 
> (microsec_per_quarternote/ticks_per_quarternote)/1000
> 
> See attached patch.
> 
> Martin
> 


___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] MIDIFILE read Tempo

2013-09-05 Thread Martin Peach

On 2013-09-05 07:04, Maciej Sledziecki wrote:

Hello,

ist there any way to read the tempo information contained in a midi file?
Or do I really have to set up a metro for mrpeach/midifile everytime ?



It's been a while since I worked on that but I think you can dump the 
info and use that to set up a metro. I could probably add a message to 
get it to play automatically.


Martin


___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


[PD] MIDIFILE read Tempo

2013-09-05 Thread Maciej Sledziecki
Hello,

ist there any way to read the tempo information contained in a midi file?
Or do I really have to set up a metro for mrpeach/midifile everytime ?

Thanks for any advice,

Maciej

___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list