From c02991ca5d19956607f70a9c997e7c8207fb8acc Mon Sep 17 00:00:00 2001 From: John Anderson Date: Wed, 8 Aug 2007 18:09:27 +0000 Subject: [PATCH] fix for #3 mute button not lighting at startup. Because LCD messages sent as straight bytes instead of sysex msg. git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2271 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/mackie/TODO | 8 ++++++ .../mackie/mackie_control_protocol.cc | 17 ++++++------- libs/surfaces/mackie/mackie_midi_builder.cc | 25 +++++++++++++------ libs/surfaces/mackie/mackie_midi_builder.h | 21 ++++++++++------ 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/libs/surfaces/mackie/TODO b/libs/surfaces/mackie/TODO index bc01baecdc..eec729289b 100644 --- a/libs/surfaces/mackie/TODO +++ b/libs/surfaces/mackie/TODO @@ -1,5 +1,8 @@ +* fader problem (reported by Giso Grimm). Also with P4 (hyperthread) +* two bcf doesn't work * remappable buttons * 7/1 configurable to 8 +* need an object that can encapsulate different port types, ie BCF vs MCU. Not at the surface level. * finish button implementations. * concurrency for bank switching? And make sure "old" events aren't sent to "new" faders * TODOs in code @@ -41,3 +44,8 @@ UI integration * maybe use current snap state for jog wheel and ffwd/rew * Some indication on the UI of currently bank-switched-in routes? Useful for surfaces that don't have a scribble strip. + +Bugs +---- +* when using alsa/sequencer, some midi events intended for mcu port end up being + read by the seq port. diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 0612d6aed5..790eef7ee9 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -309,7 +309,8 @@ void MackieControlProtocol::switch_banks( int initial ) { Strip & strip = *surface().strips[i]; // send zero for this strip - port_for_id(i).write( builder.zero_strip( strip ) ); + MackiePort & port = port_for_id(i); + port.write( builder.zero_strip( port, strip ) ); } } @@ -342,11 +343,12 @@ void MackieControlProtocol::zero_all() // zero all strips for ( Surface::Strips::iterator it = surface().strips.begin(); it != surface().strips.end(); ++it ) { - port_for_id( (*it)->index() ).write( builder.zero_strip( **it ) ); + MackiePort & port = port_for_id( (*it)->index() ); + port.write( builder.zero_strip( port, **it ) ); } // and the master strip - mcu_port().write( builder.zero_strip( master_strip() ) ); + mcu_port().write( builder.zero_strip( mcu_port(), master_strip() ) ); // and the led ring for the master strip, in bcf mode if ( mcu_port().emulation() == MackiePort::bcf2000 ) @@ -1006,12 +1008,9 @@ void MackieControlProtocol::notify_name_changed( void *, RouteSignal * route_sig line1 = PBD::short_version( fullname, 6 ); } - route_signal->port().write_sysex( - builder.strip_display( strip, 0, line1 ) - ); - route_signal->port().write_sysex( - builder.strip_display_blank( strip, 1 ) - ); + MackiePort & port = route_signal->port(); + port.write( builder.strip_display( port, strip, 0, line1 ) ); + port.write( builder.strip_display_blank( port, strip, 1 ) ); } } catch( exception & e ) diff --git a/libs/surfaces/mackie/mackie_midi_builder.cc b/libs/surfaces/mackie/mackie_midi_builder.cc index 872b63d02a..1ef2853114 100644 --- a/libs/surfaces/mackie/mackie_midi_builder.cc +++ b/libs/surfaces/mackie/mackie_midi_builder.cc @@ -23,6 +23,7 @@ #include "controls.h" #include "midi_byte_array.h" +#include "mackie_port.h" using namespace Mackie; using namespace std; @@ -100,7 +101,7 @@ MidiByteArray MackieMidiBuilder::build_fader( const Fader & fader, float pos ) ); } -MidiByteArray MackieMidiBuilder::zero_strip( const Strip & strip ) +MidiByteArray MackieMidiBuilder::zero_strip( MackiePort & port, const Strip & strip ) { Group::Controls::const_iterator it = strip.controls().begin(); MidiByteArray retval; @@ -110,8 +111,10 @@ MidiByteArray MackieMidiBuilder::zero_strip( const Strip & strip ) if ( control.accepts_feedback() ) retval << zero_control( control ); } - retval << strip_display_blank( strip, 0 ); - retval << strip_display_blank( strip, 1 ); + + // These must have sysex headers + retval << strip_display_blank( port, strip, 0 ); + retval << strip_display_blank( port, strip, 1 ); return retval; } @@ -174,13 +177,13 @@ MidiByteArray MackieMidiBuilder::two_char_display( unsigned int value, const std return two_char_display( os.str() ); } -MidiByteArray MackieMidiBuilder::strip_display_blank( const Strip & strip, unsigned int line_number ) +MidiByteArray MackieMidiBuilder::strip_display_blank( MackiePort & port, const Strip & strip, unsigned int line_number ) { // 6 spaces, not 7 because strip_display adds a space where appropriate - return strip_display( strip, line_number, " " ); + return strip_display( port, strip, line_number, " " ); } -MidiByteArray MackieMidiBuilder::strip_display( const Strip & strip, unsigned int line_number, const std::string & line ) +MidiByteArray MackieMidiBuilder::strip_display( MackiePort & port, const Strip & strip, unsigned int line_number, const std::string & line ) { if ( line_number > 1 ) { @@ -197,6 +200,10 @@ MidiByteArray MackieMidiBuilder::strip_display( const Strip & strip, unsigned in #endif MidiByteArray retval; + + // sysex header + retval << port.sysex_hdr(); + // code for display retval << 0x12; // offset (0 to 0x37 first line, 0x38 to 0x6f for second line ) @@ -208,6 +215,10 @@ MidiByteArray MackieMidiBuilder::strip_display( const Strip & strip, unsigned in { retval << ' '; } + + // sysex trailer + retval << MIDI::eox; + #ifdef DEBUG cout << "MackieMidiBuilder::strip_display midi: " << retval << endl; @@ -215,7 +226,7 @@ MidiByteArray MackieMidiBuilder::strip_display( const Strip & strip, unsigned in return retval; } -MidiByteArray MackieMidiBuilder::all_strips_display( std::vector & lines1, std::vector & lines2 ) +MidiByteArray MackieMidiBuilder::all_strips_display( MackiePort & port, std::vector & lines1, std::vector & lines2 ) { MidiByteArray retval; retval << 0x12 << 0; diff --git a/libs/surfaces/mackie/mackie_midi_builder.h b/libs/surfaces/mackie/mackie_midi_builder.h index 96e4b3f0f9..2a0ece6e85 100644 --- a/libs/surfaces/mackie/mackie_midi_builder.h +++ b/libs/surfaces/mackie/mackie_midi_builder.h @@ -25,6 +25,8 @@ namespace Mackie { +class MackiePort; + /** This knows how to build midi messages given a control and a state. @@ -62,8 +64,8 @@ public: MidiByteArray build_fader( const Fader & fader, float pos ); /// return bytes that will reset all controls to their zero positions - /// And blank the display for the strip - MidiByteArray zero_strip( const Strip & strip ); + /// And blank the display for the strip. Pass MackiePort so we know which sysex header to use. + MidiByteArray zero_strip( MackiePort &, const Strip & strip ); // provide bytes to zero the given control MidiByteArray zero_control( const Control & control ); @@ -74,14 +76,17 @@ public: MidiByteArray two_char_display( const std::string & msg, const std::string & dots = " " ); MidiByteArray two_char_display( unsigned int value, const std::string & dots = " " ); - /// for displaying characters on the strip LCD - MidiByteArray strip_display( const Strip & strip, unsigned int line_number, const std::string & line ); + /** + for displaying characters on the strip LCD + pass MackiePort so we know which sysex header to use + */ + MidiByteArray strip_display( MackiePort &, const Strip & strip, unsigned int line_number, const std::string & line ); - /// blank the strip LCD, ie write all spaces - MidiByteArray strip_display_blank( const Strip & strip, unsigned int line_number ); + /// blank the strip LCD, ie write all spaces. Pass MackiePort so we know which sysex header to use. + MidiByteArray strip_display_blank( MackiePort &, const Strip & strip, unsigned int line_number ); - /// for generating all strip names - MidiByteArray all_strips_display( std::vector & lines1, std::vector & lines2 ); + /// for generating all strip names. Pass MackiePort so we know which sysex header to use. + MidiByteArray all_strips_display( MackiePort &, std::vector & lines1, std::vector & lines2 ); protected: static MIDI::byte calculate_pot_value( midi_pot_mode mode, const ControlState & );