annotate Source/Mappings/ReleaseAngle/TouchkeyReleaseAngleMappingFactory.cpp @ 16:61e3c9df4674

Fix bug where TouchKeys standalone mode turns off when mode is changed.
author Andrew McPherson <andrewm@eecs.qmul.ac.uk>
date Mon, 25 Nov 2013 21:36:02 +0000
parents 3580ffe87dc8
children 0deac2806a7b
rev   line source
andrewm@0 1 /*
andrewm@0 2 TouchKeys: multi-touch musical keyboard control software
andrewm@0 3 Copyright (c) 2013 Andrew McPherson
andrewm@0 4
andrewm@0 5 This program is free software: you can redistribute it and/or modify
andrewm@0 6 it under the terms of the GNU General Public License as published by
andrewm@0 7 the Free Software Foundation, either version 3 of the License, or
andrewm@0 8 (at your option) any later version.
andrewm@0 9
andrewm@0 10 This program is distributed in the hope that it will be useful,
andrewm@0 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
andrewm@0 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrewm@0 13 GNU General Public License for more details.
andrewm@0 14
andrewm@0 15 You should have received a copy of the GNU General Public License
andrewm@0 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
andrewm@0 17
andrewm@0 18 =====================================================================
andrewm@0 19
andrewm@0 20 TouchkeyReleaseAngleMappingFactory.cpp: factory for the release angle
andrewm@0 21 mapping, which measures the speed of finger motion along the key at
andrewm@0 22 the time of MIDI note off.
andrewm@0 23 */
andrewm@0 24
andrewm@0 25 #include "TouchkeyReleaseAngleMappingFactory.h"
andrewm@0 26
andrewm@0 27 // Class constants
andrewm@0 28 const timestamp_diff_type TouchkeyReleaseAngleMappingFactory::kDefaultMaxLookbackTime = milliseconds_to_timestamp(100);
andrewm@0 29
andrewm@0 30
andrewm@0 31 TouchkeyReleaseAngleMappingFactory::TouchkeyReleaseAngleMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment)
andrewm@0 32 : TouchkeyBaseMappingFactory<TouchkeyReleaseAngleMapping>(keyboard, segment) {}
andrewm@0 33
andrewm@0 34 // MIDI note ended: see whether the mapping was suspended and if not, execute the angle calculation
andrewm@0 35 void TouchkeyReleaseAngleMappingFactory::midiNoteOff(int noteNumber, bool touchIsOn, bool keyMotionActive,
andrewm@0 36 Node<KeyTouchFrame>* touchBuffer,
andrewm@0 37 Node<key_position>* positionBuffer,
andrewm@0 38 KeyPositionTracker* positionTracker) {
andrewm@0 39 if(mappings_.count(noteNumber) != 0) {
andrewm@0 40 mappings_[noteNumber]->processRelease(keyboard_.schedulerCurrentTimestamp());
andrewm@0 41 }
andrewm@0 42
andrewm@0 43 // Call base class method
andrewm@0 44 TouchkeyBaseMappingFactory<TouchkeyReleaseAngleMapping>::midiNoteOff(noteNumber, touchIsOn, keyMotionActive, touchBuffer, positionBuffer, positionTracker);
andrewm@0 45 }