Coder Social home page Coder Social logo

Comments (10)

brunchboy avatar brunchboy commented on May 16, 2024

Interesting, it would be worth looking into deeper when you have more time. I agree, it may be related to the fact that the cue ends over time. But it could be some other thing too, would be worth looking in the logs, perhaps adding debug statements, and watching the MIDI event log. I have found sometimes my pads don’t send all the events they are supposed to.

from afterglow.

brunchboy avatar brunchboy commented on May 16, 2024

Looking over this again, I thought the problem could not be due to the fact that it takes a sparkle cue a while to end, because show/add-effect! is perfectly happy to replace a running effect with a new one when you add it with the same keyword. But I wondered if something might be going on at the level of the MIDI/cue binding function. And indeed, there is a bug there. This section of add-midi-control-to-cue-mapping checks if the cue already has an effect running, and based on that decides if it should end or start it:

;; Control or note has been pressed
(if active
  (end-effect! (:key cue))
  (reset! our-id (add-effect-from-cue-grid! x y)))

While that made perfect sense before I added the :held flag, it doesn’t work when you want to use :held, as you are in your example. So you are right: When you let go of the button, your mapping tells Afterglow to start ending the cue, but sparkle can take a while to end, so if you hit the button again quickly enough, rather than starting a new sparkle, the mapping will ask the show to end the one that is already ending, which will kill it at that point, but never start your new one.

So I will change the logic so it checks (if (and active (not (:held cue)))). That means for your held cue, pressing the button will always start a new effect, even if the old one has not quite finished ending.

Please let me know if this change solves the issue for you. I found the same logic problem exists in the Ableton Push mapping, and making this change there fixed it for me. (I had not previously noticed it because my default sparkle fade time of 50ms was short enough that I never hit the button again fast enough to trigger it. But experimenting with turning up the fade time before releasing and pressing revealed exactly the issue that you reported.)

And as I was about to commit the fix, I realized that the web UI has the same issue, and fixed it there as well. Thanks for catching this! 👍

Also, does your MIDI controller support pressure sensitivity and aftertouch? I see I have a TODO to add that capability for generic MIDI controllers, and if we can test it with yours, that would be helpful. Sparkle is very nice with pressure sensitivity affecting the chance variable on the Ableton Push.

from afterglow.

dandaka avatar dandaka commented on May 16, 2024

I have a few MIDI controllers. I think all of them have pressure sensitivity (you meant velocity?) on pads. Also I have Quneo, which has velocity + x + y on the same pad at the same time, need to find some time to do mapping and experiment.

I was planning to map these additional axis as another MIDI parameters to the Sparkle effect. Are you suggesting something else?

from afterglow.

brunchboy avatar brunchboy commented on May 16, 2024

When I was talking about pressure sensitivity, I meant two different aspects. Velocity is the first, so the note-on message reports how hard you pressed it. Then aftertouch is another series of MIDI messages which get sent while you are holding it down, so you can vary the pressure. The Ableton Push has both of those features, and your controllers probably do too.

In order to take advantage of these features, when you create a cue, you can also create cue-specific variables for that cue, as part of defining the cue. These variables can either exist separately, or get added to the show with unique names when the cue is started, and removed when it ends. On the Push, the first two variables get displayed in the text area, and you can manipulate them with rotary encoders above the display. You can also assign one of the variables to be affected by velocity and aftertouch, and that relationship will automatically be set up when you launch that cue with one of the pads. This is done using the :velocity, :velocity-min and :velocity-max keys described in Table 2 in Creating Cues.

I would like to make that velocity and aftertouch relationship automatically work for your controllers as well; I just need to copy the code from the Push mapping into add-midi-control-to-cue-mapping.

But it would be nice to be able to add support for your x and y axes on your Quneo (I assume those have aftertouch as well as velocity components too). Then a cue could have up to three different variables introduced and automatically tied to the pad when you launch it. How do the additional axes work? Are they separate control channels, or something else? Can you point me at documentation? I could try to implement support for them in the mapping, and then you could tell me if it works.

I also hope to add support for viewing and manipulating cue variables to the Web UI this week. It has been on the to-do list for a long time.

from afterglow.

brunchboy avatar brunchboy commented on May 16, 2024

All right, I have implemented velocity and aftertouch support for cue variables in add-midi-control-to-cue-mapping. But note that in order to do that, I had to move the function to the afterglow.effects.cues namespace. I put a stub in afterglow.show so your code that is calling it there will still work, but it is deprecated and will be removed in a future release, so you should update those calls.

If you are using the same sparkle cue I had in my examples.clj, and you seem to be, all you need to do to enable the velocity and aftertouch sensitivity (after updating to the latest snapshot) is change the call where you map the cue to a note on your controller so it includes :use-velocity? true at the end of the parameter list.

So, in my-show.clj at line 240 where you had:

(show/add-midi-control-to-cue-mapping "Automap MIDI" 10 :control 51 0 7)

instead use:

(cues/add-midi-control-to-cue-mapping "Automap MIDI" 10
     :control 51 0 7 :use-velocity? true)

That would set the value of the sparkle :chance variable based on the velocity of the control when you pressed it. If you want to be able to vary the variable by pressing harder and softer while holding it down, you will need to switch to a controller that sends note messages rather than control-change messages, and which supports aftertouch (polyphonic key pressure). Then it would look something like:

(cues/add-midi-control-to-cue-mapping "Other Controller" 0
     :note 43 0 7 :use-velocity? true)

If your Automap MIDI controller sends control-change messages with different velocities while you hold down the pad with variable pressure, and then a zero velocity when you release it, please let me know! I will need to add different code to support controllers that work that way, if any do.

Please let me know if any of this stuff seems to work for you!

from afterglow.

dandaka avatar dandaka commented on May 16, 2024

I need to fix #46 to close this.

from afterglow.

dandaka avatar dandaka commented on May 16, 2024

I can't test :use-velocity, since my controller doesn't have "polyphonic aftertouch" feature.

Instead it has 3 CCs for each pad — velocity (kind of), X and Y position. Mapping these CC to Notes with velocity has turned out as a hard task. And I don't see necessity, since I could map CCs to any parameters, including (and not limiting) to chance and duration.

from afterglow.

dandaka avatar dandaka commented on May 16, 2024

I have tested the original bug and it seems disappeared. Closing this. If you need me to test :use-velocity, let me know in another issue.

from afterglow.

brunchboy avatar brunchboy commented on May 16, 2024

Thanks, that’s great! I have tested :use-velocity with some of my own controllers, so I am willing to accept that it is working until we get an issue from someone else. 👍

from afterglow.

brunchboy avatar brunchboy commented on May 16, 2024

I should try to get some other interesting controllers to experiment with, perhaps a MIDI Fighter. Ah, an excuse to buy hardware to play with… 😊

from afterglow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.