[improvement] [ChannelN], channel and engine.isScratching(channel)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mixxx |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Doesn't it looks like some kind of inconsistency with all that Channels numbers in code?
I am pretty understand that some changes in this area will break a lot of stuff, but still...
In Mixxx Controls we have
[𝗖𝗵𝗮𝗻𝗻𝗲𝗹𝟭], [𝗖𝗵𝗮𝗻𝗻𝗲𝗹𝟮], [𝗖𝗵𝗮𝗻𝗻𝗲𝗹𝗡], ... (start from 1)
in MyController.
print(channel); //start from 0
in `engine.
in `engine.
thus we should do something like this:
MyController.
engine.
or
MyController.
switch (value) {
case '[Channel1]': return 0;
case '[Channel2]': return 1;
case '[Channel3]': return 2;
case '[Channel4]': return 3;
default: return 0;
}
}
what is weird.
My proposition is to make channels start from 0
and pass in all functions '[ChannelN]' not integer or other stuff
Because I couldn't understand what's wrong with this function for 30 min
engine.
All the time I had this error
𝐂𝐨𝐮𝐥𝐝 𝐧𝐨𝐭 𝐠𝐞𝐭𝐂𝐨𝐧𝐭𝐫𝐨𝐥𝐎𝐛𝐣𝐞𝐜
and
𝐖𝐚𝐫𝐧𝐢𝐧𝐠 [𝐂𝐨𝐧𝐭𝐫𝐨𝐥𝐥𝐞𝐫]: 𝐂𝐨𝐧𝐭𝐫𝐨𝐥𝐃𝐨𝐮𝐛𝐥𝐞𝐏𝐫
We should direct the attention on this in Wiki and I gonna make some edits.
I agree this is an easy way to get tripped up, but in Mixxx we strictly maintain backwards compatibility, especially of user control scripts so we effectively can't change this even if we wanted to.
> My proposition is to make channels start from 0 and pass in all functions '[ChannelN]' not integer or other stuff
The unfortunate bit is that strings are far less efficient than integers, and you frequently want to be using an integer to index into something, so if you're passing strings around you're going to be constantly slicing them up and converting them into indices which is wasteful.
I'd suggest doing the opposite -- stop using strings in your JS except where you need to interact with the control system. Instead, use indices everywhere, and whenever you need a group, pretend you know nothing about how to construct a group manually (since that can cause you to make off-by-one errors). Always call a helper function that gives you a group for an index e.g. groupForDeck( index), groupForSampler (index) , etc.