Re: [Loopdub-devel] Synchronizing MIDI controls with LoopDub
Brought to you by:
radarsat1
From: Stephen S. <rad...@gm...> - 2007-12-30 03:33:57
|
Hi, I'm afraid I don't have time to give you a point-for-point answer right now. I've thought about it a bit, but in fact I think a lot better about these things in C++ rather than in english, so I started coding a little to see what issues might arise. I have to thank you for making me take a critical eye to the midi code, I haven't looked at it in a while. I was horrified to find that the control codes are indexed by slider rather than the other way around.. It means each CC message received is passed through a whole series of if/else clauses-- ugly! Thinking about my suggestion for how to do it, I created a class to represent MIDI values. Each one is assigned to a control code when the configuration file is loaded, and each one has access to a GUI slider. (I had to create some base classes for the GUI sliders and buttons to abstract the Set/GetValue functionality, which I think is probably a good idea anyways..) There are two Set functions for the MidiValue class, one is SetValue() which is equivalent to your "internal" CtrlSource enum, and the other is ReceiveCC() which is equivalent to "midi" CtrlSource. Depending on which of these functions is called it will set the state of the MidiValue as NEEDSYNC or PICKUP. Anyways, this can be found in the "feature/midisync" branch in git. It's not at all complete, but should give you some idea of what I'm talking about. I'm not at all sure this is better or worse than what you suggest.. perhaps the LoobOb is afterall the right place for this stuff. However I think it's definitely a good idea to reduce the processing that occurs whenever a CC message is received, and indexing the sliders by control code is probably necessary, so I'm glad I had a hack at it. I would be interested to know what you think, and how it differs from your approach. There are only two points in your message that I think I disagree with. First is the necessity of handling this corner case where the user unplugs a MIDI cable and reattaches it. I have little interest in handing that case -- if the user is doing such a thing, he'll expect things to go strange, and a key command 's' to re-synchronize manually is probably sufficient, as we have now. Secondly, > 2. When we receive a CC message, if is exactly one tick away from the > current internal value, then we update the value. If it is not, then > we know that the MIDI slider and the internal slider have drifted > apart, and the user needs to get them back into sync before we will > respond to their CC messages. I think it is quite dangerous to assume that all CC messages will be exactly 1 tick apart. You mention yourself that it won't handle the button case -- there may be other cases where the user wants to set everything to a particular value. (Loading a preset for example.) My idea for 'pick up' was to only enable that state when a sample is loaded (i.e., the 'internal' case, a context change.) It might also be useful for when the user moves a slider, but again, this state is deterministically available to the program and doesn't depend on the difference between two successive CC values. cheers, Steve |