1 /*********************************************************************************/ 2 /*! 3 @file Util.h 4 5 @brief xxxx. 6 7 @author L. J. Barman 8 9 Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved 10 11 This file is part of the PianoBooster application 12 13 PianoBooster is free software: you can redistribute it and/or modify 14 it under the terms of the GNU General Public License as published by 15 the Free Software Foundation, either version 3 of the License, or 16 (at your option) any later version. 17 18 PianoBooster is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with PianoBooster. If not, see <http://www.gnu.org/licenses/>. 25 26 */ 27 /*********************************************************************************/ 28 29 #ifndef __UTIL_H__ 30 #define __UTIL_H__ 31 32 #include <assert.h> 33 #include <string> 34 #include <QString> 35 #include <QApplication> 36 37 using namespace std; 38 39 #define MAX_MIDI_CHANNELS 16 // There are always at most 16 midi channels 40 #define MIDDLE_C 60 41 #define MIDI_OCTAVE 12 42 #define MIDI_BOTTOM_C (MIDDLE_C - MIDI_OCTAVE*2) 43 #define MIDI_TOP_C (MIDDLE_C + MIDI_OCTAVE*2) 44 #define MIDI_DRUM_CHANNEL (10-1) 45 46 #define MAX_MIDI_NOTES 128 47 48 #define MAX_MIDI_TRACKS 32 // This will allow us to map midi track on to midi channels 49 typedef unsigned char byte_t; 50 51 #define arraySize(a) (sizeof(a)/sizeof(a[0])) /* Returns (at compile time) the number of elements in an array */ 52 53 #define ppDEBUG(args) ppLogDebug args 54 55 typedef enum 56 { 57 PB_LOG_error, 58 PB_LOG_warn, 59 PB_LOG_info, 60 PB_LOG_verbose, 61 } logLevel_t; 62 63 void fatal(const char *msg, ...); 64 void ppLogTrace(const char *msg, ...); 65 void ppLogDebug(const char *msg, ...); 66 void ppLog(logLevel_t level, const char *msg, ...); 67 void ppLogInfo(const char *msg, ...); 68 void ppLogWarn(const char *msg, ...); 69 void ppLogError(const char *msg, ...); 70 void ppTiming(const char *msg, ...); 71 void closeLogs(); 72 73 #define SPEED_ADJUST_FACTOR 1000 74 #define deltaAdjust(delta) ((delta)/SPEED_ADJUST_FACTOR ) 75 76 void benchMarkInit(); 77 void benchMark(unsigned int id, QString message); 78 void benchMarkResults(); 79 80 class Util { 81 public: 82 static QString dataDir(); 83 }; 84 85 #endif //__UTIL_H__ 86