1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 /* 3 Rosegarden 4 A sequencer and musical notation editor. 5 Copyright 2020 the Rosegarden development team. 6 7 This program is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the 10 License, or (at your option) any later version. See the file 11 COPYING included with this distribution for more information. 12 */ 13 14 #pragma once 15 16 17 #include "base/MidiProgram.h" // For MidiByte 18 19 20 namespace Rosegarden 21 { 22 23 24 class MappedEvent; 25 26 27 /// Support for the Korg nanoKONTROL2 control surface. 28 /** 29 * This only supports the nanoKONTROL2 in "CC" mode. To reset the nanoKONTROL2 30 * to factory defaults (removing any custom programming) and switch to CC 31 * mode: 32 * 33 * Hold down the PREV TRACK, NEXT TRACK, and CYCLE buttons and then 34 * connect the nanoKONTROL2 to USB. 35 * 36 * More support for the nanoKONTROL2 is present in AlsaDriver and elsewhere. 37 * Search the sourcebase on "nanokontrol2" (case insensitive, non-whole-word) 38 * to find it. 39 */ 40 class KorgNanoKontrol2 41 { 42 public: 43 KorgNanoKontrol2(); 44 45 /// Call this after the device is connected to set it up. 46 void init(); 47 48 /// Call when the document is modified to update the LEDs. 49 void documentModified(); 50 51 void stopped(); 52 void playing(); 53 void recording(); 54 55 /// Handle MappedEvent's from the external controller port. 56 void processEvent(const MappedEvent *event); 57 58 private: 59 // Current 8-channel page. 60 unsigned m_page; 61 62 void processFader(MidiByte controlNumber, MidiByte value); 63 void processKnob(MidiByte controlNumber, MidiByte value); 64 void processSolo(MidiByte controlNumber); 65 void processMute(MidiByte controlNumber); 66 void processRecord(MidiByte controlNumber); 67 68 void testLEDs(bool on); 69 void initLEDs(); 70 bool m_firstRefresh; 71 void refreshLEDs(); 72 73 bool m_solo[8]; 74 bool m_mute[8]; 75 bool m_recordArmed[8]; 76 77 bool m_play; 78 bool m_record; 79 bool m_stop; 80 void setPlayRecordStopLEDs(bool play, bool record, bool stop); 81 82 bool m_rewind; 83 bool m_fastForward; 84 85 bool m_cycle; 86 87 }; 88 89 90 } 91