Changeset 588

Show
Ignore:
Timestamp:
10/22/08 04:20:05 (3 months ago)
Author:
wolke
Message:

change midi note_off record

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/new_fx_rack_and_sample_fun/gui/src/AudioFileBrowser/AudioFileBrowser.cpp

    r585 r588  
    100100        if( ev->modifiers()==Qt::ControlModifier ){ 
    101101                tree->setSelectionMode( QAbstractItemView::MultiSelection ); 
     102                openBTN->setEnabled( true ); 
    102103        } 
    103104         
     
    350351        tree->collapse( model->index( updir  ) ); 
    351352} 
     353 
     354 
     355 
     356void AudioFileBrowser::on_hiddenCB_clicked() 
     357{ 
     358        if ( hiddenCB->isChecked() ){ 
     359                model->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden ); 
     360        }else 
     361        { 
     362                model->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot ); 
     363                tree->setRootIndex( model->index( pathLineEdit->text() ) ); 
     364        } 
     365} 
  • branches/new_fx_rack_and_sample_fun/gui/src/AudioFileBrowser/AudioFileBrowser.h

    r585 r588  
    6262                void on_m_pPathUptoolButton_clicked(); 
    6363                void on_playSamplescheckBox_clicked(); 
     64                void on_hiddenCB_clicked(); 
    6465                 
    6566                virtual void keyPressEvent (QKeyEvent *ev); 
  • branches/new_fx_rack_and_sample_fun/gui/src/AudioFileBrowser/AudioFileBrowser_UI.ui

    r570 r588  
    9090     <x>10</x> 
    9191     <y>530</y> 
    92      <width>271</width> 
     92     <width>216</width> 
    9393     <height>21</height> 
    9494    </rect> 
     
    110110    <item> 
    111111     <widget class="QLineEdit" name="pathLineEdit" /> 
     112    </item> 
     113    <item> 
     114     <widget class="QRadioButton" name="hiddenCB" > 
     115      <property name="toolTip" > 
     116       <string>View hidden folders</string> 
     117      </property> 
     118      <property name="text" > 
     119       <string/> 
     120      </property> 
     121     </widget> 
    112122    </item> 
    113123    <item> 
     
    231241 <tabstops> 
    232242  <tabstop>pathLineEdit</tabstop> 
     243  <tabstop>hiddenCB</tabstop> 
    233244  <tabstop>m_pPathUptoolButton</tabstop> 
    234245  <tabstop>m_pPathHometoolButton</tabstop> 
     
    239250  <tabstop>useNameCheckBox</tabstop> 
    240251  <tabstop>playSamplescheckBox</tabstop> 
     252  <tabstop>autoVelCheckBox</tabstop> 
    241253  <tabstop>openBTN</tabstop> 
    242254  <tabstop>cancelBTN</tabstop> 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/include/hydrogen/IO/MidiInput.h

    r581 r588  
    103103 
    104104 
     105private: 
     106        unsigned long  __noteOnTick; 
     107        unsigned long  __noteOffTick; 
     108        unsigned long computeDeltaNoteOnOfftime(); 
     109 
     110 
    105111 
    106112}; 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/include/hydrogen/hydrogen.h

    r583 r588  
    201201 
    202202        void __panic(); 
     203        int __get_selected_PatterNumber(); 
    203204         
    204205 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/include/hydrogen/sampler/Sampler.h

    r583 r588  
    7474        void makeTrackOutputQueues(); 
    7575 
    76         bool istInstrumentPlaying( Instrument* instrument ); 
     76        void setPlayingNotelenght( Instrument* instrument, unsigned long ticks, unsigned long noteOnTick ); 
    7777 
    7878private: 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/src/IO/midi_input.cpp

    r585 r588  
    152152} 
    153153 
     154 
     155 
    154156void MidiInput::handleNoteOnMessage( const MidiMessage& msg ) 
    155157{ 
     
    181183         
    182184        bool action = aH->handleAction( mM->getNoteAction( msg.m_nData1 ) ); 
     185        __noteOnTick = pEngine->getTickPosition(); 
    183186         
    184187        if ( action && Preferences::getInstance()->m_bMidiDiscardNoteAfterAction) 
     
    228231        Song *pSong = pEngine->getSong(); 
    229232 
     233        __noteOffTick = pEngine->getTickPosition(); 
     234        unsigned long notelenght = computeDeltaNoteOnOfftime(); 
     235 
    230236        int nNote = msg.m_nData1; 
     237        //float fVelocity = msg.m_nData2 / 127.0; //we need this in future to controll release velocity 
    231238        int nInstrument = nNote - 36; 
    232239        if ( nInstrument < 0 ) { 
     
    237244        } 
    238245        Instrument *pInstr = pSong->get_instrument_list()->get( nInstrument ); 
     246 
     247        if ( pInstr ){ //set the notelength 
     248                AudioEngine::get_instance()->get_sampler()->setPlayingNotelenght( pInstr, notelenght, __noteOnTick ); 
     249        } 
     250 
    239251        const unsigned nPosition = 0; 
    240252        const float fVelocity = 0.0f; 
     
    245257        Note *pNewNote = new Note( pInstr, nPosition, fVelocity, fPan_L, fPan_R, nLenght, fPitch ); 
    246258 
    247 //      if ( pInstr && AudioEngine::get_instance()->get_sampler()->istInstrumentPlaying( pInstr ) ){ 
    248 //              pEngine->addRealtimeNote( nInstrument, fVelocity, fPan_L, fPan_R, 0.0, true, true ); 
    249 //      } 
    250259        pEngine->midi_noteOff( pNewNote ); 
    251260 
    252261} 
    253262 
    254  
     263unsigned long MidiInput::computeDeltaNoteOnOfftime() 
     264
     265        unsigned long  __notelenghtTicks = __noteOffTick - __noteOnTick; 
     266        //INFOLOG( QString( "notenlÀnge %1" ).arg( __notelenghtTicks )); 
     267        return __notelenghtTicks; 
     268         
     269
    255270 
    256271void MidiInput::handleSysexMessage( const MidiMessage& msg ) 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/src/hydrogen.cpp

    r583 r588  
    19031903                                std::make_pair( column, note ) 
    19041904                                ); 
     1905/* 
    19051906                        if ( noteOff ) { 
    19061907                                note->set_noteoff( true ); 
    19071908                                note->set_lenght( 1 ); 
    19081909                        } 
    1909  
     1910*/ 
    19101911                        // hear note if its not in the future 
    19111912                        if ( pref->getHearNewNotes() 
     
    29482949} 
    29492950 
     2951int Hydrogen::__get_selected_PatterNumber() 
     2952{ 
     2953        return m_nSelectedPatternNumber; 
     2954} 
     2955 
    29502956 
    29512957}; 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/src/sampler/sampler.cpp

    r583 r588  
    3737#include <hydrogen/sample.h> 
    3838#include <hydrogen/Song.h> 
     39#include <hydrogen/Pattern.h> 
     40 
     41#include "gui/src/HydrogenApp.h" 
     42#include "gui/src/PatternEditor/PatternEditorPanel.h" 
     43#include "gui/src/PatternEditor/DrumPatternEditor.h" 
    3944 
    4045#include <hydrogen/fx/Effects.h> 
     
    760765} 
    761766 
    762 bool Sampler::istInstrumentPlaying( Instrument* instrument ) 
    763 
     767 
     768 
     769void Sampler::setPlayingNotelenght( Instrument* instrument, unsigned long ticks, unsigned long noteOnTick ) 
     770
     771 
    764772        if ( instrument ) { // stop all notes using this instrument 
    765                 for ( unsigned i = 0; i < __playing_notes_queue.size(); ) { 
    766                         Note *pNote = __playing_notes_queue[ i ]; 
    767                         assert( pNote ); 
    768                         if ( pNote->get_instrument() == instrument ) { 
    769                                 return true; 
     773                Hydrogen *pEngine = Hydrogen::get_instance();    
     774                Song* mSong = pEngine->getSong(); 
     775                int selectedpattern = pEngine->__get_selected_PatterNumber(); 
     776                Pattern* currentPattern = NULL; 
     777                PatternList *pPatternList = mSong->get_pattern_list(); 
     778 
     779                if ( ( selectedpattern != -1 ) 
     780                && ( selectedpattern < ( int )pPatternList->get_size() ) ) { 
     781                        currentPattern = pPatternList->get( selectedpattern ); 
     782                } 
     783 
     784                 
     785                if ( currentPattern ) { 
     786                                int patternsize = currentPattern->get_lenght(); 
     787         
     788                                for ( unsigned nNote = 0 ; 
     789                                nNote < currentPattern->get_lenght() ; 
     790                                nNote++ ) { 
     791                                        std::multimap <int, Note*>::iterator pos; 
     792                                        for ( pos = currentPattern->note_map.lower_bound( nNote ) ; 
     793                                        pos != currentPattern->note_map.upper_bound( nNote ) ; 
     794                                        ++pos ) { 
     795                                                Note *pNote = pos->second; 
     796                                                if ( pNote!=NULL ) { 
     797                                                        if ( pNote->get_instrument() == instrument 
     798                                                        && pNote->get_position() == noteOnTick ) { 
     799                                                                AudioEngine::get_instance()->lock("Sample::setnotelenght_event"); 
     800         
     801         
     802                                                                if ( ticks >  patternsize ) ticks = -1; 
     803                                                                pNote->set_lenght( ticks ); 
     804                                                                Hydrogen::get_instance()->getSong()->__is_modified = true; 
     805                                                                AudioEngine::get_instance()->unlock(); // unlock the audio engine 
     806                                                                                                                         
     807                                                        } 
     808                                                } 
     809                                        } 
     810                                } 
    770811                        } 
    771                         ++i; 
    772                 } 
    773         } else { 
    774         return false; 
    775         } 
    776 
    777  
     812         
     813                } 
     814 
     815        HydrogenApp::getInstance()->getPatternEditorPanel()->getDrumPatternEditor()->updateEditor(); 
     816 
     817
    778818}; 
    779819