patman.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * patman.h - header for a GUS-compatible patch instrument plugin
  3. *
  4. * Copyright (c) 2007-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef PATMAN_H_
  25. #define PATMAN_H_
  26. #include "Instrument.h"
  27. #include "InstrumentView.h"
  28. #include "SampleBuffer.h"
  29. #include "AutomatableModel.h"
  30. #include "MemoryManager.h"
  31. class PixmapButton;
  32. #define MODES_16BIT ( 1 << 0 )
  33. #define MODES_UNSIGNED ( 1 << 1 )
  34. #define MODES_LOOPING ( 1 << 2 )
  35. #define MODES_PINGPONG ( 1 << 3 )
  36. #define MODES_REVERSE ( 1 << 4 )
  37. #define MODES_SUSTAIN ( 1 << 5 )
  38. #define MODES_ENVELOPE ( 1 << 6 )
  39. #define MODES_CLAMPED ( 1 << 7 )
  40. class patmanInstrument : public Instrument
  41. {
  42. Q_OBJECT
  43. public:
  44. patmanInstrument( InstrumentTrack * _track );
  45. virtual ~patmanInstrument();
  46. virtual void playNote( NotePlayHandle * _n,
  47. sampleFrame * _working_buffer );
  48. virtual void deleteNotePluginData( NotePlayHandle * _n );
  49. virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
  50. virtual void loadSettings( const QDomElement & _this );
  51. virtual void loadFile( const QString & _file );
  52. virtual QString nodeName( void ) const;
  53. virtual f_cnt_t desiredReleaseFrames( void ) const
  54. {
  55. return( 128 );
  56. }
  57. virtual PluginView * instantiateView( QWidget * _parent );
  58. public slots:
  59. void setFile( const QString & _patch_file, bool _rename = true );
  60. private:
  61. typedef struct
  62. {
  63. MM_OPERATORS
  64. SampleBuffer::handleState* state;
  65. bool tuned;
  66. SampleBuffer* sample;
  67. } handle_data;
  68. QString m_patchFile;
  69. QVector<SampleBuffer *> m_patchSamples;
  70. BoolModel m_loopedModel;
  71. BoolModel m_tunedModel;
  72. enum LoadErrors
  73. {
  74. LoadOK,
  75. LoadOpen,
  76. LoadNotGUS,
  77. LoadInstruments,
  78. LoadLayers,
  79. LoadIO
  80. } ;
  81. LoadErrors loadPatch( const QString & _filename );
  82. void unloadCurrentPatch( void );
  83. void selectSample( NotePlayHandle * _n );
  84. friend class PatmanView;
  85. signals:
  86. void fileChanged( void );
  87. } ;
  88. class PatmanView : public InstrumentViewFixedSize
  89. {
  90. Q_OBJECT
  91. public:
  92. PatmanView( Instrument * _instrument, QWidget * _parent );
  93. virtual ~PatmanView();
  94. public slots:
  95. void openFile( void );
  96. void updateFilename( void );
  97. protected:
  98. virtual void dragEnterEvent( QDragEnterEvent * _dee );
  99. virtual void dropEvent( QDropEvent * _de );
  100. virtual void paintEvent( QPaintEvent * );
  101. private:
  102. virtual void modelChanged( void );
  103. patmanInstrument * m_pi;
  104. QString m_displayFilename;
  105. PixmapButton * m_openFileButton;
  106. PixmapButton * m_loopButton;
  107. PixmapButton * m_tuneButton;
  108. } ;
  109. #endif