Files
Dalton MessmerandGustavo Chicato 70aeceeff9 MidiExport: Support multi-track export, banks/programs, and more (#8048)
- Map each instrument track to a different incremental MIDI channel (except for channel 10 which is reserved for drums)
- Support Sf2 Player and Gig Player patches
- Major refactoring
- Allow instruments to provide their MIDI bank/program
- Add std::filesystem::path/string conversion utilities + unit tests
- Remove Qt usage from MidiExport
- Support bank select events in MidiExport and MidiImport
- Rework endian_handling.h, adding polyfill for std::byteswap
- Remove extraneous patch automation tracks
- Fix initial playback after MIDI import

---------

Co-authored-by: Gustavo Chicato <gustavo.chicato@usp.br>
2026-09-15 19:17:45 -04:00

58 lines
1.5 KiB
C++

/*
* MidiPatch.h
*
* Copyright (c) 2026 Dalton Messmer <messmer.dalton/at/gmail.com>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef LMMS_MIDI_PATCH_H
#define LMMS_MIDI_PATCH_H
#include <cstdint>
namespace lmms
{
struct MidiPatch
{
//! 14-bit bank
std::uint16_t bank = 0;
//! 7-bit program
std::uint8_t program = 0;
constexpr auto bankMSB() const noexcept -> std::uint8_t { return (bank >> 7) & 0x7F; }
constexpr auto bankLSB() const noexcept -> std::uint8_t { return bank & 0x7F; }
constexpr void setBankMSB(std::uint8_t value) noexcept
{
bank = ((static_cast<std::uint16_t>(value) & 0x7F) << 7) | (bank & 0x7F);
}
constexpr void setBankLSB(std::uint8_t value) noexcept
{
bank = (bank & 0x3F80) | (value & 0x7F);
}
};
} // namespace lmms
#endif // LMMS_MIDI_PATCH_H