Changeset 2234

Show
Ignore:
Timestamp:
06/26/11 23:09:19 (2 years ago)
Author:
wolke
Message:

fix broken sampleeditor visual ratio-meter.

Location:
branches/undo/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/undo/src/core/include/hydrogen/globals.h

    r2113 r2234  
    2525#define MAX_INSTRUMENTS         1000 
    2626 
    27 #define MAX_NOTES                       192 
     27#define MAX_NOTES               192 
    2828 
    2929#define MAX_LAYERS              16 
    3030 
    31 #define MAX_FX                          4 
     31#define MAX_FX                  4 
    3232 
    33 #define MAX_BUFFER_SIZE             8192 
     33#define MAX_BUFFER_SIZE         8192 
    3434 
    3535#define MIDI_OUT_NOTE_MIN       0 
  • branches/undo/src/gui/src/SampleEditor/SampleEditor.cpp

    r2226 r2234  
    7373        m_pslframes = 0; 
    7474        m_pPositionsRulerPath = NULL; 
    75         m_pPlayButton = false; 
    76         m_pratio = 1.0; 
     75        m_pPlayButton = false; 
     76        m_pratio = 1.0f; 
    7777        __rubberband.c_settings = 4; 
    7878 
     
    532532        //calculate the new rubberband sample length 
    533533        if( __rubberband.use ){ 
    534                 m_prealtimeframeendfortarget = Hydrogen::get_instance()->getRealtimeFrames() + (m_pslframes * m_pratio + 0.1); 
     534                m_prealtimeframeendfortarget = Hydrogen::get_instance()->getRealtimeFrames() + (m_pslframes * m_pratio + 0.1); 
    535535        }else 
    536536        { 
     
    595595        unsigned targetsamplelength; 
    596596        if( __rubberband.use ){ 
    597                 targetsamplelength =  m_pslframes * m_pratio + 0.1; 
     597                targetsamplelength =  m_pslframes * m_pratio + 0.1; 
    598598        }else 
    599599        { 
     
    802802void SampleEditor::checkRatioSettings() 
    803803{ 
    804         //my personal ratio quality settings 
    805         //ratios < 0.1 || > 3.0 are bad (red) or experimental sounds 
    806         //ratios > 0.1 - 0.5 || > 2.0 are middle (yellow) 
    807         //ratios < 0.5 || < 2.0 are good (green) 
    808  
    809         bool is_green = false; 
    810         //green ratio 
    811         if( (m_pratio >= 0.5) && (m_pratio <= 2.0) ){ 
    812                 rubberComboBox->setStyleSheet("QComboBox { background-color: green; }"); 
    813                 is_green = true; 
    814         } 
    815         //yellow ratio 
    816         if( ( (m_pratio > 0.1) || ( m_pratio <=  3.0 ) )&& (!is_green)){ 
    817                 rubberComboBox->setStyleSheet("QComboBox { background-color: yellow; }"); 
    818         } 
    819         //red ratio 
    820         if( ( m_pratio <= 0.1 ) || ( m_pratio > 3.0 ) && (!is_green) ){ 
    821                 rubberComboBox->setStyleSheet("QComboBox { background-color: red; }"); 
    822         } 
    823         QString text = QString( " RB-Ratio = %1").arg(m_pratio); 
    824         ratiolabel->setText( text ); 
    825  
    826         //no rubberband = default 
    827         if( !__rubberband.use ){ 
    828                 rubberComboBox->setStyleSheet("QComboBox { background-color: 58, 62, 72; }"); 
    829                 ratiolabel->setText( "" ); 
    830         } 
     804        //calculate ration 
     805        double durationtime = 60.0 / Hydrogen::get_instance()->getNewBpmJTM() * __rubberband.divider; 
     806        double induration = (double) m_pslframes / (double) m_pSamplerate; 
     807        if (induration != 0.0) m_pratio = durationtime / induration; 
     808 
     809        //my personal ratio quality settings 
     810        //ratios < 0.1 || > 3.0 are bad (red) or experimental sounds 
     811        //ratios > 0.1 - 0.5 || > 2.0 are middle (yellow) 
     812        //ratios < 0.5 || < 2.0 are good (green) 
     813 
     814        bool is_green = false; 
     815        //green ratio 
     816        if( (m_pratio >= 0.5) && (m_pratio <= 2.0) ){ 
     817            rubberComboBox->setStyleSheet("QComboBox { background-color: green; }"); 
     818            is_green = true; 
     819        } 
     820        //yellow ratio 
     821        if( ( (m_pratio > 0.1) || ( m_pratio <=  3.0 ) )&& (!is_green)){ 
     822            rubberComboBox->setStyleSheet("QComboBox { background-color: yellow; }"); 
     823        } 
     824        //red ratio 
     825        if( ( m_pratio <= 0.1 ) || ( m_pratio > 3.0 ) && (!is_green) ){ 
     826            rubberComboBox->setStyleSheet("QComboBox { background-color: red; }"); 
     827        } 
     828        QString text = QString( " RB-Ratio = %1").arg(m_pratio); 
     829        ratiolabel->setText( text ); 
     830 
     831        //no rubberband = default 
     832        if( !__rubberband.use ){ 
     833            rubberComboBox->setStyleSheet("QComboBox { background-color: 58, 62, 72; }"); 
     834            ratiolabel->setText( "" ); 
     835        } 
    831836} 
    832837 
  • branches/undo/src/gui/src/SampleEditor/SampleEditor.h

    r2128 r2234  
    120120                QTimer *m_pTargetDisplayTimer; 
    121121                unsigned *m_pPositionsRulerPath; 
    122                 bool m_pPlayButton; 
    123                 float m_pratio; 
    124         H2Core::Sample::Loops __loops; 
    125         H2Core::Sample::Rubberband __rubberband; 
     122                bool m_pPlayButton; 
     123                float m_pratio; 
     124                H2Core::Sample::Loops __loops; 
     125                H2Core::Sample::Rubberband __rubberband; 
    126126 
    127127