Ticking sound on splice, and cps question

I have the following trick I use sometimes to get the length of a sample into tidal:
you need to copy the following code into supercollider and execute it:

(
OSCdef.new(
	\sampleLength,
	{
		arg msg, time, addr, port;
		var name, number, address, length;

		address = NetAddr.new("localhost", 6010);

		name = msg[1].asSymbol;

		number = msg[2];

		length = ~dirt.soundLibrary.buffers[name][number].duration.round(0.01);

		address.sendMsg("/ctrl", "sampleLength", length);
	},
	'/sampleLength'  
  );
  )

in Tidal you now can add the following function:

import qualified Sound.OSC as O

get_length:: String -> Int -> IO ()
get_length sampleName n = do sendO False (sListen tidal) (head $ sCxs tidal) $ O.Message "/sampleLength" [O.string sampleName, O.int32 n]

the above function expects the name of the sample folder as a string and the number of the sample in that folder, so for example you can run

get_length "bd" 0

The sample length of that specific sample will then be stored in a state variable sampleLength, which you can accsess in patterns via ^sampleLength. This approach is currently restricted to having the length of one sample accsessible at a time. I still need to figure out how to do it with multiple samples. Nevertheless, I still use it frequently for my longer samples like this:

get_length "geodrone" 1

let sampLen = ("^sampleLength" * "^_cps")

d1 $ loopAt sampLen $ s "geodrone:1"
4 Likes