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