# Ticking sound on splice, and cps question

**URL:** <https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033>\
**Category:** TidalCycles\
**Tags:** questions\
**Created:** [30 March 2021 18:45 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033 "2021-03-30T18:45:08Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![polymorphic.engine](https://uzu.lurk.org/user_avatar/uzu.lurk.org/polymorphic.engine/32/30_2.png) [@polymorphic.engine](https://uzu.lurk.org/u/polymorphic.engine)\
**Post date:** [31 March 2021 07:49 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/3 "2021-03-31T07:49:16Z")

</div>

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:

```haskell
(
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:

```haskell
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

```haskell
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:

```haskell
get_length "geodrone" 1

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

d1 $ loopAt sampLen $ s "geodrone:1"

```

---

_[View the full topic](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033)._
