| | 267 | } |
|---|
| | 268 | |
|---|
| | 269 | |
|---|
| | 270 | if( sActionString == "PAN_ABSOULTE" ){ |
|---|
| | 271 | /* |
|---|
| | 272 | * sets the absolute panning of a given mixer channel |
|---|
| | 273 | */ |
|---|
| | 274 | |
|---|
| | 275 | bool ok; |
|---|
| | 276 | int nLine = pAction->getParameter1().toInt(&ok,10); |
|---|
| | 277 | int pan_param = pAction->getParameter2().toInt(&ok,10); |
|---|
| | 278 | |
|---|
| | 279 | |
|---|
| | 280 | float pan_L; |
|---|
| | 281 | float pan_R; |
|---|
| | 282 | |
|---|
| | 283 | Hydrogen *engine = Hydrogen::get_instance(); |
|---|
| | 284 | engine->setSelectedInstrumentNumber( nLine ); |
|---|
| | 285 | Song *song = engine->getSong(); |
|---|
| | 286 | InstrumentList *instrList = song->get_instrument_list(); |
|---|
| | 287 | |
|---|
| | 288 | Instrument *instr = instrList->get( nLine ); |
|---|
| | 289 | |
|---|
| | 290 | if( instr == NULL ) |
|---|
| | 291 | return false; |
|---|
| | 292 | |
|---|
| | 293 | pan_L = instr->get_pan_l(); |
|---|
| | 294 | pan_R = instr->get_pan_r(); |
|---|
| | 295 | |
|---|
| | 296 | // pan |
|---|
| | 297 | float fPanValue = 0.0; |
|---|
| | 298 | if (pan_R == 1.0) { |
|---|
| | 299 | fPanValue = 1.0 - (pan_L / 2.0); |
|---|
| | 300 | } |
|---|
| | 301 | else { |
|---|
| | 302 | fPanValue = pan_R / 2.0; |
|---|
| | 303 | } |
|---|
| | 304 | |
|---|
| | 305 | |
|---|
| | 306 | fPanValue = 1 * ( ((float) pan_param) / 127.0 ); |
|---|
| | 307 | |
|---|
| | 308 | |
|---|
| | 309 | if (fPanValue >= 0.5) { |
|---|
| | 310 | pan_L = (1.0 - fPanValue) * 2; |
|---|
| | 311 | pan_R = 1.0; |
|---|
| | 312 | } |
|---|
| | 313 | else { |
|---|
| | 314 | pan_L = 1.0; |
|---|
| | 315 | pan_R = fPanValue * 2; |
|---|
| | 316 | } |
|---|
| | 317 | |
|---|
| | 318 | |
|---|
| | 319 | instr->set_pan_l( pan_L ); |
|---|
| | 320 | instr->set_pan_r( pan_R ); |
|---|
| | 321 | |
|---|
| | 322 | Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); |
|---|
| | 323 | |
|---|
| | 324 | return true; |
|---|
| | 325 | } |
|---|
| | 326 | |
|---|
| | 327 | if( sActionString == "PAN_RELATIVE" ){ |
|---|
| | 328 | /* |
|---|
| | 329 | * changes the panning of a given mixer channel |
|---|
| | 330 | * this is useful if the panning is set by a rotary control knob |
|---|
| | 331 | */ |
|---|
| | 332 | |
|---|
| | 333 | bool ok; |
|---|
| | 334 | int nLine = pAction->getParameter1().toInt(&ok,10); |
|---|
| | 335 | int pan_param = pAction->getParameter2().toInt(&ok,10); |
|---|
| | 336 | |
|---|
| | 337 | |
|---|
| | 338 | float pan_L; |
|---|
| | 339 | float pan_R; |
|---|
| | 340 | |
|---|
| | 341 | Hydrogen *engine = Hydrogen::get_instance(); |
|---|
| | 342 | engine->setSelectedInstrumentNumber( nLine ); |
|---|
| | 343 | Song *song = engine->getSong(); |
|---|
| | 344 | InstrumentList *instrList = song->get_instrument_list(); |
|---|
| | 345 | |
|---|
| | 346 | Instrument *instr = instrList->get( nLine ); |
|---|
| | 347 | |
|---|
| | 348 | if( instr == NULL ) |
|---|
| | 349 | return false; |
|---|
| | 350 | |
|---|
| | 351 | pan_L = instr->get_pan_l(); |
|---|
| | 352 | pan_R = instr->get_pan_r(); |
|---|
| | 353 | |
|---|
| | 354 | // pan |
|---|
| | 355 | float fPanValue = 0.0; |
|---|
| | 356 | if (pan_R == 1.0) { |
|---|
| | 357 | fPanValue = 1.0 - (pan_L / 2.0); |
|---|
| | 358 | } |
|---|
| | 359 | else { |
|---|
| | 360 | fPanValue = pan_R / 2.0; |
|---|
| | 361 | } |
|---|
| | 362 | |
|---|
| | 363 | if( pan_param == 1 && fPanValue < 1 ){ |
|---|
| | 364 | fPanValue += 0.05; |
|---|
| | 365 | } |
|---|
| | 366 | |
|---|
| | 367 | if( pan_param != 1 && fPanValue > 0 ){ |
|---|
| | 368 | fPanValue -= 0.05; |
|---|
| | 369 | } |
|---|
| | 370 | |
|---|
| | 371 | if (fPanValue >= 0.5) { |
|---|
| | 372 | pan_L = (1.0 - fPanValue) * 2; |
|---|
| | 373 | pan_R = 1.0; |
|---|
| | 374 | } |
|---|
| | 375 | else { |
|---|
| | 376 | pan_L = 1.0; |
|---|
| | 377 | pan_R = fPanValue * 2; |
|---|
| | 378 | } |
|---|
| | 379 | |
|---|
| | 380 | |
|---|
| | 381 | instr->set_pan_l( pan_L ); |
|---|
| | 382 | instr->set_pan_r( pan_R ); |
|---|
| | 383 | |
|---|
| | 384 | Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); |
|---|
| | 385 | |
|---|
| | 386 | return true; |
|---|