Old 05-03-2008, 06:51 PM   #1
mbncp
Human being with feelings
 
Join Date: Mar 2008
Posts: 197
Default Midi Clock

I know reaper can send midi clock but not exactly my way.
This one has 2 options.

1) Start offset (see below)
Useful if you need to compensate for latency.

2) Start resolution (in beats)
If you set this slider to 4, it will wait until the beginning of the next bar before sending the start message(assuming you are in 4:4).
This gives some time to the other device to catch the proper tempo, plus it's necessary if you want a negative delay (start early).

Edit:
Changed a little the offsets, it has 3 sliders now, being summed.
You can now offset by buffer size (+/-4 audio buffers), by msec (+/-500 msec) and by beats (+/- 1 beat).
It shows also current position in beats(when stopped) and where the Start will/was sent, in beats value (divide by 4 for 4:4 measures).
Edit v1.2:
Now compensates the tempo to match reapers special loop size.
The 7th slider (Loop compensation time) let's you decide how fast the compensation is done(over 0 to 8 beats).
I still have some problems with very high buffers(4096), but looping a single measure with a 512 samples buffer at 140 bpm is good, even after 5 minutes.
Attached Files
File Type: txt MidiClock.txt (2.3 KB, 1392 views)

Last edited by mbncp; 05-05-2008 at 01:40 PM. Reason: Code change
mbncp is offline   Reply With Quote
Old 05-04-2008, 11:53 AM   #2
mbncp
Human being with feelings
 
Join Date: Mar 2008
Posts: 197
Default

I have a little problem when I'm looping, my code is based on the fact that loops are beat based.

So if I set a 2 bars long loop, at some point, either the last buffer and the first one of the loop should have different sizes (split), or at least there should be an info about the loop position.

But I don't see any variable telling me the loop position and the buffer size doesn't change.

Is this a limitation of JS or is reaper taking some shortcuts with timing .. ?
mbncp is offline   Reply With Quote
Old 05-04-2008, 02:54 PM   #3
xackley
Human being with feelings
 
Join Date: Feb 2007
Location: Kitchen table, next to frig
Posts: 1,179
Default

Is this a problem of not checking a beat_position != savedbeat_position when looping. Start position keeps shifting because the loop controls start and end?

Also the download version contains only 2 sliders.
__________________
^^^^^^^^^^
https://soundcloud.com/user-463176271
xackley is offline   Reply With Quote
Old 05-04-2008, 04:15 PM   #4
mbncp
Human being with feelings
 
Join Date: Mar 2008
Posts: 197
Default

Quote:
Originally Posted by xackley View Post
Is this a problem of not checking a beat_position != savedbeat_position when looping. Start position keeps shifting because the loop controls start and end?
With this little script, I check that the new beat_position is the correct one based on previous position + samplesblock.
The math must be ok. As long as I don't loop the values do match.

Now on a loop, I get some strange results:
my loop is between beat 4 and 8 ( 1 bar), tempo=30, buffer=4096 samples

next should be position : 8.021769 (0.021769 too long)
beat_position after the loop: 3.975329 (0.024671 too long)

Values are changing each time off course, but this means that the loop is not 4 beat long as it should be but a little longer.

So, I can compensate and send the clock at the correct time to keep the right tempo, but it will get out of sync.
A trick would be to compensate the tempo, but as we don't know in advance where the loop is, it's a bit hard to do it in a smooth way, not even speaking about my little brain :/

I'm not aware of all the issues, but wouldn't it be better that reaper splits the buffer in 2 on a loop ?
At least as an option (Accurate loop size) ?

The code I used for testing:
Code:
desc:test
slider1:0<0,0,0>Low buffer size
slider2:0<0,0,0>Hi Buffer size
slider3:0<0,0,0>init counter
slider4:0<0,0,0>Next_beat_position 
slider5:0<0,0,0>beat_position
//-------------------------
@init
slider1 = 50000;
slider2 = 0;
slider3 = slider3+1;
Next_beat_position = -1;

//-------------------------
@slider
//-------------------------
@block
samplesblock < slider1 ? slider1 = samplesblock;
samplesblock > slider2 ? slider2 = samplesblock;

play_state&1 ?
(
	beat_position != Next_beat_position ?
	(
		slider4 = Next_beat_position;
		slider5 = beat_position;
	);
	Next_beat_position = beat_position + samplesblock*tempo/(srate*60);
);
Quote:
Originally Posted by xackley View Post
Also the download version contains only 2 sliders.
It should have 6 sliders, v1.1
mbncp is offline   Reply With Quote
Old 05-05-2008, 07:04 PM   #5
xackley
Human being with feelings
 
Join Date: Feb 2007
Location: Kitchen table, next to frig
Posts: 1,179
Default

ok, this made me curious. what I am seeing is the start of loop is exactly the .xxxxxx of the end of the loop minus the number of beats.

so a loop from bar 3 to bar 4
example:
If the loop ends on 11.994974 it will rewind to 7.994974.
If the loop ends on 11.999509 it will rewind to 7.999509.


The end of loop varies, so the beginning of loop varies too. The loop has to stop before bar 4, so the 11.994974 range of number is probably right, but the program shouldn't be doing a straight subtract of 4. The start of loop should be static. The slop at the end of the loop should not be carried over to the beginning of the loop

I think what I am seeing is a bug in how loop are handled?
__________________
^^^^^^^^^^
https://soundcloud.com/user-463176271
xackley is offline   Reply With Quote
Old 05-06-2008, 03:30 AM   #6
mbncp
Human being with feelings
 
Join Date: Mar 2008
Posts: 197
Default

As it's handled now, the loop is always 1 audio buffer larger than it should be.
Making the start of the loop a little early is maybe a way to distribute this extra buffer between the start and the end of the loop. (?)

In a vst, cycleStartPos and cycleEndPos show the "correct" values so the plug knows at least that it shouldn't fill totally the last buffer.
mbncp is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.