# "once" at beginning of cycle?

**URL:** <https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345>\
**Category:** Uncategorized\
**Created:** [22 July 2021 04:22 UTC](https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345 "2021-07-22T04:22:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Albert](https://uzu.lurk.org/user_avatar/uzu.lurk.org/albert/32/1216_2.png) [@Albert](https://uzu.lurk.org/u/Albert)\
**Post date:** [22 July 2021 04:22 UTC](https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345/1 "2021-07-22T04:22:06Z")

</div>

Is there a way to trigger with "once" but not until the beginning of the cycle?

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [22 July 2021 23:08 UTC](https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345/2 "2021-07-22T23:08:06Z")

</div>

I think `qtrigger 1` maybe of assistance

Some ref: [Resetting Cycle Start?](https://club.tidalcycles.org/t/resetting-cycle-start/546)

---

<div class="post-metadata">

**Author:** ![Albert](https://uzu.lurk.org/user_avatar/uzu.lurk.org/albert/32/1216_2.png) [@Albert](https://uzu.lurk.org/u/Albert)\
**Post date:** [23 July 2021 03:54 UTC](https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345/3 "2021-07-23T03:54:41Z")

</div>

Thanks! I played around with `qtrigger` but it appears to have no effect on what I am working on.

For context I am sending midi clock to a 909 drum machine with this:

`p "midiclock" $ midicmd "midiClock*96" # s "roland"`

When I execute the following it syncs with the 909 quite nicely.

`d1 $ n "e2 f2 f2 f2 f2 f2 f2 f2" # s "akai" # midichan 0`

When I attempt this however .. it is not in sync with the 909 or d1.

`once $ n "e2 f2 f2 f2 f2 f2 f2 f2" # s "akai" # midichan 0`

qtrigger had no effect when I tried like this

`once $ qtrigger 1 $ n "e2 f2 f2 f2 f2 f2 f2 f2" # s "akai" # midichan 0`

Is there a way to execute `once` so it fires off only at the beginning of the next cycle?

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [25 July 2021 19:50 UTC](https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345/4 "2021-07-25T19:50:28Z")

</div>

Interesting - I'm afraid I'm really not sure from here, I recall doing a similar battle with `seqP` blocks many months ago which I don't think I ever resolved ☹

---

<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:** [26 July 2021 20:05 UTC](https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345/5 "2021-07-26T20:05:26Z")

</div>

Hello @Albert this is because with `once` you trigger your pattern immediately one time.  
You can try the functionality by executing something like `once $ s "bd"` serveral times fast with your keyboard. It is not quantized to the current global cycle position.

When you use `qtrigger` without `once` it is quantized to the current cycle position. So everything should be synchronized when you simply use it like

```haskell
p "midiclock" $ midicmd "midiClock*96" # s "roland"

d1 $ qtrigger 1 $ n "e2 f2 f2 f2 f2 f2 f2 f2" # s "akai" # midichan 0

```

The number `1` in `qtrigger` refers to the channel id. So for `d1` you need to use `qtrigger 1` for `d2` you need to use `qtrigger 2` (or `p 4 $ qtrigger 4`) and so on.

When you just want to play your pattern once but quantized you need a custom function like:

```haskell
-- Maybe there is a more elegant way then abusing seqP for this?
seqC x y pt= (p x . (|< orbit (x-1))) $ qtrigger x $ seqP [(0, y, pt)]
once' x = seqC x 1

```

And use it like:

```haskell
p "midiclock" $ midicmd "midiClock*96" # s "roland"

once' 1 $ n "e2 f2 f2 f2 f2 f2 f2 f2" # s "akai" # midichan 0

```

This will start your sequence with the beginning of the next cycle and just play it once.

Hopefully this helps you!

---

<div class="post-metadata">

**Author:** ![bgold](https://uzu.lurk.org/user_avatar/uzu.lurk.org/bgold/32/383_2.png) [@bgold](https://uzu.lurk.org/u/bgold)\
**Post date:** [27 July 2021 18:02 UTC](https://uzu.lurk.org/t/once-at-beginning-of-cycle/3345/6 "2021-07-27T18:02:00Z")

</div>

I think a `once'` that triggered on the next cycle boundary would be possible to implement, but for some reason the version I've been trying out is consistently about 20-30 ms too early, which can sound really weird. I'll see if I can figure out what's going on.
