Skip to content

Commit

Permalink
Fixing sysex in progress, clang-12 found more warnings re issue #124.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed Dec 7, 2023
1 parent 5dcd2cc commit 5e52283
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 85 deletions.
7 changes: 7 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ Misc:
[seq66] Unexpected meta type 0x2f offset ~0x167df
[seq66] Unexpected meta type 0x2f offset ~0x16822
[seq66] Read: '/home/ahlstrom/Downloads/Trilogy.mid'
Also make sure SysEx messages in first track are being stored.
Write a module to show SysEx (and optionally store them as
a macro.
Also handle meta-midi-port message tracks, and add them as
patterns if they also have trkname messages.
Also test with the Dixie04.mid file, as our SysEx reading was
wrong!!!!

Mutes:

Expand Down
13 changes: 8 additions & 5 deletions libseq66/include/midi/midifile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,16 @@ class midifile
*
* \return
* Returns true if the byte is SysEx special ID.
*
* THIS FUNCTION IS WRONG, BOGUS!!!
*
* bool is_sysex_special_id (midibyte ch)
* {
* return ch >= 0x7D && ch <= 0x7F;
* }
*
*/

bool is_sysex_special_id (midibyte ch)
{
return ch >= 0x7D && ch <= 0x7F;
}

}; // class midifile

/*
Expand Down
4 changes: 3 additions & 1 deletion libseq66/src/midi/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,9 @@ event::append_meta_data (midibyte metatype, const midibytes & data)
* event.
*
* \return
* Returns true if the event is not a SysEx-end event.
* Returns true if the event is not a SysEx-end event. The EOX ($F7)
* status byte can be replaced with any other status byte except for
* a Real-Time message, but this probably never is done.
*/

bool
Expand Down
65 changes: 34 additions & 31 deletions libseq66/src/midi/midifile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-07-24
* \updates 2023-12-06
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* For a quick guide to the MIDI format, see, for example:
Expand Down Expand Up @@ -729,6 +729,8 @@ midifile::grab_input_stream (const std::string & tag)
* messages properly for a MIDI file. Instead of a varinum length value,
* they are followed by extended IDs (0x7D, 0x7E, or 0x7F).
*
* THE ABOVE IS WRONG!
*
* We've covered some of those cases by disabling access to m_data if the
* position passes the size of the file, but we want try to bypass these
* odd cases properly. So we look ahead for one of these special values.
Expand Down Expand Up @@ -1106,6 +1108,11 @@ midifile::parse_smf_1 (performer & p, int screenset, bool is_smf0)
status = m_data[m_pos]; /* current event byte */
if (event::is_status(status)) /* is there a 0x80 bit? */
{
/*
* For SysEx, the skip is undone. For meta events, the
* correct event type is obtained anyway.
*/

skip(1); /* get to d0 */
if (event::is_system_common_msg(status))
runningstatus = 0; /* clear it */
Expand Down Expand Up @@ -1223,6 +1230,11 @@ midifile::parse_smf_1 (performer & p, int screenset, bool is_smf0)

case EVENT_META_END_OF_TRACK: /* FF 2F 00 */

/*
* This is an optional event according to the MIDI
* specification.
*/

s.set_length(currenttime, false);
s.zero_markers();
done = true;
Expand Down Expand Up @@ -1525,39 +1537,23 @@ midifile::parse_smf_1 (performer & p, int screenset, bool is_smf0)
}
else if (status == EVENT_MIDI_SYSEX) /* 0xF0 */
{
/*
* Some files do not properly encode SysEx messages;
* see the function banner for notes.
*/

midibyte check = read_byte();
if (is_sysex_special_id(check))
#if defined SEQ66_USE_SYSEX_PROCESSING
midishort mfg_id;
midibyte id = read_byte();
if (id == 0)
mfg_id = read_short();
else
mfg_id = midishort(id);

(void) mfg_id; /* later, store it? */
back_up(2); /* back to F0 */
for (;;)
{
/*
* TMI: "SysEx ID byte = 7D to 7F");
*/
midibyte b = read_byte();
if (! e.append_sysex_byte(b)) /* F7 byte? */
break;
}
else /* handle normally */
{
--m_pos; /* put byte back */
len = read_varinum(); /* sysex */
#if defined SEQ66_USE_SYSEX_PROCESSING
while (len-- > 0)
{
midibyte b = read_byte();
if (! e.append_sysex_byte(b)) /* end byte? */
break;
}
skip(len); /* eat it */
#else
skip(len); /* eat it */
if (m_data[m_pos-1] != 0xF7)
{
std::string m = "SysEx terminator F7 not found";
(void) set_error_dump(m);
}
#endif
}
}
else
{
Expand Down Expand Up @@ -1718,6 +1714,13 @@ midifile::parse_seqspec_header (int file_size)
(void) read_varinum(); /* prop section length */
result = read_long(); /* control tag */
}
else if (type == EVENT_META_END_OF_TRACK)
{
msgprintf
(
msglevel::warn, "End-of-track, offset ~0x%lx", long(m_pos)
);
}
else
{
msgprintf
Expand Down
5 changes: 3 additions & 2 deletions libsessions/include/nsm/nsmclient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* \library seq66
* \author Chris Ahlstrom and other authors; see documentation
* \date 2020-03-01
* \updates 2021-11-29
* \updates 2021-12-07
* \version $Revision$
* \license GNU GPL v2 or above
*
Expand Down Expand Up @@ -140,7 +140,8 @@ class nsmclient : public nsmbase

public: // Other virtual functions

virtual bool open_session (); // prospective helper a la qtractorMainForm
virtual bool open_session () override; // helper a la qtractorMainForm

virtual void session_manager_name (const std::string & mgrname);
virtual void session_manager_path (const std::string & pathname);
virtual void session_display_name (const std::string & dispname);
Expand Down
6 changes: 3 additions & 3 deletions seq_qt5/include/gui_palette_qt5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-02-23
* \updates 2023-10-27
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* This module defines some QColor objects. We might consider replacing the
Expand Down Expand Up @@ -159,8 +159,8 @@ class gui_palette_qt5 : public basesettings
public:

gui_palette_qt5 (const std::string & filename = "");
gui_palette_qt5 (const gui_palette_qt5 &) = default;
gui_palette_qt5 & operator = (const gui_palette_qt5 &) = default;
gui_palette_qt5 (const gui_palette_qt5 &) = delete;
gui_palette_qt5 & operator = (const gui_palette_qt5 &) = delete;
virtual ~gui_palette_qt5 ();

static Color calculate_inverse (const Color & c);
Expand Down
4 changes: 2 additions & 2 deletions seq_qt5/include/qeditbase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2019-08-05
* \updates 2023-11-01
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* This class will be the base class for the qseqbase and qperfbase classes.
Expand Down Expand Up @@ -616,7 +616,7 @@ class qeditbase : public qbase

public:

virtual bool change_ppqn (int ppq);
virtual bool change_ppqn (int ppq) override;

/**
* Make the view cover less horizontal length. The lowest zoom possible
Expand Down
3 changes: 1 addition & 2 deletions seq_qt5/include/qloopbutton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2019-06-28
* \updates 2023-02-27
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
*/
Expand Down Expand Up @@ -201,7 +201,6 @@ class qloopbutton final : public qslotbutton

bool m_text_initialized;
bool m_draw_text;
bool m_draw_background;
textbox m_top_left;
textbox m_top_right;
textbox m_bottom_left;
Expand Down
4 changes: 2 additions & 2 deletions seq_qt5/include/qperfroll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-01-01
* \updates 2023-11-01
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* This class represents the central piano-roll user-interface area of the
Expand Down Expand Up @@ -135,7 +135,7 @@ public slots:

private:

virtual void set_adding (bool adding);
virtual void set_adding (bool adding) override;

qperfeditframe64 * frame64 ()
{
Expand Down
5 changes: 3 additions & 2 deletions seq_qt5/include/qseqroll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-01-01
* \updates 2023-11-01
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* We are currently moving toward making this class a base class.
Expand Down Expand Up @@ -155,13 +155,14 @@ class qseqroll final : public QWidget, public qseqbase

private:

virtual void set_adding (bool a_adding) override;

#if defined USE_GROW_SELECTED_NOTES_FUNCTION
void grow_selected_notes (int dx);
#endif

void move_selected_notes (int dx, int dy);
void snap_y (int & y);
void set_adding (bool a_adding);
void start_paste();
void draw_grid (QPainter & painter, const QRect & r);
void draw_notes (QPainter & painter, const QRect & r, bool background);
Expand Down
5 changes: 3 additions & 2 deletions seq_qt5/include/qslivegrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2019-06-21
* \updates 2023-08-29
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
*
Expand Down Expand Up @@ -164,6 +164,8 @@ class qslivegrid final :

private:

virtual bool recreate_all_slots () override;

seq::number seq_id_from_xy (int click_x, int click_y);
qslotbutton * create_one_button (seq::number seqno);
qslotbutton * button (int row, int column);
Expand All @@ -174,7 +176,6 @@ class qslivegrid final :
bool delete_slot (int row, int column);
bool delete_slot (seq::number seqno);
bool delete_all_slots ();
bool recreate_all_slots ();
bool refresh_all_slots ();
bool modify_slot (qslotbutton * newslot, int row, int column);
void button_toggle_enabled (seq::number seqno);
Expand Down
5 changes: 3 additions & 2 deletions seq_qt5/include/qstriggereditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-01-01
* \updates 2023-08-31
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* This class represents the central piano-roll user-interface area of the
Expand Down Expand Up @@ -146,12 +146,13 @@ public slots:

private:

virtual void set_adding (bool adding) override;

void x_to_w (int x1, int x2, int & x, int & w);
void start_paste ();
void convert_x (int x, midipulse & tick);
void convert_t (midipulse ticks, int & x);
void drop_event (midipulse tick);
void set_adding (bool adding);
bool movement_key_press (int key);
void move_selected_events (midipulse dt);

Expand Down
3 changes: 1 addition & 2 deletions seq_qt5/src/qloopbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2019-06-28
* \updates 2023-11-22
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* A paint event is a request to repaint all/part of a widget. It happens for
Expand Down Expand Up @@ -185,7 +185,6 @@ qloopbutton::qloopbutton
m_text_font (),
m_text_initialized (false),
m_draw_text (true),
m_draw_background (true),
m_top_left (),
m_top_right (),
m_bottom_left (),
Expand Down
9 changes: 6 additions & 3 deletions seq_qt5/src/qperfroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-01-01
* \updates 2023-11-01
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* This class represents the central piano-roll user-interface area of the
Expand Down Expand Up @@ -71,12 +71,15 @@ static const int c_alpha_muted = 100;
*/

static const int c_ycorrection = 1; /* horizontal grid line fix */
static const int c_border_width = 2;
static const int c_pen_width = 2;
static const int c_background_x = (c_base_ppqn * 4 * 16) / c_perf_scale_x;
static const int c_size_box_w = 8;
static const int c_size_box_click_w = c_size_box_w + 1 ;

#if defined THIS_CODE_ADDS_VALUE
static const int c_background_x = (c_base_ppqn * 4 * 16) / c_perf_scale_x;
static const int c_border_width = 2;
#endif

/**
* Font sizes for small, normal, and expanded vertical zoom
*/
Expand Down
8 changes: 4 additions & 4 deletions seq_qt5/src/qseqbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-01-01
* \updates 2023-10-19
* \updates 2023-12-07
* \license GNU GPLv2 or above
*
* We are currently moving toward making this class a base class.
Expand All @@ -47,11 +47,11 @@ namespace seq66

/**
* We need to square this away. This should be the configurable usr()
* key-height.
* key-height. But it is not used, and we already have made it configurable.
*
* static const int c_key_y = 8;
*/

static const int c_key_y = 8;

/**
* Primary constructor
*/
Expand Down
Loading

0 comments on commit 5e52283

Please sign in to comment.