Skip to content

Commit

Permalink
Add protocol for sound channels!
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed Oct 19, 2024
1 parent c0f2a31 commit 556a8fe
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion src/common/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ https://github.com/curiousdannii/asyncglk

/** GlkOte->GlkApi/RemGlk input events */
export type Event = ArrangeEvent | CharEvent | DebugEvent | ExternalEvent | HyperlinkEvent |
InitEvent | LineEvent | MouseEvent | RedrawEvent | RefreshEvent | SpecialEvent | TimerEvent
InitEvent | LineEvent | MouseEvent | RedrawEvent | RefreshEvent | SoundEvent | SpecialEvent |
TimerEvent | VolumeEvent

interface EventBase {
/** Event code */
Expand Down Expand Up @@ -113,6 +114,15 @@ export interface RefreshEvent extends EventBase {
type: 'refresh',
}

export interface SoundEvent extends EventBase {
/** Event code */
type: 'sound',
/** Sound resource ID which finished playing */
snd: number,
/** Notification value */
notify: number,
}

export interface SpecialEvent extends EventBase {
/** Event code */
type: 'specialresponse',
Expand All @@ -135,6 +145,13 @@ export interface TimerEvent extends EventBase {
type: 'timer',
}

export interface VolumeEvent extends EventBase {
/** Event code */
type: 'volume',
/** Notification value */
notify: number,
}

/** Screen and font metrics - all potential options */
export interface Metrics {
/** Buffer character height */
Expand Down Expand Up @@ -266,6 +283,8 @@ export interface StateUpdate {
input?: InputUpdate[],
/** Background colour for the page margin (ie, outside of the gameport) */
page_margin_bg?: string,
/** Sound channels (new channels, or new operations) */
schannels?: SoundChannelUpdate[],
/** Special input */
specialinput?: SpecialInput,
timer?: number | null,
Expand Down Expand Up @@ -425,6 +444,46 @@ export interface InputUpdate {
export type TerminatorCode = 'escape' | 'func1' | 'func2' | 'func3' | 'func4' | 'func5' | 'func6'
| 'func7' | 'func8' | 'func9' | 'func10' | 'func11' | 'func12'

export interface SoundChannelUpdate {
/** Sound channel ID */
id: number,
/** Sound channel operations */
ops?: SoundChannelOperation[],
}

export type SoundChannelOperation = PauseOperation | PlayOperation | SetVolumeOperation | StopOperation | UnpauseOperation

export interface PauseOperation {
op: 'pause',
}

export interface PlayOperation {
op: 'play',
/** Notification value */
notify?: number,
/** Number of repeats (default: 1) */
repeats?: number,
snd: number,
}

export interface SetVolumeOperation {
op: 'volume',
/** Duration in milliseconds */
dur?: number,
/** Notification value */
notify?: number,
/** The volume as a number between 0 and 1 */
vol: number,
}

export interface StopOperation {
op: 'stop',
}

export interface UnpauseOperation {
op: 'unpause',
}

export interface SpecialInput {
/** Special input type */
type: 'fileref_prompt',
Expand Down

0 comments on commit 556a8fe

Please sign in to comment.