Changeset 1464

Show
Ignore:
Timestamp:
12/02/09 03:02:10 (4 years ago)
Author:
wolke
Message:

create a play/stop toggle button to toggle sample preview

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gui/src/SampleEditor/SampleEditor.cpp

    r1452 r1464  
    159159{ 
    160160        Hydrogen *pEngine = Hydrogen::get_instance(); 
    161         H2Core::Instrument *m_pInstrument = NULL; 
     161        H2Core::Instrument *pInstrument = NULL; 
    162162        Sample* pSample = NULL; 
    163163        Song *pSong = Hydrogen::get_instance()->getSong(); 
     
    170170 
    171171                if (nInstr == -1) { 
    172                         m_pInstrument = NULL; 
     172                        pInstrument = NULL; 
    173173                } 
    174174                else { 
    175                         m_pInstrument = pInstrList->get( nInstr ); 
    176                         //INFOLOG( "new instr: " + m_pInstrument->m_sName ); 
    177                 } 
    178         } 
    179         H2Core::InstrumentLayer *pLayer = m_pInstrument->get_layer( m_pSelectedLayer ); 
     175                        pInstrument = pInstrList->get( nInstr ); 
     176                        //INFOLOG( "new instr: " + pInstrument->m_sName ); 
     177                } 
     178        } 
     179        H2Core::InstrumentLayer *pLayer = pInstrument->get_layer( m_pSelectedLayer ); 
    180180        if ( pLayer ) { 
    181181                pSample = pLayer->get_sample(); 
     
    293293void SampleEditor::openDisplays() 
    294294{ 
    295         H2Core::Instrument *m_pInstrument = NULL; 
     295        H2Core::Instrument *pInstrument = NULL; 
    296296        Song *pSong = Hydrogen::get_instance()->getSong(); 
    297297        if (pSong != NULL) { 
     
    303303 
    304304                if (nInstr == -1) { 
    305                         m_pInstrument = NULL; 
     305                        pInstrument = NULL; 
    306306                } 
    307307                else { 
    308                         m_pInstrument = pInstrList->get( nInstr ); 
    309                         //INFOLOG( "new instr: " + m_pInstrument->m_sName ); 
     308                        pInstrument = pInstrList->get( nInstr ); 
     309                        //INFOLOG( "new instr: " + pInstrument->m_sName ); 
    310310                } 
    311311        } 
     
    390390                AudioEngine::get_instance()->lock( RIGHT_HERE ); 
    391391 
    392                 H2Core::Instrument *m_pInstrument = NULL; 
     392                H2Core::Instrument *pInstrument = NULL; 
    393393                Song *pSong = Hydrogen::get_instance()->getSong(); 
    394394                if (pSong != NULL) { 
     
    400400         
    401401                        if (nInstr == -1) { 
    402                                 m_pInstrument = NULL; 
     402                                pInstrument = NULL; 
    403403                        } 
    404404                        else { 
    405                                 m_pInstrument = pInstrList->get( nInstr ); 
     405                                pInstrument = pInstrList->get( nInstr ); 
    406406                        } 
    407407                } 
    408408         
    409                 H2Core::InstrumentLayer *pLayer = m_pInstrument->get_layer( m_pSelectedLayer ); 
     409                H2Core::InstrumentLayer *pLayer = pInstrument->get_layer( m_pSelectedLayer ); 
    410410 
    411411                Sample *oldSample = pLayer->get_sample(); 
     
    536536void SampleEditor::on_PlayPushButton_clicked() 
    537537{ 
    538  
     538        if (PlayPushButton->text() == "Stop" ){ 
     539                testpTimer(); 
     540                return; 
     541        } 
    539542        const int selectedlayer = InstrumentEditorPanel::get_instance()->getselectedLayer(); 
    540543        const float pan_L = 0.5f; 
     
    574577        } 
    575578        m_pTargetDisplayTimer->start(40);       // update ruler at 25 fps 
     579        PlayPushButton->setText( QString( "Stop") );  
    576580         
    577581} 
     
    581585void SampleEditor::on_PlayOrigPushButton_clicked() 
    582586{ 
     587        if (PlayOrigPushButton->text() == "Stop" ){ 
     588                testpTimer(); 
     589                return; 
     590        } 
    583591        Sample *pNewSample = Sample::load( m_samplename ); 
    584592        if ( pNewSample ){ 
     
    592600        m_pTimer->start(40);    // update ruler at 25 fps        
    593601        m_prealtimeframeend = Hydrogen::get_instance()->getRealtimeFrames() + m_pslframes; 
     602        PlayOrigPushButton->setText( QString( "Stop") );  
    594603} 
    595604 
     
    613622                m_pMainSampleWaveDisplay->paintLocatorEvent( -1 , false); 
    614623                m_pTimer->stop(); 
     624                PlayPushButton->setText( QString("&Play") ); 
     625                PlayOrigPushButton->setText( QString( "P&lay original sample") );  
    615626                m_pPlayButton = false; 
    616627        } 
     
    636647                m_pTargetSampleView->paintLocatorEventTargetDisplay( -1 , false); 
    637648                m_pTargetDisplayTimer->stop(); 
    638 //              m_pPlayButton = false; 
     649                PlayPushButton->setText(QString( "&Play") ); 
     650                PlayOrigPushButton->setText( QString( "P&lay original sample") );  
     651                m_pPlayButton = false; 
    639652        } 
    640653} 
     
    901914void SampleEditor::testpTimer() 
    902915{ 
    903         if ( m_pTimer->isActive() ){ 
     916        if ( m_pTimer->isActive() || m_pTargetDisplayTimer->isActive() ){ 
    904917                m_pMainSampleWaveDisplay->paintLocatorEvent( -1 , false); 
    905918                m_pTimer->stop(); 
     919                m_pTargetDisplayTimer->stop(); 
     920                PlayPushButton->setText( QString( "&Play" ) ); 
     921                PlayOrigPushButton->setText( QString( "P&lay original sample") );  
    906922                AudioEngine::get_instance()->get_sampler()->stop_playing_notes(); 
    907923                m_pPlayButton = false;