Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions example-workspace/Presentasjon/demo.sidscore
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
TITLE "Moog to MOS - SID Demo"
AUTHOR "Torkild"
TEMPO 132
TIME 4/4
SYSTEM PAL

; ------------------------------------------------------------
; Modulation tables
; ------------------------------------------------------------

; Pulse-width modulation.
; Move around the 50% ($0800) pulse width.
TABLE pw DemoPWM {
$0300 @3
$0500 @3
$0800 @3
$0B00 @3
$0D00 @3
$0B00 @3
$0800 @3
$0500 @3
LOOP
}

; Start dark and rapidly open the low-pass filter.
TABLE filter DemoSweep {
120 @3
300 @3
600 @3
1000 @3
1500 @3
1900 HOLD
}

; ------------------------------------------------------------
; Instruments
; Keep ADSR identical so we mainly hear the waveform changes.
; ------------------------------------------------------------

INSTR triangle
WAVE=TRI
ADSR=2,4,12,4

INSTR saw
WAVE=SAW
ADSR=2,4,12,4

INSTR pulse
WAVE=PULSE
PW=$0800
ADSR=2,4,12,4

INSTR pulseFilter
WAVE=PULSE
PW=$0800
ADSR=2,4,12,4
FILTER=LP
CUTOFF=900
RES=8

INSTR pulseVibrato
WAVE=PULSE
PW=$0800
ADSR=2,4,12,4
FILTER=LP
CUTOFF=900
RES=8
VIBRATO=0,32,128,0

INSTR pulsePWM
WAVE=PULSE
PW=$0800
ADSR=2,4,12,4
FILTER=LP
CUTOFF=900
RES=8
PWSEQ=DemoPWM

INSTR pulseSweep
WAVE=PULSE
PW=$0800
ADSR=2,4,12,4
FILTER=LP
CUTOFF=120
RES=12
FILTERSEQ=DemoSweep

; ------------------------------------------------------------
; Tune 1 - Triangle
; ------------------------------------------------------------

VOICE 1 triangle:
O4 L8
C E G > C
< G4 E4
D8 F A > C
< B4 G4

; ------------------------------------------------------------
; Tune 2 - Saw
; ------------------------------------------------------------

TUNE 2 {
TITLE "Saw"

VOICE 1 saw:
O4 L8
C E G > C
< G4 E4
D8 F A > C
< B4 G4
}

; ------------------------------------------------------------
; Tune 3 - Pulse
; ------------------------------------------------------------

TUNE 3 {
TITLE "Pulse"

VOICE 1 pulse:
O4 L8
C E G > C
< G4 E4
D8 F A > C
< B4 G4
}

; ------------------------------------------------------------
; Tune 4 - Pulse + filter
; ------------------------------------------------------------

TUNE 4 {
TITLE "Pulse + Filter"

VOICE 1 pulseFilter:
O4 L8
C E G > C
< G4 E4
D8 F A > C
< B4 G4
}

; ------------------------------------------------------------
; Tune 5 - Vibrato
; ------------------------------------------------------------

TUNE 5 {
TITLE "Pulse + Filter + Vibrato"

VOICE 1 pulseVibrato:
O4 L8
C E G > C
< G4 E4
D8 F A > C
< B4 G4
}

; ------------------------------------------------------------
; Tune 6 - PWM
; ------------------------------------------------------------

TUNE 6 {
TITLE "Pulse + Filter + PWM"

VOICE 1 pulsePWM:
O4 L8
C E G > C
< G4 E4
D8 F A > C
< B4 G4
}

; ------------------------------------------------------------
; Tune 7 - Filter sweep
; ------------------------------------------------------------

TUNE 7 {
TITLE "Pulse + Filter Sweep"

VOICE 1 pulseSweep:
O4 L8
C E G > C
< G4 E4
D8 F A > C
< B4 G4
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import {
} from './vice-canvas-scaling';
import {
createViceEmbedKeyEvent,
isViceEmbedCommodoreFunctionKeyEvent
isViceEmbedCommodoreFunctionKeyEvent,
ViceEmbedKeyEventTracker
} from './vice-keyboard-mapping';
import {
DEFAULT_COMMODORE_EMULATOR_VICE_MENU_SHORTCUT,
Expand Down Expand Up @@ -163,6 +164,7 @@ export class CommodoreMachineProfileWidget
protected virtualShiftLatched = false;
protected virtualCommodoreLatched = false;
protected virtualControlLatched = false;
protected readonly keyEventTracker = new ViceEmbedKeyEventTracker();
protected readonly activeVirtualKeyboardKeys =
new Map<string, ActiveVirtualKeyboardKey>();
protected pressedVirtualMouseKey: PressedVirtualMouseKey | undefined;
Expand Down Expand Up @@ -869,7 +871,9 @@ export class CommodoreMachineProfileWidget
};

protected readonly handleWindowBlur = (): void => {
const releasedTrackedKeys = this.releaseTrackedKeyboardKeys();
if (
releasedTrackedKeys ||
this.pressedVirtualMouseKey ||
this.hostShiftPressed ||
this.hostCommodorePressed ||
Expand Down Expand Up @@ -1427,6 +1431,7 @@ export class CommodoreMachineProfileWidget
if (releaseMouseKey) {
this.releasePressedVirtualMouseKey();
}
this.keyEventTracker.reset();
this.hostShiftPressed = false;
this.hostCommodorePressed = false;
this.hostControlPressed = false;
Expand Down Expand Up @@ -1814,7 +1819,12 @@ export class CommodoreMachineProfileWidget
}

this.consumeEmulatorShortcutEvent(event);
this.sendKeyEventPayload(createViceEmbedKeyEvent(event, pressed));
this.sendKeyEventPayload(
this.keyEventTracker.createKeyEvent(
this.keyboardEventForEmulator(event),
pressed
)
);
this.trackVirtualKeyboardKey(event, pressed);
return true;
}
Expand Down Expand Up @@ -1873,10 +1883,21 @@ export class CommodoreMachineProfileWidget
}
}
const keyEvent: CommodoreViceEmbedKeyEvent =
createViceEmbedKeyEvent(this.keyboardEventForEmulator(event), pressed);
this.keyEventTracker.createKeyEvent(
this.keyboardEventForEmulator(event),
pressed
);
this.sendKeyEventPayload(keyEvent);
}

protected releaseTrackedKeyboardKeys(): boolean {
const releases = this.keyEventTracker.releasePressedMatrixKeys();
for (const keyEvent of releases) {
this.sendKeyEventPayload(keyEvent);
}
return releases.length > 0;
}

protected keyboardEventForEmulator(
event: React.KeyboardEvent<HTMLCanvasElement> | KeyboardEvent
): React.KeyboardEvent<HTMLCanvasElement> | KeyboardEvent | NormalizedKeyboardEventLike {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,15 @@ export class SidInstrumentControlWidget extends ReactWidget {
}
}

beginScoreInstrumentLoad(): void {
this.clearInstrumentUpdateTimer();
this.clearPendingInstrumentVoices();
this.instrumentStates.clear();
this.nonOverrideInstrumentStates.clear();
this.instrumentSource = 'default';
this.update();
}

async initializeMidiDevices(): Promise<void> {
if (!shouldStartInitialMidiDeviceScan({
initialMidiScanStarted: this.initialMidiScanStarted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ export class SidScoreRuntimeContribution
this.scorePlaybackRequestId = requestId;
this.scorePlaybackScoreId = undefined;
const instrumentWidget = await this.openInstrumentWidgetForScorePlayback();
instrumentWidget?.beginScoreInstrumentLoad();
instrumentWidget?.setScorePlaybackActive(true, false);
await instrumentWidget?.prepareMidiForScorePlayback();
const result = await this.sidScoreRuntimeService.play({
Expand Down
27 changes: 23 additions & 4 deletions packages/theia-extension/src/browser/vice-embedded-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
type ViceCanvasDisplaySize
} from './vice-canvas-scaling';
import {
createViceEmbedKeyEvent,
isViceEmbedCommodoreFunctionKeyEvent
isViceEmbedCommodoreFunctionKeyEvent,
ViceEmbedKeyEventTracker
} from './vice-keyboard-mapping';

export const VICE_EMBEDDED_WIDGET_ID = 'commodore-commander.vice-embedded';
Expand Down Expand Up @@ -52,6 +52,7 @@ export class ViceEmbeddedWidget
protected lastOutput = '';
protected starting = false;
protected hostCommodorePressed = false;
protected readonly keyEventTracker = new ViceEmbedKeyEventTracker();

@postConstruct()
protected init(): void {
Expand All @@ -68,12 +69,14 @@ export class ViceEmbeddedWidget
);
document.addEventListener('keydown', this.handleDocumentKeyDown, true);
document.addEventListener('keyup', this.handleDocumentKeyUp, true);
window.addEventListener('blur', this.handleWindowBlur);
this.update();
}

override dispose(): void {
document.removeEventListener('keydown', this.handleDocumentKeyDown, true);
document.removeEventListener('keyup', this.handleDocumentKeyUp, true);
window.removeEventListener('blur', this.handleWindowBlur);
this.resizeObserver?.disconnect();
this.resizeObserver = undefined;
this.viceEmbedService.setClient(undefined);
Expand All @@ -99,6 +102,7 @@ export class ViceEmbeddedWidget
this.statusMessage = event.message ?? event.state;
this.starting = event.state === 'starting';
if (event.state === 'stopped' || event.state === 'error') {
this.keyEventTracker.reset();
this.frame = undefined;
this.refreshCanvasDisplaySize();
}
Expand Down Expand Up @@ -223,6 +227,7 @@ export class ViceEmbeddedWidget

protected readonly stopVice = async (): Promise<void> => {
await this.viceEmbedService.stop();
this.keyEventTracker.reset();
this.status = 'stopped';
this.statusMessage = 'Stopped';
this.frame = undefined;
Expand Down Expand Up @@ -331,7 +336,12 @@ export class ViceEmbeddedWidget
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
void this.viceEmbedService.sendKey(createViceEmbedKeyEvent(event, pressed));
void this.viceEmbedService.sendKey(
this.keyEventTracker.createKeyEvent(
this.keyboardEventForEmulator(event),
pressed
)
);
return true;
}

Expand All @@ -353,10 +363,19 @@ export class ViceEmbeddedWidget
this.hostCommodorePressed = pressed;
}
const keyEvent: CommodoreViceEmbedKeyEvent =
createViceEmbedKeyEvent(this.keyboardEventForEmulator(event), pressed);
this.keyEventTracker.createKeyEvent(
this.keyboardEventForEmulator(event),
pressed
);
void this.viceEmbedService.sendKey(keyEvent);
}

protected readonly handleWindowBlur = (): void => {
for (const keyEvent of this.keyEventTracker.releasePressedMatrixKeys()) {
void this.viceEmbedService.sendKey(keyEvent);
}
};

protected keyboardEventForEmulator(
event: React.KeyboardEvent<HTMLCanvasElement> | KeyboardEvent
): React.KeyboardEvent<HTMLCanvasElement> | KeyboardEvent | NormalizedKeyboardEventLike {
Expand Down
Loading