Diffstat (limited to 'noncore/multimedia/powerchord/powerchordbase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/powerchord/powerchordbase.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/multimedia/powerchord/powerchordbase.cpp b/noncore/multimedia/powerchord/powerchordbase.cpp index 0b97984..7978426 100644 --- a/noncore/multimedia/powerchord/powerchordbase.cpp +++ b/noncore/multimedia/powerchord/powerchordbase.cpp | |||
@@ -291,199 +291,199 @@ PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) | |||
291 | tabs->insertTab( tab_2, tr( "Options" ) ); | 291 | tabs->insertTab( tab_2, tr( "Options" ) ); |
292 | 292 | ||
293 | Tuner = new QWidget( tabs, "Tuner" ); | 293 | Tuner = new QWidget( tabs, "Tuner" ); |
294 | 294 | ||
295 | Frame4 = new QFrame( Tuner, "Frame4" ); | 295 | Frame4 = new QFrame( Tuner, "Frame4" ); |
296 | Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); | 296 | Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); |
297 | Frame4->setFrameShape( QFrame::Box ); | 297 | Frame4->setFrameShape( QFrame::Box ); |
298 | Frame4->setFrameShadow( QFrame::Raised ); | 298 | Frame4->setFrameShadow( QFrame::Raised ); |
299 | 299 | ||
300 | vu = new VUMeter( Frame4, "vu" ); | 300 | vu = new VUMeter( Frame4, "vu" ); |
301 | vu->setGeometry( QRect( 5, 5, 220, 115 ) ); | 301 | vu->setGeometry( QRect( 5, 5, 220, 115 ) ); |
302 | 302 | ||
303 | tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); | 303 | tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); |
304 | tuner_note->insertItem( tr( "auto" ) ); | 304 | tuner_note->insertItem( tr( "auto" ) ); |
305 | tuner_note->insertItem( tr( "E" ) ); | 305 | tuner_note->insertItem( tr( "E" ) ); |
306 | tuner_note->insertItem( tr( "D" ) ); | 306 | tuner_note->insertItem( tr( "D" ) ); |
307 | tuner_note->insertItem( tr( "G" ) ); | 307 | tuner_note->insertItem( tr( "G" ) ); |
308 | tuner_note->insertItem( tr( "A" ) ); | 308 | tuner_note->insertItem( tr( "A" ) ); |
309 | tuner_note->insertItem( tr( "B" ) ); | 309 | tuner_note->insertItem( tr( "B" ) ); |
310 | tuner_note->insertItem( tr( "C" ) ); | 310 | tuner_note->insertItem( tr( "C" ) ); |
311 | tuner_note->insertItem( tr( "F" ) ); | 311 | tuner_note->insertItem( tr( "F" ) ); |
312 | tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); | 312 | tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); |
313 | 313 | ||
314 | Frame8 = new QFrame( Tuner, "Frame8" ); | 314 | Frame8 = new QFrame( Tuner, "Frame8" ); |
315 | Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); | 315 | Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); |
316 | Frame8->setFrameShape( QFrame::HLine ); | 316 | Frame8->setFrameShape( QFrame::HLine ); |
317 | Frame8->setFrameShadow( QFrame::Raised ); | 317 | Frame8->setFrameShadow( QFrame::Raised ); |
318 | 318 | ||
319 | tuner_start = new QPushButton( Tuner, "tuner_start" ); | 319 | tuner_start = new QPushButton( Tuner, "tuner_start" ); |
320 | tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); | 320 | tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); |
321 | tuner_start->setText( tr( "Start" ) ); | 321 | tuner_start->setText( tr( "Start" ) ); |
322 | 322 | ||
323 | tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); | 323 | tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); |
324 | tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); | 324 | tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); |
325 | tuner_lab1->setText( tr( "Tuner operation" ) ); | 325 | tuner_lab1->setText( tr( "Tuner operation" ) ); |
326 | 326 | ||
327 | tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); | 327 | tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); |
328 | tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); | 328 | tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); |
329 | tuner_lab2->setText( tr( "Pitch calibration" ) ); | 329 | tuner_lab2->setText( tr( "Pitch calibration" ) ); |
330 | 330 | ||
331 | tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); | 331 | tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); |
332 | tuner_calib_note->insertItem( tr( "A" ) ); | 332 | tuner_calib_note->insertItem( tr( "A" ) ); |
333 | tuner_calib_note->insertItem( tr( "C" ) ); | 333 | tuner_calib_note->insertItem( tr( "C" ) ); |
334 | tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); | 334 | tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); |
335 | 335 | ||
336 | tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); | 336 | tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); |
337 | tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); | 337 | tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); |
338 | tuner_calib_freq->setSuffix( tr( "Hz" ) ); | 338 | tuner_calib_freq->setSuffix( tr( "Hz" ) ); |
339 | tuner_calib_freq->setWrapping( TRUE ); | 339 | tuner_calib_freq->setWrapping( TRUE ); |
340 | tuner_calib_freq->setMaxValue( 500 ); | 340 | tuner_calib_freq->setMaxValue( 500 ); |
341 | tuner_calib_freq->setMinValue( 300 ); | 341 | tuner_calib_freq->setMinValue( 300 ); |
342 | tuner_calib_freq->setValue( 440 ); | 342 | tuner_calib_freq->setValue( 440 ); |
343 | 343 | ||
344 | tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); | 344 | tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); |
345 | tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); | 345 | tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); |
346 | tuner_lab3->setText( tr( "Pitch" ) ); | 346 | tuner_lab3->setText( tr( "Pitch" ) ); |
347 | 347 | ||
348 | tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); | 348 | tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); |
349 | tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); | 349 | tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); |
350 | tuner_pic1->setFrameShape( QLabel::NoFrame ); | 350 | tuner_pic1->setFrameShape( QLabel::NoFrame ); |
351 | tuner_pic1->setPixmap( image6 ); | 351 | tuner_pic1->setPixmap( image6 ); |
352 | tuner_pic1->setScaledContents( TRUE ); | 352 | tuner_pic1->setScaledContents( TRUE ); |
353 | tabs->insertTab( Tuner, tr( "Tuner" ) ); | 353 | tabs->insertTab( Tuner, tr( "Tuner" ) ); |
354 | 354 | ||
355 | tab_3 = new QWidget( tabs, "tab_3" ); | 355 | tab_3 = new QWidget( tabs, "tab_3" ); |
356 | 356 | ||
357 | chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); | 357 | chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); |
358 | chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); | 358 | chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); |
359 | chordlistlab1->setText( tr( "Chord list" ) ); | 359 | chordlistlab1->setText( tr( "Chord list" ) ); |
360 | 360 | ||
361 | chordlist = new QListBox( tab_3, "chordlist" ); | 361 | chordlist = new QListBox( tab_3, "chordlist" ); |
362 | chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); | 362 | chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); |
363 | 363 | ||
364 | list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); | 364 | list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); |
365 | list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); | 365 | list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); |
366 | list_remove_btn->setText( tr( "Remove" ) ); | 366 | list_remove_btn->setText( tr( "Remove" ) ); |
367 | tabs->insertTab( tab_3, tr( "Chords" ) ); | 367 | tabs->insertTab( tab_3, tr( "Chords" ) ); |
368 | 368 | ||
369 | // hope this does what it's supposed to!! | 369 | // hope this does what it's supposed to!! |
370 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); | 370 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); |
371 | 371 | ||
372 | // signals and slots connections | 372 | // signals and slots connections |
373 | 373 | ||
374 | //cxm | 374 | //cxm |
375 | connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); | 375 | connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); |
376 | connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); | 376 | connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); |
377 | connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); | 377 | connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); |
378 | connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); | 378 | connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); |
379 | connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); | 379 | connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); |
380 | connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); | 380 | connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); |
381 | connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); | 381 | connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); |
382 | 382 | ||
383 | connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); | 383 | connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); |
384 | connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); | 384 | connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); |
385 | connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); | 385 | connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); |
386 | connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); | 386 | connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); |
387 | connect( frets, SIGNAL( s1nameChanged(const QString &) ), s1_1, SLOT( setText(const QString&) ) ); | 387 | connect( frets, SIGNAL( s1nameChanged(const QString&) ), s1_1, SLOT( setText(const QString&) ) ); |
388 | connect( frets, SIGNAL( s2nameChanged(const QString &) ), s1_2, SLOT( setText(const QString&) ) ); | 388 | connect( frets, SIGNAL( s2nameChanged(const QString&) ), s1_2, SLOT( setText(const QString&) ) ); |
389 | connect( frets, SIGNAL( s3nameChanged(const QString &) ), s1_3, SLOT( setText(const QString&) ) ); | 389 | connect( frets, SIGNAL( s3nameChanged(const QString&) ), s1_3, SLOT( setText(const QString&) ) ); |
390 | connect( frets, SIGNAL( s4nameChanged(const QString &) ), s1_4, SLOT( setText(const QString&) ) ); | 390 | connect( frets, SIGNAL( s4nameChanged(const QString&) ), s1_4, SLOT( setText(const QString&) ) ); |
391 | connect( frets, SIGNAL( s5nameChanged(const QString &) ), s1_5, SLOT( setText(const QString&) ) ); | 391 | connect( frets, SIGNAL( s5nameChanged(const QString&) ), s1_5, SLOT( setText(const QString&) ) ); |
392 | connect( frets, SIGNAL( s6nameChanged(const QString &) ), s1_6, SLOT( setText(const QString&) ) ); | 392 | connect( frets, SIGNAL( s6nameChanged(const QString&) ), s1_6, SLOT( setText(const QString&) ) ); |
393 | connect( frets, SIGNAL( nameChanged(const QString &) ), chordname, SLOT( setText(const QString&) ) ); | 393 | connect( frets, SIGNAL( nameChanged(const QString&) ), chordname, SLOT( setText(const QString&) ) ); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | static int known=0; | 397 | static int known=0; |
398 | #include <qmessagebox.h> | 398 | #include <qmessagebox.h> |
399 | void PowerchordBase::transport_rec_cb(){ | 399 | void PowerchordBase::transport_rec_cb(){ |
400 | chordlist->insertItem(chordname->text(),-1); | 400 | chordlist->insertItem(chordname->text(),-1); |
401 | if (!known){ | 401 | if (!known){ |
402 | QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); | 402 | QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); |
403 | known = 1; | 403 | known = 1; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | void PowerchordBase::list_remove_cb(){ | 406 | void PowerchordBase::list_remove_cb(){ |
407 | if (chordlist->count() > 0){ | 407 | if (chordlist->count() > 0){ |
408 | chordlist->removeItem(0); | 408 | chordlist->removeItem(0); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | void PowerchordBase::play_chord_cb(){ | 411 | void PowerchordBase::play_chord_cb(){ |
412 | // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); | 412 | // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); |
413 | 413 | ||
414 | 414 | ||
415 | if (audio_timer){ | 415 | if (audio_timer){ |
416 | audio_timer->stop(); | 416 | audio_timer->stop(); |
417 | // set pixmap? | 417 | // set pixmap? |
418 | synth->Stop(); | 418 | synth->Stop(); |
419 | delete(audio_timer); | 419 | delete(audio_timer); |
420 | audio_timer = 0; | 420 | audio_timer = 0; |
421 | }else{ | 421 | }else{ |
422 | // get notes from chord engine | 422 | // get notes from chord engine |
423 | 423 | ||
424 | int note; | 424 | int note; |
425 | int base; | 425 | int base; |
426 | int octave; | 426 | int octave; |
427 | note = frets->ce.noteindex(0); | 427 | note = frets->ce.noteindex(0); |
428 | if (note >= 0){ | 428 | if (note >= 0){ |
429 | //fprintf(stderr, "Note was %d\n", note); | 429 | //fprintf(stderr, "Note was %d\n", note); |
430 | base = note % 12; | 430 | base = note % 12; |
431 | octave = note / 12; | 431 | octave = note / 12; |
432 | synth->note_start(0, base, octave); | 432 | synth->note_start(0, base, octave); |
433 | }else{ | 433 | }else{ |
434 | // subtle bug here - replay second note if 1st one muted | 434 | // subtle bug here - replay second note if 1st one muted |
435 | note = frets->ce.noteindex(1); | 435 | note = frets->ce.noteindex(1); |
436 | base = note % 12; | 436 | base = note % 12; |
437 | octave = note / 12; | 437 | octave = note / 12; |
438 | synth->note_start(1, base, octave); | 438 | synth->note_start(1, base, octave); |
439 | 439 | ||
440 | } | 440 | } |
441 | 441 | ||
442 | // init synth | 442 | // init synth |
443 | if (synth->Play()){ | 443 | if (synth->Play()){ |
444 | // error | 444 | // error |
445 | QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); | 445 | QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); |
446 | return; | 446 | return; |
447 | } | 447 | } |
448 | synth->fill_buffer(); | 448 | synth->fill_buffer(); |
449 | 449 | ||
450 | // start timer | 450 | // start timer |
451 | audio_timer = new QTimer(); | 451 | audio_timer = new QTimer(); |
452 | connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); | 452 | connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); |
453 | // set pixmap on player? | 453 | // set pixmap on player? |
454 | audio_timer->start(19); // 19 msec (fudge factor!!) | 454 | audio_timer->start(19); // 19 msec (fudge factor!!) |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | 459 | ||
460 | void PowerchordBase::audio_cb(){ | 460 | void PowerchordBase::audio_cb(){ |
461 | // play the next bit of audio until quiet | 461 | // play the next bit of audio until quiet |
462 | 462 | ||
463 | // strum timing | 463 | // strum timing |
464 | #define INTERVAL 2 | 464 | #define INTERVAL 2 |
465 | 465 | ||
466 | if ((synth->Frames() % INTERVAL) == 0){ | 466 | if ((synth->Frames() % INTERVAL) == 0){ |
467 | int string = synth->Frames() / INTERVAL; | 467 | int string = synth->Frames() / INTERVAL; |
468 | if (string <= 5){ | 468 | if (string <= 5){ |
469 | int note; | 469 | int note; |
470 | int base; | 470 | int base; |
471 | int octave; | 471 | int octave; |
472 | note = frets->ce.noteindex(string); | 472 | note = frets->ce.noteindex(string); |
473 | // check not muted... | 473 | // check not muted... |
474 | if (note > 0){ | 474 | if (note > 0){ |
475 | base = note % 12; | 475 | base = note % 12; |
476 | octave = note / 12; | 476 | octave = note / 12; |
477 | synth->note_start(string, base, octave); | 477 | synth->note_start(string, base, octave); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | if (synth->Playing()){ | 482 | if (synth->Playing()){ |
483 | synth->write_buffer(); | 483 | synth->write_buffer(); |
484 | synth->fill_buffer(); | 484 | synth->fill_buffer(); |
485 | }else{ | 485 | }else{ |
486 | audio_timer->stop(); | 486 | audio_timer->stop(); |
487 | // set pixmap? | 487 | // set pixmap? |
488 | synth->Stop(); | 488 | synth->Stop(); |
489 | delete(audio_timer); | 489 | delete(audio_timer); |