superboucle icon indicating copy to clipboard operation
superboucle copied to clipboard

duplicated code in learn.py

Open IARI opened this issue 9 years ago • 6 comments

look at the processNote method - why is it that way?

IARI avatar Jul 21 '15 22:07 IARI

I think it's more readable this way. But I agree with you, this is not good... There is also a bug with knowCtrl and knownBtn list : When you overwrite some mapping, old values are not removed from lists of used btn an ctrl. So you cannot switch two controls (for example play and pause). Those lines :

self.knownCtrl.add(ctrl_key)
self.knownBtn.add(btn_key)

are not present in every if part. Maybe we can replace string in self.send_midi_to by a callable function. This way, we can create separate little functions that will handle midi event.

Vampouille avatar Jul 24 '15 09:07 Vampouille

That's a good idea - i'll put it in our fork :)

IARI avatar Jul 25 '15 16:07 IARI

Actually I in gui.py there is a similar situation in processNote: There is a big if construct to decode what function to use for what message. i would consistently replace it with a mapping from midi-messages (or your abstract representations of them) directly to functions. Would you agree?

IARI avatar Jul 25 '15 17:07 IARI

yes, but can you make this modification in a new branch created from last tag 1.2.0 ?

Vampouille avatar Jul 27 '15 08:07 Vampouille

Damn i have already started - To be honest i have rewritten the whole device and most of learn.py. in the main branch of our fork..but I will try to put it in a new branch!

IARI avatar Jul 27 '15 09:07 IARI

Ok, brace yourself @Vampouille, here it is: 660dd953ac96a5a0a9492f65db1e5f281f13242b

I'll clean it up a bit more, then we will do some more extensive testing - and then I'll issue a pull request. Its much but I hope you like it ;) I had to add another dependency: the wrapt package. Tried to get around without it, but vanilla python decorators aren't that nice with objects. I hope that's not a huge issue?!

IARI avatar Aug 03 '15 17:08 IARI