Changeset 597

Show
Ignore:
Timestamp:
10/26/08 21:30:33 (2 months ago)
Author:
wolke
Message:

play instruments (samples) with your keyboard with different notes (like a synthesizer) and directly record the note values

Files:

Legend:

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

    r570 r597  
    13721372                        float pan_R = 1.0; 
    13731373 
    1374                         engine->addRealtimeNote (row, velocity, pan_L, pan_R); 
     1374                        engine->addRealtimeNote (row, velocity, pan_L, pan_R, NULL, NULL, NULL , row + 36); 
    13751375 
    13761376                        return TRUE; // eat event 
  • branches/new_fx_rack_and_sample_fun/gui/src/PatternEditor/PatternEditorPanel.cpp

    r593 r597  
    202202//      editor_top_hbox_2->addWidget( pZoom ); 
    203203 
     204        QComboBox *selInstrument = new QComboBox( NULL ); 
     205        selInstrument->setFixedSize( 170, 20 ); 
     206        selInstrument->move( 2, 1 ); 
     207        selInstrument->addItem ( QString( "keyb: play drumset" )); 
     208        selInstrument->addItem ( QString( "keyb: play instrument" )); 
     209        editor_top_hbox_2->addWidget( selInstrument ); 
     210        connect( selInstrument, SIGNAL( currentIndexChanged( QString ) ), this, SLOT( playselectedinstrument(QString) ) ); 
     211 
    204212        // zoom-in btn 
    205213        Button *zoom_in_btn = new Button( 
     
    10151023        } 
    10161024} 
     1025 
     1026 
     1027void PatternEditorPanel::playselectedinstrument( QString text ) 
     1028{ 
     1029        if ( text == "keyb: play drumset" ){ 
     1030                Preferences::getInstance()->__playselectedinstrument = false; 
     1031        }else 
     1032        { 
     1033                Preferences::getInstance()->__playselectedinstrument = true; 
     1034        } 
     1035} 
  • branches/new_fx_rack_and_sample_fun/gui/src/PatternEditor/PatternEditorPanel.h

    r593 r597  
    9797                void moveUpBtnClicked(Button *); 
    9898 
     99                void playselectedinstrument( QString text ); 
     100 
    99101        private: 
    100102                H2Core::Pattern *m_pPattern; 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/include/hydrogen/Preferences.h

    r582 r597  
    149149        bool __playsamplesonclicking; // audio file browser 
    150150 
     151        bool __playselectedinstrument; 
     152 
    151153        bool m_bFollowPlayhead; 
    152154         
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/include/hydrogen/hydrogen.h

    r596 r597  
    8080        void removeSong(); 
    8181 
    82         void addRealtimeNote ( int instrument, float velocity, float pan_L=1.0, float pan_R=1.0, float pitch=0.0, bool noteoff=false, bool forcePlay=false ); 
     82        void addRealtimeNote ( int instrument, float velocity, float pan_L=1.0, float pan_R=1.0, float pitch=0.0, bool noteoff=false, bool forcePlay=false, int msg1=0 ); 
    8383 
    8484        float getMasterPeak_L(); 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/src/IO/midi_input.cpp

    r596 r597  
    188188                return; 
    189189        } 
    190  
    191  
    192  
    193190         
    194191 
     
    213210                        } 
    214211 
    215                         pEngine->addRealtimeNote( nInstrument, fVelocity, fPan_L, fPan_R, 0.0, false, true ); 
     212                        pEngine->addRealtimeNote( nInstrument, fVelocity, fPan_L, fPan_R, 0.0, false, true, nNote ); 
    216213                } 
    217214        } 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/src/hydrogen.cpp

    r596 r597  
    18141814                                float pitch, 
    18151815                                bool noteOff, 
    1816                                 bool forcePlay ) 
     1816                                bool forcePlay, 
     1817                                int msg1 ) 
    18171818{ 
    18181819        UNUSED( pitch ); 
     
    18271828        AudioEngine::get_instance()->lock( "Hydrogen::addRealtimeNote" ); 
    18281829 
     1830 
    18291831        Song *song = getSong(); 
    1830         if ( instrument >= ( int )song->get_instrument_list()->get_size() ) { 
    1831                 // unused instrument 
    1832                 AudioEngine::get_instance()->unlock(); 
    1833                 return; 
     1832        if ( !pref->__playselectedinstrument ){ 
     1833                if ( instrument >= ( int )song->get_instrument_list()->get_size() ) { 
     1834                        // unused instrument 
     1835                        AudioEngine::get_instance()->unlock(); 
     1836                        return; 
     1837                } 
    18341838        } 
    18351839 
     
    18661870        unsigned position = column; 
    18671871        m_naddrealtimenotetickposition = column; 
    1868          
     1872 
    18691873 
    18701874        Instrument *instrRef = 0; 
     
    19071911                        } 
    19081912                } else { 
    1909                         // create the new note 
    1910                         Note *note = new Note( instrRef, 
    1911                                                position, 
    1912                                                velocity, 
    1913                                                pan_L, 
    1914                                                pan_R, 
    1915                                                -1, 
    1916                                                0 ); 
    1917                         currentPattern->note_map.insert( 
    1918                                 std::make_pair( column, note ) 
    1919                                 ); 
    1920 /* 
    1921                         if ( noteOff ) { 
    1922                                 note->set_noteoff( true ); 
    1923                                 note->set_lenght( 1 ); 
    1924                         } 
    1925 */ 
    1926                         // hear note if its not in the future 
    1927                         if ( pref->getHearNewNotes() 
    1928                              && position <= getTickPosition() ) { 
    1929                                 hearnote = true; 
    1930                         } 
    1931  
    1932                         song->__is_modified = true; 
    1933  
    1934                         EventQueue::get_instance()->push_event( EVENT_PATTERN_MODIFIED, -1 ); 
     1913                        if ( !pref->__playselectedinstrument ){ 
     1914                                // create the new note 
     1915                                Note *note = new Note( instrRef, 
     1916                                                position, 
     1917                                                velocity, 
     1918                                                pan_L, 
     1919                                                pan_R, 
     1920                                                -1, 
     1921                                                0 ); 
     1922                                currentPattern->note_map.insert( 
     1923                                        std::make_pair( column, note ) 
     1924                                        ); 
     1925        /* 
     1926                                if ( noteOff ) { 
     1927                                        note->set_noteoff( true ); 
     1928                                        note->set_lenght( 1 ); 
     1929                                } 
     1930        */ 
     1931                                // hear note if its not in the future 
     1932                                if ( pref->getHearNewNotes() 
     1933                                        && position <= getTickPosition() ) { 
     1934                                        hearnote = true; 
     1935                                } 
     1936         
     1937                                song->__is_modified = true; 
     1938         
     1939                                EventQueue::get_instance()->push_event( EVENT_PATTERN_MODIFIED, -1 ); 
     1940                        } 
     1941                        else if ( pref->__playselectedinstrument ){ 
     1942 
     1943                                Note *note = new Note( song->get_instrument_list()->get( getSelectedInstrumentNumber()), 
     1944                                                        position, 
     1945                                                        velocity, 
     1946                                                        pan_L, 
     1947                                                        pan_R, 
     1948                                                        -1, 
     1949                                                        0 ); 
     1950         
     1951                                int divider = msg1 / 12; 
     1952                                int octave = divider -3; 
     1953                                int notehigh = msg1 - (12 * divider); 
     1954                                note->m_noteKey.m_nOctave = octave; 
     1955                                if ( notehigh == 0) note->m_noteKey.m_key = H2Core::NoteKey::C; 
     1956                                else if ( notehigh == 1 ) note->m_noteKey.m_key = H2Core::NoteKey::Cs; 
     1957                                else if ( notehigh == 2 ) note->m_noteKey.m_key = H2Core::NoteKey::D; 
     1958                                else if ( notehigh == 3 ) note->m_noteKey.m_key = H2Core::NoteKey::Ef; 
     1959                                else if ( notehigh == 4 ) note->m_noteKey.m_key = H2Core::NoteKey::E; 
     1960                                else if ( notehigh == 5 ) note->m_noteKey.m_key = H2Core::NoteKey::F; 
     1961                                else if ( notehigh == 6 ) note->m_noteKey.m_key = H2Core::NoteKey::Fs; 
     1962                                else if ( notehigh == 7 ) note->m_noteKey.m_key = H2Core::NoteKey::G; 
     1963                                else if ( notehigh == 8 ) note->m_noteKey.m_key = H2Core::NoteKey::Af; 
     1964                                else if ( notehigh == 9 ) note->m_noteKey.m_key = H2Core::NoteKey::A; 
     1965                                else if ( notehigh == 10 ) note->m_noteKey.m_key = H2Core::NoteKey::Bf; 
     1966                                else if ( notehigh == 11 ) note->m_noteKey.m_key = H2Core::NoteKey::B; 
     1967 
     1968                                currentPattern->note_map.insert( 
     1969                                        std::make_pair( column, note ) 
     1970                                        ); 
     1971 
     1972                                // hear note if its not in the future 
     1973                                if ( pref->getHearNewNotes() 
     1974                                        && position <= getTickPosition() ) { 
     1975                                        hearnote = true; 
     1976                                } 
     1977         
     1978                                song->__is_modified = true; 
     1979         
     1980                                EventQueue::get_instance()->push_event( EVENT_PATTERN_MODIFIED, -1 );                            
     1981                        } 
    19351982                } 
    19361983        } else if ( pref->getHearNewNotes() ) { 
    19371984                hearnote = true; 
    19381985        } 
    1939  
    1940         if ( hearnote && instrRef ) { 
    1941                 Note *note2 = new Note( instrRef, 
    1942                                         realcolumn, 
    1943                                         velocity, 
    1944                                         pan_L, 
    1945                                         pan_R, 
    1946                                         -1, 
    1947                                         0 ); 
    1948                 midi_noteOn( note2 ); 
    1949         } 
     1986         
     1987        if ( !pref->__playselectedinstrument ){ 
     1988                if ( hearnote && instrRef ) { 
     1989                        Note *note2 = new Note( instrRef, 
     1990                                                realcolumn, 
     1991                                                velocity, 
     1992                                                pan_L, 
     1993                                                pan_R, 
     1994                                                -1, 
     1995                                                0 ); 
     1996                        midi_noteOn( note2 ); 
     1997                } 
     1998        }else 
     1999        { 
     2000                if ( hearnote  ) { 
     2001                        Note *note2 = new Note( song->get_instrument_list()->get( getSelectedInstrumentNumber()), 
     2002                                                realcolumn, 
     2003                                                velocity, 
     2004                                                pan_L, 
     2005                                                pan_R, 
     2006                                                -1, 
     2007                                                0 ); 
     2008 
     2009                        int divider = msg1 / 12; 
     2010                        int octave = divider -3; 
     2011                        int notehigh = msg1 - (12 * divider); 
     2012 
     2013                        ERRORLOG( QString( "octave: %1, note: %2, instrument %3" ).arg( octave ).arg(notehigh).arg(instrument)); 
     2014                        note2->m_noteKey.m_nOctave = octave; 
     2015                        if ( notehigh == 0) note2->m_noteKey.m_key = H2Core::NoteKey::C; 
     2016                        else if ( notehigh == 1 ) note2->m_noteKey.m_key = H2Core::NoteKey::Cs; 
     2017                        else if ( notehigh == 2 ) note2->m_noteKey.m_key = H2Core::NoteKey::D; 
     2018                        else if ( notehigh == 3 ) note2->m_noteKey.m_key = H2Core::NoteKey::Ef; 
     2019                        else if ( notehigh == 4 ) note2->m_noteKey.m_key = H2Core::NoteKey::E; 
     2020                        else if ( notehigh == 5 ) note2->m_noteKey.m_key = H2Core::NoteKey::F; 
     2021                        else if ( notehigh == 6 ) note2->m_noteKey.m_key = H2Core::NoteKey::Fs; 
     2022                        else if ( notehigh == 7 ) note2->m_noteKey.m_key = H2Core::NoteKey::G; 
     2023                        else if ( notehigh == 8 ) note2->m_noteKey.m_key = H2Core::NoteKey::Af; 
     2024                        else if ( notehigh == 9 ) note2->m_noteKey.m_key = H2Core::NoteKey::A; 
     2025                        else if ( notehigh == 10 ) note2->m_noteKey.m_key = H2Core::NoteKey::Bf; 
     2026                        else if ( notehigh == 11 ) note2->m_noteKey.m_key = H2Core::NoteKey::B; 
     2027 
     2028                        midi_noteOn( note2 ); 
     2029                }        
     2030 
     2031        } 
     2032 
    19502033 
    19512034        AudioEngine::get_instance()->unlock(); // unlock the audio engine 
  • branches/new_fx_rack_and_sample_fun/libs/hydrogen/src/preferences.cpp

    r582 r597  
    128128        __lastsampleDirectory = QDir::homePath(); //audio file browser 
    129129        __playsamplesonclicking = false; // audio file browser 
     130        __playselectedinstrument = false; // midi keyboard and keyboard play only selected instrument 
    130131  
    131132        loadPreferences( true );        // Global settings