Browse Source

Initial commit

Tested with a real MIDI keyboard.
master
TheoryOfNekomata 4 years ago
commit
932f7fefa7
5 changed files with 1925 additions and 0 deletions
  1. +92
    -0
      .gitignore
  2. +53
    -0
      index.js
  3. +19
    -0
      package.json
  4. +230
    -0
      pages/piano.html
  5. +1531
    -0
      yarn.lock

+ 92
- 0
.gitignore View File

@@ -0,0 +1,92 @@
.DS_Store
.AppleDouble
.LSOverride
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
.idea/
cmake-build-*/
*.iws
out/
.idea_modules/
atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.vscode/
*.code-workspace
.history/
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msix
*.msm
*.msp
*.lnk
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
pids
*.pid
*.seed
*.pid.lock
lib-cov
coverage
*.lcov
.nyc_output
.grunt
bower_components
.lock-wscript
build/Release
node_modules/
jspm_packages/
web_modules/
*.tsbuildinfo
.npm
.eslintcache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
.node_repl_history
*.tgz
.yarn-integrity
.env
.env.test
.cache
.parcel-cache
.next
.nuxt
dist
.cache/
.vuepress/dist
.serverless/
.fusebox/
.dynamodb/
.tern-port
.vscode-test
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*

+ 53
- 0
index.js View File

@@ -0,0 +1,53 @@
const { app, BrowserWindow } = require('electron')
const midi = require('midi')

const SCREEN_HEIGHT = 96
const SCREEN_WIDTH = 1152

const createWindow = () => {
const win = new BrowserWindow({
width: SCREEN_WIDTH,
height: SCREEN_HEIGHT,
webPreferences: {
nodeIntegration: true
}
})

win.loadFile('pages/piano.html')

const input = new midi.Input()

if (input.getPortCount() > 0) {
input.openPort(0)
}

input.on('message', (deltaTime, message) => {
const [type, data1, data2] = message
switch (type) {
case 144:
win.webContents.send('note', data1 + ':' + data2)
break
case 176:
win.webContents.send('pedal', data1 + ':' + data2)
break
}
})
}

app
.whenReady()
.then(() => {
createWindow()
})

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})

+ 19
- 0
package.json View File

@@ -0,0 +1,19 @@
{
"name": "piano-keyboard-electron",
"version": "0.0.0",
"description": "Simple piano keyboard reading MIDI messages",
"main": "index.js",
"author": "TheoryOfNekomata <allan.crisostomo@outlook.com>",
"license": "MIT",
"private": true,
"scripts": {
"start": "electron ."
},
"devDependencies": {
"electron": "^9.1.2",
"electron-rebuild": "^1.11.0"
},
"dependencies": {
"midi": "^1.0.0"
}
}

+ 230
- 0
pages/piano.html
File diff suppressed because it is too large
View File


+ 1531
- 0
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save