Browse Source

Actually mute notes outside of current mapping.

tags/non-sequencer-v1.9.4
Jonathan Moore Liles 17 years ago
parent
commit
742679c5ad
7 changed files with 23 additions and 12 deletions
  1. +8
    -2
      instrument.C
  2. +1
    -1
      instrument.H
  3. +3
    -1
      mapping.C
  4. +1
    -1
      mapping.H
  5. +4
    -3
      pattern.C
  6. +5
    -3
      scale.C
  7. +1
    -1
      scale.H

+ 8
- 2
instrument.C View File

@@ -113,11 +113,17 @@ Instrument::velocity ( int n, int v )
_dirty = true; _dirty = true;
} }


/* Should only be passed NOTE ON/OFF events! */
void
/** Translate event, should only be passed NOTE ON/OFF events, returns
true if note is valid for this mapping */
bool
Instrument::translate ( midievent *e ) const Instrument::translate ( midievent *e ) const
{ {
if ( ! note_name( e->note() ) )
return false;

e->note_velocity( e->note_velocity() * _map[ e->note() ].velocity / 100 ); e->note_velocity( e->note_velocity() * _map[ e->note() ].velocity / 100 );

return true;
} }


const char * const char *


+ 1
- 1
instrument.H View File

@@ -55,7 +55,7 @@ public:
void note_name ( int n, char *s ); void note_name ( int n, char *s );


/* inspection */ /* inspection */
void translate ( midievent *e ) const;
bool translate ( midievent *e ) const;
const char * note_name ( int n ) const; const char * note_name ( int n ) const;
int height ( void ) const; int height ( void ) const;
const char * name ( void ) const; const char * name ( void ) const;


+ 3
- 1
mapping.C View File

@@ -101,7 +101,7 @@ Mapping::key ( void ) const
return _type == INSTRUMENT ? -1 : _key; return _type == INSTRUMENT ? -1 : _key;
} }


void
bool
Mapping::translate ( midievent *e ) const Mapping::translate ( midievent *e ) const
{ {
switch ( _type ) switch ( _type )
@@ -111,6 +111,8 @@ Mapping::translate ( midievent *e ) const
case SCALE: case SCALE:
return _scale->translate( _key, e ); return _scale->translate( _key, e );
} }

return false;
} }


int int


+ 1
- 1
mapping.H View File

@@ -64,7 +64,7 @@ public:
void key ( int n ); void key ( int n );


/* inspection */ /* inspection */
void translate ( midievent *e ) const;
bool translate ( midievent *e ) const;
const char * note_name ( int n ) const; const char * note_name ( int n ) const;
int velocity ( int n ) const; int velocity ( int n ) const;
int key ( void ) const; int key ( void ) const;


+ 4
- 3
pattern.C View File

@@ -454,12 +454,13 @@ try_again:


if ( me.is_note_on() ) if ( me.is_note_on() )
{ {
mapping.translate( &me );
midi_output_event( _port, &me, 1 + e->note_duration() );
if ( mapping.translate( &me ) )
midi_output_event( _port, &me, 1 + e->note_duration() );
} }
else else
if ( me.is_note_off() ) if ( me.is_note_off() )
midi_output_event( _port, &me, 0 );
if ( mapping.translate( &me ) )
midi_output_event( _port, &me, 0 );
else else
/* any other event type */ /* any other event type */
midi_output_event( _port, &me ); midi_output_event( _port, &me );


+ 5
- 3
scale.C View File

@@ -176,11 +176,13 @@ Scale::_degree ( int k, int n ) const
} }


/* translate NOTE event. Behavior is undefined for other event types */ /* translate NOTE event. Behavior is undefined for other event types */
void
bool
Scale::translate ( int k, midievent *e ) const Scale::translate ( int k, midievent *e ) const
{ {
/* does nothing now... */
/* TODO: invalidate events that are note on/offs for notes outside the scale. */
if ( ! note_name( k, e->note() ) )
return false;
else
return true;
} }


const char * const char *


+ 1
- 1
scale.H View File

@@ -41,7 +41,7 @@ public:
static const char * chromatic_name ( int n ); static const char * chromatic_name ( int n );
static int octave ( int n ); static int octave ( int n );


void translate ( int k, midievent *e ) const;
bool translate ( int k, midievent *e ) const;
int note ( int k, int n ) const; int note ( int k, int n ) const;
const char * note_name ( int k, int n ) const; const char * note_name ( int k, int n ) const;
const char * name ( void ) const; const char * name ( void ) const;


Loading…
Cancel
Save