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