# Sharing custom functions

**URL:** <https://uzu.lurk.org/t/sharing-custom-functions/1032>\
**Category:** TidalCycles\
**Tags:** resources\
**Created:** [19 May 2020 01:59 UTC](https://uzu.lurk.org/t/sharing-custom-functions/1032 "2020-05-19T01:59:50Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![mrreason](https://uzu.lurk.org/user_avatar/uzu.lurk.org/mrreason/32/3203_2.png) [@mrreason](https://uzu.lurk.org/u/mrreason)\
**Post date:** [30 July 2020 10:36 UTC](https://uzu.lurk.org/t/sharing-custom-functions/1032/17 "2020-07-30T10:36:47Z")

</div>

Hi folks!

[Edit:] I completely overlooked that there is already the `up` function. However I have made this for using and customizing the live pitch-shifting of an input signal. So this could be helpfully anyway, I think.

I made my own function that converts the speed ratio parameter into notes. For this I wrote a speed' function which I am currently experimenting with:

```haskell
-- Calculating the n'th root of a value
nroot :: (Integral a, Floating b) => a -> b -> b 
n `nroot` x = x ** (1 / fromIntegral n)

-- Calculates the n'th root of all pattern values in p and use the function f (like speed)
nrootFuncs :: Pattern Double -> (Pattern Double -> ControlPattern) -> ControlPattern
nrootFuncs p f = f (fmap (12 `nroot` 2 **) (p))

-- Define custom speed function
speed' :: Pattern Double -> ControlPattern
speed' p = nrootFuncs p speed  

```

To demonstrate this I have created a short video for you:

[![](https://img.youtube.com/vi/LaJaaGAtPmc/maxresdefault.jpg "Custom speed function for Tidal") ](https://www.youtube.com/watch?v=LaJaaGAtPmc)

The video also contains the function `psrate` and `psrate'`. Unfortunately, you can't reproduce the `in` stuff with `psrate` at the moment, because there is a small bug in SuperDirt (but it's fixed and waits for the approval)

You can also download the code from the video here:

> **[algorithm-mu/tidal/custom at master · thgrund/algorithm-mu](https://github.com/thgrund/algorithm-mu/tree/master/tidal/custom)**
>
> master/tidal/custom

---

_[View the full topic](https://uzu.lurk.org/t/sharing-custom-functions/1032)._
