# Rounding Float patterns

**URL:** <https://uzu.lurk.org/t/rounding-float-patterns/2250>\
**Category:** TidalCycles\
**Tags:** questions\
**Created:** [4 October 2020 16:14 UTC](https://uzu.lurk.org/t/rounding-float-patterns/2250 "2020-10-04T16:14:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![th4](https://uzu.lurk.org/user_avatar/uzu.lurk.org/th4/32/505_2.png) [@th4](https://uzu.lurk.org/u/th4)\
**Post date:** [4 October 2020 16:14 UTC](https://uzu.lurk.org/t/rounding-float-patterns/2250/1 "2020-10-04T16:14:27Z")

</div>

Hi!  
How can I turn a `Pattern Float` into a `Pattern Int` by rounding the values inside the `Pattern Float`? For example, I could have a process that yields floating-point values in the form of a pattern (this could be for example `sine`), and I want to feed such values to `up`, but only as notes from the twelve-tones scale.

I have tried to use `round <$> myPattern` (where `myPattern` is of type `Pattern Double`), but I don't seem to have luck when plugging it in `up` (apparently the types don't match).

Does anyone have any clue what I could do about it?

---

<div class="post-metadata">

**Author:** ![crashingbooth](https://uzu.lurk.org/user_avatar/uzu.lurk.org/crashingbooth/32/1619_2.png) [@crashingbooth](https://uzu.lurk.org/u/crashingbooth)\
**Post date:** [4 October 2020 17:11 UTC](https://uzu.lurk.org/t/rounding-float-patterns/2250/2 "2020-10-04T17:11:28Z")

</div>

If `up` and `sine` are decent proxies for your end goal/custom function, how about something like this?

`d1 $ (# up (fromIntegral <$> round <$> sine)) $ s "pluck"`

Actually, checking the types I can see that  
`(round <$> sine) :: Integral b => Pattern b`  
and  
`up :: Pattern Double -> ControlPattern`

The problem isn't getting `Pattern Float` into a `Pattern Int`, but getting `Pattern Int` to `Pattern Double`, hence `fromIntegral`. Not sure if this was the real problem you were up against.

---

<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:** [4 October 2020 17:12 UTC](https://uzu.lurk.org/t/rounding-float-patterns/2250/3 "2020-10-04T17:12:31Z")

</div>

`round <$>` should work for that. If you can share a pattern that doesn't run, with its error message, we can have a look

---

<div class="post-metadata">

**Author:** ![th4](https://uzu.lurk.org/user_avatar/uzu.lurk.org/th4/32/505_2.png) [@th4](https://uzu.lurk.org/u/th4)\
**Post date:** [4 October 2020 19:10 UTC](https://uzu.lurk.org/t/rounding-float-patterns/2250/4 "2020-10-04T19:10:30Z")

</div>

Thanks, that was exactly my problem, I didn't realize that `up` took a `Pattern Double` as an argument, in my mind it was more polymorphic!
