| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY, without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #include "Skin.h" |
|---|
| 25 | #include "PlayerControl.h" |
|---|
| 26 | #include "InstrumentRack.h" |
|---|
| 27 | #include "HydrogenApp.h" |
|---|
| 28 | |
|---|
| 29 | #include "widgets/LCD.h" |
|---|
| 30 | #include "widgets/Button.h" |
|---|
| 31 | #include "widgets/CpuLoadWidget.h" |
|---|
| 32 | #include "widgets/MidiActivityWidget.h" |
|---|
| 33 | #include "widgets/PixmapWidget.h" |
|---|
| 34 | |
|---|
| 35 | #include "Mixer/Mixer.h" |
|---|
| 36 | #include "SongEditor/SongEditorPanel.h" |
|---|
| 37 | #include "PatternEditor/PatternEditorPanel.h" |
|---|
| 38 | #include "InstrumentEditor/InstrumentEditorPanel.h" |
|---|
| 39 | |
|---|
| 40 | #include <hydrogen/hydrogen.h> |
|---|
| 41 | #include <hydrogen/audio_engine.h> |
|---|
| 42 | #include <hydrogen/IO/JackOutput.h> |
|---|
| 43 | #include <hydrogen/Preferences.h> |
|---|
| 44 | #include <hydrogen/event_queue.h> |
|---|
| 45 | using namespace H2Core; |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | //beatconter global |
|---|
| 49 | int bcDisplaystatus = 0; |
|---|
| 50 | //~ beatcounter |
|---|
| 51 | |
|---|
| 52 | PlayerControl::PlayerControl(QWidget *parent) |
|---|
| 53 | : QLabel(parent) |
|---|
| 54 | , Object( "PlayerControl" ) |
|---|
| 55 | { |
|---|
| 56 | // Background image |
|---|
| 57 | setPixmap( QPixmap( Skin::getImagePath() + "/playerControlPanel/background.png" ) ); |
|---|
| 58 | setScaledContents( true ); |
|---|
| 59 | |
|---|
| 60 | QHBoxLayout *hbox = new QHBoxLayout(); |
|---|
| 61 | hbox->setSpacing( 0 ); |
|---|
| 62 | hbox->setMargin( 0 ); |
|---|
| 63 | setLayout( hbox ); |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | // CONTROLS |
|---|
| 68 | PixmapWidget *pControlsPanel = new PixmapWidget( NULL ); |
|---|
| 69 | pControlsPanel->setFixedSize( 344, 43 ); |
|---|
| 70 | pControlsPanel->setPixmap( "/playerControlPanel/background_Control.png" ); |
|---|
| 71 | hbox->addWidget( pControlsPanel ); |
|---|
| 72 | |
|---|
| 73 | m_pTimeDisplayH = new LCDDisplay( pControlsPanel, LCDDigit::LARGE_GRAY, 2 ); |
|---|
| 74 | m_pTimeDisplayH->move( 27, 12 ); |
|---|
| 75 | m_pTimeDisplayH->setText( "00" ); |
|---|
| 76 | |
|---|
| 77 | m_pTimeDisplayM = new LCDDisplay( pControlsPanel, LCDDigit::LARGE_GRAY, 2 ); |
|---|
| 78 | m_pTimeDisplayM->move( 61, 12 ); |
|---|
| 79 | m_pTimeDisplayM->setText( "00" ); |
|---|
| 80 | |
|---|
| 81 | m_pTimeDisplayS = new LCDDisplay( pControlsPanel, LCDDigit::LARGE_GRAY, 2 ); |
|---|
| 82 | m_pTimeDisplayS->move( 95, 12 ); |
|---|
| 83 | m_pTimeDisplayS->setText( "00" ); |
|---|
| 84 | |
|---|
| 85 | m_pTimeDisplayMS = new LCDDisplay( pControlsPanel, LCDDigit::SMALL_GRAY, 3 ); |
|---|
| 86 | m_pTimeDisplayMS->move( 122, 16 ); |
|---|
| 87 | m_pTimeDisplayMS->setText( "000" ); |
|---|
| 88 | |
|---|
| 89 | // Rewind button |
|---|
| 90 | m_pRwdBtn = new Button( |
|---|
| 91 | pControlsPanel, |
|---|
| 92 | "/playerControlPanel/btn_rwd_on.png", |
|---|
| 93 | "/playerControlPanel/btn_rwd_off.png", |
|---|
| 94 | "/playerControlPanel/btn_rwd_over.png", |
|---|
| 95 | QSize(21, 15) |
|---|
| 96 | ); |
|---|
| 97 | m_pRwdBtn->move(168, 17); |
|---|
| 98 | m_pRwdBtn->setToolTip( trUtf8("Rewind") ); |
|---|
| 99 | connect(m_pRwdBtn, SIGNAL(clicked(Button*)), this, SLOT(RewindBtnClicked(Button*))); |
|---|
| 100 | |
|---|
| 101 | // Record button |
|---|
| 102 | m_pRecBtn = new ToggleButton( |
|---|
| 103 | pControlsPanel, |
|---|
| 104 | "/playerControlPanel/btn_rec_on.png", |
|---|
| 105 | "/playerControlPanel/btn_rec_off.png", |
|---|
| 106 | "/playerControlPanel/btn_rec_over.png", |
|---|
| 107 | QSize(21, 15) |
|---|
| 108 | ); |
|---|
| 109 | m_pRecBtn->move(195, 17); |
|---|
| 110 | m_pRecBtn->setPressed(false); |
|---|
| 111 | m_pRecBtn->setHidden(false); |
|---|
| 112 | m_pRecBtn->setToolTip( trUtf8("Record") ); |
|---|
| 113 | connect(m_pRecBtn, SIGNAL(clicked(Button*)), this, SLOT(recBtnClicked(Button*))); |
|---|
| 114 | connect(m_pRecBtn, SIGNAL(rightClicked(Button*)), this, SLOT(recBtnRightClicked(Button*))); |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | // Record+delete button |
|---|
| 118 | m_pRecDelBtn = new ToggleButton( |
|---|
| 119 | pControlsPanel, |
|---|
| 120 | "/playerControlPanel/btn_recdel_on.png", |
|---|
| 121 | "/playerControlPanel/btn_recdel_off.png", |
|---|
| 122 | "/playerControlPanel/btn_recdel_over.png", |
|---|
| 123 | QSize(21, 15) |
|---|
| 124 | ); |
|---|
| 125 | m_pRecDelBtn->move(195, 17); |
|---|
| 126 | m_pRecDelBtn->setPressed(false); |
|---|
| 127 | m_pRecDelBtn->setHidden(true); |
|---|
| 128 | m_pRecDelBtn->setToolTip( trUtf8("Destructive Record") ); |
|---|
| 129 | connect(m_pRecDelBtn, SIGNAL(clicked(Button*)), this, SLOT(recBtnClicked(Button*))); |
|---|
| 130 | connect(m_pRecDelBtn, SIGNAL(rightClicked(Button*)), this, SLOT(recBtnRightClicked(Button*))); |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | // Play button |
|---|
| 135 | m_pPlayBtn = new ToggleButton( |
|---|
| 136 | pControlsPanel, |
|---|
| 137 | "/playerControlPanel/btn_play_on.png", |
|---|
| 138 | "/playerControlPanel/btn_play_off.png", |
|---|
| 139 | "/playerControlPanel/btn_play_over.png", |
|---|
| 140 | QSize(26, 17) |
|---|
| 141 | ); |
|---|
| 142 | m_pPlayBtn->move(222, 17); |
|---|
| 143 | m_pPlayBtn->setPressed(false); |
|---|
| 144 | m_pPlayBtn->setToolTip( trUtf8("Play/ Pause") ); |
|---|
| 145 | connect(m_pPlayBtn, SIGNAL(clicked(Button*)), this, SLOT(playBtnClicked(Button*))); |
|---|
| 146 | Action* pAction = new Action("PLAY"); |
|---|
| 147 | m_pPlayBtn->setAction( pAction ); |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | // Stop button |
|---|
| 151 | m_pStopBtn = new Button( |
|---|
| 152 | pControlsPanel, |
|---|
| 153 | "/playerControlPanel/btn_stop_on.png", |
|---|
| 154 | "/playerControlPanel/btn_stop_off.png", |
|---|
| 155 | "/playerControlPanel/btn_stop_over.png", |
|---|
| 156 | QSize(21, 15) |
|---|
| 157 | ); |
|---|
| 158 | m_pStopBtn->move(254, 17); |
|---|
| 159 | m_pStopBtn->setToolTip( trUtf8("Stop") ); |
|---|
| 160 | connect(m_pStopBtn, SIGNAL(clicked(Button*)), this, SLOT(stopBtnClicked(Button*))); |
|---|
| 161 | pAction = new Action("STOP"); |
|---|
| 162 | m_pStopBtn->setAction( pAction ); |
|---|
| 163 | |
|---|
| 164 | // Fast forward button |
|---|
| 165 | m_pFfwdBtn = new Button( |
|---|
| 166 | pControlsPanel, |
|---|
| 167 | "/playerControlPanel/btn_ffwd_on.png", |
|---|
| 168 | "/playerControlPanel/btn_ffwd_off.png", |
|---|
| 169 | "/playerControlPanel/btn_ffwd_over.png", |
|---|
| 170 | QSize(21, 15) |
|---|
| 171 | ); |
|---|
| 172 | m_pFfwdBtn->move(281, 17); |
|---|
| 173 | m_pFfwdBtn->setToolTip( trUtf8("Fast Forward") ); |
|---|
| 174 | connect(m_pFfwdBtn, SIGNAL(clicked(Button*)), this, SLOT(FFWDBtnClicked(Button*))); |
|---|
| 175 | |
|---|
| 176 | // Loop song button button |
|---|
| 177 | m_pSongLoopBtn = new ToggleButton( |
|---|
| 178 | pControlsPanel, |
|---|
| 179 | "/playerControlPanel/btn_loop_on.png", |
|---|
| 180 | "/playerControlPanel/btn_loop_off.png", |
|---|
| 181 | "/playerControlPanel/btn_loop_over.png", |
|---|
| 182 | QSize(21, 15) |
|---|
| 183 | ); |
|---|
| 184 | m_pSongLoopBtn->move(310, 17); |
|---|
| 185 | m_pSongLoopBtn->setToolTip( trUtf8("Loop song") ); |
|---|
| 186 | connect( m_pSongLoopBtn, SIGNAL( clicked(Button*) ), this, SLOT( songLoopBtnClicked(Button*) ) ); |
|---|
| 187 | //~ CONTROLS |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | // MODE |
|---|
| 191 | PixmapWidget *pModePanel = new PixmapWidget( NULL ); |
|---|
| 192 | pModePanel->setFixedSize( 90, 43 ); |
|---|
| 193 | pModePanel->setPixmap( "/playerControlPanel/background_Mode.png" ); |
|---|
| 194 | hbox->addWidget( pModePanel ); |
|---|
| 195 | |
|---|
| 196 | // Live mode button |
|---|
| 197 | m_pLiveModeBtn = new ToggleButton( |
|---|
| 198 | pModePanel, |
|---|
| 199 | "/playerControlPanel/statusLED_on.png", |
|---|
| 200 | "/playerControlPanel/statusLED_off.png", |
|---|
| 201 | "/playerControlPanel/statusLED_off.png", |
|---|
| 202 | QSize(11, 9) |
|---|
| 203 | ); |
|---|
| 204 | m_pLiveModeBtn->move(10, 4); |
|---|
| 205 | m_pLiveModeBtn->setPressed(true); |
|---|
| 206 | m_pLiveModeBtn->setToolTip( trUtf8("Pattern Mode") ); |
|---|
| 207 | connect(m_pLiveModeBtn, SIGNAL(clicked(Button*)), this, SLOT(liveModeBtnClicked(Button*))); |
|---|
| 208 | |
|---|
| 209 | // Song mode button |
|---|
| 210 | m_pSongModeBtn = new ToggleButton( |
|---|
| 211 | pModePanel, |
|---|
| 212 | "/playerControlPanel/statusLED_on.png", |
|---|
| 213 | "/playerControlPanel/statusLED_off.png", |
|---|
| 214 | "/playerControlPanel/statusLED_off.png", |
|---|
| 215 | QSize(11, 9) |
|---|
| 216 | ); |
|---|
| 217 | m_pSongModeBtn->move(10, 15); |
|---|
| 218 | m_pSongModeBtn->setPressed(false); |
|---|
| 219 | m_pSongModeBtn->setToolTip( trUtf8("Song Mode") ); |
|---|
| 220 | connect(m_pSongModeBtn, SIGNAL(clicked(Button*)), this, SLOT(songModeBtnClicked(Button*))); |
|---|
| 221 | |
|---|
| 222 | // Switch mode button |
|---|
| 223 | m_pSwitchModeBtn = new Button( |
|---|
| 224 | pModePanel, |
|---|
| 225 | "/playerControlPanel/btn_mode_on.png", |
|---|
| 226 | "/playerControlPanel/btn_mode_off.png", |
|---|
| 227 | "/playerControlPanel/btn_mode_over.png", |
|---|
| 228 | QSize(69, 13) |
|---|
| 229 | ); |
|---|
| 230 | m_pSwitchModeBtn->move(10, 26); |
|---|
| 231 | m_pSwitchModeBtn->setToolTip( trUtf8("Switch Song/ Pattern Mode") ); |
|---|
| 232 | connect(m_pSwitchModeBtn, SIGNAL(clicked(Button*)), this, SLOT(switchModeBtnClicked(Button*))); |
|---|
| 233 | //~ MODE |
|---|
| 234 | |
|---|
| 235 | // BC on off |
|---|
| 236 | PixmapWidget *pControlsBBTBConoffPanel = new PixmapWidget( NULL ); |
|---|
| 237 | pControlsBBTBConoffPanel->setFixedSize( 15, 43 ); |
|---|
| 238 | pControlsBBTBConoffPanel->setPixmap( "/playerControlPanel/onoff.png" ); |
|---|
| 239 | hbox->addWidget( pControlsBBTBConoffPanel ); |
|---|
| 240 | |
|---|
| 241 | m_pBConoffBtn = new ToggleButton( |
|---|
| 242 | pControlsBBTBConoffPanel, |
|---|
| 243 | "/playerControlPanel/bc_on.png", |
|---|
| 244 | "/playerControlPanel/bc_off.png", |
|---|
| 245 | "/playerControlPanel/bc_off.png", |
|---|
| 246 | QSize(10, 40) |
|---|
| 247 | ); |
|---|
| 248 | m_pBConoffBtn->move(1, 1); |
|---|
| 249 | m_pBConoffBtn->setPressed(false); |
|---|
| 250 | m_pBConoffBtn->setToolTip( trUtf8("BeatCounter Panel on") ); |
|---|
| 251 | connect(m_pBConoffBtn, SIGNAL(clicked(Button*)), this, SLOT(bconoffBtnClicked(Button*))); |
|---|
| 252 | //~ BC on off |
|---|
| 253 | |
|---|
| 254 | //beatcounter |
|---|
| 255 | m_pControlsBCPanel = new PixmapWidget( NULL ); |
|---|
| 256 | m_pControlsBCPanel->setFixedSize( 86, 43 ); |
|---|
| 257 | m_pControlsBCPanel->setPixmap( "/playerControlPanel/beatConter_BG.png" ); |
|---|
| 258 | hbox->addWidget( m_pControlsBCPanel ); |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | m_pBCDisplayZ = new LCDDisplay( m_pControlsBCPanel, LCDDigit::LARGE_GRAY, 2 ); |
|---|
| 262 | m_pBCDisplayZ->move( 36, 8 ); |
|---|
| 263 | m_pBCDisplayZ->setText( "--" ); |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | m_pBCDisplayT = new LCDDisplay( m_pControlsBCPanel, LCDDigit::SMALL_GRAY, 1 ); |
|---|
| 267 | m_pBCDisplayT->move( 23, 26 ); |
|---|
| 268 | m_pBCDisplayT->setText( "4" ); |
|---|
| 269 | |
|---|
| 270 | m_pBCDisplayB = new LCDDisplay( m_pControlsBCPanel, LCDDigit::SMALL_GRAY, 2 ); |
|---|
| 271 | m_pBCDisplayB->move( 39, 26 ); |
|---|
| 272 | // set display from 4 to 04. fix against qt4 transparent problem |
|---|
| 273 | // m_pBCDisplayB->setText( "4" ); |
|---|
| 274 | m_pBCDisplayB->setText( "04" ); |
|---|
| 275 | |
|---|
| 276 | m_pBCTUpBtn = new Button( |
|---|
| 277 | m_pControlsBCPanel, |
|---|
| 278 | "/lcd/LCDSpinBox_up_on.png", |
|---|
| 279 | "/lcd/LCDSpinBox_up_off.png", |
|---|
| 280 | "/lcd/LCDSpinBox_up_over.png", |
|---|
| 281 | QSize(16, 8) |
|---|
| 282 | ); |
|---|
| 283 | m_pBCTUpBtn->move( 4, 6 ); |
|---|
| 284 | connect( m_pBCTUpBtn, SIGNAL( clicked( Button* ) ), this, SLOT(bctButtonClicked( Button* ) ) ); |
|---|
| 285 | |
|---|
| 286 | m_pBCTDownBtn = new Button( |
|---|
| 287 | m_pControlsBCPanel, |
|---|
| 288 | "/lcd/LCDSpinBox_down_on.png", |
|---|
| 289 | "/lcd/LCDSpinBox_down_off.png", |
|---|
| 290 | "/lcd/LCDSpinBox_down_over.png", |
|---|
| 291 | QSize(16, 8) |
|---|
| 292 | ); |
|---|
| 293 | m_pBCTDownBtn->move( 4, 16 ); |
|---|
| 294 | connect( m_pBCTDownBtn, SIGNAL( clicked( Button* ) ), this, SLOT(bctButtonClicked( Button* ) ) ); |
|---|
| 295 | |
|---|
| 296 | m_pBCBUpBtn = new Button( |
|---|
| 297 | m_pControlsBCPanel, |
|---|
| 298 | "/lcd/LCDSpinBox_up_on.png", |
|---|
| 299 | "/lcd/LCDSpinBox_up_off.png", |
|---|
| 300 | "/lcd/LCDSpinBox_up_over.png", |
|---|
| 301 | QSize(16, 8) |
|---|
| 302 | ); |
|---|
| 303 | m_pBCBUpBtn->move( 65, 6 ); |
|---|
| 304 | connect( m_pBCBUpBtn, SIGNAL( clicked( Button* ) ), this, SLOT(bcbButtonClicked( Button* ) ) ); |
|---|
| 305 | |
|---|
| 306 | m_pBCBDownBtn = new Button( |
|---|
| 307 | m_pControlsBCPanel, |
|---|
| 308 | "/lcd/LCDSpinBox_down_on.png", |
|---|
| 309 | "/lcd/LCDSpinBox_down_off.png", |
|---|
| 310 | "/lcd/LCDSpinBox_down_over.png", |
|---|
| 311 | QSize(16, 8) |
|---|
| 312 | ); |
|---|
| 313 | m_pBCBDownBtn->move( 65, 16 ); |
|---|
| 314 | connect( m_pBCBDownBtn, SIGNAL( clicked( Button* ) ), this, SLOT(bcbButtonClicked( Button* ) ) ); |
|---|
| 315 | |
|---|
| 316 | m_pBCSetPlayBtn = new ToggleButton( |
|---|
| 317 | m_pControlsBCPanel, |
|---|
| 318 | "/playerControlPanel/btn_set_play_on.png", |
|---|
| 319 | "/playerControlPanel/btn_set_play_off.png", |
|---|
| 320 | "/playerControlPanel/btn_set_play_off.png", |
|---|
| 321 | QSize(15, 13) |
|---|
| 322 | ); |
|---|
| 323 | m_pBCSetPlayBtn->move(67, 27); |
|---|
| 324 | m_pBCSetPlayBtn->setPressed(false); |
|---|
| 325 | m_pBCSetPlayBtn->setToolTip( trUtf8("Set BPM / Set BPM and play") ); |
|---|
| 326 | connect(m_pBCSetPlayBtn, SIGNAL(clicked(Button*)), this, SLOT(bcSetPlayBtnClicked(Button*))); |
|---|
| 327 | //~ beatcounter |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | // BPM |
|---|
| 331 | PixmapWidget *pBPMPanel = new PixmapWidget( NULL ); |
|---|
| 332 | pBPMPanel->setFixedSize( 145, 43 ); |
|---|
| 333 | pBPMPanel->setPixmap( "/playerControlPanel/background_BPM.png" ); |
|---|
| 334 | hbox->addWidget( pBPMPanel ); |
|---|
| 335 | |
|---|
| 336 | // LCD BPM SpinBox |
|---|
| 337 | m_pLCDBPMSpinbox = new LCDSpinBox( pBPMPanel, 6, LCDSpinBox::FLOAT, 30, 400 ); |
|---|
| 338 | m_pLCDBPMSpinbox->move( 43, 6 ); |
|---|
| 339 | connect( m_pLCDBPMSpinbox, SIGNAL(changed(LCDSpinBox*)), this, SLOT(bpmChanged())); |
|---|
| 340 | connect( m_pLCDBPMSpinbox, SIGNAL(spinboxClicked()), this, SLOT(bpmClicked())); |
|---|
| 341 | |
|---|
| 342 | m_pBPMUpBtn = new Button( |
|---|
| 343 | pBPMPanel, |
|---|
| 344 | "/lcd/LCDSpinBox_up_on.png", |
|---|
| 345 | "/lcd/LCDSpinBox_up_off.png", |
|---|
| 346 | "/lcd/LCDSpinBox_up_over.png", |
|---|
| 347 | QSize(16, 8) |
|---|
| 348 | ); |
|---|
| 349 | m_pBPMUpBtn->move( 12, 5 ); |
|---|
| 350 | connect( m_pBPMUpBtn, SIGNAL( clicked( Button* ) ), this, SLOT(bpmButtonClicked( Button* ) ) ); |
|---|
| 351 | connect( m_pBPMUpBtn, SIGNAL( mousePress( Button* ) ), this, SLOT(bpmButtonPressed( Button* ) ) ); |
|---|
| 352 | |
|---|
| 353 | m_pBPMDownBtn = new Button( |
|---|
| 354 | pBPMPanel, |
|---|
| 355 | "/lcd/LCDSpinBox_down_on.png", |
|---|
| 356 | "/lcd/LCDSpinBox_down_off.png", |
|---|
| 357 | "/lcd/LCDSpinBox_down_over.png", |
|---|
| 358 | QSize(16, 8) |
|---|
| 359 | ); |
|---|
| 360 | m_pBPMDownBtn->move( 12, 14 ); |
|---|
| 361 | connect( m_pBPMDownBtn, SIGNAL( clicked( Button* ) ), this, SLOT(bpmButtonClicked( Button* ) ) ); |
|---|
| 362 | connect( m_pBPMDownBtn, SIGNAL( mousePress( Button* ) ), this, SLOT(bpmButtonPressed( Button* ) ) ); |
|---|
| 363 | |
|---|
| 364 | m_pRubberBPMChange = new ToggleButton( |
|---|
| 365 | pBPMPanel, |
|---|
| 366 | "/playerControlPanel/rubber_on.png", |
|---|
| 367 | "/playerControlPanel/rubber_off.png", |
|---|
| 368 | "/playerControlPanel/rubber_off.png", |
|---|
| 369 | QSize(9, 37) |
|---|
| 370 | ); |
|---|
| 371 | m_pRubberBPMChange->move( 133, 3 ); |
|---|
| 372 | m_pRubberBPMChange->setToolTip( trUtf8("Recalculate Rubberband modified samples if bpm will change") ); |
|---|
| 373 | m_pRubberBPMChange->setPressed(false); |
|---|
| 374 | connect( m_pRubberBPMChange, SIGNAL( clicked( Button* ) ), this, SLOT(rubberbandButtonToggle( Button* ) ) ); |
|---|
| 375 | QString program = Preferences::get_instance()->m_rubberBandCLIexecutable; |
|---|
| 376 | //test the path. if test fails, no button |
|---|
| 377 | if ( QFile( program ).exists() == false) { |
|---|
| 378 | m_pRubberBPMChange->hide(); |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | |
|---|
| 382 | m_pMetronomeWidget = new MetronomeWidget( pBPMPanel ); |
|---|
| 383 | m_pMetronomeWidget->resize( 85, 5 ); |
|---|
| 384 | m_pMetronomeWidget->move( 42, 25 ); |
|---|
| 385 | |
|---|
| 386 | m_pMetronomeBtn = new ToggleButton( |
|---|
| 387 | pBPMPanel, |
|---|
| 388 | "/playerControlPanel/btn_metronome_on.png", |
|---|
| 389 | "/playerControlPanel/btn_metronome_off.png", |
|---|
| 390 | "/playerControlPanel/btn_metronome_over.png", |
|---|
| 391 | QSize( 20, 13 ) |
|---|
| 392 | ); |
|---|
| 393 | m_pMetronomeBtn->move( 10, 26 ); |
|---|
| 394 | connect( m_pMetronomeBtn, SIGNAL( clicked( Button* ) ), this, SLOT(metronomeButtonClicked( Button* ) ) ); |
|---|
| 395 | //~ BPM |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | // JACK |
|---|
| 399 | PixmapWidget *pJackPanel = new PixmapWidget( NULL ); |
|---|
| 400 | pJackPanel->setFixedSize( 113, 43 ); |
|---|
| 401 | pJackPanel->setPixmap( "/playerControlPanel/background_Jack.png" ); |
|---|
| 402 | hbox->addWidget( pJackPanel ); |
|---|
| 403 | |
|---|
| 404 | // Jack transport mode button |
|---|
| 405 | m_pJackTransportBtn = new ToggleButton( |
|---|
| 406 | pJackPanel, |
|---|
| 407 | "/playerControlPanel/jackTransportBtn_on.png", |
|---|
| 408 | "/playerControlPanel/jackTransportBtn_off.png", |
|---|
| 409 | "/playerControlPanel/jackTransportBtn_over.png", |
|---|
| 410 | QSize(45, 13) |
|---|
| 411 | ); |
|---|
| 412 | m_pJackTransportBtn->hide(); |
|---|
| 413 | m_pJackTransportBtn->setPressed(true); |
|---|
| 414 | m_pJackTransportBtn->setToolTip( trUtf8("Jack-transport on/off") ); |
|---|
| 415 | connect(m_pJackTransportBtn, SIGNAL(clicked(Button*)), this, SLOT(jackTransportBtnClicked(Button*))); |
|---|
| 416 | m_pJackTransportBtn->move(10, 26); |
|---|
| 417 | |
|---|
| 418 | //jack time master |
|---|
| 419 | m_pJackMasterBtn = new ToggleButton( |
|---|
| 420 | pJackPanel, |
|---|
| 421 | "/playerControlPanel/jackMasterBtn_on.png", |
|---|
| 422 | "/playerControlPanel/jackMasterBtn_off.png", |
|---|
| 423 | "/playerControlPanel/jackMasterBtn_over.png", |
|---|
| 424 | QSize(45, 13) |
|---|
| 425 | ); |
|---|
| 426 | m_pJackMasterBtn->hide(); |
|---|
| 427 | m_pJackMasterBtn->setPressed(true); |
|---|
| 428 | m_pJackMasterBtn->setToolTip( trUtf8("Jack-Time-Master on/off") ); |
|---|
| 429 | connect(m_pJackMasterBtn, SIGNAL(clicked(Button*)), this, SLOT(jackMasterBtnClicked(Button*))); |
|---|
| 430 | m_pJackMasterBtn->move(56, 26); |
|---|
| 431 | //~ jack time master |
|---|
| 432 | |
|---|
| 433 | m_pEngine = Hydrogen::get_instance(); |
|---|
| 434 | |
|---|
| 435 | // CPU load widget |
|---|
| 436 | m_pCpuLoadWidget = new CpuLoadWidget( pJackPanel ); |
|---|
| 437 | |
|---|
| 438 | // Midi Activity widget |
|---|
| 439 | m_pMidiActivityWidget = new MidiActivityWidget( pJackPanel ); |
|---|
| 440 | |
|---|
| 441 | m_pMidiActivityWidget->move( 10, 14 ); |
|---|
| 442 | m_pCpuLoadWidget->move( 10, 4 ); |
|---|
| 443 | //~ JACK |
|---|
| 444 | |
|---|
| 445 | |
|---|
| 446 | PixmapWidget *pLcdBackGround = new PixmapWidget( NULL ); |
|---|
| 447 | pLcdBackGround->setFixedSize( 256, 43 ); |
|---|
| 448 | pLcdBackGround->setPixmap( "/playerControlPanel/lcd_background.png" ); |
|---|
| 449 | hbox->addWidget( pLcdBackGround ); |
|---|
| 450 | |
|---|
| 451 | m_pShowMixerBtn = new ToggleButton( |
|---|
| 452 | pLcdBackGround, |
|---|
| 453 | "/skin_btn_on.png", |
|---|
| 454 | "/skin_btn_off.png", |
|---|
| 455 | "/skin_btn_over.png", |
|---|
| 456 | QSize( 80, 17 ), |
|---|
| 457 | true |
|---|
| 458 | ); |
|---|
| 459 | m_pShowMixerBtn->move( 7, 6 ); |
|---|
| 460 | m_pShowMixerBtn->setToolTip( trUtf8( "Show mixer" ) ); |
|---|
| 461 | m_pShowMixerBtn->setText( trUtf8( "Mixer" ) ); |
|---|
| 462 | connect(m_pShowMixerBtn, SIGNAL(clicked(Button*)), this, SLOT(showButtonClicked(Button*))); |
|---|
| 463 | |
|---|
| 464 | m_pShowInstrumentRackBtn = new ToggleButton( |
|---|
| 465 | pLcdBackGround, |
|---|
| 466 | "/skin_btn_on.png", |
|---|
| 467 | "/skin_btn_off.png", |
|---|
| 468 | "/skin_btn_over.png", |
|---|
| 469 | QSize( 160, 17 ), |
|---|
| 470 | true |
|---|
| 471 | ); |
|---|
| 472 | m_pShowInstrumentRackBtn->move( 88, 6 ); |
|---|
| 473 | m_pShowInstrumentRackBtn->setToolTip( trUtf8( "Show Instrument Rack" ) ); |
|---|
| 474 | m_pShowInstrumentRackBtn->setText( trUtf8( "Instrument rack" ) ); |
|---|
| 475 | connect( m_pShowInstrumentRackBtn, SIGNAL( clicked(Button*) ), this, SLOT( showButtonClicked( Button*)) ); |
|---|
| 476 | |
|---|
| 477 | m_pStatusLabel = new LCDDisplay(pLcdBackGround , LCDDigit::SMALL_BLUE, 30, true ); |
|---|
| 478 | m_pStatusLabel->move( 7, 25 ); |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | hbox->addStretch( 1000 ); // this must be the last widget in the HBOX!! |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | |
|---|
| 486 | QTimer *timer = new QTimer( this ); |
|---|
| 487 | connect(timer, SIGNAL(timeout()), this, SLOT(updatePlayerControl())); |
|---|
| 488 | timer->start(100); // update player control at 10 fps |
|---|
| 489 | |
|---|
| 490 | m_pBPMTimer = new QTimer( this ); |
|---|
| 491 | connect(m_pBPMTimer, SIGNAL(timeout()), this, SLOT(onBpmTimerEvent())); |
|---|
| 492 | |
|---|
| 493 | m_pStatusTimer = new QTimer( this ); |
|---|
| 494 | connect( m_pStatusTimer, SIGNAL( timeout() ), this, SLOT( onStatusTimerEvent() ) ); |
|---|
| 495 | |
|---|
| 496 | m_pScrollTimer = new QTimer( this ); |
|---|
| 497 | connect( m_pScrollTimer, SIGNAL( timeout() ), this, SLOT( onScrollTimerEvent() ) ); |
|---|
| 498 | m_pScrollMessage = ""; |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | |
|---|
| 504 | PlayerControl::~PlayerControl() { |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | |
|---|
| 508 | |
|---|
| 509 | |
|---|
| 510 | |
|---|
| 511 | void PlayerControl::updatePlayerControl() |
|---|
| 512 | { |
|---|
| 513 | Preferences *pPref = Preferences::get_instance(); |
|---|
| 514 | HydrogenApp *pH2App = HydrogenApp::get_instance(); |
|---|
| 515 | m_pShowMixerBtn->setPressed( pH2App->getMixer()->isVisible() ); |
|---|
| 516 | m_pShowInstrumentRackBtn->setPressed( pH2App->getInstrumentRack()->isVisible() ); |
|---|
| 517 | |
|---|
| 518 | int state = m_pEngine->getState(); |
|---|
| 519 | if (state == STATE_PLAYING ) { |
|---|
| 520 | m_pPlayBtn->setPressed(true); |
|---|
| 521 | } |
|---|
| 522 | else { |
|---|
| 523 | m_pPlayBtn->setPressed(false); |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | if (pPref->getRecordEvents()) { |
|---|
| 527 | m_pRecBtn->setPressed(true); |
|---|
| 528 | m_pRecDelBtn->setPressed(true); |
|---|
| 529 | } |
|---|
| 530 | else { |
|---|
| 531 | m_pRecBtn->setPressed(false); |
|---|
| 532 | m_pRecDelBtn->setPressed(false); |
|---|
| 533 | } |
|---|
| 534 | |
|---|
| 535 | if (pPref->getDestructiveRecord()) { |
|---|
| 536 | if ( m_pRecDelBtn->isHidden() ) { |
|---|
| 537 | m_pRecBtn->setHidden(true); |
|---|
| 538 | m_pRecDelBtn->setHidden(false); |
|---|
| 539 | } |
|---|
| 540 | } |
|---|
| 541 | else { |
|---|
| 542 | if ( m_pRecBtn->isHidden() ) { |
|---|
| 543 | m_pRecBtn->setHidden(false); |
|---|
| 544 | m_pRecDelBtn->setHidden(true); |
|---|
| 545 | } |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | Song *song = m_pEngine->getSong(); |
|---|
| 549 | |
|---|
| 550 | m_pSongLoopBtn->setPressed( song->is_loop_enabled() ); |
|---|
| 551 | |
|---|
| 552 | m_pLCDBPMSpinbox->setValue( song->__bpm ); |
|---|
| 553 | |
|---|
| 554 | if ( song->get_mode() == Song::PATTERN_MODE ) { |
|---|
| 555 | m_pLiveModeBtn->setPressed( true ); |
|---|
| 556 | m_pSongModeBtn->setPressed( false ); |
|---|
| 557 | } |
|---|
| 558 | else { |
|---|
| 559 | m_pLiveModeBtn->setPressed( false ); |
|---|
| 560 | m_pSongModeBtn->setPressed( true ); |
|---|
| 561 | } |
|---|
| 562 | |
|---|
| 563 | //beatcounter |
|---|
| 564 | if ( pPref->m_bbc == Preferences::BC_OFF ) { |
|---|
| 565 | m_pControlsBCPanel->hide(); |
|---|
| 566 | m_pBConoffBtn->setPressed(false); |
|---|
| 567 | }else |
|---|
| 568 | { |
|---|
| 569 | m_pControlsBCPanel->show(); |
|---|
| 570 | m_pBConoffBtn->setPressed(true); |
|---|
| 571 | } |
|---|
| 572 | |
|---|
| 573 | if ( pPref->m_mmcsetplay == Preferences::SET_PLAY_OFF) { |
|---|
| 574 | m_pBCSetPlayBtn->setPressed(false); |
|---|
| 575 | }else |
|---|
| 576 | { |
|---|
| 577 | m_pBCSetPlayBtn->setPressed(true); |
|---|
| 578 | } |
|---|
| 579 | //~ beatcounter |
|---|
| 580 | |
|---|
| 581 | |
|---|
| 582 | |
|---|
| 583 | |
|---|
| 584 | if ( pPref->m_sAudioDriver == "Jack" ) { |
|---|
| 585 | m_pJackTransportBtn->show(); |
|---|
| 586 | switch ( pPref->m_bJackTransportMode ) { |
|---|
| 587 | case Preferences::NO_JACK_TRANSPORT: |
|---|
| 588 | m_pJackTransportBtn->setPressed(false); |
|---|
| 589 | // Jack Master Btn |
|---|
| 590 | m_pJackMasterBtn->setPressed(false); |
|---|
| 591 | break; |
|---|
| 592 | |
|---|
| 593 | case Preferences::USE_JACK_TRANSPORT: |
|---|
| 594 | m_pJackTransportBtn->setPressed(true); |
|---|
| 595 | //m_pJackMasterBtn->setPressed(false); |
|---|
| 596 | break; |
|---|
| 597 | } |
|---|
| 598 | } |
|---|
| 599 | else { |
|---|
| 600 | m_pJackTransportBtn->hide(); |
|---|
| 601 | } |
|---|
| 602 | |
|---|
| 603 | //jack transport master |
|---|
| 604 | #ifdef JACK_SUPPORT |
|---|
| 605 | if ( pPref->m_sAudioDriver == "Jack" ) { |
|---|
| 606 | m_pJackMasterBtn->show(); |
|---|
| 607 | switch ( pPref->m_bJackMasterMode ) { |
|---|
| 608 | case Preferences::NO_JACK_TIME_MASTER: |
|---|
| 609 | m_pJackMasterBtn->setPressed(false); |
|---|
| 610 | break; |
|---|
| 611 | |
|---|
| 612 | case Preferences::USE_JACK_TIME_MASTER: |
|---|
| 613 | if ( m_pJackTransportBtn->isPressed()){ |
|---|
| 614 | m_pJackMasterBtn->setPressed(true); |
|---|
| 615 | } |
|---|
| 616 | else |
|---|
| 617 | { |
|---|
| 618 | m_pJackMasterBtn->setPressed(false); |
|---|
| 619 | Hydrogen::get_instance()->offJackMaster(); |
|---|
| 620 | pPref->m_bJackMasterMode = Preferences::NO_JACK_TIME_MASTER; |
|---|
| 621 | } |
|---|
| 622 | //m_pJackTransportBtn->setPressed(true); |
|---|
| 623 | break; |
|---|
| 624 | } |
|---|
| 625 | } |
|---|
| 626 | else { |
|---|
| 627 | m_pJackMasterBtn->hide(); |
|---|
| 628 | |
|---|
| 629 | } |
|---|
| 630 | #endif |
|---|
| 631 | //~ jack transport master |
|---|
| 632 | |
|---|
| 633 | // time |
|---|
| 634 | float fFrames = m_pEngine->getAudioOutput()->m_transport.m_nFrames; |
|---|
| 635 | if ( Preferences::get_instance()->m_bJackTransportMode == Preferences::USE_JACK_TRANSPORT ) |
|---|
| 636 | fFrames = m_pEngine->getHumantimeFrames(); |
|---|
| 637 | float fSampleRate = m_pEngine->getAudioOutput()->getSampleRate(); |
|---|
| 638 | if ( fSampleRate != 0 ) { |
|---|
| 639 | float fSeconds = fFrames / fSampleRate; |
|---|
| 640 | |
|---|
| 641 | int nMSec = (int)( (fSeconds - (int)fSeconds) * 1000.0 ); |
|---|
| 642 | int nSeconds = ( (int)fSeconds ) % 60; |
|---|
| 643 | int nMins = (int)( fSeconds / 60.0 ) % 60; |
|---|
| 644 | int nHours = (int)( fSeconds / 3600.0 ); |
|---|
| 645 | |
|---|
| 646 | char tmp[100]; |
|---|
| 647 | sprintf(tmp, "%02d", nHours ); |
|---|
| 648 | m_pTimeDisplayH->setText( QString( tmp ) ); |
|---|
| 649 | |
|---|
| 650 | sprintf(tmp, "%02d", nMins ); |
|---|
| 651 | m_pTimeDisplayM->setText( QString( tmp ) ); |
|---|
| 652 | |
|---|
| 653 | sprintf(tmp, "%02d", nSeconds ); |
|---|
| 654 | m_pTimeDisplayS->setText( QString( tmp ) ); |
|---|
| 655 | |
|---|
| 656 | sprintf(tmp, "%03d", nMSec ); |
|---|
| 657 | m_pTimeDisplayMS->setText( QString( tmp ) ); |
|---|
| 658 | } |
|---|
| 659 | |
|---|
| 660 | m_pMetronomeBtn->setPressed(pPref->m_bUseMetronome); |
|---|
| 661 | |
|---|
| 662 | |
|---|
| 663 | //beatcounter get BC message |
|---|
| 664 | char bcstatus[4]; |
|---|
| 665 | int beatstocountondisplay = 1; |
|---|
| 666 | beatstocountondisplay = m_pEngine->getBcStatus(); |
|---|
| 667 | |
|---|
| 668 | switch (beatstocountondisplay){ |
|---|
| 669 | case 1 : |
|---|
| 670 | if (bcDisplaystatus == 1){ |
|---|
| 671 | Preferences::get_instance()->m_bbc = Preferences::BC_OFF; |
|---|
| 672 | bcDisplaystatus = 0; |
|---|
| 673 | } |
|---|
| 674 | sprintf(bcstatus, "R"); |
|---|
| 675 | m_pBCDisplayZ->setText( QString (bcstatus) ); |
|---|
| 676 | |
|---|
| 677 | break; |
|---|
| 678 | default: |
|---|
| 679 | if (Preferences::get_instance()->m_bbc == Preferences::BC_OFF){ |
|---|
| 680 | Preferences::get_instance()->m_bbc = Preferences::BC_ON; |
|---|
| 681 | bcDisplaystatus = 1; |
|---|
| 682 | } |
|---|
| 683 | sprintf(bcstatus, "%02d ", beatstocountondisplay -1); |
|---|
| 684 | m_pBCDisplayZ->setText( QString (bcstatus) ); |
|---|
| 685 | |
|---|
| 686 | } |
|---|
| 687 | //~ beatcounter |
|---|
| 688 | |
|---|
| 689 | //timeline check |
|---|
| 690 | // if( Preferences::get_instance()->__usetimeline ){ |
|---|
| 691 | // m_pRubberBPMChange->setPressed( false ); |
|---|
| 692 | // Preferences::get_instance()->m_useTheRubberbandBpmChangeEvent = false; |
|---|
| 693 | // } |
|---|
| 694 | } |
|---|
| 695 | |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | /// Toggle record mode |
|---|
| 699 | void PlayerControl::recBtnClicked(Button* ref) { |
|---|
| 700 | if ( m_pEngine->getState() != STATE_PLAYING ) { |
|---|
| 701 | if (ref->isPressed()) { |
|---|
| 702 | Preferences::get_instance()->setRecordEvents(true); |
|---|
| 703 | (HydrogenApp::get_instance())->setScrollStatusBarMessage(trUtf8("Record midi events = On" ), 2000 ); |
|---|
| 704 | } |
|---|
| 705 | else { |
|---|
| 706 | Preferences::get_instance()->setRecordEvents(false); |
|---|
| 707 | (HydrogenApp::get_instance())->setScrollStatusBarMessage(trUtf8("Record midi events = Off" ), 2000 ); |
|---|
| 708 | } |
|---|
| 709 | } |
|---|
| 710 | } |
|---|
| 711 | |
|---|
| 712 | |
|---|
| 713 | /// Toggle destructive/nondestructive move |
|---|
| 714 | void PlayerControl::recBtnRightClicked(Button* ref) { |
|---|
| 715 | UNUSED( ref ); |
|---|
| 716 | if ( Preferences::get_instance()->getDestructiveRecord() ) { |
|---|
| 717 | Preferences::get_instance()->setDestructiveRecord(false); |
|---|
| 718 | (HydrogenApp::get_instance())->setScrollStatusBarMessage(trUtf8("Destructive mode = Off" ), 2000 ); |
|---|
| 719 | } |
|---|
| 720 | else { |
|---|
| 721 | Preferences::get_instance()->setDestructiveRecord(true); |
|---|
| 722 | (HydrogenApp::get_instance())->setScrollStatusBarMessage(trUtf8("Destructive mode = On" ), 2000 ); |
|---|
| 723 | } |
|---|
| 724 | HydrogenApp::get_instance()->enableDestructiveRecMode(); |
|---|
| 725 | } |
|---|
| 726 | |
|---|
| 727 | |
|---|
| 728 | /// Start audio engine |
|---|
| 729 | void PlayerControl::playBtnClicked(Button* ref) { |
|---|
| 730 | if (ref->isPressed()) { |
|---|
| 731 | m_pEngine->sequencer_play(); |
|---|
| 732 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Playing."), 5000); |
|---|
| 733 | } |
|---|
| 734 | else { |
|---|
| 735 | // m_pPlayBtn->setPressed(true); |
|---|
| 736 | m_pEngine->sequencer_stop(); |
|---|
| 737 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Pause."), 5000); |
|---|
| 738 | } |
|---|
| 739 | } |
|---|
| 740 | |
|---|
| 741 | |
|---|
| 742 | |
|---|
| 743 | |
|---|
| 744 | /// Stop audio engine |
|---|
| 745 | void PlayerControl::stopBtnClicked(Button* ref) |
|---|
| 746 | { |
|---|
| 747 | UNUSED( ref ); |
|---|
| 748 | m_pPlayBtn->setPressed(false); |
|---|
| 749 | m_pEngine->sequencer_stop(); |
|---|
| 750 | m_pEngine->setPatternPos( 0 ); |
|---|
| 751 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Stopped."), 5000); |
|---|
| 752 | Hydrogen::get_instance()->setTimelineBpm(); |
|---|
| 753 | } |
|---|
| 754 | |
|---|
| 755 | |
|---|
| 756 | |
|---|
| 757 | |
|---|
| 758 | /// Switch mode |
|---|
| 759 | void PlayerControl::switchModeBtnClicked(Button* ref) |
|---|
| 760 | { |
|---|
| 761 | UNUSED( ref ); |
|---|
| 762 | |
|---|
| 763 | Song *song = m_pEngine->getSong(); |
|---|
| 764 | |
|---|
| 765 | m_pEngine->sequencer_stop(); |
|---|
| 766 | m_pEngine->setPatternPos( 0 ); // from start |
|---|
| 767 | if( song->get_mode() == Song::PATTERN_MODE ) { |
|---|
| 768 | m_pEngine->getSong()->set_mode( Song::SONG_MODE ); |
|---|
| 769 | m_pSongModeBtn->setPressed(true); |
|---|
| 770 | m_pLiveModeBtn->setPressed(false); |
|---|
| 771 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Song mode selected."), 5000); |
|---|
| 772 | } |
|---|
| 773 | else { |
|---|
| 774 | m_pEngine->getSong()->set_mode( Song::PATTERN_MODE ); |
|---|
| 775 | m_pSongModeBtn->setPressed(false); |
|---|
| 776 | m_pLiveModeBtn->setPressed(true); |
|---|
| 777 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Pattern mode selected."), 5000); |
|---|
| 778 | } |
|---|
| 779 | } |
|---|
| 780 | |
|---|
| 781 | |
|---|
| 782 | |
|---|
| 783 | |
|---|
| 784 | /// Set Song mode |
|---|
| 785 | void PlayerControl::songModeBtnClicked(Button* ref) |
|---|
| 786 | { |
|---|
| 787 | UNUSED( ref ); |
|---|
| 788 | |
|---|
| 789 | m_pEngine->sequencer_stop(); |
|---|
| 790 | m_pEngine->setPatternPos( 0 ); // from start |
|---|
| 791 | m_pEngine->getSong()->set_mode( Song::SONG_MODE ); |
|---|
| 792 | m_pSongModeBtn->setPressed(true); |
|---|
| 793 | m_pLiveModeBtn->setPressed(false); |
|---|
| 794 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Song mode selected."), 5000); |
|---|
| 795 | } |
|---|
| 796 | |
|---|
| 797 | |
|---|
| 798 | |
|---|
| 799 | |
|---|
| 800 | ///Set Live mode |
|---|
| 801 | void PlayerControl::liveModeBtnClicked(Button* ref) |
|---|
| 802 | { |
|---|
| 803 | UNUSED( ref ); |
|---|
| 804 | |
|---|
| 805 | m_pEngine->sequencer_stop(); |
|---|
| 806 | m_pEngine->getSong()->set_mode( Song::PATTERN_MODE ); |
|---|
| 807 | //m_pEngine->sequencer_setNextPattern( m_pEngine->getSelectedPatternNumber() ); // imposto il pattern correntemente selezionato come il prossimo da suonare |
|---|
| 808 | m_pSongModeBtn->setPressed(false); |
|---|
| 809 | m_pLiveModeBtn->setPressed(true); |
|---|
| 810 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Pattern mode selected."), 5000); |
|---|
| 811 | } |
|---|
| 812 | |
|---|
| 813 | |
|---|
| 814 | |
|---|
| 815 | void PlayerControl::bpmChanged() { |
|---|
| 816 | float fNewBpmValue = m_pLCDBPMSpinbox->getValue(); |
|---|
| 817 | if (fNewBpmValue < 30) { |
|---|
| 818 | fNewBpmValue = 30; |
|---|
| 819 | } |
|---|
| 820 | else if (fNewBpmValue > 400 ) { |
|---|
| 821 | fNewBpmValue = 400; |
|---|
| 822 | } |
|---|
| 823 | |
|---|
| 824 | m_pEngine->getSong()->__is_modified = true; |
|---|
| 825 | |
|---|
| 826 | AudioEngine::get_instance()->lock( RIGHT_HERE ); |
|---|
| 827 | m_pEngine->setBPM( fNewBpmValue ); |
|---|
| 828 | AudioEngine::get_instance()->unlock(); |
|---|
| 829 | } |
|---|
| 830 | |
|---|
| 831 | |
|---|
| 832 | |
|---|
| 833 | //beatcounter |
|---|
| 834 | void PlayerControl::bconoffBtnClicked( Button* ) |
|---|
| 835 | { |
|---|
| 836 | Preferences *pPref = Preferences::get_instance(); |
|---|
| 837 | if (m_pBConoffBtn->isPressed()) { |
|---|
| 838 | pPref->m_bbc = Preferences::BC_ON; |
|---|
| 839 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8(" BC Panel on"), 5000); |
|---|
| 840 | m_pControlsBCPanel->show(); |
|---|
| 841 | |
|---|
| 842 | } |
|---|
| 843 | else { |
|---|
| 844 | pPref->m_bbc = Preferences::BC_OFF; |
|---|
| 845 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8(" BC Panel off"), 5000); |
|---|
| 846 | m_pControlsBCPanel->hide(); |
|---|
| 847 | } |
|---|
| 848 | |
|---|
| 849 | } |
|---|
| 850 | |
|---|
| 851 | void PlayerControl::bcSetPlayBtnClicked( Button* ) |
|---|
| 852 | { |
|---|
| 853 | Preferences *pPref = Preferences::get_instance(); |
|---|
| 854 | if (m_pBCSetPlayBtn->isPressed()) { |
|---|
| 855 | pPref->m_mmcsetplay = Preferences::SET_PLAY_ON; |
|---|
| 856 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8(" Count BPM and start PLAY"), 5000); |
|---|
| 857 | |
|---|
| 858 | } |
|---|
| 859 | else { |
|---|
| 860 | pPref->m_mmcsetplay = Preferences::SET_PLAY_OFF; |
|---|
| 861 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8(" Count and set BPM"), 5000); |
|---|
| 862 | } |
|---|
| 863 | |
|---|
| 864 | } |
|---|
| 865 | |
|---|
| 866 | |
|---|
| 867 | void PlayerControl::rubberbandButtonToggle(Button* ) |
|---|
| 868 | { |
|---|
| 869 | Preferences *pPref = Preferences::get_instance(); |
|---|
| 870 | if (m_pRubberBPMChange->isPressed()) { |
|---|
| 871 | EventQueue::get_instance()->push_event( EVENT_RECALCULATERUBBERBAND, -1); |
|---|
| 872 | pPref->m_useTheRubberbandBpmChangeEvent = true; |
|---|
| 873 | (HydrogenApp::get_instance())->setScrollStatusBarMessage(trUtf8("Recalculate all samples using Rubberband ON"), 2000); |
|---|
| 874 | |
|---|
| 875 | } |
|---|
| 876 | else { |
|---|
| 877 | pPref->m_useTheRubberbandBpmChangeEvent = false; |
|---|
| 878 | (HydrogenApp::get_instance())->setScrollStatusBarMessage(trUtf8("Recalculate all samples using Rubberband OFF"), 2000); |
|---|
| 879 | } |
|---|
| 880 | } |
|---|
| 881 | |
|---|
| 882 | |
|---|
| 883 | void PlayerControl::bcbButtonClicked( Button* bBtn) |
|---|
| 884 | { |
|---|
| 885 | int tmp = m_pEngine->getbeatsToCount(); |
|---|
| 886 | char tmpb[3]; // m_pBCBUpBtn |
|---|
| 887 | if ( bBtn == m_pBCBUpBtn ) { |
|---|
| 888 | tmp ++; |
|---|
| 889 | if (tmp > 16) |
|---|
| 890 | tmp = 2; |
|---|
| 891 | //small fix against qt4 png transparent problem |
|---|
| 892 | //think this will be solved in next time |
|---|
| 893 | // if (tmp < 10 ){ |
|---|
| 894 | // sprintf(tmpb, "%01d", tmp ); |
|---|
| 895 | // }else |
|---|
| 896 | // { |
|---|
| 897 | sprintf(tmpb, "%02d", tmp ); |
|---|
| 898 | // } |
|---|
| 899 | m_pBCDisplayB->setText( QString( tmpb ) ); |
|---|
| 900 | m_pEngine->setbeatsToCount( tmp ); |
|---|
| 901 | } |
|---|
| 902 | else { |
|---|
| 903 | tmp --; |
|---|
| 904 | if (tmp < 2 ) |
|---|
| 905 | tmp = 16; |
|---|
| 906 | //small fix against qt4 png transparent problem |
|---|
| 907 | //think this will be solved in next time |
|---|
| 908 | // if (tmp < 10 ){ |
|---|
| 909 | // sprintf(tmpb, "%01d", tmp ); |
|---|
| 910 | // }else |
|---|
| 911 | // { |
|---|
| 912 | sprintf(tmpb, "%02d", tmp ); |
|---|
| 913 | // } |
|---|
| 914 | m_pBCDisplayB->setText( QString( tmpb ) ); |
|---|
| 915 | m_pEngine->setbeatsToCount( tmp ); |
|---|
| 916 | } |
|---|
| 917 | } |
|---|
| 918 | |
|---|
| 919 | |
|---|
| 920 | |
|---|
| 921 | void PlayerControl::bctButtonClicked( Button* tBtn) |
|---|
| 922 | { |
|---|
| 923 | float tmp = m_pEngine->getNoteLength() * 4; |
|---|
| 924 | |
|---|
| 925 | if ( tBtn == m_pBCTUpBtn) { |
|---|
| 926 | tmp = tmp / 2 ; |
|---|
| 927 | if (tmp < 1) |
|---|
| 928 | tmp = 8; |
|---|
| 929 | |
|---|
| 930 | m_pBCDisplayT->setText( QString::number( tmp ) ); |
|---|
| 931 | m_pEngine->setNoteLength( (tmp) / 4 ); |
|---|
| 932 | } else { |
|---|
| 933 | tmp = tmp * 2; |
|---|
| 934 | if (tmp > 8 ) |
|---|
| 935 | tmp = 1; |
|---|
| 936 | m_pBCDisplayT->setText( QString::number(tmp) ); |
|---|
| 937 | m_pEngine->setNoteLength( (tmp) / 4 ); |
|---|
| 938 | } |
|---|
| 939 | } |
|---|
| 940 | //~ beatcounter |
|---|
| 941 | |
|---|
| 942 | |
|---|
| 943 | |
|---|
| 944 | void PlayerControl::jackTransportBtnClicked( Button* ) |
|---|
| 945 | { |
|---|
| 946 | Preferences *pPref = Preferences::get_instance(); |
|---|
| 947 | |
|---|
| 948 | if (m_pJackTransportBtn->isPressed()) { |
|---|
| 949 | AudioEngine::get_instance()->lock( RIGHT_HERE ); |
|---|
| 950 | pPref->m_bJackTransportMode = Preferences::USE_JACK_TRANSPORT; |
|---|
| 951 | AudioEngine::get_instance()->unlock(); |
|---|
| 952 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Jack-transport mode = On"), 5000); |
|---|
| 953 | } |
|---|
| 954 | else { |
|---|
| 955 | AudioEngine::get_instance()->lock( RIGHT_HERE ); |
|---|
| 956 | pPref->m_bJackTransportMode = Preferences::NO_JACK_TRANSPORT; |
|---|
| 957 | AudioEngine::get_instance()->unlock(); |
|---|
| 958 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8("Jack-transport mode = Off"), 5000); |
|---|
| 959 | } |
|---|
| 960 | |
|---|
| 961 | if (pPref->m_sAudioDriver != "Jack") { |
|---|
| 962 | QMessageBox::warning( this, "Hydrogen", trUtf8( "JACK-transport will work only with JACK driver." ) ); |
|---|
| 963 | } |
|---|
| 964 | } |
|---|
| 965 | |
|---|
| 966 | |
|---|
| 967 | //jack time master |
|---|
| 968 | void PlayerControl::jackMasterBtnClicked( Button* ) |
|---|
| 969 | { |
|---|
| 970 | #ifdef JACK_SUPPORT |
|---|
| 971 | Preferences *pPref = Preferences::get_instance(); |
|---|
| 972 | |
|---|
| 973 | if (m_pJackMasterBtn->isPressed()) { |
|---|
| 974 | AudioEngine::get_instance()->lock( RIGHT_HERE ); |
|---|
| 975 | pPref->m_bJackMasterMode = Preferences::USE_JACK_TIME_MASTER; |
|---|
| 976 | AudioEngine::get_instance()->unlock(); |
|---|
| 977 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8(" Jack-Time-Master mode = On"), 5000); |
|---|
| 978 | Hydrogen::get_instance()->onJackMaster(); |
|---|
| 979 | |
|---|
| 980 | } |
|---|
| 981 | else { |
|---|
| 982 | AudioEngine::get_instance()->lock( RIGHT_HERE ); |
|---|
| 983 | pPref->m_bJackMasterMode = Preferences::NO_JACK_TIME_MASTER; |
|---|
| 984 | AudioEngine::get_instance()->unlock(); |
|---|
| 985 | (HydrogenApp::get_instance())->setStatusBarMessage(trUtf8(" Jack-Time-Master mode = Off"), 5000); |
|---|
| 986 | //m_pControlsBBTPanel->hide(); |
|---|
| 987 | Hydrogen::get_instance()->offJackMaster(); |
|---|
| 988 | } |
|---|
| 989 | |
|---|
| 990 | if (pPref->m_sAudioDriver != "Jack") { |
|---|
| 991 | QMessageBox::warning( this, "Hydrogen", trUtf8( "JACK-transport will work only with JACK driver." ) ); |
|---|
| 992 | } |
|---|
| 993 | #endif |
|---|
| 994 | } |
|---|
| 995 | //~ jack time master |
|---|
| 996 | |
|---|
| 997 | void PlayerControl::bpmClicked() |
|---|
| 998 | { |
|---|
| 999 | bool bIsOkPressed; |
|---|
| 1000 | double fNewVal= QInputDialog::getDouble( this, "Hydrogen", trUtf8( "New BPM value" ), m_pLCDBPMSpinbox->getValue(), 10, 400, 2, &bIsOkPressed ); |
|---|
| 1001 | if ( bIsOkPressed ) { |
|---|
| 1002 | if ( fNewVal < 30 ) { |
|---|
| 1003 | return; |
|---|
| 1004 | } |
|---|
| 1005 | |
|---|
| 1006 | m_pEngine->getSong()->__is_modified = true; |
|---|
| 1007 | |
|---|
| 1008 | AudioEngine::get_instance()->lock( RIGHT_HERE ); |
|---|
| 1009 | m_pEngine->setBPM( fNewVal ); |
|---|
| 1010 | AudioEngine::get_instance()->unlock(); |
|---|
| 1011 | } |
|---|
| 1012 | else { |
|---|
| 1013 | // user entered nothing or pressed Cancel |
|---|
| 1014 | } |
|---|
| 1015 | } |
|---|
| 1016 | |
|---|
| 1017 | |
|---|
| 1018 | void PlayerControl::bpmButtonPressed( Button* pBtn) |
|---|
| 1019 | { |
|---|
| 1020 | if ( pBtn == m_pBPMUpBtn ) { |
|---|
| 1021 | m_pLCDBPMSpinbox->upBtnClicked(); |
|---|
| 1022 | m_nBPMIncrement = 1; |
|---|
| 1023 | } |
|---|
| 1024 | else { |
|---|
| 1025 | m_pLCDBPMSpinbox->downBtnClicked(); |
|---|
| 1026 | m_nBPMIncrement = -1; |
|---|
| 1027 | } |
|---|
| 1028 | m_pBPMTimer->start( 100 ); |
|---|
| 1029 | } |
|---|
| 1030 | |
|---|
| 1031 | |
|---|
| 1032 | void PlayerControl::bpmButtonClicked( Button* ) |
|---|
| 1033 | { |
|---|
| 1034 | m_pBPMTimer->stop(); |
|---|
| 1035 | } |
|---|
| 1036 | |
|---|
| 1037 | |
|---|
| 1038 | void PlayerControl::onBpmTimerEvent() |
|---|
| 1039 | { |
|---|
| 1040 | if (m_nBPMIncrement == 1) { |
|---|
| 1041 | m_pLCDBPMSpinbox->upBtnClicked(); |
|---|
| 1042 | } |
|---|
| 1043 | else { |
|---|
| 1044 | m_pLCDBPMSpinbox->downBtnClicked(); |
|---|
| 1045 | } |
|---|
| 1046 | } |
|---|
| 1047 | |
|---|
| 1048 | |
|---|
| 1049 | void PlayerControl::FFWDBtnClicked( Button* ) |
|---|
| 1050 | { |
|---|
| 1051 | Hydrogen *pEngine = Hydrogen::get_instance(); |
|---|
| 1052 | pEngine->setPatternPos( pEngine->getPatternPos() + 1 ); |
|---|
| 1053 | Hydrogen::get_instance()->setTimelineBpm(); |
|---|
| 1054 | } |
|---|
| 1055 | |
|---|
| 1056 | |
|---|
| 1057 | |
|---|
| 1058 | void PlayerControl::RewindBtnClicked( Button* ) |
|---|
| 1059 | { |
|---|
| 1060 | Hydrogen *pEngine = Hydrogen::get_instance(); |
|---|
| 1061 | pEngine->setPatternPos( pEngine->getPatternPos() - 1 ); |
|---|
| 1062 | Hydrogen::get_instance()->setTimelineBpm(); |
|---|
| 1063 | } |
|---|
| 1064 | |
|---|
| 1065 | |
|---|
| 1066 | void PlayerControl::songLoopBtnClicked( Button* ) |
|---|
| 1067 | { |
|---|
| 1068 | Hydrogen *pEngine = Hydrogen::get_instance(); |
|---|
| 1069 | Song *song = pEngine->getSong(); |
|---|
| 1070 | song->set_loop_enabled( ! song->is_loop_enabled() ); |
|---|
| 1071 | song->__is_modified = true; |
|---|
| 1072 | |
|---|
| 1073 | if ( song->is_loop_enabled() ) { |
|---|
| 1074 | HydrogenApp::get_instance()->setStatusBarMessage(trUtf8("Loop song = On"), 5000); |
|---|
| 1075 | } |
|---|
| 1076 | else { |
|---|
| 1077 | HydrogenApp::get_instance()->setStatusBarMessage(trUtf8("Loop song = Off"), 5000); |
|---|
| 1078 | } |
|---|
| 1079 | } |
|---|
| 1080 | |
|---|
| 1081 | void PlayerControl::metronomeButtonClicked(Button* ref) |
|---|
| 1082 | { |
|---|
| 1083 | Preferences::get_instance()->m_bUseMetronome = ref->isPressed(); |
|---|
| 1084 | } |
|---|
| 1085 | |
|---|
| 1086 | |
|---|
| 1087 | void PlayerControl::showButtonClicked( Button* pRef ) |
|---|
| 1088 | { |
|---|
| 1089 | //INFOLOG( "[showButtonClicked]" ); |
|---|
| 1090 | HydrogenApp *pH2App = HydrogenApp::get_instance(); |
|---|
| 1091 | |
|---|
| 1092 | if ( pRef == m_pShowMixerBtn ) { |
|---|
| 1093 | bool isVisible = pH2App->getMixer()->isVisible(); |
|---|
| 1094 | pH2App->showMixer( !isVisible ); |
|---|
| 1095 | } |
|---|
| 1096 | else if ( pRef == m_pShowInstrumentRackBtn ) { |
|---|
| 1097 | bool isVisible = pH2App->getInstrumentRack()->isVisible(); |
|---|
| 1098 | pH2App->getInstrumentRack()->setHidden( isVisible ); |
|---|
| 1099 | } |
|---|
| 1100 | } |
|---|
| 1101 | |
|---|
| 1102 | |
|---|
| 1103 | |
|---|
| 1104 | void PlayerControl::showMessage( const QString& msg, int msec ) |
|---|
| 1105 | { |
|---|
| 1106 | if ( m_pScrollTimer->isActive ()) |
|---|
| 1107 | m_pScrollTimer->stop(); |
|---|
| 1108 | m_pStatusLabel->setText( msg ); |
|---|
| 1109 | m_pStatusTimer->start( msec ); |
|---|
| 1110 | |
|---|
| 1111 | |
|---|
| 1112 | } |
|---|
| 1113 | |
|---|
| 1114 | |
|---|
| 1115 | |
|---|
| 1116 | void PlayerControl::showScrollMessage( const QString& msg, int msec, bool test ) |
|---|
| 1117 | { |
|---|
| 1118 | |
|---|
| 1119 | if ( test == false ){ |
|---|
| 1120 | m_pStatusLabel->setText( msg ); |
|---|
| 1121 | m_pScrollTimer->start( msec ); |
|---|
| 1122 | }else |
|---|
| 1123 | { |
|---|
| 1124 | m_pScrollMessage = msg; |
|---|
| 1125 | m_pStatusLabel->setText( msg ); |
|---|
| 1126 | m_pStatusTimer->start( msec ); |
|---|
| 1127 | m_pScrollTimer->start( msec ); |
|---|
| 1128 | |
|---|
| 1129 | } |
|---|
| 1130 | |
|---|
| 1131 | |
|---|
| 1132 | } |
|---|
| 1133 | |
|---|
| 1134 | void PlayerControl::onScrollTimerEvent() |
|---|
| 1135 | { |
|---|
| 1136 | int lwl = 25; |
|---|
| 1137 | int msgLength = m_pScrollMessage.length(); |
|---|
| 1138 | if ( msgLength > lwl) |
|---|
| 1139 | m_pScrollMessage = m_pScrollMessage.right( msgLength - 1 ); |
|---|
| 1140 | m_pScrollTimer->stop(); |
|---|
| 1141 | |
|---|
| 1142 | if ( msgLength > lwl){ |
|---|
| 1143 | showScrollMessage( m_pScrollMessage, 150, false ); |
|---|
| 1144 | }else |
|---|
| 1145 | { |
|---|
| 1146 | showMessage( m_pScrollMessage, 2000 ); |
|---|
| 1147 | } |
|---|
| 1148 | } |
|---|
| 1149 | |
|---|
| 1150 | void PlayerControl::onStatusTimerEvent() |
|---|
| 1151 | { |
|---|
| 1152 | m_pStatusTimer->stop(); |
|---|
| 1153 | m_pStatusLabel->setText( "" ); |
|---|
| 1154 | } |
|---|
| 1155 | |
|---|
| 1156 | |
|---|
| 1157 | |
|---|
| 1158 | //:::::::::::::::::::::::::::::::::::::::::::::::: |
|---|
| 1159 | |
|---|
| 1160 | |
|---|
| 1161 | |
|---|
| 1162 | MetronomeWidget::MetronomeWidget(QWidget *pParent) |
|---|
| 1163 | : QWidget( pParent ) |
|---|
| 1164 | , Object( "MetronomeWidget" ) |
|---|
| 1165 | , m_nValue( 0 ) |
|---|
| 1166 | , m_state( METRO_OFF ) |
|---|
| 1167 | { |
|---|
| 1168 | // INFOLOG( "INIT" ); |
|---|
| 1169 | HydrogenApp::get_instance()->addEventListener( this ); |
|---|
| 1170 | |
|---|
| 1171 | m_metro_off.load( Skin::getImagePath() + "/playerControlPanel/metronome_off.png" ); |
|---|
| 1172 | m_metro_on_firstbeat.load( Skin::getImagePath() + "/playerControlPanel/metronome_up.png" ); |
|---|
| 1173 | m_metro_on.load( Skin::getImagePath() + "/playerControlPanel/metronome_down.png" ); |
|---|
| 1174 | |
|---|
| 1175 | QTimer *timer = new QTimer(this); |
|---|
| 1176 | connect( timer, SIGNAL( timeout() ), this, SLOT( updateWidget() ) ); |
|---|
| 1177 | timer->start(50); // update player control at 20 fps |
|---|
| 1178 | } |
|---|
| 1179 | |
|---|
| 1180 | |
|---|
| 1181 | MetronomeWidget::~MetronomeWidget() |
|---|
| 1182 | { |
|---|
| 1183 | // INFOLOG( "DESTROY" ); |
|---|
| 1184 | } |
|---|
| 1185 | |
|---|
| 1186 | |
|---|
| 1187 | void MetronomeWidget::metronomeEvent( int nValue ) |
|---|
| 1188 | { |
|---|
| 1189 | if (nValue == 2) // 2 = set pattern position is not needed here |
|---|
| 1190 | return; |
|---|
| 1191 | |
|---|
| 1192 | if (nValue == 1) { |
|---|
| 1193 | m_state = METRO_FIRST; |
|---|
| 1194 | m_nValue = 5; |
|---|
| 1195 | } |
|---|
| 1196 | else { |
|---|
| 1197 | m_state = METRO_ON; |
|---|
| 1198 | m_nValue = 5; |
|---|
| 1199 | } |
|---|
| 1200 | updateWidget(); |
|---|
| 1201 | } |
|---|
| 1202 | |
|---|
| 1203 | |
|---|
| 1204 | void MetronomeWidget::updateWidget() |
|---|
| 1205 | { |
|---|
| 1206 | if ( m_nValue > 0 ) { |
|---|
| 1207 | m_nValue -= 1; |
|---|
| 1208 | if (m_nValue == 0 ) { |
|---|
| 1209 | m_nValue = 0; |
|---|
| 1210 | m_state = METRO_OFF; |
|---|
| 1211 | } |
|---|
| 1212 | update(); |
|---|
| 1213 | } |
|---|
| 1214 | } |
|---|
| 1215 | |
|---|
| 1216 | |
|---|
| 1217 | void MetronomeWidget::paintEvent( QPaintEvent* ev) |
|---|
| 1218 | { |
|---|
| 1219 | QPainter painter(this); |
|---|
| 1220 | switch( m_state ) { |
|---|
| 1221 | case METRO_FIRST: |
|---|
| 1222 | painter.drawPixmap( ev->rect(), m_metro_on_firstbeat, ev->rect() ); |
|---|
| 1223 | break; |
|---|
| 1224 | |
|---|
| 1225 | case METRO_ON: |
|---|
| 1226 | painter.drawPixmap( ev->rect(), m_metro_on, ev->rect() ); |
|---|
| 1227 | break; |
|---|
| 1228 | |
|---|
| 1229 | case METRO_OFF: |
|---|
| 1230 | painter.drawPixmap( ev->rect(), m_metro_off, ev->rect() ); |
|---|
| 1231 | break; |
|---|
| 1232 | } |
|---|
| 1233 | } |
|---|
| 1234 | |
|---|
| 1235 | |
|---|
| 1236 | |
|---|
| 1237 | |
|---|