Groove.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Groove.h - classes for addinng swing/funk/groove/slide (you can't name it but you can feel it)
  3. * to midi which is not precise enough at 192 ticks per tact to make your arse move.
  4. *
  5. * In it simplest terms a groove is a subtle delay on some notes in a pattern.
  6. *
  7. * Copyright (c) 2005-2008 teknopaul <teknopaul/at/users.sourceforge.net>
  8. *
  9. * This file is part of LMMS - https://lmms.io
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 2 of the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public
  22. * License along with this program (see COPYING); if not, write to the
  23. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  24. * Boston, MA 02110-1301 USA.
  25. *
  26. */
  27. #ifndef GROOVE_H
  28. #define GROOVE_H
  29. #include <QWidget>
  30. #include "lmms_basics.h"
  31. #include "MidiTime.h"
  32. #include "Note.h"
  33. #include "Pattern.h"
  34. #include "SerializingObject.h"
  35. class Groove : public QObject, public SerializingObject
  36. {
  37. Q_OBJECT
  38. public:
  39. Groove(QObject* parent = nullptr);
  40. /*
  41. * Groove should return true if the note should be played in the curr_time tick,
  42. * at the start of the tick or any time before the next tick.
  43. *
  44. * cur_start - the tick about to be played
  45. * n - the note to be played, or not played
  46. * p - the pattern to which the note belongs
  47. *
  48. * default implementation (no groove) would be return n.pos() == cur_start ? 0 : -1;
  49. *
  50. * returns 0 to play now on the tick, -1 to not play at all and the new offset
  51. * that the note should be shifted if it is to be played later in this tick.
  52. */
  53. virtual int isInTick(MidiTime * curStart, fpp_t frames, f_cnt_t offset,
  54. Note * n, Pattern * p);
  55. int amount() const {return m_amount;}
  56. virtual void saveSettings(QDomDocument & doc, QDomElement & element);
  57. virtual void loadSettings(const QDomElement & element);
  58. virtual QWidget * instantiateView(QWidget * parent);
  59. virtual QString nodeName() const
  60. {
  61. return "none";
  62. }
  63. signals:
  64. void amountChanged(int newAmount);
  65. public slots:
  66. void setAmount(int amount);
  67. protected:
  68. int m_amount;
  69. float m_swingFactor; // = (m_amount / 127)
  70. };
  71. #endif // GROOVE_H