summaryrefslogtreecommitdiff
path: root/noncore/multimedia/powerchord/powerchordbase.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/powerchord/powerchordbase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/powerchord/powerchordbase.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/noncore/multimedia/powerchord/powerchordbase.cpp b/noncore/multimedia/powerchord/powerchordbase.cpp
index 4fb5dda..0694ba3 100644
--- a/noncore/multimedia/powerchord/powerchordbase.cpp
+++ b/noncore/multimedia/powerchord/powerchordbase.cpp
@@ -1,118 +1,122 @@
1/**************************************************************************** 1/****************************************************************************
2** Form implementation generated from reading ui file 'powerchordbase.ui' 2** Form implementation generated from reading ui file 'powerchordbase.ui'
3** 3**
4** Created: Sun Jan 13 23:05:11 2002 4** Created: Sun Jan 13 23:05:11 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9#include "powerchordbase.h" 9#include "powerchordbase.h"
10
11#include "fretboard.h" 10#include "fretboard.h"
12#include "vumeter.h" 11#include "vumeter.h"
12
13/* OPIE */
14#include <opie2/odebug.h>
15#include <qpe/resource.h>
16using namespace Opie::Core;
17
18/* QT */
13#include <qcombobox.h> 19#include <qcombobox.h>
14#include <qlabel.h> 20#include <qlabel.h>
15#include <qlistbox.h> 21#include <qlistbox.h>
16#include <qpushbutton.h> 22#include <qpushbutton.h>
17#include <qspinbox.h> 23#include <qspinbox.h>
18#include <qtabwidget.h> 24#include <qtabwidget.h>
19#include <qlayout.h> 25#include <qlayout.h>
20#include <qtooltip.h> 26#include <qtooltip.h>
21#include <qpe/resource.h>
22
23 27
24/* 28/*
25 * Constructs a PowerchordBase which is a child of 'parent', with the 29 * Constructs a PowerchordBase which is a child of 'parent', with the
26 * name 'name' and widget flags set to 'f' 30 * name 'name' and widget flags set to 'f'
27 */ 31 */
28PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) 32PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl )
29 : QWidget( parent, name, fl ) 33 : QWidget( parent, name, fl )
30{ 34{
31 simulation_timer = 0; 35 simulation_timer = 0;
32 audio_timer = 0; 36 audio_timer = 0;
33 37
34 // setPalette( QPalette( QColor( 232, 227, 215) ) ); 38 // setPalette( QPalette( QColor( 232, 227, 215) ) );
35 39
36 // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0")); 40 // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0"));
37 QPixmap image1 = Resource::loadPixmap( "powerchord/image1"); 41 QPixmap image1 = Resource::loadPixmap( "powerchord/image1");
38 QPixmap image2 = Resource::loadPixmap( "powerchord/image2"); 42 QPixmap image2 = Resource::loadPixmap( "powerchord/image2");
39 QPixmap image3 = Resource::loadPixmap( "powerchord/image3"); 43 QPixmap image3 = Resource::loadPixmap( "powerchord/image3");
40 QPixmap image4 = Resource::loadPixmap( "powerchord/image4"); 44 QPixmap image4 = Resource::loadPixmap( "powerchord/image4");
41 QPixmap image5 = Resource::loadPixmap( "powerchord/image5"); 45 QPixmap image5 = Resource::loadPixmap( "powerchord/image5");
42 image6 = Resource::loadPixmap( "powerchord/image6"); 46 image6 = Resource::loadPixmap( "powerchord/image6");
43 image_open = Resource::loadPixmap( "powerchord/image_open"); 47 image_open = Resource::loadPixmap( "powerchord/image_open");
44 48
45 // image0.setMask(image0.createHeuristicMask()); 49 // image0.setMask(image0.createHeuristicMask());
46 image1.setMask(image1.createHeuristicMask()); 50 image1.setMask(image1.createHeuristicMask());
47 // image2.setMask(image2.createHeuristicMask()); 51 // image2.setMask(image2.createHeuristicMask());
48 // image3.setMask(image3.createHeuristicMask()); 52 // image3.setMask(image3.createHeuristicMask());
49 // image4.setMask(image4.createHeuristicMask()); 53 // image4.setMask(image4.createHeuristicMask());
50 // image5.setMask(image5.createHeuristicMask()); 54 // image5.setMask(image5.createHeuristicMask());
51 // image6->setMask(image6->createHeuristicMask()); 55 // image6->setMask(image6->createHeuristicMask());
52 // image_open->setMask(image_open->createHeuristicMask()); 56 // image_open->setMask(image_open->createHeuristicMask());
53 57
54 if ( !name ) 58 if ( !name )
55 setName( "PowerchordBase" ); 59 setName( "PowerchordBase" );
56 resize( 240, 284 ); 60 resize( 240, 284 );
57 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); 61 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) );
58 setMinimumSize( QSize( 240, 284 ) ); 62 setMinimumSize( QSize( 240, 284 ) );
59 setMaximumSize( QSize( 240, 284 ) ); 63 setMaximumSize( QSize( 240, 284 ) );
60 setCaption( tr( "Powerchord" ) ); 64 setCaption( tr( "Powerchord" ) );
61 65
62 tabs = new QTabWidget( this, "tabs" ); 66 tabs = new QTabWidget( this, "tabs" );
63 tabs->setEnabled( TRUE ); 67 tabs->setEnabled( TRUE );
64 tabs->setGeometry( QRect( 0, 0, 240, 286 ) ); 68 tabs->setGeometry( QRect( 0, 0, 240, 286 ) );
65 tabs->setTabPosition( QTabWidget::Bottom ); 69 tabs->setTabPosition( QTabWidget::Bottom );
66 70
67 tab = new QWidget( tabs, "tab" ); 71 tab = new QWidget( tabs, "tab" );
68 72
69 chordkey = new QComboBox( FALSE, tab, "chordkey" ); 73 chordkey = new QComboBox( FALSE, tab, "chordkey" );
70 chordkey->insertItem( tr( "maj" ) ); 74 chordkey->insertItem( tr( "maj" ) );
71 chordkey->insertItem( tr( "min" ) ); 75 chordkey->insertItem( tr( "min" ) );
72 chordkey->insertItem( tr( "7th" ) ); 76 chordkey->insertItem( tr( "7th" ) );
73 chordkey->insertItem( tr( "m7" ) ); 77 chordkey->insertItem( tr( "m7" ) );
74 chordkey->insertItem( tr( "maj7" ) ); 78 chordkey->insertItem( tr( "maj7" ) );
75 chordkey->insertItem( tr( "6th" ) ); 79 chordkey->insertItem( tr( "6th" ) );
76 chordkey->insertItem( tr( "m6th" ) ); 80 chordkey->insertItem( tr( "m6th" ) );
77 chordkey->insertItem( tr( "aug" ) ); 81 chordkey->insertItem( tr( "aug" ) );
78 chordkey->insertItem( tr( "dim" ) ); 82 chordkey->insertItem( tr( "dim" ) );
79 chordkey->insertItem( tr( "sus4" ) ); 83 chordkey->insertItem( tr( "sus4" ) );
80 chordkey->insertItem( tr( "7sus4" ) ); 84 chordkey->insertItem( tr( "7sus4" ) );
81 chordkey->insertItem( tr( "9th" ) ); 85 chordkey->insertItem( tr( "9th" ) );
82 chordkey->insertItem( tr( "add9" ) ); 86 chordkey->insertItem( tr( "add9" ) );
83 chordkey->insertItem( tr( "m9th" ) ); 87 chordkey->insertItem( tr( "m9th" ) );
84 chordkey->insertItem( tr( "maj9" ) ); 88 chordkey->insertItem( tr( "maj9" ) );
85 chordkey->insertItem( tr( "sus2" ) ); 89 chordkey->insertItem( tr( "sus2" ) );
86 chordkey->insertItem( tr( "7sus2" ) ); 90 chordkey->insertItem( tr( "7sus2" ) );
87 chordkey->insertItem( tr( "11th" ) ); 91 chordkey->insertItem( tr( "11th" ) );
88 chordkey->insertItem( tr( "m11th" ) ); 92 chordkey->insertItem( tr( "m11th" ) );
89 chordkey->insertItem( tr( "13th" ) ); 93 chordkey->insertItem( tr( "13th" ) );
90 chordkey->insertItem( tr( "m13th" ) ); 94 chordkey->insertItem( tr( "m13th" ) );
91 chordkey->insertItem( tr( "maj13" ) ); 95 chordkey->insertItem( tr( "maj13" ) );
92 chordkey->insertItem( tr( "6/9" ) ); 96 chordkey->insertItem( tr( "6/9" ) );
93 chordkey->insertItem( tr( "flat5" ) ); 97 chordkey->insertItem( tr( "flat5" ) );
94 chordkey->insertItem( tr( "7#9" ) ); 98 chordkey->insertItem( tr( "7#9" ) );
95 chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) ); 99 chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) );
96 chordkey->insertItem( tr( "5" ) ); 100 chordkey->insertItem( tr( "5" ) );
97 chordkey->setGeometry( QRect( 40, 0, 51, 21 ) ); 101 chordkey->setGeometry( QRect( 40, 0, 51, 21 ) );
98 102
99 chordfret = new QComboBox( FALSE, tab, "chordfret" ); 103 chordfret = new QComboBox( FALSE, tab, "chordfret" );
100 chordfret->insertItem( tr( "open" ) ); 104 chordfret->insertItem( tr( "open" ) );
101 chordfret->insertItem( tr( "1st" ) ); 105 chordfret->insertItem( tr( "1st" ) );
102 chordfret->insertItem( tr( "2nd" ) ); 106 chordfret->insertItem( tr( "2nd" ) );
103 chordfret->insertItem( tr( "3rd" ) ); 107 chordfret->insertItem( tr( "3rd" ) );
104 chordfret->insertItem( tr( "4th" ) ); 108 chordfret->insertItem( tr( "4th" ) );
105 chordfret->insertItem( tr( "5th" ) ); 109 chordfret->insertItem( tr( "5th" ) );
106 chordfret->insertItem( tr( "6th" ) ); 110 chordfret->insertItem( tr( "6th" ) );
107 chordfret->insertItem( tr( "7th" ) ); 111 chordfret->insertItem( tr( "7th" ) );
108 chordfret->insertItem( tr( "8th" ) ); 112 chordfret->insertItem( tr( "8th" ) );
109 chordfret->insertItem( tr( "9th" ) ); 113 chordfret->insertItem( tr( "9th" ) );
110 chordfret->insertItem( tr( "10th" ) ); 114 chordfret->insertItem( tr( "10th" ) );
111 chordfret->insertItem( tr( "11th" ) ); 115 chordfret->insertItem( tr( "11th" ) );
112 chordfret->insertItem( tr( "12th" ) ); 116 chordfret->insertItem( tr( "12th" ) );
113 chordfret->insertItem( tr( "13th" ) ); 117 chordfret->insertItem( tr( "13th" ) );
114 chordfret->insertItem( tr( "14th" ) ); 118 chordfret->insertItem( tr( "14th" ) );
115 chordfret->insertItem( tr( "15th" ) ); 119 chordfret->insertItem( tr( "15th" ) );
116 chordfret->insertItem( tr( "16th" ) ); 120 chordfret->insertItem( tr( "16th" ) );
117 chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width 121 chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width
118 122
@@ -487,99 +491,99 @@ void PowerchordBase::audio_cb(){
487// the real tuner 491// the real tuner
488// void PowerchordBase::tuner_start_cb(){ 492// void PowerchordBase::tuner_start_cb(){
489 493
490// if (tuner->Listening()){ 494// if (tuner->Listening()){
491// simulation_timer->stop(); 495// simulation_timer->stop();
492// tuner->Stop(); 496// tuner->Stop();
493// tuner_pic1->setPixmap( *image6 ); 497// tuner_pic1->setPixmap( *image6 );
494 498
495// }else{ 499// }else{
496// tuner_pic1->setPixmap( *image_open ); 500// tuner_pic1->setPixmap( *image_open );
497 501
498// if (!simulation_timer){ 502// if (!simulation_timer){
499// simulation_timer = new QTimer(); 503// simulation_timer = new QTimer();
500 504
501 505
502// connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() )); 506// connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() ));
503// } 507// }
504 508
505// simulation_timer->start(50); 509// simulation_timer->start(50);
506// tuner->Listen(); 510// tuner->Listen();
507 511
508// } 512// }
509// } 513// }
510 514
511void PowerchordBase::tuner_cb(){ 515void PowerchordBase::tuner_cb(){
512 if (tuner->Listening()){ 516 if (tuner->Listening()){
513 tuner->read_buffer(); 517 tuner->read_buffer();
514 tuner->process_buffer(); 518 tuner->process_buffer();
515 519
516 // update gui 520 // update gui
517 // do something with the note: tuner->Note() 521 // do something with the note: tuner->Note()
518 emit frequency_change(tuner->Tuning()); 522 emit frequency_change(tuner->Tuning());
519 523
520 }else{ 524 }else{
521 simulation_timer->stop(); 525 simulation_timer->stop();
522 tuner->Stop(); 526 tuner->Stop();
523 tuner_pic1->setPixmap( image6 ); 527 tuner_pic1->setPixmap( image6 );
524 } 528 }
525} 529}
526 530
527 531
528void PowerchordBase::tuner_start_cb(){ 532void PowerchordBase::tuner_start_cb(){
529 if (0 == QMessageBox::information(this, "Powerchord", "Using the microphone,\nthe note's frequency\nis analysed. This\nis a simulation.", "OK", "Cancel", 0, 1)){ 533 if (0 == QMessageBox::information(this, "Powerchord", "Using the microphone,\nthe note's frequency\nis analysed. This\nis a simulation.", "OK", "Cancel", 0, 1)){
530 if (simulation_timer){ 534 if (simulation_timer){
531 simulation_timer->stop(); 535 simulation_timer->stop();
532 }else{ 536 }else{
533 simulation_timer = new QTimer(); 537 simulation_timer = new QTimer();
534 connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() )); 538 connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() ));
535 539
536 } 540 }
537 simulation_x = -45; 541 simulation_x = -45;
538 simulation_v = 0; 542 simulation_v = 0;
539 simulation_iter = 0; 543 simulation_iter = 0;
540 544
541 tuner_pic1->setPixmap( image_open ); 545 tuner_pic1->setPixmap( image_open );
542 simulation_timer->start(100); 546 simulation_timer->start(100);
543 } 547 }
544} 548}
545 549
546#include <stdio.h> 550#include <stdio.h>
547 551
548void PowerchordBase::tuner_simulation_cb(){ 552void PowerchordBase::tuner_simulation_cb(){
549 if (simulation_x < -10 || simulation_x > 10){ 553 if (simulation_x < -10 || simulation_x > 10){
550 simulation_v = (simulation_v/2)-(simulation_x/5); 554 simulation_v = (simulation_v/2)-(simulation_x/5);
551 } 555 }
552 556
553 simulation_x += simulation_v; 557 simulation_x += simulation_v;
554 simulation_iter++; 558 simulation_iter++;
555 559
556 if (simulation_x > 50){ 560 if (simulation_x > 50){
557 simulation_x = 50; 561 simulation_x = 50;
558 } 562 }
559 563
560 if (simulation_x < -50){ 564 if (simulation_x < -50){
561 simulation_x = -50; 565 simulation_x = -50;
562 } 566 }
563 567
564 if (simulation_iter > 50){ 568 if (simulation_iter > 50){
565 simulation_timer->stop(); 569 simulation_timer->stop();
566 emit frequency_change(0); 570 emit frequency_change(0);
567 tuner_pic1->setPixmap( image6 ); 571 tuner_pic1->setPixmap( image6 );
568 }else{ 572 }else{
569 emit frequency_change(simulation_x); 573 emit frequency_change(simulation_x);
570 } 574 }
571} 575}
572 576
573/* 577/*
574 * Destroys the object and frees any allocated resources 578 * Destroys the object and frees any allocated resources
575 */ 579 */
576PowerchordBase::~PowerchordBase() 580PowerchordBase::~PowerchordBase()
577{ 581{
578 // no need to delete child widgets, Qt does it all for us 582 // no need to delete child widgets, Qt does it all for us
579} 583}
580 584
581void PowerchordBase::change_handler() 585void PowerchordBase::change_handler()
582{ 586{
583 qWarning( "PowerchordBase::change_handler(): Not implemented yet!" ); 587 owarn << "PowerchordBase::change_handler(): Not implemented yet!" << oendl;
584} 588}
585 589