Subversion Repositories svn.mios32

Rev

Rev 1809 | Rev 1813 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1809 Rev 1810
Line 1... Line 1...
1
// $Id: seq_core.c 1809 2013-06-17 19:05:41Z tk $
1
// $Id: seq_core.c 1810 2013-06-17 21:14:23Z tk $
2
/*
2
/*
3
 * Sequencer Core Routines
3
 * Sequencer Core Routines
4
 *
4
 *
5
 * ==========================================================================
5
 * ==========================================================================
6
 *
6
 *
Line 535... Line 535...
535
    SEQ_CORE_ResetTrkPos(track, t, tcc);
535
    SEQ_CORE_ResetTrkPos(track, t, tcc);
536
      }
536
      }
537
537
538
      // NEW: temporary layer mutes on incoming MIDI
538
      // NEW: temporary layer mutes on incoming MIDI
539
      // take over _next mutes
539
      // take over _next mutes
540
      // TEST: do this only each 8th note
540
      int num_steps = (seq_core_options.LIVE_LAYER_MUTE_STEPS < 2) ? 1 : (seq_core_options.LIVE_LAYER_MUTE_STEPS-2+1);
541
      if( (bpm_tick % (384/2)) ) {
541
      if( (bpm_tick % (num_steps*(384/4))) == 0 ) {
542
    // layer mutes
542
    // layer mutes
543
    t->layer_muted_from_midi = t->layer_muted_from_midi_next;
543
    t->layer_muted_from_midi = t->layer_muted_from_midi_next;
544
    t->layer_muted_from_midi_next = 0;
544
    t->layer_muted_from_midi_next = 0;
545
545
546
    // the same for the LFO CC
546
    // the same for the LFO CC
Line 1812... Line 1812...
1812
/////////////////////////////////////////////////////////////////////////////
1812
/////////////////////////////////////////////////////////////////////////////
1813
s32 SEQ_CORE_NotifyIncomingMIDIEvent(u8 track, mios32_midi_package_t p)
1813
s32 SEQ_CORE_NotifyIncomingMIDIEvent(u8 track, mios32_midi_package_t p)
1814
{
1814
{
1815
  if( track >= SEQ_CORE_NUM_TRACKS )
1815
  if( track >= SEQ_CORE_NUM_TRACKS )
1816
    return -1; // invalid track
1816
    return -1; // invalid track
-
 
1817
-
 
1818
  if( !seq_core_options.LIVE_LAYER_MUTE_STEPS )
-
 
1819
    return 0; // disabled
1817
1820
1818
  seq_core_trk_t *t = &seq_core_trk[track];
1821
  seq_core_trk_t *t = &seq_core_trk[track];
1819
  seq_cc_trk_t *tcc = &seq_cc_trk[track];
1822
  seq_cc_trk_t *tcc = &seq_cc_trk[track];
1820
1823
1821
  if( tcc->event_mode == SEQ_EVENT_MODE_Drum )
1824
  if( tcc->event_mode == SEQ_EVENT_MODE_Drum )
Line 1837... Line 1840...
1837
    // hm... should we also play a note off for active notes?
1840
    // hm... should we also play a note off for active notes?
1838
    // and should we mute the sequencer notes as long as no Note Off has been played?
1841
    // and should we mute the sequencer notes as long as no Note Off has been played?
1839
    // problem: we would have to track all actively played MIDI notes, this consumes a lot of memory
1842
    // problem: we would have to track all actively played MIDI notes, this consumes a lot of memory
1840
1843
1841
    portENTER_CRITICAL();
1844
    portENTER_CRITICAL();
-
 
1845
    if( seq_core_options.LIVE_LAYER_MUTE_STEPS == 1 ) {
-
 
1846
      t->layer_muted |= mask;      // mute layer immediately
-
 
1847
    } else {
1842
    t->layer_muted_from_midi |= mask;      // mute layer immediately
1848
      t->layer_muted_from_midi |= mask;      // mute layer immediately
1843
    t->layer_muted_from_midi_next |= mask; // and for the next step
1849
      t->layer_muted_from_midi_next |= mask; // and for the next step
-
 
1850
    }
1844
    portEXIT_CRITICAL();
1851
    portEXIT_CRITICAL();
1845
      }
1852
      }
1846
    }
1853
    }
1847
  } break;
1854
  } break;
1848
1855
Line 1854... Line 1861...
1854
    // temporary mute layers which are assigned to the corresponding event
1861
    // temporary mute layers which are assigned to the corresponding event
1855
    u8 *layer_type_ptr = (u8 *)&tcc->lay_const[0*16];
1862
    u8 *layer_type_ptr = (u8 *)&tcc->lay_const[0*16];
1856
    int par_layer;
1863
    int par_layer;
1857
    int num_p_layers = SEQ_PAR_NumLayersGet(track);
1864
    int num_p_layers = SEQ_PAR_NumLayersGet(track);
1858
    u16 mask = 1;
1865
    u16 mask = 1;
-
 
1866
    u8 apply_mask = 0;
1859
    for(par_layer=0; par_layer<num_p_layers; ++par_layer, ++layer_type_ptr, mask <<= 1) {
1867
    for(par_layer=0; par_layer<num_p_layers; ++par_layer, ++layer_type_ptr, mask <<= 1) {
1860
      switch( *layer_type_ptr ) {
1868
      switch( *layer_type_ptr ) {
1861
      case SEQ_PAR_Type_CC: {
1869
      case SEQ_PAR_Type_CC: {
1862
    if( p.event == CC && p.cc_number == tcc->lay_const[1*16 + par_layer] ) {
1870
    if( p.event == CC && p.cc_number == tcc->lay_const[1*16 + par_layer] ) {
1863
      portENTER_CRITICAL();
-
 
1864
      t->layer_muted_from_midi |= mask;      // mute layer immediately
-
 
1865
      t->layer_muted_from_midi_next |= mask; // and for the next step
-
 
1866
      portEXIT_CRITICAL();
1871
      apply_mask = 1;
1867
    }
1872
    }
1868
      } break;
1873
      } break;
1869
1874
1870
      case SEQ_PAR_Type_PitchBend: {
1875
      case SEQ_PAR_Type_PitchBend: {
1871
    if( p.event == PitchBend ) {
1876
    if( p.event == PitchBend ) {
1872
      portENTER_CRITICAL();
-
 
1873
      t->layer_muted_from_midi |= mask;      // mute layer immediately
-
 
1874
      t->layer_muted_from_midi_next |= mask; // and for the next step
-
 
1875
      portEXIT_CRITICAL();
1877
      apply_mask = 1;
1876
    }
1878
    }
1877
      } break;
1879
      } break;
1878
1880
1879
      case SEQ_PAR_Type_ProgramChange: {
1881
      case SEQ_PAR_Type_ProgramChange: {
1880
    if( p.event == ProgramChange ) {
1882
    if( p.event == ProgramChange ) {
-
 
1883
      apply_mask = 1;
-
 
1884
    }
-
 
1885
      } break;
-
 
1886
      }
-
 
1887
-
 
1888
      if( apply_mask ) {
1881
      portENTER_CRITICAL();
1889
    portENTER_CRITICAL();
-
 
1890
    if( seq_core_options.LIVE_LAYER_MUTE_STEPS == 1 ) {
-
 
1891
      t->layer_muted |= mask;      // mute layer immediately
-
 
1892
    } else {
1882
      t->layer_muted_from_midi |= mask;      // mute layer immediately
1893
      t->layer_muted_from_midi |= mask;      // mute layer immediately
1883
      t->layer_muted_from_midi_next |= mask; // and for the next step
1894
      t->layer_muted_from_midi_next |= mask; // and for the next step
1884
      portEXIT_CRITICAL();
-
 
1885
    }
1895
    }
1886
      } break;
1896
    portEXIT_CRITICAL();
1887
      }
1897
      }
1888
    }
1898
    }
1889
1899
1890
    // check also LFO CC
1900
    // check also LFO CC (note: only handled as temporary change)
1891
    if( p.event == CC && p.cc_number == tcc->lfo_cc ) {
1901
    if( p.event == CC && p.cc_number == tcc->lfo_cc ) {
1892
      portENTER_CRITICAL();
1902
      portENTER_CRITICAL();
1893
      t->lfo_cc_muted_from_midi = 1;
1903
      t->lfo_cc_muted_from_midi = 1;
1894
      t->lfo_cc_muted_from_midi_next = 1;
1904
      t->lfo_cc_muted_from_midi_next = 1;
1895
      portEXIT_CRITICAL();
1905
      portEXIT_CRITICAL();