ahlstromcj / seq66

Seq66: Seq24-based live MIDI looper/editor. v. 0.99.16 2024-12-03. NSM support; Linux/Windows/FreeBSD; PDF manual & tutorial with Help access.
https://ahlstromcj.github.io/
GNU Free Documentation License v1.3
158 stars 14 forks source link

Toggle MIDI Recording via CC message #66

Open szszoke opened 3 years ago

szszoke commented 3 years ago

It's me again. I ended up getting a Launchpad Pro MK3 and I started setting things up.

I have the loop control and play/pause working so far.

I'm trying to set up a toggle for the MIDI Recording button.

Is that supported?

ahlstromcj commented 3 years ago

Should be. Haven't tried Song Recording lately. Is the Pro MK3 partly compatible with the Mini? Would save some time to use the existing mini ctrl if so. Let me know if recording works as you expect. I'm sure there's some bugs lurking. On another note, I have an idea to wedge additional functionality into [loop-control]. Will eventually get to that....

Thanks for your reports!

On Tue, Nov 9, 2021 at 17:58 Szabolcs Szőke @.***> wrote:

It's me again. I ended up getting a Launchpad Pro MK3 and I started setting things up.

I have the loop control and play/pause working so far.

I'm trying to set up a toggle for the MIDI Recording button.

Is that supported?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ahlstromcj/seq66/issues/66, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB45LKA7HDUYDTTMC2GBUSTULGRQHANCNFSM5HWO6BYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Chris Ahlstrom

szszoke commented 3 years ago

It's not song recording that I'm trying to do.

I'm trying to control the MIDI Record Toggle (page 63 in the manual) button. As far as I know this should be supported but I couldn't get it to work.

Another question is that it seems this button is activated individually for each pattern. It's not obvious how a specific pattern can be targeted when a CC message is used.

szszoke commented 3 years ago

There are some similarities between the devices but I ended up starting from scratch just so that I familiarize myself with the config files.

ahlstromcj commented 3 years ago

Ah, thanks for the clarification! Right now drinking wine and getting ready for sleep time. I will look into all this soon.

On Tue, Nov 9, 2021 at 18:46 Szabolcs Szőke @.***> wrote:

It's not song recording that I'm trying to do.

I'm trying to control the MIDI Record Toggle (page 63 in the manual) button. As far as I know this should be supported but I couldn't get it to work.

Another question is that it seems this button is activated individually for each pattern. It's not obvious how a specific pattern can be targeted when a CC message is used.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ahlstromcj/seq66/issues/66#issuecomment-964646059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB45LKEMO4ESFJW2LKTG7ULULGXD7ANCNFSM5HWO6BYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Chris Ahlstrom

szszoke commented 3 years ago

No worries! Enjoy your wine :)

szszoke commented 3 years ago

It seems that Seq66 sees the MIDI CC message but nothing seems to be happening.

Here is the output with the --verbose switch:

Record 'Toggle'; d0 = 1; d1 = 17; inv = 0

Here is how I assigned the CC message to Record:

17 "KP_*"        [ 0 0xb0   1   0   0 ] [ 0 0x00   0   0   0 ] [ 0 0x00   0   0   0 ] # Record
ahlstromcj commented 3 years ago

I know the LaunchPad Mini's top row of (circular) buttons emit 0xb0 XX 127 on press and 0xb0 XX 0 on release, where XX is the button number ranging from 104 to 111. So make sure you are using the right XX value.

Also, depending on what value your Launchpad emit, change the "0 0" to "1 127" or "127 127". I would suspect your more-sophisticated Launchpad might emit a value that depends on how fast/ you press the key. An example:

10 "." [ 0 0xb0 106 127 127 ] [ 0 0xb0 107 1 127 ] [ 0 0xb0 105 1 127 ] # Playback 11 "P" [ 0 0xb0 109 127 127 ] [ 0 0x00 0 0 0 ] [ 0 0x00 0 0 0 ] # Song Record

If it still doesn't work, let me know. There's always a chance I broke something. (You should have seen how I broke JACK transport completely once! Embarassing!)

Also take a look at the Mini spreadsheet in the "doc" directory. That show's diagrams for the Mini (only).

szszoke commented 3 years ago

My device just emits two CC messages. One on press with the value of 127 and another on release with the value of 0.

I'm still don't understand how Seq66 knows which loop to arm.

I tried to set the Record option to a keyboard shortcut so that no MIDI controller is in the equation. The key press is detected as "toggle Record" but nothing actually happens.

ahlstromcj commented 3 years ago

The loop number is based on the row number in loop-control

Unfortunately, for keystrokes in the [automation-control] section, there is no way to specify the loop number. So automation keystrokes are basically limited to toggle.

Will beef up the documentation soon; I have surveyed all the controls to refresh my memory of how they work.

By the way, you can find a programmers manual for the launchpads. The one for the MK3 is kind of confusing, not as well written as the one for the Mini.

szszoke commented 3 years ago

But what does that mean? Is toggling the Record option in [automation-control] supposed to toggle the MIDI Record option for all loops?

ahlstromcj commented 3 years ago

The Record option for keystrokes doesn't do anything. Although your idea about it sounds interesting and I will try that at some point to see if it is workable. The problem with keystrokes is that the have only two states, press and release, where as MIDI controls have d0 and the d1 range, so they are capable of lookup.

d1 is currently used only to test if the MIDI event is usable/valid. I will probably make it usable to choose items in the next release, 0.97.3. The new and current release is 0.97.2, just pushed it to master today.

Sorry about the issues, but thanks for giving me some more things to try!

szszoke commented 3 years ago

No worries. I in the meantime tried Ableton and Bitwig which both support my Launchpad I'm thinking that taking inspiration from how they handle arming a pattern for recording could worth a try.

The only thing is that it requires stateful MIDI controller handling.

By that I mean that the functions of the main grid buttons depend on what "state" was activated earlier.

If the program is in "arm for recording" mode then the grid buttons arm or disarm patterns for recording and overdub.

If the program is in "loop control" mode then the grid buttons play/pause patterns.

ahlstromcj commented 3 years ago

Hmmmmm. I had not thought of "modes". Going to think about that one. Thank you!!!

On Thu, Nov 11, 2021 at 11:14 Szabolcs Szőke @.***> wrote:

No worries. I in the meantime tried Ableton and Bitwig which both support my Launchpad I'm thinking that taking inspiration from how they handle arming a pattern for recording could worth a try.

The only thing is that it requires stateful MIDI controller handling.

By that I mean that the functions of the main grid buttons depend on what "state" was activated earlier.

If the program is in "arm for recording" mode then the grid buttons arm or disarm patterns for recording and overdub.

If the program is in "loop control" mode then the grid buttons play/pause patterns.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ahlstromcj/seq66/issues/66#issuecomment-966431056, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB45LKGWIA2MKZJ4EIAMKR3ULPTUXANCNFSM5HWO6BYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Chris Ahlstrom

ahlstromcj commented 3 years ago

I added a couple of modes. First, the control mode for clicking on the grid buttons or sending keystroke/MIDI commands. There is a button in the main window to cycle between: Loop, Overdub (same as Merge in the pattern editor), Overwrite, Expand, and One Shot. In the recording modes, a red circle appears in the slot the is recording.

Another button controls the recording mode: Normal, Quantize, and Tighten. The latter two add "Q" or "T" to the red circle indicator, respectively.

There is currently a trick there. Quantize and Tighten can turn on recording, but cannot turn it off. Also there is still a remaining bug where the record indicator remains lit.

Also, the 'ctrl' file commands "Record" and "Quan Record" have been modified to perform the functions of those new buttons.

Let me know of any thoughts or issues you have for this new code. Thanks! (See the "optimizing" branch).

szszoke commented 3 years ago

I tried running the application but I might be something wrong here. Nothing really happens when I press the buttons.

ahlstromcj commented 3 years ago

Hmmm, the buttons should change text every time you press them:

Loop --> Overdub --> Overwrite --> Expand --> One-shot --> back to Loop

Note that the states after "Loop" correspond to the recording handling drop-down in the pattern editor:

       Merge   --> Overwrite --> Expand --> Oneshot

When the Loop button is pressed and goes into one of the other modes, then the button to the right of it comes into play. It allows for normal recording or for quantization of the events while recording:

       Normal --> Quantize --> TIghten --> back to Normal

It would be cool to be able to change something about the whole grid to indicate this, but I haven't thought about that.

Here's an example:

- Create or load a tune with patterns.
- Pick a pattern and verify that clicking on it unmutes/mutes the pattern.
- Open the pattern editor for one of the patterns.
- Click the Loop button; verify it changes to Overdub.  You are now in a
  Record mode.
- Click the pattern slot. This should happen:
  - The pattern slot shows a red circle indicating record mode is active.
  - The pattern editor's Record button becomes active.
  - If Quantize or Tighten are in force, a "Q" or "T" will show up in the red
    circle.

After that, the following can happen, but some bugs are still present with this feature in its incomplete progress (still workin' on it!!!).

- Clicking again should turn off the red indicator and the pattern editor's
  record button.  NOT WORKING YET.
- If the Record mode is Quantize or Tighten, the "Q" or "T" letter will
  disappear, but the Record mode is still active.  This follows the current
  rules of the buttons in the pattern editor.

I obviously still have work and documentation to do.

Anything you can add (complaints, preferences...) will help me get this Mode stuff working clearly. Thank you for your input so far!

-------- Szabolcs Szőke 11:34 Wed 17 Nov --------

I tried running the application but I might be something wrong here. Nothing really happens when I press the buttons.

szszoke commented 3 years ago

Your last comment helped a lot!

It works as you said and it looks really good now.

One final thing would be the possibility to assign a CC message for idividual modes.

In my case I would be mostly using the Loop and the Overdub mode.

The ideal flow would be that on startup the app is on loop mode and that is also the "neutral" mode.

Then if I send a CC (let's aay CC1) message, that will trigger the overdub mode. If I send the same the CC1 message then that will trigger the neutral mode again.

If I'm already in a non-neutral mode and send a CC (let's say CC2) to switch to a different mode, like expand, then the active mode should switch to that.

If I send CC2 again then the mode should be switched back to neutral.

In a more algorithmic way, I want CC messages to be able to trigger specific modes. I also want that whenever the CC message of the currently active mode is received then the mode switches back to neutral.

If you want flexibility, you can make it so that the neutral mode is configurable.

The only thing that is still unclear is how to implement LED feedback.

My launchpad has no concept of these modes, so whenever there is a transition of modes in Seq66, a set of MIDI messages should be sent out.

The easiest would be to add "on" and "off" messages to each mode, and then when when there is a mode transition, the following would happen:

  1. Old mode off message sent
  2. New mode on message sent
ahlstromcj commented 3 years ago

Right now, there are already controls for those two buttons. They cycle through the modes of each button. For the Loop button, hitting it 5 times goes through all the mode back to the Loop mode. Similar for the Normal button.

Not sure it is worth adding extra commands (using up 7 more automation slots!), but I will think about adding a "flip mode" or "toggle mode" that will simply toggle from Loop to the selected mode of the recording mode, etc.....

In any case, in the default 'ctrl' mode, the Keypad-* key is assigned to stepping through the loop modes, and the Keypad-+ key is assigned to stepping through the normal/quantize/tighten mode. Haven't had a chance to set up a 'ctrl' test of these for the Launchpad Mini, yet.

I'd also like a more obvious way to see the modes. Maybe changing the button colors, or, if possible, the color of the grid background.

Thank you for all the good ideas!

-------- Szabolcs Szőke 04:06 Sat 20 Nov --------

szszoke commented 3 years ago

Actually I have been thinking about the mode transition logic and it would be nice to have support for temporary transition.

Here is my original suggested flow

1. Controller button pressed
2. MIDI CC message with `on value` sent
3. Seq66 reacts to the message and changes modes
4. Controller button released
5. MIDI CC message with `off value` sent
6. Seq66 does nothing
7. ...
8. Same controller button pressed
9. MIDI CC message with `on value` sent
10. Seq66 reacts to the message and changes to neutral mode
11. Controller button released
12. MIDI CC message with `off value` sent
13. Seq66 does nothing

A temporary transition would be engaged by holding a button down on the MIDI controller and then releasing it later.

While the button is held down, Seq66 switches to the configured mode, the grid buttons can then be used to engage with the mode. When the button is released, Seq66 switches back to the previous mode and not to the neutral one.

This could be implemented via a timer that starts when a CC from a button press is released. If the button is released under a threshold amount of time then the mode is toggled permamently. If no button released CC message is received within a threshold amount of time then the transition becomes temporary and when the button released CC message is finally received then Seq66 switches back to the previous mode.

szszoke commented 3 years ago
Not sure it is worth adding extra commands (using up 7 more automation slots!),
but I will think about adding a "flip mode" or "toggle mode" that will simply
toggle from Loop to the selected mode of the recording mode, etc.....

I would say it does within the context of a MIDI controller. The idea is that with a MIDI controller you could assign different functions to a single button.

It would also fit nicely with a Launchpad where apart from the grid buttons, there are "mode" buttons on the side.

szszoke commented 3 years ago

I think modes generally should be triggerable individually. Especially if there will be more to come in the future, it will get messy when you only have a single button for them.

I'm thinking that a next candidate would be for copy and clear mode.

In copy mode, the first grid button press would highlight a pattern and the second one would paste it to the appropriate slot.

On clear mode, the patterns could be emptied or removed via the grid buttons on the controller.

ahlstromcj commented 3 years ago

We could end up with a lot of modes, perhaps more than keystrokes could support. If a MIDI controller can emit specific D2 data programmably from 0 to 127 (for Notes, D1 is the note number and D2 is the velocity; for Controllers, D1 is the CC number and D2 is the value), then we could consolidate modes in one command (and preserve the stepping through the modes as an alternative for less flexible controllers).

There is a lot to think about!

-------- Szabolcs Szőke 05:09 Sat 20 Nov --------

-- The human race has one really effective weapon, and that is laughter. -- Mark Twain

szszoke commented 3 years ago

I think if you try to keep feature parity between MIDI controllers and standard PC keyboards, you will eventually run out of keys and keyboards will hold back MIDI controllers.

Also consider that not everyone would use exactly all of the features.

People can set up custom keymaps with features they need.

I'm not asking you to build something that only works with a MIDI controller.

I'm asking you to consider providing options.

As for the Launchpad, in programmer mode which I'm planning on using all the buttons have fixed and separate MIDI messages that cannot be changed.

szszoke commented 3 years ago

Ideally there would be an automation control for cycling through the modes and one for each mode separately.

Then people could chose if they want to set up a control that cycles through the options or set up a control that instantly activates a specific mode.

ahlstromcj commented 3 years ago

I will likely be adding a whole new slough (slew?) of automation controls at some point. I am still thinking about it and am also fixing some issues I found with the existing automation container, which has 113 keys and 339 MIDI commands.

I've surveyed some controller pads; they all seemed to be geared toward Ableton :-D

And none of them seem to allow changing the value part of a CC messages. I would like to leverage velocity and data values to increase functionality, but these devices (Akai, Novation) don't support that.

-------- Szabolcs Szőke 09:52 Sat 20 Nov --------

szszoke commented 3 years ago

Indeed the controllers don't support changing the value of the CC messages because the idea is that the DAW that integrates them will build a state machine.

This state machine will then just listen for the CC messages and depending on the current state, the same CC message might do one thing or another. This is how you can increase the functionality of the buttons.

I will soon take my winter vacation and I will likely work on a state machine implementation that essentially implements the buttons the same way they work in Ableton.

At the very beginning it will be something that is somewhat generic but mostly designed to work with the Launchpad Pro MK3.

I will eventually want to add support for this controller in Ardour.