Skip to content

Commit

Permalink
Enhancement and fixes to borken portmidi code re issue #110.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed May 13, 2023
1 parent efc8db2 commit 37a2920
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 179 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# README for Seq66 0.99.4 2023-05-10
# README for Seq66 0.99.4 2023-05-13

__Seq66__: MIDI sequencer and live-looper with a hardware-sampler grid
interface, pattern sets/banks, pattern triggers, and playlists for song
Expand Down Expand Up @@ -99,6 +99,7 @@ Windows, and using a conventional source tarball.
build NSIS-based install without leaving Windows, if desired.
* Internal refactoring to regularize handling of the session/config
directory between Linux and Windows.
* Fixed portmidi bugs in Linux and Windows, enhanced device naming..
* Rearranged the Seq66 man pages more sensibly.
* Version 0.99.4:
* Issue #3: The scroll wheel is enabled in the piano rolls (only).
Expand Down
12 changes: 5 additions & 7 deletions libseq66/include/util/basic_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66
* \author Chris Ahlstrom and other authors; see documentation
* \date 2018-11-10
* \updates 2021-11-12
* \updates 2023-05-13
* \version $Revision$
* \license GNU GPL v2 or above
*
Expand Down Expand Up @@ -119,15 +119,13 @@
#if ! defined __cplusplus

/**
* Provides the "false" value of the wbool_t type definition.
* Provides a type to better represent a boolean value. Provides the "true"
* and "false" values of the cbool_t type definition.
*/

#define false 0

/**
* Provides the "true" value of the wbool_t type definition.
*/
typedef int cbool_t;

#define false 0
#define true 1

#endif
Expand Down
19 changes: 8 additions & 11 deletions libseq66/src/cfg/rcfile.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-11-23
* \updates 2023-05-07
* \updates 2023-05-12
* \license GNU GPLv2 or above
*
* The <code> ~/.config/seq66.rc </code> configuration file is fairly simple
Expand Down Expand Up @@ -783,7 +783,7 @@ rcfile::write ()
write_file_status
(
file, "[midi-control-file]",
rc_ref().midi_control_filename(), rc_ref().midi_control_active()
rc_ref().midi_control_filespec(), rc_ref().midi_control_active()
);
file << "\n"
"# Provides a flag and file-name for mute-groups settings. '\"\"' means no\n"
Expand All @@ -793,11 +793,10 @@ rcfile::write ()
write_file_status
(
file, "[mute-group-file]",
rc_ref().mute_group_filename(), rc_ref().mute_group_file_active()
rc_ref().mute_group_filespec(), rc_ref().mute_group_file_active()
);

std::string usrname = rc_ref().user_filespec();
usrname = rc_ref().trim_home_directory(usrname);
file << "\n"
"# Provides a flag and file-name for 'user' settings. '\"\"' means no 'usr'\n"
"# file. If none, there are no special user settings. Using no 'usr' file\n"
Expand All @@ -806,7 +805,7 @@ rcfile::write ()
write_file_status
(
file, "[usr-file]",
rc_ref().user_filename(), rc_ref().user_file_active()
usrname, rc_ref().user_file_active()
);
file << "\n"
"# Provides a flag and play-list file. If no list, use '\"\"' and set active\n"
Expand All @@ -816,9 +815,8 @@ rcfile::write ()
"# another; it preserves sub-directories (e.g. in creating an NSM session).\n"
;

std::string plname = rc_ref().playlist_filename();
std::string plname = rc_ref().playlist_filespec();
std::string mbasedir = rc_ref().midi_base_directory();
plname = rc_ref().trim_home_directory(plname);
write_file_status(file, "[playlist]", plname, rc_ref().playlist_active());
write_string(file, "base-directory", mbasedir, true);

Expand All @@ -829,10 +827,9 @@ rcfile::write ()
"# transposable to allow this operation.\n"
;

std::string drumfile = rc_ref().notemap_filename();
std::string drumname = rc_ref().trim_home_directory(drumfile);
std::string drumfile = rc_ref().notemap_filespec();
bool drumactive = rc_ref().notemap_active();
write_file_status(file, "[note-mapper]", drumname, drumactive);
write_file_status(file, "[note-mapper]", drumfile, drumactive);

/*
* New section for palette file.
Expand All @@ -846,7 +843,7 @@ rcfile::write ()
write_file_status
(
file, "[palette-file]",
rc_ref().palette_filename(), rc_ref().palette_active()
rc_ref().palette_filespec(), rc_ref().palette_active()
);

/*
Expand Down
39 changes: 18 additions & 21 deletions libseq66/src/cfg/rcsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Seq24 team; modifications by Chris Ahlstrom
* \date 2015-09-22
* \updates 2023-05-11
* \updates 2023-05-12
* \license GNU GPLv2 or above
*
* Note that this module also sets the legacy global variables, so that
Expand All @@ -34,10 +34,10 @@
* \warning
* No more "statistics" support.
*
* \todo
* Kepler34 has two more settings values: [midi-clock-mod-ticks],
* [note-resume] and [key-height]. The latter sounds more like a "usr"
* setting.
* ca 2023-05-12:
*
* A number of calls to rc() occur in this module. but that doesn't make
* sense. Go back to commit efc8db20 if removing them is a flub.
*/

#include <algorithm> /* std::find() */
Expand Down Expand Up @@ -114,7 +114,7 @@ rcsettings::rcsettings () :
m_config_subdirectory (),
m_config_filename (seq_config_name()), /* updated in body */
m_full_config_directory (),
m_user_file_active (true),
m_user_file_active (true), /* keep it true */
m_user_filename (seq_config_name()), /* updated in body */
m_midi_control_active (false),
m_midi_control_filename (seq_config_name()), /* updated in body */
Expand Down Expand Up @@ -310,7 +310,7 @@ rcsettings::auto_options_save () const
return
(
auto_rc_save() || auto_usr_save() ||
rc().is_modified() || usr().is_modified()
is_modified() || usr().is_modified()
);
}

Expand Down Expand Up @@ -497,9 +497,6 @@ rcsettings::home_config_directory () const
bool ok = make_directory_path(result);
if (ok)
{
#if defined SEQ66_PLATFORM_WINDOWS
result += path_slash();
#endif
result = normalize_path(result);
m_full_config_directory = result;
}
Expand Down Expand Up @@ -662,7 +659,7 @@ rcsettings::trim_home_directory (const std::string & filepath)
void
rcsettings::create_config_names (const std::string & base)
{
std::string cfgname = base.empty() ? rc().config_filename() : base ;
std::string cfgname = base.empty() ? config_filename() : base ;
cfgname = filename_base(cfgname, true); /* strip extension */

std::string cc = file_extension_set(cfgname, ".rc");
Expand All @@ -673,13 +670,13 @@ rcsettings::create_config_names (const std::string & base)
std::string nm = file_extension_set(cfgname, ".drums");
std::string pa = file_extension_set(cfgname, ".palette");
std::string af = cfgname + ".rc,ctrl,midi,mutes,drums,playlist,palette";
rc().config_filename(cc);
rc().user_filename(uf);
rc().midi_control_filename(cf);
rc().mute_group_filename(mf);
rc().playlist_filename(pl);
rc().notemap_filename(nm);
rc().palette_filename(pa);
config_filename(cc);
user_filename(uf);
midi_control_filename(cf);
mute_group_filename(mf);
playlist_filename(pl);
notemap_filename(nm);
palette_filename(pa);
file_message("Configuration files", af);
}

Expand Down Expand Up @@ -712,7 +709,7 @@ rcsettings::filespec_helper (const std::string & baseext) const
result = home_config_directory();
result += baseext;
}
result = os_normalize_path(result); /* change to OS's slash */
result = normalize_path(result); /* change to UNIX slash */
}
return result;
}
Expand Down Expand Up @@ -1001,7 +998,7 @@ rcsettings::jack_session (const std::string & uuid)
}
}
if (save_config)
rc().auto_usr_save(true); /* hmmmm, why the rc() here? */
auto_usr_save(true);

if (clear_uuid)
m_jack_session_uuid.clear();
Expand Down Expand Up @@ -1128,7 +1125,7 @@ rcsettings::full_config_directory (const::std::string & value)
m_full_config_directory = normalize_path(tv, true, true);
}

std::string homedir = rc().home_config_directory();
std::string homedir = home_config_directory();
if (make_directory_path(homedir)) // REDUNDANT
{
/*
Expand Down
5 changes: 3 additions & 2 deletions seq_portmidi/include/midibus_pm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* \library seq66 application
* \author Seq24 team; modifications by Chris Ahlstrom
* \date 2015-07-24
* \updates 2019-03-10
* \updates 2023-05-13
* \license GNU GPLv2 or above
*
* This midibus module is the Windows (PortMidi) version of the midibus
Expand Down Expand Up @@ -77,7 +77,8 @@ class midibus : public midibase
int index,
int bus_id,
int port_id,
const std::string & client_name
const std::string & client_name,
const std::string & port_name
);

virtual ~midibus ();
Expand Down
20 changes: 10 additions & 10 deletions seq_portmidi/seq_portmidi.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
# \library qpseq66 application
# \author Chris Ahlstrom
# \date 2018-04-08
# \update 2020-11-14
# \update 2023-05-13
# \version $Revision$
# \license $XPC_SUITE_GPL_LICENSE$
#
# Created by and for Qt Creator. This file was created for editing the project
# sources only. You may attempt to use it for building too, by modifying this
# file here. [Which we have done. -- Chris]
# file here.
#
# Important:
#
# This project file is designed only for Qt 5 (and above?).
# This project file is designed only for Qt 5 (and above?).
#
#------------------------------------------------------------------------------

Expand Down Expand Up @@ -48,19 +48,19 @@ HEADERS += \
include/portmidi.h \
include/porttime.h

# Linux:
# Linux

unix:!macx {
HEADERS += include/pmlinux.h include/pmlinuxalsa.h
}

# Mac OSX

macx: {
macx {
HEADERS += include/pmmac.h include/pmmacosxcm.h
}

# Windows:
# Windows

windows {
HEADERS += include/pmerrmm.h include/pmwinmm.h
Expand All @@ -69,7 +69,7 @@ windows {
QMAKE_CFLAGS_WARN_ON += -Wno-unused-parameter
}

# Common:
# Common

SOURCES += \
src/mastermidibus.cpp \
Expand All @@ -78,7 +78,7 @@ SOURCES += \
src/portmidi.c \
src/porttime.c

# Linux:
# Linux

unix:!macx {
SOURCES += src/pmlinux.c src/pmlinuxalsa.c src/ptlinux.c
Expand All @@ -88,11 +88,11 @@ unix:!macx {
#
# We have removed the readbinaryplist.c file; we use INI-style files.

macx: {
macx {
SOURCES += src/pmmac.c pmmacosxcm.c src/ptmacosx_mach.c
}

# Windows:
# Windows

windows: SOURCES += src/pmwin.c \
src/pmerrmm.c \
Expand Down
18 changes: 11 additions & 7 deletions seq_portmidi/src/mastermidibus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Seq24 team; modifications by Chris Ahlstrom
* \date 2015-07-24
* \updates 2022-03-06
* \updates 2023-05-15
* \license GNU GPLv2 or above
*
* This file provides a Windows-only implementation of the mastermidibus
Expand Down Expand Up @@ -133,12 +133,14 @@ mastermidibus::api_init (int ppqn, midibpm /*bpm*/)

midibus * m = new (std::nothrow) midibus
(
numouts, numouts, i, dev_info->name
numouts, dev_info->client,
i, /* not dev_info->port */
dev_info->interf, dev_info->name
);
m->is_input_port(false); /* add to ctor! */
m->is_virtual_port(false); /* add to ctor! */
m_outbus_array.add(m, clock(numouts)); /* not i */
++numouts;
if (m_outbus_array.add(m, clock(numouts))) /* not i */
++numouts;
}
else if (dev_info->input)
{
Expand All @@ -149,12 +151,14 @@ mastermidibus::api_init (int ppqn, midibpm /*bpm*/)

midibus * m = new (std::nothrow) midibus
(
numins, numins, i, dev_info->name
numins, dev_info->client,
i, /* not dev_info->port */
dev_info->interf, dev_info->name
);
m->is_input_port(true); /* add to ctor! */
m->is_virtual_port(false); /* add to ctor! */
m_inbus_array.add(m, input(numins)); /* not i */
++numins;
if (m_inbus_array.add(m, input(numins))) /* not i */
++numins;
}
}

Expand Down
Loading

0 comments on commit 37a2920

Please sign in to comment.