# 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:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucyjp786](https://uzu.lurk.org/user_avatar/uzu.lurk.org/lucyjp786/32/337_2.png) [@lucyjp786](https://uzu.lurk.org/u/lucyjp786)\
**Post date:** [30 March 2021 18:45 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/1 "2021-03-30T18:45:08Z")

</div>

Hey all I have a quick question, I have this pattern:  
d1 $ splice 30 "0 1 4 2" $ s "air"

There is a little tick sound now and then, any idea how to get rid of that?

Also, does anyone know how to tell how long a sound is? Like is there a way for tidal to tell you how long it is so you can set the cps to the right value to get the full sound

Thanks in advance! 🙂

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [30 March 2021 23:23 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/2 "2021-03-30T23:23:01Z")

</div>

Hi @lucyjp786,  
These will be added to the next tidal version but for now you have to run this:

```haskell
let fadeTime = pF "fadeTime"
    fadeInTime = pF "fadeInTime"

```

Then you will be able to do

```haskell
 d1 $ splice 30 "0 1 4 2" $ s "air" # fadeTime 0.03 # fadeInTime 0.03

```

That should get rid of the clicks, you might need to increase / decrease 0.03 for taste.

To make it shorter you could also do

```haskell
declick pat = pat # fadeTime 0.03 # fadeInTime 0.03

```

and then

```haskell
d1 $ declick $ splice 30 "0 1 4 2" $ s "air" 

```

---

<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"

```

---

<div class="post-metadata">

**Author:** ![lucyjp786](https://uzu.lurk.org/user_avatar/uzu.lurk.org/lucyjp786/32/337_2.png) [@lucyjp786](https://uzu.lurk.org/u/lucyjp786)\
**Post date:** [31 March 2021 12:45 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/4 "2021-03-31T12:45:57Z")

</div>

Thanks yaxu. I found that the tick is still there even when I did this...

I forgot to mention that I changed the cps so maybe that's why -  
it is  
d1 $ splice 30 "0 1 4 2" $ s "air"  
but at setcps 0.1

....?

---

<div class="post-metadata">

**Author:** ![lucyjp786](https://uzu.lurk.org/user_avatar/uzu.lurk.org/lucyjp786/32/337_2.png) [@lucyjp786](https://uzu.lurk.org/u/lucyjp786)\
**Post date:** [31 March 2021 12:46 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/5 "2021-03-31T12:46:13Z")

</div>

Thank you! Will try this!

---

<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:** [2 April 2021 15:19 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/6 "2021-04-02T15:19:52Z")

</div>

I have looked into generalizing my approach and it was actually easier than I thought! Here is the slightly modified SC code 🙂

```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", name.asString ++ number.asString, length);
	},
	'/sampleLength'
);
)

```

you can now load multiple lengths of samples into Tidal as state variables that will be of the form sampleName ++ numberInFolder. For example if you want to get the length of the 3rd sample in the folder bd, you can use

```haskell
get_length "bd" 3

```

and use ^bd3 in patterns, for example like this:

```haskell
d1 $ stut 4 0.2 "^bd3" $ s "bd:3(3,8)"

```

---

<div class="post-metadata">

**Author:** ![lucyjp786](https://uzu.lurk.org/user_avatar/uzu.lurk.org/lucyjp786/32/337_2.png) [@lucyjp786](https://uzu.lurk.org/u/lucyjp786)\
**Post date:** [6 April 2021 09:23 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/7 "2021-04-06T09:23:45Z")

</div>

Thanks so much this was really useful.

I'm getting a bit confused, probably because my patterns are too noisy...but say if I have something like this:

d1 $ every 1 rev $ splice 30 "0 1 3 7 8 2 3 4" $ s "bsperc bsperc:2 bsperc:3" # gain 2 # delay 3 # resonance 1.5

where it sounds completely different to the original samples - here mainly because of the splice, reverse and delay - does the cps / sample length stay the same still even though its not really recognisable? Particularly with the delay, does the effect of that not carry on into the following cycles?

If it is longer, then how do I tell how long the new version is from when the sound starts to when it stops?

Hope that makes sense..

---

<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:** [6 April 2021 12:10 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/8 "2021-04-06T12:10:01Z")

</div>

hmmm not really sure what you mean - the sample length remains always constant, no matter how you manipulate the samples, so to get the exact length of a manipulated sound you would have to calculate it somehow.  
like, if you have a pattern chop 16 $ s "bsperc", then the length of each chopped bit would be a 16th of the length of the sample (I think).

---

<div class="post-metadata">

**Author:** ![lucyjp786](https://uzu.lurk.org/user_avatar/uzu.lurk.org/lucyjp786/32/337_2.png) [@lucyjp786](https://uzu.lurk.org/u/lucyjp786)\
**Post date:** [6 April 2021 14:57 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/9 "2021-04-06T14:57:36Z")

</div>

Ok thanks. Referring to your previous message, as i'm not a programmer i don't really understand what you mean by "the above function expects the name of the sample folder as a string and the number of the sample in that folder' relating to -

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]

Please could you give a step to step example for someone who doesn't understand this language?! Sorry to make you spell it out...many thanks 🙂

---

<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:** [6 April 2021 15:51 UTC](https://uzu.lurk.org/t/ticking-sound-on-splice-and-cps-question/3033/10 "2021-04-06T15:51:51Z")

</div>

Don't worry!  
First of all you need to load the following code in supercollider and execute it by selecting it and pressing CTRL + Enter:

```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", name.asString ++ number.asString, length);
	},
	'/sampleLength'
);
)

```

Next you open a .tidal file in Atom and execute the line

```haskell
import qualified Sound.OSC as O

```

then execute

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

```

You need to do these steps every time you startup SuperCollider and Tidal. Now, this is how you use it:  
Let's say you want to use the lengths of the first three samples in the samplefolder bsperc. To get them you can execute the line

```haskell
get_length "bsperc" 0

get_length "bsperc" 1

get_length "bsperc" 2

```

one after the other in Tidal (note that we begin to count at 0). There will be no confirmation that anything happened, but you will now be able to use "^bsperc0", "^bsperc1","^bsperc2"as a placeholders that stores the lengths of your samples. Try to play the following after completing the above steps:

```haskell
d1 $ s "bsperc bsperc:1 bsperc:2" # speed ("<^bsperc0 ^bsperc1 ^bsperc2>")

```

So in the first cycle, the speed will be adjusted according to the length of the first sample, in the second cycle according to second one and in the third cycle according to the third one.

Hope this helps! Feel free to ask if you have any questions, I'm happy to help 🙂

Edit: I just read through your original question again, where you specifically asked for a way to know how long your sample is so you can set the cps right. This will be better to try on a longer sample so first get the length of the sample (I'll use the pad sample):

```haskell
get_length "pad" 0

```

then set the cps to 1 divided by the length of the sample:

```haskell
setcps (1/"^pad0")

```

and try it out:

```haskell
d1 $ s "pad"

```
