Actually mute notes outside of current mapping.
This commit is contained in:
parent
9bebbffd46
commit
742679c5ad
10
instrument.C
10
instrument.C
|
@ -113,11 +113,17 @@ Instrument::velocity ( int n, int v )
|
|||
_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
|
||||
{
|
||||
if ( ! note_name( e->note() ) )
|
||||
return false;
|
||||
|
||||
e->note_velocity( e->note_velocity() * _map[ e->note() ].velocity / 100 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
void note_name ( int n, char *s );
|
||||
|
||||
/* inspection */
|
||||
void translate ( midievent *e ) const;
|
||||
bool translate ( midievent *e ) const;
|
||||
const char * note_name ( int n ) const;
|
||||
int height ( void ) const;
|
||||
const char * name ( void ) const;
|
||||
|
|
|
@ -101,7 +101,7 @@ Mapping::key ( void ) const
|
|||
return _type == INSTRUMENT ? -1 : _key;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
Mapping::translate ( midievent *e ) const
|
||||
{
|
||||
switch ( _type )
|
||||
|
@ -111,6 +111,8 @@ Mapping::translate ( midievent *e ) const
|
|||
case SCALE:
|
||||
return _scale->translate( _key, e );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
void key ( int n );
|
||||
|
||||
/* inspection */
|
||||
void translate ( midievent *e ) const;
|
||||
bool translate ( midievent *e ) const;
|
||||
const char * note_name ( int n ) const;
|
||||
int velocity ( int n ) const;
|
||||
int key ( void ) const;
|
||||
|
|
|
@ -454,12 +454,13 @@ try_again:
|
|||
|
||||
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
|
||||
if ( me.is_note_off() )
|
||||
midi_output_event( _port, &me, 0 );
|
||||
if ( mapping.translate( &me ) )
|
||||
midi_output_event( _port, &me, 0 );
|
||||
else
|
||||
/* any other event type */
|
||||
midi_output_event( _port, &me );
|
||||
|
|
8
scale.C
8
scale.C
|
@ -176,11 +176,13 @@ Scale::_degree ( int k, int n ) const
|
|||
}
|
||||
|
||||
/* translate NOTE event. Behavior is undefined for other event types */
|
||||
void
|
||||
bool
|
||||
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 *
|
||||
|
|
2
scale.H
2
scale.H
|
@ -41,7 +41,7 @@ public:
|
|||
static const char * chromatic_name ( 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;
|
||||
const char * note_name ( int k, int n ) const;
|
||||
const char * name ( void ) const;
|
||||
|
|
Loading…
Reference in New Issue