Utils.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. This file is part of QTau
  3. Copyright (C) 2013-2018 Tobias "Tomoko" Platen <tplaten@posteo.de>
  4. Copyright (C) 2013 digited <https://github.com/digited>
  5. Copyright (C) 2010-2013 HAL@ShurabaP <https://github.com/haruneko>
  6. QTau is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. SPDX-License-Identifier: GPL-3.0+
  17. */
  18. #ifndef UTILS_H
  19. #define UTILS_H
  20. #include <QObject>
  21. #include <QVector>
  22. #include <QString>
  23. #include <QPoint>
  24. #include <QSize>
  25. #include <QPair>
  26. #include <QVariant>
  27. #define STR(x) QVariant(x).toString()
  28. void __devlog__(QString logtype,QString filename,int line,QString msg);
  29. #define DEVLOG_ERROR(msg) {if(__devloglevel__>=1) __devlog__ ("ERROR",__FILE__,__LINE__,msg);}
  30. #define DEVLOG_WARNING(msg) {if(__devloglevel__>=2) __devlog__ ("WARNING",__FILE__,__LINE__,msg);}
  31. #define DEVLOG_DEBUG(msg) {if(__devloglevel__>=3) __devlog__ ("DEBUG",__FILE__,__LINE__,msg);}
  32. #define DEVLOG_INFO(msg) {if(__devloglevel__>=4) __devlog__ ("INFO",__FILE__,__LINE__,msg);}
  33. const QString c_qtau_name = QStringLiteral("QTau");
  34. const QString c_qtau_ver = QStringLiteral("α1");
  35. /* Pulses Per Quarter note - standard timing resolution of a MIDI sequencer,
  36. needs to be divisible by 16 and 3 to support 1/64 notes and triplets.
  37. Used to determine note offset (in bars/seconds) and duration */
  38. const int c_midi_ppq = 480;
  39. const int c_zoom_num = 17;
  40. const int cdef_zoom_index = 4;
  41. const int cdef_note_height = 14;
  42. const int c_zoom_note_widths[c_zoom_num] = {16, 32, 48, 64, 80,
  43. 96, 112, 128, 144, 160,
  44. 176, 208, 240, 304, 368, 480, 608};
  45. class TempoMap;
  46. struct SNoteSetup {
  47. QSize note; // gui dimensions (in pixels)
  48. int baseOctave;
  49. int numOctaves;
  50. int numBars;
  51. //int noteLength; // denominator of note length 1
  52. //int notesInBar; // noteLength=4 and notesInBar=4 means music time signature 4/4
  53. //int tempo; // bpm
  54. //QMap <int,STimeSignature*> times;
  55. TempoMap* tmap;
  56. int quantize; // 1/x note length, used as unit of offset for singing notes
  57. int length; // 1/x singing note length unit (len=4 means 1/4, 2/4 etc +1/4)
  58. int barWidth;
  59. int octHeight;
  60. SNoteSetup() : note(c_zoom_note_widths[cdef_zoom_index], cdef_note_height),
  61. baseOctave(1), numOctaves(8),numBars(128), tmap(0), quantize(32), length(32),
  62. barWidth(note.width() * /*notesInBar*/4), octHeight(note.height() * 12) {}
  63. };
  64. //----------------------------------------------------
  65. enum class ELog : char {
  66. none,
  67. info,
  68. debug,
  69. error,
  70. success
  71. };
  72. enum class EColor : char {
  73. none,
  74. green,
  75. red
  76. };
  77. #define MAXRECENTFILES 8
  78. //#define DEFAULT_SAMPLERATE 44100
  79. #endif // UTILS_H