LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
8.05k stars 1k forks source link

Remap Keyboard #2486

Open feedbackex opened 8 years ago

feedbackex commented 8 years ago

Hi,

Is there a way to remap key assignment to play note for piano roll? (For normal PC keyboard) Example; For now when I press q key in piano roll, playing C4 note. I want to change that example when I press q key, playing G7 note.

If there is now way for that, can I write? For that; Which header and cpp files are required, those I must know or investigate?

tresf commented 8 years ago

If you want to avoid any "master pitch" or "instrument base note" hackery, the place to start in the codebase is here: https://github.com/LMMS/lmms/blob/master/src/gui/PianoView.cpp#L169

feedbackex commented 8 years ago

Thank you tresf. That is exactly what I want. Secondly I want to add combo box to Piano Roll View like chords. I intend to map keys according to that combo box choosing.

Can you direct me about classes again?

tresf commented 8 years ago

Dig in using a member variable (m_zoomingModel) for example. i.e. src/gui/editors/PianoRoll.cpp#L180

You'll see the word "model" quite a bit. That's because all of our controls are automatable and inherit from the AutomatableModel class. Just start to mimic the way those are added as member variables and to the GUI and you should have the GUI components you need.

Fetching values from the GUI components can be a bit trickier, but before you put too much time into this, you should probably run it past @grejppi @michaelgregorius @Wallacoloo @Umcaruje. Depending on exactly how you want to implement it, it would certainly benefit to run the finished idea past a few other developers first.

feedbackex commented 8 years ago

I am glad you tresf to clear tips. I will start to code as soon as possible.

feedbackex commented 8 years ago

Hi tresf, I have problem about building, I use Linux Mint 17.2 Rafaela 64-bit and I have qt5.5. I get that erorr while make process:

[ 35%] Generating RemoteVstPlugin [ 35%] Built target tripleoscillator In file included from /home/ian/git/lmms/include/MidiEvent.h:28:0, from /home/ian/git/lmms/include/RemotePlugin.h:29, from /home/ian/git/lmms/plugins/vst_base/RemoteVstPlugin.cpp:35: /usr/include/c++/4.8/cstdlib:41:28: fatal error: bits/c++config.h: No such file or directory

include <bits/c++config.h>

                        ^

compilation terminated. [ 35%] Built target watsyn [ 35%] winegcc: g++ failed make[2]: * [plugins/vst_base/RemoteVstPlugin] Error 2 make[1]: * [plugins/vst_base/CMakeFiles/vstbase.dir/all] Error 2 make[1]: *\ Waiting for unfinished jobs....

Can you help me about that?

feedbackex commented 8 years ago

[Solved]: It's fix when install g++-4.8-multilib

feedbackex commented 8 years ago

Hi tresf, I use new static class called PianoKeyboard in new header and cpp file, to fetch values from GUI.

I get error when make build:

CMakeFiles/lmms.dir/src/gui/PianoRoll.o: In function `PianoKeyboard::setOctaveNumber(int)':
/home/ian/git/lmms/include/PianoKeyboard.h:44: undefined reference to `PianoKeyboard::m_octave'
CMakeFiles/lmms.dir/src/gui/PianoRoll.o: In function `PianoKeyboard::setScaleNote(QString)':
/home/ian/git/lmms/include/PianoKeyboard.h:47: undefined reference to `PianoKeyboard::m_scaleNote'
CMakeFiles/lmms.dir/src/gui/PianoRoll.o: In function `PianoKeyboard::setScaleType(QString)':
/home/ian/git/lmms/include/PianoKeyboard.h:50: undefined reference to `PianoKeyboard::m_scaleType'
CMakeFiles/lmms.dir/src/gui/PianoRoll.o: In function `~QString':
/usr/include/qt4/QtCore/qstring.h:880: undefined reference to `PianoKeyboard::m_notes'
CMakeFiles/lmms.dir/src/gui/PianoView.o: In function `PianoView::getKeyFromKeyEvent(QKeyEvent*)':
/home/ian/git/lmms/src/gui/PianoView.cpp:227: undefined reference to `PianoKeyboard::getLinuxKey(int)'
collect2: error: ld returned 1 exit status
make[2]: *** [lmms] Error 1
make[1]: *** [CMakeFiles/lmms.dir/all] Error 2
make: *** [all] Error 2

I guess, I must register or declare new header file where I don't know. Can you help me again?

tresf commented 8 years ago

If you'd like a code review, you will need to fork and create a pull request as explained here:

https://github.com/LMMS/lmms/wiki/Submitting-a-patch

This way, any developer familiar with CPP can chime in and offer assistance.

tresf commented 8 years ago

@feedbackex it appears as if you've issued this pull request against your own repository rather than upstream. Please issue it against upstream so that other developers are notified of the change and can make comments.

https://github.com/LMMS/lmms/compare/master...feedbackex:feature/piano-keyboard

P.S. I like the new cross-platform mapping functions. :+1:

In regards to why this is failing (I'm not a C++ expert) but I would suspect some confusion in your code between static and instantiated classes. In most cases, you want to stick to instantiated classes, so the member variables would be set in the default constructor.

This means you'd define PianoKeyboard with m_octave, m_scaleNote and m_scaleType defaults provided within the constructor like we do with other classes. Here is an example: https://github.com/LMMS/lmms/blob/master/src/core/Effect.cpp#L41

Instead, your code appears to access the member variables statically like MyClass::m_member = x; which AFAIK would only be available to a static variable. In most cases, good OO code tries to avoid unneeded static variables, so I think going the route of creating a new PianoKeyboard instance is preferred unless this happens to be an exception.

Hope this helps.

feedbackex commented 8 years ago

Hi tresf, thanks for instructions. I have reviewed my code and have pull request again.

Also for now, I do not have problem about C++ code. (In C++, static member initialize out of constructors, except in a few situation).

I have just problem about cpp path. Compiler do not recognize my cpp file. So that, temporarily I have added code in PianoView.cpp.

tresf commented 8 years ago

Compiler do not recognize my cpp file

Oh... in that case, it may just need to be added to a particular CMakeLists.txt file.

feedbackex commented 8 years ago

Thank you tresf, it's working. I have reorganized my code. I will add commit after I decide switch mode style.

tresf commented 8 years ago

Thanks, but you still are doing a pull request against the wrong location. You'll need to open a PR against our code, not your own. I'll make a few comments on code style, but please re-issue the PR against lmms/lmms/master. This can be done via the GitHub, just click on the branch, click "compare", click "Create Pull Request".

Also, when you add additional commits to an existing PR, no one gets notified, you'll have to chime in after each commit if you require feedback. :+1:

feedbackex commented 8 years ago

Thanks Trefs, I have finalized my codes for now and have pull request to lmm/master.