Pārlūkot izejas kodu

Initial commit

Tested with a real MIDI keyboard.
master
TheoryOfNekomata pirms 3 gadiem
revīzija
932f7fefa7
5 mainītis faili ar 1925 papildinājumiem un 0 dzēšanām
  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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 1531
- 0
yarn.lock
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


Notiek ielāde…
Atcelt
Saglabāt