# Clojure Sound - 5 - Double Click with Foot Control

DevFeed: [Clojure Sound - 5 - Double Click with Foot Control](<https://devfeed.tech/articles/clojure-sound-5-double-click-with-foot-control-20723.md>)

Original publisher: [Read original article](<http://dragan.rocks/articles/22/Clojure-Sound-5-Double-Click-with-Foot-Control>)

Published: 2022-07-30T15:45:00Z

Content type: tutorial

Language: en

Sources: [Dragan Djuric](<https://devfeed.tech/sources/dragan-djuric.md>)

Topics: [Clojure](<https://devfeed.tech/topics/clojure.md>), [MIDI](<https://devfeed.tech/topics/midi.md>), [Playback](<https://devfeed.tech/topics/playback.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [audio](<https://devfeed.tech/tags/audio.md>), [clojure](<https://devfeed.tech/tags/clojure.md>), [desktop](<https://devfeed.tech/tags/desktop.md>), [interface](<https://devfeed.tech/tags/interface.md>), [music](<https://devfeed.tech/tags/music.md>), [playback](<https://devfeed.tech/tags/playback.md>), [sound](<https://devfeed.tech/tags/sound.md>), [user-interface](<https://devfeed.tech/tags/user-interface.md>)

## AI overview

This article discusses designing foot-controller gestures for a Clojure audio player. It examines button press, release, and double-click signals, and describes how those signals could control clip playback and address the need to rewind tracks.

## Source excerpt

In the last article we created a receiver function that listened to signals from our foot controller and started or stopped playback on consecutive clicks. The trouble with our player it that it only works until the end of the track. The start! function does not automatically rewind the playback. Neither stop! does that. Our program is responsible for detecting that the track should be rewound, perhaps by detecting that we reached the end of track (but even that is not fool proof, since audio infrastructure is not that precise). Now we have to think about a foot user interface that is useful and simple at the same time - there's not many different precise actions that a foot can do. My idea at this time is the following: distinguish three gestures: Button (un)pressed (value 0) Button pressed (value 127) Button pressed twice in a short time span (doubleclick). This can have two varieties: First pressed (value 127), then (un)pressed (value 0) (Un)pressed (value 0), then pressed (value 127). The values 0 and 127 always interchange, there's no way to send the same value twice in a row (with the MIDI controller I have). This gives us 4 different signals from one button that we can work with, which doesn't seem that much, but on the other hand, we can't assume that the feet of our user that is doing all this stomping is able or eager for much more complicated stuff. So, if I assume that the particular button is dedicated to a particular clip playback, I see the following actions: If the button is (un)pressed (value 0), the clip should stop, regardless of the previous state. If the clip has not been playing, nothing changes. If the button is pressed (value 127), the clip should start, regardless of the previous state. If the clip has been playing, it just keeps playing. If the button is clicked twice in a row, the things might get complicated! It's not exactly rocket science level complicated, but we still need to think what to do. In our desktop user interface toolkits, w