Skip to content

Commit

Permalink
Merge pull request #6 from assaron/linux-support
Browse files Browse the repository at this point in the history
WIP: Linux support
  • Loading branch information
aolsenjazz authored Sep 4, 2023
2 parents c2a5235 + 67e427a commit b30d3d5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
os: [macos-latest]
os: [macos-latest, ubuntu-latest]

steps:
- name: Check out Git repository
Expand All @@ -19,6 +19,11 @@ jobs:
with:
node-version: 16

- name: install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get install -y libasound2-dev
- name: run post-clone
run: |
npm run post-clone
Expand Down
2 changes: 1 addition & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const createWindow = async () => {
width: 1024,
height: 600,
transparent: true,
frame: false,
frame: os.platform() !== 'darwin',
minHeight: 312,
minWidth: 850,
titleBarStyle: os.platform() === 'darwin' ? 'hiddenInset' : 'default',
Expand Down
34 changes: 32 additions & 2 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class MenuBuilder {
const template =
process.platform === 'darwin'
? this.buildDarwinTemplate(createWindow)
: this.buildDefaultTemplate();
: this.buildDefaultTemplate(createWindow);

const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
Expand Down Expand Up @@ -246,14 +246,44 @@ export default class MenuBuilder {
];
}

buildDefaultTemplate() {
buildDefaultTemplate(createWindow: () => void): MenuItemConstructorOptions[] {
const templateDefault = [
{
label: '&File',
submenu: [
{
label: '&New',
accelerator: 'Ctrl+N',
click: () => {
this.background
.onNew()
.then(createWindow)
.catch(() => {});
},
},
{
label: '&Save',
accelerator: 'Ctrl+S',
click: () => {
this.background.onSave().catch(() => {}); // ignore cancels
},
},
{
label: 'Save &As',
accelerator: 'Shift+Ctrl+S',
click: () => {
this.background.onSaveAs().catch(() => {}); // ignore cancels
},
},
{
label: '&Open',
accelerator: 'Ctrl+O',
click: () => {
this.background
.onOpen()
.then(createWindow)
.catch(() => {});
},
},
{
label: '&Close',
Expand Down
2 changes: 1 addition & 1 deletion src/main/port-service/port-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function all(omitSCPorts = true) {

if (omitSCPorts) {
portMap.forEach((_value, key, map) => {
if (key.startsWith('SC ')) map.delete(key);
if (key.startsWith('SC ') || key.startsWith('RtMidi ')) map.delete(key);
});
}

Expand Down
14 changes: 12 additions & 2 deletions src/main/port-service/port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Port {

name: string;

port: midi.Input | midi.Output;
port: midi.Input | midi.Output | null;

constructor(
index: number,
Expand All @@ -21,14 +21,21 @@ export class Port {
this.siblingIndex = siblingIndex;
this.type = type;
this.name = name;
this.port = type === 'input' ? new midi.Input() : new midi.Output();
this.port = null;
}

open() {
if (this.port === null) {
this.port = this.type === 'input' ? new midi.Input() : new midi.Output();
}
this.port.openPort(this.index);
}

close() {
if (this.port === null) {
// closing unopened port
return;
}
this.port.closePort();
}

Expand All @@ -45,6 +52,9 @@ export class Port {
}

isPortOpen() {
if (this.port === null) {
return false;
}
return this.port.isPortOpen();
}
}

0 comments on commit b30d3d5

Please sign in to comment.