-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cleaner types & smart message values
- Loading branch information
1 parent
07b5425
commit b8c44d7
Showing
17 changed files
with
140 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { BaseMessage, ExpMessage, SmartMessage } from '../types/Messages'; | ||
import { convertStatusByteToType } from './midiHexHelpers'; | ||
import { MidiMessageType } from './types'; | ||
import { | ||
RawMessage, | ||
RawExpMessage, | ||
RawSmartMessage, | ||
MidiMessageType, | ||
} from '../types'; | ||
|
||
export const isMidiMessageType = (type: string): type is MidiMessageType => | ||
Object.values(MidiMessageType).includes(type as MidiMessageType); | ||
|
||
export const isExpressionMidiMessage = ( | ||
message: BaseMessage | ExpMessage | SmartMessage | ||
): message is ExpMessage => !!(message as ExpMessage).sweep; | ||
message: RawMessage | RawExpMessage | RawSmartMessage | ||
): message is RawExpMessage => !!(message as RawExpMessage).sweep; | ||
|
||
export const isSmartMidiMessage = ( | ||
message: BaseMessage | ExpMessage | SmartMessage | ||
): message is SmartMessage => { | ||
const type = convertStatusByteToType(message.statusByte); | ||
return type === MidiMessageType.SmartMessage; | ||
}; | ||
message: RawMessage | RawExpMessage | RawSmartMessage | ||
): message is RawSmartMessage => message.statusByte === '70'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { RawMessage } from './RawMessage'; | ||
|
||
export interface MessageStack<Message = RawMessage> { | ||
numMessages: number; | ||
messages: Message[]; | ||
} | ||
|
||
export interface AuxMessages { | ||
tip: AuxMessageStacks; | ||
ring: AuxMessageStacks; | ||
tipRing: AuxMessageStacks; | ||
} | ||
|
||
export interface AuxMessageStacks { | ||
pressMessages: MessageStack; | ||
holdMessages: MessageStack; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { EnabledMidiOuts } from './EnabledMidiOuts'; | ||
import { SmartMessageType } from './SmartMessageType'; | ||
|
||
export interface ExpressionParameters { | ||
minLimit: number; | ||
maxLimit: number; | ||
sweep: 'linear' | 'log' | 'reverseLog'; | ||
} | ||
|
||
export interface RawMessage { | ||
statusByte: string; // 8-bit hex | ||
dataByte1: string; // 8-bit hex | ||
dataByte2?: string; // 8-bit hex | ||
outputs: EnabledMidiOuts; | ||
} | ||
|
||
export interface RawSmartMessage { | ||
statusByte: string; // 8-bit hex | ||
dataByte1: string; // 8-bit hex | ||
dataByte2?: string; // 8-bit hex | ||
smartType: SmartMessageType; | ||
} | ||
|
||
export interface RawExpMessage extends RawMessage, ExpressionParameters {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.