You are here

Midi control for QTractor

I'm experimenting with external midi control for qtractor. For example, I have a midi device connected to qtractor that sends cc7 volume changes for a particular channel. Those changes doesn't seem to have any effect on qtractor, in the mixer the volume stays where it is. is there a way, perhaps, to enable such behavior so I could change channel volumes (and maybe other things) from external device?

Best regards,
Marko

Forums: 

Hi again, please let me tell you what I did. I implemented a new class "qtractorMidiController" which should do a kind of mapping midi controllers to functions inside of qtractor. I'm pretty sure, that some things I did in the code are more like hacks, than a fine programming. And of course, my implementation is missing a GUI.
Another problem is, that you mentioned that you did you implementation with the MVC pattern. This means, that with my MidiControllerMap i am adding a new controller and view. And as the controller does update the view, a lot of code has to be copied into the MidiControllerMap. I think, one should implement the VIEW with an observer pattern, so that the MidiControllerMap is just another observing view which reacts on changes of the model data. What do you think?

Maybe I should send you my code? Unfortunately I did my changes to the 0.4.1 version and therefore I would have to update it to the 1317 revision. Please let me know, what is the best way for supporting the project.

rncbc's picture

Although I've been referring to the MVC pattern before, that was just theoretic I'm afraid. Current code is just a big bunch of hacks glued together :)) No sweat. Your proposal seems conceptually similar to the one I have in mind.

Of course you can send your code as is or whenever ready for review.

Cheers.

Hey Rui,

so ok (after some days of holiday): Here you can find my first tries to implement the so called "MidiControllerMap". Please be aware that this is only a fast try to get into it. Unfortunately it is based on sources from 0.4.1 but I think, that's ok for a discussion about how to go on. I think you have to add the new class to the makefiles .... i just added them by hand...

So here's what I did (or better: What I wanted to do *g*):
I created a class "qtractorMidiController" (which should be renamed to "qtractorMidiControllerMap"). It includes a MidiControllerMap which maps Midi CC messages to functions with its parameters. This is something like they did in hydrogen. At the moment, this map has no gui, so I create the map in the constructor by hand. At the moment, I am configuring 8 channels with PAN, LEVEL and MUTE functionality.

One of the biggest problems is, that at the moment, the COMMANDs do all the updates of the GUI and other things. Thats why I added a call to MidiControllerMap for all the TrackGainCommands, TrackButtonCommands and TrackPanCommands, I think, the commands should only update the model data, and then, the observer pattern could be used, to update the GUI and all the other stuff. My "MidiController" would then be another subscriber of the model data. What do you think?

The function "resendControllersOut" is used, to actualize all the outside controllers, but at the moment, the data is not initialized when loading a session. I think, this will also be fixed with the observer-pattern.

The last thing, is, that I did not manage to build the right converting function from MIDI CC messages with its ranges to the db values of the TrackGains .... but that's another issue....

It would be great if you could have a look at the code and maybe test the functions (just connect the BCF to the dedicated control ports of qtractor)... and then, give me some instructions... as far as you think that I am able to help you....

regards,
mathias alias gizzmo

rncbc's picture

Howdy! Been busy lately and didn't had the time to work out on your implementation. Sorry. From the least I could see, it looks promising :)

Took the chance and made some rather minor restyling tweaks, nothing much and brought the code to latest CVS HEAD (currently qtractor 0.4.1.1317). The complete patch is here (-p1) -- nb. includes project makefile changes so it's ready to go:).

Cheers

Thanks for that quick overview *g*
Sorry for the need to restyle the code .... i tried to take your style, but it seems that i did a lot of mistakes *g* ... sorry for that ... i will try to do it better...
now ... the next thing i will try to do is to restyle one part implementation and try the use of the observer pattern ...

rncbc's picture

No need for apologies on the style front. There were just kind of nitpickings ;)

I'm also working and trying on the observer pattern (GoF) to this very purpose. You can have a look at my experiments, as a stand-alone, kind-of sandbox code, here. I'm not making it through the official Qtractor CVS tree just yet because it's still in its early conceptual phase. There's too many things to think about before a proper integration. But you can have a try on it just for the fun :)

Seeya

I had a look at your experiments. Looks very good, doesn't it? As I can see, you're planing to use the observer pattern for the midi controller... what I would suggest is to go further: Use the observer pattern for all the model data changes. For example, if the gain of a track is changing, the mixer and the midi bus (and the midi controller map) are implemented as observers to the track gain data. What do you think?

OK, as you're just experimenting with that midi controller observer thing, i think i should not bother you, with hacking codes in a similar direction but in a different way. Maybe I should take another issue from the TODO and put my mind into that? Maybe something I was missing yesterday (compressing and expanding velocity values of a midi track, add and subtract velocity values of a midi track, or a thing called DRUM track). What do you think?

rncbc's picture

An update to the observer sandbox (here), now with the help of the visitor pattern, or sort of -- it's all GoFun :)

Seeya

rncbc's picture

hi Jim,

I'm glad you can pick the manual stuff yet again. The New Mexico guy, from whom we don't have notice whether he still lives in that state or else, is absent_with_leave. We shall await for him to catch up later. You must realize now and comfortable enough that we ain't under any pressure nor deadline. So to speak ;)

However, the latest manual incarnation is not that disparate from your seminal writing. I'm pretty sure there's just additions and not deletions or transliterations. Awe. You can pick it up from latest 0.3.0 ODF source and play on ;)

Give it a go, or do whatever you feel it's better

Cheers

I am sorry, but I have to tell you, that changing the winecfg did not help with this problem. But I reallized, that a special VSTi is the problem. It is the ORGANized Trio. It's a pitty because it is a really good sounding Hammond sound :-( ...

Humm, I'm not sure dssi-vst supports VSTi. VSTis are stand-alone executables, aren't they?. I must have overlooked that before. Have you tried just running "wine Organized.exe" (or whatever)? It may also improve things if you get and install wineasio as well. http://sourceforge.net/projects/wineasio

Lexridge

Hi Lexridge,
sorry, I mixed something up. What I meant was a VST Pluginn. So just a .dll file. But this ORGANIZEDTrio.dll implements a midi instrument. Sorry for that. I will play around with some sample-rates as I think it has something to do with it. Thanks for your thoughts, but I think as one of the 1000 VST Plugins is not working, it surely has something to do with the plugin....

Ah, okay.

You could also try fst instead of dssi-vst. I've had varying success with fst, mainly GUI issues. eg, even though the speed control doesn't move in B4 when clicking on it, or the keyboard doesn't push down when clicking on the keys, they work nonetheless. Just zero visual feedback on this particular vst app.

Lexridge

If I use the vsthost instrument.dll and then connect a midi output from qtractor to it, the problem does not exist. Unfortunately this way is not satisfying, as the presets cannot be saved in this mode...

Today, I tried out some example vsts with FST. Works well. Every instrument with doesn't produce any output with dssi-vst seems to work. So, the multi million dollar question: Is there a way to include FST in qtractor? At the moment, I do have to start lashd, and then start the fst with its instrument. For a big session, this is really a lot of work...

Hi Rui,
Thanks a lot for your beautiful software!
I'm really looking forward to using the knobs on my m-audio axiom 49 to control qtractor and also to be able to draw nice automation. :)
Do you have any ideas of when those features will be implemented?
Cheers.
boost wifi signal

rncbc's picture

duh :-) it's all in there already, since this pre-holidays relase (qtractor 0.5.0) you can't miss it

thanks && cheers

rncbc's picture

Getting back to your MidiControllerMap code, after a few hours dabbling with the keyboard, making some cleanups and refactoring here and there, specially on the qtractorTrackCommand front, here goes a second version of the patch which applies to current CVS HEAD (qtractor 0.4.1.1317 still).

You may notice that I've renamed the qtractorMidiController class and files to qtractorMidiControl; made even more code restyling (SCNRT:); all subject actions have moved to a newer qtractorTrackControlCommand base class that now accounts for proper MIDI controller triggering; with additional control targets TrackRecord, TrackSolo and TrackMonitor, just in case ;) etc. etc.

Please try and hopefully report whether it works as originally designed (by you). It still has the hardwired settings, which I think is applicable to the BCx2000. You tell me, please...

Cheers

rncbc's picture

@gizzmo:

Third version for the MidiControllerMap is here. It's getting pretty final and ready to apply against CVS as is. Notice that it has been through a major rewrite since last one. Most importantly, it now handles MIDI channel and controller generic mapping, like wildcards wrt. tracks, in addition. A feedback flag is now also featured which is specially intended option for motorized faders support, as eagerly awaited for the BCF2000:).

As before, please have it a go and tell. As said this will be soon be delivered in main trunk.

Things still missing:

  • in-session and/or stand-alone load/save;
  • a map user interface (editor);

Enjoy.

Hey Rui,
wow, you're so fast? How do you manage your time to get these things done so fast?
I had a quick look at your source code... i think there's nothing left which was written by me ;-(... but it looks very good and i hope i will understand what you're doing there...

I tried it out with the BCF2000 but I can not get things to work. I think i will try to activate some debugging output (i see there's a define CONFIG_DEUB). When I shut down qtractor, my system hangs, that means, that qtractor does never stop .... but maybe this has nothing to do with qtractor ... maybe its an ubuntu-update-thing *g* ... i will have to do some investigations ... before making some music...

EDIT: Ok ... it was an ubunut-update think. I had to switch back to the older realtime-kernel, otherwise usb-midi is not working. Now, everything seems to work fine. Great!

If i could help you in programming something, please give me some instructions ...

cheers

rncbc's picture

Mathias.

I might have done a lot of changes but i's YOUR original concept code, NTL. And to give credit where it belongs, the headers of the qtractorMidiControl.h/cpp source files should have your copyright notice in addition to mine. Please.

I'm about to commit it to CVS as soon we settle this. The latest patch (the fourth) is found here.

Seeya.

[UPDATE:] Committed to CVS (qtractor-0.4.1.1318+); although the BCx2000 related rules are left out you can turn it back on (see qtractorMidiControl.cpp:180, #ifdef TEST_BCx2000).

Hey,
i tried out the last CVS version with the last patch (#4). It is really working very well. There's just a problem with the faders on an audio track. I think this is because the gain of the audio track is not linear from 0.0 to 1.0 but logarithmic scaled from 0.0 to 2.0? I will have to think about how to convert linear faders to this scale...
BTW: Mixing some track with real faders makes a lot of fun... especially for an old analogue live-mixer...
regards,
gizzmo

rncbc's picture

As of today, qtractor-0.4.1.1320 (cvs), you can manage this MIDI controllers configuration from/to external XML files (*.qtc).

See View/Controllers... that will lead you to the new configuration dialog, still rough in the edges. You can only load (import) and save (export) configurations at this time. All that's experimental and subject to change still.

All previous hardcoded test configurations are there available as separate files: usx2y.qtc and bcx2000.qtc, respectively for my old US224/JLCooper like control surface (no feedback) and for the BCx2000 (with feedback) as suggested. These are not final whatsoever but can give you a glimpse on what's cooking.

Of course, a proper way to edit these and any other configurations from scratch will follow.

Cheers

Rui,
You and gizzmo seem to have made extraordinary progress on this. Hopefully, I will get the chance to try this out this evening on my BCF2000. BTW, have you ever unboxed yours yet? I'd assume you're using it to test this stuff. ;)

Lexridge

Unfortunately, my time is a little limited and therefore, most of the effort is done by Rui! But progress is really fast, and believe me: Using BCF to do volume adjustements and panning is really making a lot of fun. I hope I can contribute something, but we'll see!

rncbc's picture

Today I've made the final stab on this new MIDI controller mapping infrastructure. Check qjackctl-0.4.1.1323+ (CVS of course). Global configuration is file based, managed under View/Controllers... menu. This Controllers dialog is not the best example of intuitiveness, (far from it :) but I hope you'll get it easily.

Things to note are that MIDI controller configuration is stored/retrieved in an ordered list of files (*.qtc) which are XML descriptions of a particular controller mapping. I tend to separate these files according to each (external) MIDI controller device or preset. You can have several mappings and they can overlap. The latest takes precedence, though.

The mapping works simple as follows: you map a MIDI Channel (1-16) and/or a MIDI Controller (CC# 0-127) to a particular Command action. Currently there are only track actions for you to assign (Gain/Volume, Pan, Monitor, Record, Mute or Solo). The target track is given by the Parameter value as a zero-based index, so that 0 will refer to 1st track, 1 to 2nd track, and so on.

There are special wildcard values ( * ), meaning that any Channel or Controller number matches the rule. In these cases, the target track index is given by difference against the Parameter value. When

  • Channel is "*", then track# = channel - parameter
  • Controller is "*", then track# = controller - parameter

Any changes you do with Map and Unmap takes effect immediately, but remember that you should save the changed mapset to a file (Export...) and then include it in the top list (Import...) so that the new mappings get retrieved next time you run Qtractor.

Most importantly, the controller maps are NOT stored in session/project files. This is application configuration, much like user preferences stuff (as in View/Options...) so don't expect it to vary per session/project.

Cheers.

hi Rui,
Wow. Really great thing. I played with it, the whole day. Really good! Of corse, your're right: The controller stuff should NOT be save in session/project files.
Just one ting left: When I played around, I took some tracks and moved them to the top of the screen. As the Midi-Controllers are re-arranged then, all the controllers should be updated. (B.t.w: The mixer-view is also not beeing updated). I think, both, mixer and midi controllers should be updated when re-arranging tracks. What do you think?

The last think is, that setting the level for an audio track with midi controllers is not really easy, as the audio channels use a logarithmic scale I think. I will have a look to the sources tomorrow (today, i love palying a round with the stuff).

cheers, gizzmo

rncbc's picture

@gizzmo,

re. controllers should be updated when re-arranging tracks,
A few moments before your post, I've committed a change that might just address the issue you report (qtractor-0.4.1.1326, CVS): track list editing, adding, removing and re-ordering tracks are now control/feedback-aware operations :) I assume you're referring to a previous revision, otherwise I've failed miserably in doing it :)

re. setting the level for an audio track with midi controllers
Yes, the logarithmic scaling on audio track gain/volume controller is still missing. No sweat. I'll hack something soon :)

Cheers

I finally got to try this new feature last night, and I quickly noticed the volume scaling issue. Also, the two buttons at the top of my BCF2000 do not seem to register anything in the messages log (unlike volume and pan controls). However, when pressing them they do make the input level meter (mixer) immediately peak, and then settle back down. Strange!

Major progress has been made, now it's just cleanup time. :) Good work fellows!

Lexridge

@Rui: Yes, i think it was an older revision. Will try the next one, today *g*

@Lexridge: I think this is about configuration of the buttons. How did you set them? Have in mind that you can configure, if they represent the feedback value, or not. (It's the last parameter of the setting and is called "Value indication on/off). If you want, I can send you my configuration (just need to know how this works under linux, but i think it should...)

Pages

Add new comment