Ticking sound on splice, and cps question

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! :slight_smile:

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

let fadeTime = pF "fadeTime"
    fadeInTime = pF "fadeInTime"

Then you will be able to do

 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

declick pat = pat # fadeTime 0.03 # fadeInTime 0.03

and then

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

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

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

....?

Thank you! Will try this!

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

(
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

get_length "bd" 3

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

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

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

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).

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 :slight_smile:

1 Like

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:

(
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

import qualified Sound.OSC as O

then execute

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

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:

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 :slight_smile:

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):

get_length "pad" 0

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

setcps (1/"^pad0")

and try it out:

d1 $ s "pad"