Midi remote script -> clip.quantize()

Share your favorite Ableton Live tips, tricks, and techniques.
Post Reply
lophMusic
Posts: 12
Joined: Thu Feb 11, 2021 9:23 pm

Midi remote script -> clip.quantize()

Post by lophMusic » Fri Mar 25, 2022 9:34 pm

Hello forum,

I've been playing around with midi remote scripts for a while and I grew to be quit happy with the results so far. There's just one thing, I can't get under control:

I want a clip to be quantized 'by a press of a button' (for example to quickly fix, if I mess up doing finger-druming), but I can't get clip.qualtize() to work properly. It DOES some kind of quantisation, but it's not reliable and I'm not able to track down the problem.

Here's what I'm precisely trying to do:

Code: Select all

def quantize_clip():
        #get current highlighted clip
        cur_clip_slot = self.song().view.highlighted_clip_slot

        # 'Bonus-Task: get the current quantization of the clip.
        # This only works, if I set the quantization manually,
        # it does not get the current quantization based on the
        # current clip-view        
        cur_quant = cur_clip_slot.clip.view.grid_quantization
       
        
        # this does something, but I can't figure out what exactly
        cur_clip_slot.clip.quantize(cur_quant, 1.0)


        # Alternatively, I tried to figure out a int-value to pass to the function
        # since the actual API call seems to be quantize(int, float). I guess the
        # value 7 is supposed to be 1/16ths
        # cur_clip_slot.clip.quantize(7, 1.0)
So what I observe is, that there's some quantization going on. Possibly in a 1/32 grid, possibly with the option to quatize 'to the note-ends', too - but this is really hard to track down. Strangely enough, the result is different to just pressing strg-shift-U if I do the quantization manualy.

Does anyone have an Idea what's going on and how to solve this?

Angstrom
Posts: 14923
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Re: Midi remote script -> clip.quantize()

Post by Angstrom » Sat Mar 26, 2022 1:07 am

lophMusic wrote:
Fri Mar 25, 2022 9:34 pm
Does anyone have an Idea what's going on and how to solve this?

It's a while since I looked at this, but I think I remember the first value is the note grid value (5 is 16ths I think), the second value is the amount of quantisation. So 0.7 = quantise by 70%

so here's a chunk out of my old FCB script which covers both swing from the footpedal and quantise (to 16ths). I stripped out the value part to keep it simple here

Code: Select all

def quantiseclip (self,value):
		if value>0:
			self.current_slot_clip = self.song.view.highlighted_clip_slot.clip
			self.song.swing_amount=0#set the swing to noswing, basic quantise
			self.current_slot_clip.quantize(5,0.7)

	def swingclip (self,value):
		if value>0:
			self.song.swing_amount=0.2#set the swing to swing
			self.song.view.highlighted_clip_slot.clip.quantize(5,0.7)#apply it
you'll notice these are just the defs not the calls. Also, I use a self. to containerise the instance. I think they require that ( or used to) so you can call all their setup calls on the self instance at init.

oh, and also ... notice that this swing is different than the groove pool . This one actually moves the notes on the grid.

lophMusic
Posts: 12
Joined: Thu Feb 11, 2021 9:23 pm

Re: Midi remote script -> clip.quantize()

Post by lophMusic » Sun Mar 27, 2022 11:59 pm

Thanks a lot for your answer!

That's it:
Angstrom wrote:
Sat Mar 26, 2022 1:07 am
It's a while since I looked at this, but I think I remember the first value is the note grid value (5 is 16ths I think), the second value is the amount of quantisation. So 0.7 = quantise by 70%
The int-value of 5 beeing 16ths was doing the trick. Guessing that value by looking at cur_clip_slot.clip.view.grid_quantization has sent me down a wrong path, so that I've tried (and took into consideration) all kinds of (weird) things - but not values as little as 5 ;)

So thanks Angstrom for your help! :)

Post Reply