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