andrewm@11: /* andrewm@11: TouchKeys: multi-touch musical keyboard control software andrewm@11: Copyright (c) 2013 Andrew McPherson andrewm@11: andrewm@11: This program is free software: you can redistribute it and/or modify andrewm@11: it under the terms of the GNU General Public License as published by andrewm@11: the Free Software Foundation, either version 3 of the License, or andrewm@11: (at your option) any later version. andrewm@11: andrewm@11: This program is distributed in the hope that it will be useful, andrewm@11: but WITHOUT ANY WARRANTY; without even the implied warranty of andrewm@11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrewm@11: GNU General Public License for more details. andrewm@11: andrewm@11: You should have received a copy of the GNU General Public License andrewm@11: along with this program. If not, see . andrewm@11: andrewm@11: ===================================================================== andrewm@11: andrewm@11: TouchkeyEntropyGenerator.h: generate random TouchKeys data for testing andrewm@11: */ andrewm@11: andrewm@11: #ifndef TOUCHKEYENTROPYGENERATOR_H_INCLUDED andrewm@11: #define TOUCHKEYENTROPYGENERATOR_H_INCLUDED andrewm@11: andrewm@11: #include "../../JuceLibraryCode/JuceHeader.h" andrewm@11: #include "PianoKeyboard.h" andrewm@11: andrewm@11: class TouchkeyEntropyGenerator : public Thread { andrewm@11: public: andrewm@11: // *** Constructor *** andrewm@11: TouchkeyEntropyGenerator(PianoKeyboard& keyboard); andrewm@11: andrewm@11: // *** Destructor *** andrewm@11: ~TouchkeyEntropyGenerator() { andrewm@11: stop(); andrewm@11: } andrewm@11: andrewm@11: // *** Control methods *** andrewm@11: // Start running the generator andrewm@11: void start(); andrewm@11: andrewm@11: // Stop running the generator andrewm@11: void stop(); andrewm@11: andrewm@11: // Check if the generator is running andrewm@11: bool isRunning() { return isRunning_; } andrewm@11: andrewm@11: // *** Data generation *** andrewm@11: andrewm@11: // Set the range of keys for which touch data will be generated andrewm@11: void setKeyboardRange(int lowest, int highest) { andrewm@11: keyboardRangeLow_ = lowest; andrewm@11: keyboardRangeHigh_ = highest; andrewm@11: } andrewm@11: andrewm@11: // Set the interval at which data should be generated andrewm@11: void setDataInterval(timestamp_diff_type interval) { andrewm@11: dataInterval_ = interval; andrewm@11: } andrewm@11: andrewm@11: // *** Juce Thread method *** andrewm@11: void run(); andrewm@11: andrewm@11: private: andrewm@11: void clearTouchData(int i); // Clear touch data for a particular key andrewm@11: andrewm@11: void generateRandomFrame(int key); // Generate a random touch frame on this key andrewm@11: andrewm@11: private: andrewm@11: PianoKeyboard& keyboard_; // Main keyboard controller andrewm@11: andrewm@11: WaitableEvent waitableEvent_; // For thread timing andrewm@11: bool isRunning_; andrewm@11: int keyboardRangeLow_; // Range of keys to generate data for andrewm@11: int keyboardRangeHigh_; andrewm@11: timestamp_diff_type dataInterval_; // Interval between frames of data andrewm@11: andrewm@11: KeyTouchFrame touchFrames_[127]; // Current state of each virtual TouchKey andrewm@11: int nextOnOffFrameCount_[127]; // How long until the next note goes on or off andrewm@11: }; andrewm@11: andrewm@11: andrewm@11: #endif // TOUCHKEYENTROPYGENERATOR_H_INCLUDED