---
title: Partycore (everything’s better at 140bpm)
date: 2023-12-05 12:02
tags: [partykit]
author: "Matt Webb"
pubDate: "Tue, 05 Dec 2023 12:02:00 +0000"
link: "https://interconnected.org/home/2023/12/05/partycore-140bpm-with-tonejs"
urlPrev: "https://interconnected.org/home/2023/12/04/weeknote.md"
urlNext: "https://interconnected.org/home/2023/12/05/code.md"
---
# Partycore (everything's better at 140bpm)

_By {{page.author}} on {{page.pubDate}}._

_The following was first posted on the[PartyKit blog][1] and has since been
archived here._

---

Hey come on over to **[partycore][2]** and play with our drum sequencer.

There are three tracks. You tap a step to turn it on or off. Drag the slides
at either end of a track to change the loop length --- you can get some good
polyrhythms going.

Ignore my sounds in that demo. My loops aren't great.

But some people are _really_ good at this. This sequencer is multiplayer by
default, so my main trick is to hang out on that page and wait for someone
else to come along and make a better beat.

**The code is open so you can see how it works**

Here's the GitHub repo: [sketch-sequencer][3].

The app is built and served with PartyKit using the [Remix template][4]. I
like building that way because I can serve up a whole site from
`partykit.dev`.

Data sync between the app and the server is achieved with Yjs using
[y-partykit][5], PartyKit's native Yjs backend. So there's nothing bespoke in
the server ([see sequencer.ts][6] for the code)...

...whereas on the client side there's a lot going on. Because while it's neat
to host a shared Yjs doc so easily, I find it fiddly to interact with the doc
directly. So I write high level functionality and make it available in a hook.
[Look at useSequencer][7] to see how to edit the steps and the loop ranges.
This is a pattern I reach for pretty frequently.

Finally, how are the samples scheduled? That's all client-side. While the
steps and ranges are synced across browsers, the playhead itself isn't synced.
Each browser uses the Web Audio framework [Tone.js][8] to play the tracks
independently.

**new website, who dis?**

You may have noticed the smart new look of our [homepage][9] and this blog.

We've been working with Mark Hurrell of [ThinkM Studio][10]. The new design
shipped last week.

So when Mark showed me this design of his polyrhythmic drum sequencer, we had
to make it. I wired up the multiplayer backend Thursday evening and built out
the rest on Friday.

Now we all get to play. Thanks Mark!

   [1]: https://blog.partykit.io/posts/partycore-140bpm-with-tonejs

   [2]: https://partycore.labs.partykit.dev/rooms/1999

   [3]: https://github.com/partykit/sketch-sequencer

   [4]: https://github.com/partykit/remix-starter

   [5]: https://docs.partykit.io/reference/y-partykit-api/

   [6]: https://github.com/partykit/sketch-sequencer/blob/main/party/sequencer.ts

   [7]: https://github.com/partykit/sketch-sequencer/blob/main/app/hooks/use-sequencer.tsx

   [8]: https://tonejs.github.io

   [9]: https://www.partykit.io

   [10]: https://thinkm.studio


