Problems with SMPTE

View: New views
10 Messages — Rating Filter:   Alert me  

Problems with SMPTE

by Manfred Brockhaus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

According to the MIDIOut help file SC3 provides the following method  
for sending MTC (Midi Time Code).

smpte ( frames, seconds, minutes, hours, frameRate )

Now I'm trying to use it for synchronizing SC to other midi/audio  
applications with the following MTC generator.

---------------------------------------------

~mtc = { | frm, sec, min, hrs, fr |
        loop{
                m.smpte ( frm, sec, min, hrs, fr );
                frm = frm + 1;
                if( frm == fr ){ frm = 0; sec = sec + 1 };
                if( sec == 60 ){ sec = 0; min = min + 1 };
                if( min == 60 ){ min = 0; hrs = hrs + 1 };
                wait( 1/fr );
        };
};

r = { ~mtc.( 0, 0, 0, 0, 24 ) }.fork;
r.stop;

---------------------------------------------

However, when sending for example to Logic or Cubase it doesn't seem  
to work correctly. As far as I remember MTC worked well in earlier  
versions of SC. So maybe something got corrupted in the UB version  
since the code looks rather complicated with a lot of bit  
manipulation involved.

Also, I'm not sure how to monitor the MTC messages as the MIDIIn help  
file only mentions the method

MIDIIn.smpte =  arg src, chan, val; [chan,val].postln; };

This makes no sense to me regarding the arguments.

So I'd be grateful if some expert could check the overall  
functionality and documntation of SMPTE (MTC) in SC3.



_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by thelych :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Manfred,


> According to the MIDIOut help file SC3 provides the following method  
> for sending MTC (Midi Time Code).

I do not understand if you need SMPTE or MTC ???...
But for sending MTC, you should use :

in  MIDIOut class
.start // send MTC start
.midiClock // send this 24 times per quarter note
.stop // send MTC stop
.continue // ...ect...

so try these methods first after creating a valid MIDIOut instance  
first...

But if you have a recent SC3 version (svn or recent snapshot), you  
should look at

1) the MIDIClockOut class (by Felix) that should handle everything for  
you.

or

2) the MIDISyncClock class (by James Harkins) (you have to download  
his quark lib)


> Also, I'm not sure how to monitor the MTC messages as the MIDIIn  
> help file only mentions the method
> MIDIIn.smpte =  arg src, chan, val; [chan,val].postln; };
> This makes no sense to me regarding the arguments.



For listening to MTC message, i think you have to use the MIDIIn.sysrt  
callback.

hope it will help you

best,
charles

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jul 2, 2008 at 10:35 AM,  <thelych@...> wrote:
> 2) the MIDISyncClock class (by James Harkins) (you have to download his
> quark lib)

To clarify - MIDISyncClock receives, but does not send, MIDI clock messages.

hjh


--
James Harkins /// dewdrop world
jamshark70@...
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by nescivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 02 July 2008 09:47:22 Manfred Brockhaus wrote:

> According to the MIDIOut help file SC3 provides the following method
> for sending MTC (Midi Time Code).
>
> smpte ( frames, seconds, minutes, hours, frameRate )
>
> Now I'm trying to use it for synchronizing SC to other midi/audio
> applications with the following MTC generator.
>
> ---------------------------------------------
>
> ~mtc = { | frm, sec, min, hrs, fr |
> loop{
> m.smpte ( frm, sec, min, hrs, fr );
> frm = frm + 1;
> if( frm == fr ){ frm = 0; sec = sec + 1 };
> if( sec == 60 ){ sec = 0; min = min + 1 };
> if( min == 60 ){ min = 0; hrs = hrs + 1 };
> wait( 1/fr );
> };
> };
>
> r = { ~mtc.( 0, 0, 0, 0, 24 ) }.fork;
> r.stop;
>
> ---------------------------------------------
>
> However, when sending for example to Logic or Cubase it doesn't seem
> to work correctly. As far as I remember MTC worked well in earlier
> versions of SC. So maybe something got corrupted in the UB version
> since the code looks rather complicated with a lot of bit
> manipulation involved.
>
> Also, I'm not sure how to monitor the MTC messages as the MIDIIn help
> file only mentions the method
>
> MIDIIn.smpte =  arg src, chan, val; [chan,val].postln; };
>
> This makes no sense to me regarding the arguments.
>
> So I'd be grateful if some expert could check the overall
> functionality and documntation of SMPTE (MTC) in SC3.
>


Here's a method to receive and decode MTC:

                /// MTC: only deals with forward running time!
                mtc_t = Array.fill(8,0);
                mtc_v = Array.fill(4,0);
                mtc_r = 30;
                mtctime = 0;

                                MIDIIn.smpte = { arg src, chan, val;
                                        if ( debug, { [src,chan,val].postln } );
                                        mtc_t[chan] = val;
                                        if ( chan == 7,
                                                {
                                                        mtc_v[0] = mtc_t[1] + mtc_t[0];
                                                        mtc_v[1] = mtc_t[3] + mtc_t[2];
                                                        mtc_v[2] = mtc_t[5] + mtc_t[4];
                                                        mtc_v[3] = mtc_t[7].mod(2) + mtc_t[6];
                                                        if ( mtc_t[7].asHexString[6] == $6, { mtc_r = 30; });
                                                        if ( mtc_t[7].asHexString[6] == $4, { mtc_r = 30; });
                                                        if ( mtc_t[7].asHexString[6] == $2, { mtc_r = 25; });
                                                        if ( mtc_t[7].asHexString[6] == $0, { mtc_r = 24; });
                                                        mtctime = (mtc_v[0]/mtc_r) + mtc_v[1] + (mtc_v[2]*60) +
(mtc_v[3]*3600);
                                                        this.lastTime_( mtctime );
                                                });
                                };

the tricky bit is that since MIDI messages are only 3 bytes, the time code
needs to be sent in several messages.
this also means that because of the time it takes to sent all the info on a
time frame, you cannot get the granularity of one frame. Probably your code
will work, if you put a 2 frames wait in between.

See also this:
http://www.ibiblio.org/emusic-l/info-docs-FAQs/MIDI-doc/MIDI-MTC.txt
for an explanation.

sincerely,
Marije

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by nescivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 02 July 2008 10:46:55 nescivi wrote:

> On Wednesday 02 July 2008 09:47:22 Manfred Brockhaus wrote:
> > According to the MIDIOut help file SC3 provides the following method
> > for sending MTC (Midi Time Code).
> >
> > smpte ( frames, seconds, minutes, hours, frameRate )
> >
> > Now I'm trying to use it for synchronizing SC to other midi/audio
> > applications with the following MTC generator.
> >
> > ---------------------------------------------
> >
> > ~mtc = { | frm, sec, min, hrs, fr |
> > loop{
> > m.smpte ( frm, sec, min, hrs, fr );
> > frm = frm + 1;
> > if( frm == fr ){ frm = 0; sec = sec + 1 };
> > if( sec == 60 ){ sec = 0; min = min + 1 };
> > if( min == 60 ){ min = 0; hrs = hrs + 1 };
> > wait( 1/fr );
> > };
> > };
> >
> > r = { ~mtc.( 0, 0, 0, 0, 24 ) }.fork;
> > r.stop;
> >
> > ---------------------------------------------
> >
> > However, when sending for example to Logic or Cubase it doesn't seem
> > to work correctly. As far as I remember MTC worked well in earlier
> > versions of SC. So maybe something got corrupted in the UB version
> > since the code looks rather complicated with a lot of bit
> > manipulation involved.
> >
> > Also, I'm not sure how to monitor the MTC messages as the MIDIIn help
> > file only mentions the method
> >
> > MIDIIn.smpte =  arg src, chan, val; [chan,val].postln; };
> >
> > This makes no sense to me regarding the arguments.
> >
> > So I'd be grateful if some expert could check the overall
> > functionality and documntation of SMPTE (MTC) in SC3.
>
> Here's a method to receive and decode MTC:
>
> /// MTC: only deals with forward running time!
> mtc_t = Array.fill(8,0);
> mtc_v = Array.fill(4,0);
> mtc_r = 30;
> mtctime = 0;
>
> MIDIIn.smpte = { arg src, chan, val;
> if ( debug, { [src,chan,val].postln } );
> mtc_t[chan] = val;
> if ( chan == 7,
> {
> mtc_v[0] = mtc_t[1] + mtc_t[0];
> mtc_v[1] = mtc_t[3] + mtc_t[2];
> mtc_v[2] = mtc_t[5] + mtc_t[4];
> mtc_v[3] = mtc_t[7].mod(2) + mtc_t[6];
> if ( mtc_t[7].asHexString[6] == $6, { mtc_r = 30; });
> if ( mtc_t[7].asHexString[6] == $4, { mtc_r = 30; });
> if ( mtc_t[7].asHexString[6] == $2, { mtc_r = 25; });
> if ( mtc_t[7].asHexString[6] == $0, { mtc_r = 24; });
> mtctime = (mtc_v[0]/mtc_r) + mtc_v[1] + (mtc_v[2]*60) +
> (mtc_v[3]*3600);
> this.lastTime_( mtctime );
> });
> };
>
> the tricky bit is that since MIDI messages are only 3 bytes, the time code
> needs to be sent in several messages.
> this also means that because of the time it takes to sent all the info on a
> time frame, you cannot get the granularity of one frame. Probably your code
> will work, if you put a 2 frames wait in between.
>
> See also this:
> http://www.ibiblio.org/emusic-l/info-docs-FAQs/MIDI-doc/MIDI-MTC.txt
> for an explanation.

and this:
http://jedi.ks.uiuc.edu/~johns/links/music/mtc.htm

sincerely,
Marije

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by Manfred Brockhaus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 2, 2008, at 4:35 PM, thelych@... wrote:

>
> Hi Manfred,
>
>
>> According to the MIDIOut help file SC3 provides the following  
>> method for sending MTC (Midi Time Code).
>
> I do not understand if you need SMPTE or MTC ???...
> But for sending MTC, you should use :
>
> in  MIDIOut class
> .start // send MTC start
> .midiClock // send this 24 times per quarter note
> .stop // send MTC stop
> .continue // ...ect...
>
> so try these methods first after creating a valid MIDIOut instance  
> first...
>

Just to clarify:

SMPTE is a timecode standard for synchronizing video or audio  
material, and MTC is a MIDI variant of SMPTE for synchronizing music.  
But MTC is *not* the same as MIDI clock.

The reason I need MTC instead of MIDI clock is because recent  
versions of some popular sequencers like Logic or Cubase don't  
support MIDI clock input anymore.



_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by Manfred Brockhaus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 2, 2008, at 4:48 PM, nescivi wrote:

> On Wednesday 02 July 2008 10:46:55 nescivi wrote:
>> On Wednesday 02 July 2008 09:47:22 Manfred Brockhaus wrote:
>>> According to the MIDIOut help file SC3 provides the following method
>>> for sending MTC (Midi Time Code).
>>>
>>> smpte ( frames, seconds, minutes, hours, frameRate )
>>>
>>> Now I'm trying to use it for synchronizing SC to other midi/audio
>>> applications with the following MTC generator.
>>>
>>> ---------------------------------------------
>>>
>>> ~mtc = { | frm, sec, min, hrs, fr |
>>> loop{
>>> m.smpte ( frm, sec, min, hrs, fr );
>>> frm = frm + 1;
>>> if( frm == fr ){ frm = 0; sec = sec + 1 };
>>> if( sec == 60 ){ sec = 0; min = min + 1 };
>>> if( min == 60 ){ min = 0; hrs = hrs + 1 };
>>> wait( 1/fr );
>>> };
>>> };
>>>
>>> r = { ~mtc.( 0, 0, 0, 0, 24 ) }.fork;
>>> r.stop;
>>>
>>> ---------------------------------------------
>>>
>>> However, when sending for example to Logic or Cubase it doesn't seem
>>> to work correctly. As far as I remember MTC worked well in earlier
>>> versions of SC. So maybe something got corrupted in the UB version
>>> since the code looks rather complicated with a lot of bit
>>> manipulation involved.
>>>
>>> Also, I'm not sure how to monitor the MTC messages as the MIDIIn  
>>> help
>>> file only mentions the method
>>>
>>> MIDIIn.smpte =  arg src, chan, val; [chan,val].postln; };
>>>
>>> This makes no sense to me regarding the arguments.
>>>
>>> So I'd be grateful if some expert could check the overall
>>> functionality and documntation of SMPTE (MTC) in SC3.
>>
>> Here's a method to receive and decode MTC:
>>
>> /// MTC: only deals with forward running time!
>> mtc_t = Array.fill(8,0);
>> mtc_v = Array.fill(4,0);
>> mtc_r = 30;
>> mtctime = 0;
>>
>> MIDIIn.smpte = { arg src, chan, val;
>> if ( debug, { [src,chan,val].postln } );
>> mtc_t[chan] = val;
>> if ( chan == 7,
>> {
>> mtc_v[0] = mtc_t[1] + mtc_t[0];
>> mtc_v[1] = mtc_t[3] + mtc_t[2];
>> mtc_v[2] = mtc_t[5] + mtc_t[4];
>> mtc_v[3] = mtc_t[7].mod(2) + mtc_t[6];
>> if ( mtc_t[7].asHexString[6] == $6, { mtc_r = 30; });
>> if ( mtc_t[7].asHexString[6] == $4, { mtc_r = 30; });
>> if ( mtc_t[7].asHexString[6] == $2, { mtc_r = 25; });
>> if ( mtc_t[7].asHexString[6] == $0, { mtc_r = 24; });
>> mtctime = (mtc_v[0]/mtc_r) + mtc_v[1] + (mtc_v[2]*60) +
>> (mtc_v[3]*3600);
>> this.lastTime_( mtctime );
>> });
>> };
>>
>> the tricky bit is that since MIDI messages are only 3 bytes, the  
>> time code
>> needs to be sent in several messages.
>> this also means that because of the time it takes to sent all the  
>> info on a
>> time frame, you cannot get the granularity of one frame. Probably  
>> your code
>> will work, if you put a 2 frames wait in between.
>>
>> See also this:
>> http://www.ibiblio.org/emusic-l/info-docs-FAQs/MIDI-doc/MIDI-MTC.txt
>> for an explanation.
>
> and this:
> http://jedi.ks.uiuc.edu/~johns/links/music/mtc.htm
>
> sincerely,
> Marije
>

Many thanks for the detailed info. I'll try to understand and use it...





_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by Manfred Brockhaus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 2, 2008, at 4:48 PM, nescivi wrote:

>> Probably your code will work, if you put a 2 frames wait in between.
>>

Great tip! Actually it works although the song position pointer runs  
a bit shaky.

Thanks again.



 

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by Manfred Brockhaus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 2, 2008, at 7:10 PM, Manfred Brockhaus wrote:

>
> On Jul 2, 2008, at 4:48 PM, nescivi wrote:
>
>>> Probably your code will work, if you put a 2 frames wait in between.
>>>
>
> Great tip! Actually it works although the song position pointer  
> runs a bit shaky.
>
> Thanks again.
>

Just wanted to clarify that the shakiness was due to user error as I  
had accidentally started two instances of the MTC generator. Now it  
works perfectly. I've also successfully tried your MTC decoder.

So I'm very glad and impressed that my problems could be solved  
within a few hours. Thanks to all developers for this great program.



_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Problems with SMPTE

by krgn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

oh, and isn't there also a quark for handling SMPTE in wslib? just remembered.. but since you figured it out its just noise :)


On Wed, Jul 2, 2008 at 12:52 PM, Manfred Brockhaus <manfred.brockhaus@...> wrote:

On Jul 2, 2008, at 7:10 PM, Manfred Brockhaus wrote:


On Jul 2, 2008, at 4:48 PM, nescivi wrote:

Probably your code will work, if you put a 2 frames wait in between.


Great tip! Actually it works although the song position pointer runs a bit shaky.

Thanks again.


Just wanted to clarify that the shakiness was due to user error as I had accidentally started two instances of the MTC generator. Now it works perfectly. I've also successfully tried your MTC decoder.

So I'm very glad and impressed that my problems could be solved within a few hours. Thanks to all developers for this great program.




_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

LightInTheBox - Buy quality products at wholesale price