Scamp with mouse scrolling input

I tried to combine what I did so far inspired by shiihs performance with a dyi synthesizer to do something similar with scamp and user input:

It works by scrolling the mouse up or down which moves the currentCounter by one up or one down,
or if you prefer more randomly, than just move the mouse. If you do not move the mouse, than it will play loops. A click on the mouse will change the instruments.

I hope you enjoy.

And also: Thanks Marc and shiihs! This is such a fun as opposed to writing everything at once in a midi.

Hi Marc,

I tried to do a user window with pygame and use scamp in the background. It works like this:

It has 48 counters. Each counter can be increased by pressing the left Mouse button above the counter or decreased by pressing the right mouse button above the counter.

This way the user has endless possibilites with working with different counters.

(At the moment only the first three top left are implemented.)

But it does not run smooth. I suspect this is because there is some clock in the background which is not synchron.

Do you have any idea how to solve this (only the main() function)?

Just found out about musicxml to record the session! That is great. I made a quick and dirty video capturing with musescore:

The code can be found above! :slight_smile:

The tutorials in github are great, by the way.

1 Like

Love this! It’s really great using mouse input to turn the music into a kind of explorable space. I enjoyed playing around with it.

By the way, scamp does have the Session.register_mouse_listener function, which actually uses pynput under the hood. (There are also keyboard listeners, osc listeners, and midi.) What these functions do, in addition to wrapping the relevant pynput code, is wake up the clocks. I don’t think this is important in your case, but sometimes it can be. For instance, if you want a note to be played with every mouse click, if the session is sleeping when the mouse is clicked, it needs to be woken up.

But, if you don’t need that kind of immediate responsiveness, and you’re happy with the changes taking place when the session wakes up, it may be more efficient to use pynput directly, since it doesn’t have the overhead.

So, when you have a GUI framework, it often has it’s own way of managing time. In this case, it’s often best to run the session as a server. See this example:

This example might also be a good one to check out, though it’s a little complicated (it uses PyQt):

You can see in the code that I’ve set the mouse press event to call the Barlicity.start() function, which then instantiates a Session, asks it to run as server, adds some instruments, and forks the playback functions.