From 896d5d682b0b3485438f566761a5287648459f66 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 30 May 2017 08:21:28 -0700 Subject: [PATCH] Fix drawing MIDI channels with IDs greater than 16 PRL mentioned a while ago that it was possible to get channels greater than 16 via allegro files. This makes those channels correctly work with the CHANNEL_BIT macro (which was supposed to handle them this way before). --- src/NoteTrack.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NoteTrack.h b/src/NoteTrack.h index f2c85cc71..3eda9bec8 100644 --- a/src/NoteTrack.h +++ b/src/NoteTrack.h @@ -199,8 +199,10 @@ class AUDACITY_DLL_API NoteTrack final // map all channel numbers mod 16. This will have no effect // on MIDI files, but it will allow users to at least select // all channels on non-MIDI event sequence data. -#define ALL_CHANNELS 0xFFFF -#define CHANNEL_BIT(c) (1 << (c & ALL_CHANNELS)) +#define NUM_CHANNELS 16 + // Bitmask with all NUM_CHANNELS bits set +#define ALL_CHANNELS (1 << NUM_CHANNELS) - 1 +#define CHANNEL_BIT(c) (1 << (c % NUM_CHANNELS)) bool IsVisibleChan(int c) const { return (mVisibleChannels & CHANNEL_BIT(c)) != 0; }