-rw-r--r-- | noncore/multimedia/powerchord/powerchordbase.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/noncore/multimedia/powerchord/powerchordbase.cpp b/noncore/multimedia/powerchord/powerchordbase.cpp index 0694ba3..92198bf 100644 --- a/noncore/multimedia/powerchord/powerchordbase.cpp +++ b/noncore/multimedia/powerchord/powerchordbase.cpp @@ -271,319 +271,323 @@ PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) tuning->insertItem( tr( "EADF#BE" ) ); tuning->insertItem( tr( "EADGCF" ) ); tuning->insertItem( tr( "DADGAD" ) ); tuning->insertItem( tr( "DGCGCD" ) ); tuning->insertItem( tr( "DADF#AD" ) ); tuning->insertItem( tr( "DADGBE" ) ); tuning->insertItem( tr( "DGDGBD" ) ); tuning->insertItem( tr( "DADACD" ) ); tuning->insertItem( tr( "CGCGAE" ) ); tuning->insertItem( tr( "FADGBE" ) ); tuning->insertItem( tr( "G minor" ) ); tuning->setGeometry( QRect( 140, 70, 91, 21 ) ); optlab1 = new QLabel( tab_2, "optlab1" ); optlab1->setGeometry( QRect( 8, 8, 160, 40 ) ); optlab1->setText( tr( "Span: the greatest number of frets over which you want chords to be generated" ) ); optlab1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); tabs->insertTab( tab_2, tr( "Options" ) ); Tuner = new QWidget( tabs, "Tuner" ); Frame4 = new QFrame( Tuner, "Frame4" ); Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); Frame4->setFrameShape( QFrame::Box ); Frame4->setFrameShadow( QFrame::Raised ); vu = new VUMeter( Frame4, "vu" ); vu->setGeometry( QRect( 5, 5, 220, 115 ) ); tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); tuner_note->insertItem( tr( "auto" ) ); tuner_note->insertItem( tr( "E" ) ); tuner_note->insertItem( tr( "D" ) ); tuner_note->insertItem( tr( "G" ) ); tuner_note->insertItem( tr( "A" ) ); tuner_note->insertItem( tr( "B" ) ); tuner_note->insertItem( tr( "C" ) ); tuner_note->insertItem( tr( "F" ) ); tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); Frame8 = new QFrame( Tuner, "Frame8" ); Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); Frame8->setFrameShape( QFrame::HLine ); Frame8->setFrameShadow( QFrame::Raised ); tuner_start = new QPushButton( Tuner, "tuner_start" ); tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); tuner_start->setText( tr( "Start" ) ); tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); tuner_lab1->setText( tr( "Tuner operation" ) ); tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); tuner_lab2->setText( tr( "Pitch calibration" ) ); tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); tuner_calib_note->insertItem( tr( "A" ) ); tuner_calib_note->insertItem( tr( "C" ) ); tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); tuner_calib_freq->setSuffix( tr( "Hz" ) ); tuner_calib_freq->setWrapping( TRUE ); tuner_calib_freq->setMaxValue( 500 ); tuner_calib_freq->setMinValue( 300 ); tuner_calib_freq->setValue( 440 ); tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); tuner_lab3->setText( tr( "Pitch" ) ); tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); tuner_pic1->setFrameShape( QLabel::NoFrame ); tuner_pic1->setPixmap( image6 ); tuner_pic1->setScaledContents( TRUE ); tabs->insertTab( Tuner, tr( "Tuner" ) ); tab_3 = new QWidget( tabs, "tab_3" ); chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); chordlistlab1->setText( tr( "Chord list" ) ); chordlist = new QListBox( tab_3, "chordlist" ); chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); list_remove_btn->setText( tr( "Remove" ) ); tabs->insertTab( tab_3, tr( "Chords" ) ); // hope this does what it's supposed to!! // setPalette( QPalette( QColor( 232, 227, 215) ) ); // signals and slots connections //cxm connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); connect( frets, SIGNAL( s1nameChanged(const QString&) ), s1_1, SLOT( setText(const QString&) ) ); connect( frets, SIGNAL( s2nameChanged(const QString&) ), s1_2, SLOT( setText(const QString&) ) ); connect( frets, SIGNAL( s3nameChanged(const QString&) ), s1_3, SLOT( setText(const QString&) ) ); connect( frets, SIGNAL( s4nameChanged(const QString&) ), s1_4, SLOT( setText(const QString&) ) ); connect( frets, SIGNAL( s5nameChanged(const QString&) ), s1_5, SLOT( setText(const QString&) ) ); connect( frets, SIGNAL( s6nameChanged(const QString&) ), s1_6, SLOT( setText(const QString&) ) ); connect( frets, SIGNAL( nameChanged(const QString&) ), chordname, SLOT( setText(const QString&) ) ); } static int known=0; #include <qmessagebox.h> void PowerchordBase::transport_rec_cb(){ chordlist->insertItem(chordname->text(),-1); if (!known){ - QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); + QMessageBox::information(this, tr("Powerchord"), + tr("<P>This chord has been saved into the list of chords, for later playback.<P>"); known = 1; } } void PowerchordBase::list_remove_cb(){ if (chordlist->count() > 0){ chordlist->removeItem(0); } } void PowerchordBase::play_chord_cb(){ // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); if (audio_timer){ audio_timer->stop(); // set pixmap? synth->Stop(); delete(audio_timer); audio_timer = 0; }else{ // get notes from chord engine int note; int base; int octave; note = frets->ce.noteindex(0); if (note >= 0){ // fprintf(stderr, "Note was %d\n", note); base = note % 12; octave = note / 12; synth->note_start(0, base, octave); }else{ // subtle bug here - replay second note if 1st one muted note = frets->ce.noteindex(1); base = note % 12; octave = note / 12; synth->note_start(1, base, octave); } // init synth if (synth->Play()){ // error - QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); + QMessageBox::information(this, tr("Powerchord"), + tr("<P>Unable to open device for sound playback - check that no other application is using it.</P>")); return; } synth->fill_buffer(); // start timer audio_timer = new QTimer(); connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); // set pixmap on player? audio_timer->start(19); // 19 msec (fudge factor!!) } } void PowerchordBase::audio_cb(){ // play the next bit of audio until quiet // strum timing #define INTERVAL 2 if ((synth->Frames() % INTERVAL) == 0){ int string = synth->Frames() / INTERVAL; if (string <= 5){ int note; int base; int octave; note = frets->ce.noteindex(string); // check not muted... if (note > 0){ base = note % 12; octave = note / 12; synth->note_start(string, base, octave); } } } if (synth->Playing()){ synth->write_buffer(); synth->fill_buffer(); }else{ audio_timer->stop(); // set pixmap? synth->Stop(); delete(audio_timer); audio_timer = 0; } } // the real tuner // void PowerchordBase::tuner_start_cb(){ // if (tuner->Listening()){ // simulation_timer->stop(); // tuner->Stop(); // tuner_pic1->setPixmap( *image6 ); // }else{ // tuner_pic1->setPixmap( *image_open ); // if (!simulation_timer){ // simulation_timer = new QTimer(); // connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() )); // } // simulation_timer->start(50); // tuner->Listen(); // } // } void PowerchordBase::tuner_cb(){ if (tuner->Listening()){ tuner->read_buffer(); tuner->process_buffer(); // update gui // do something with the note: tuner->Note() emit frequency_change(tuner->Tuning()); }else{ simulation_timer->stop(); tuner->Stop(); tuner_pic1->setPixmap( image6 ); } } void PowerchordBase::tuner_start_cb(){ - if (0 == QMessageBox::information(this, "Powerchord", "Using the microphone,\nthe note's frequency\nis analysed. This\nis a simulation.", "OK", "Cancel", 0, 1)){ + if (0 == QMessageBox::information(this, tr("Powerchord"), + tr("<P>Using the microphone, the note's frequency is analysed. This is a simulation.</P>"), + tr("OK"), tr("Cancel"), 0, 1)){ if (simulation_timer){ simulation_timer->stop(); }else{ simulation_timer = new QTimer(); connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() )); } simulation_x = -45; simulation_v = 0; simulation_iter = 0; tuner_pic1->setPixmap( image_open ); simulation_timer->start(100); } } #include <stdio.h> void PowerchordBase::tuner_simulation_cb(){ if (simulation_x < -10 || simulation_x > 10){ simulation_v = (simulation_v/2)-(simulation_x/5); } simulation_x += simulation_v; simulation_iter++; if (simulation_x > 50){ simulation_x = 50; } if (simulation_x < -50){ simulation_x = -50; } if (simulation_iter > 50){ simulation_timer->stop(); emit frequency_change(0); tuner_pic1->setPixmap( image6 ); }else{ emit frequency_change(simulation_x); } } /* * Destroys the object and frees any allocated resources */ PowerchordBase::~PowerchordBase() { // no need to delete child widgets, Qt does it all for us } void PowerchordBase::change_handler() { owarn << "PowerchordBase::change_handler(): Not implemented yet!" << oendl; } |