Simple monitor for displaying MIDI status for digital pianos.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

index.js 1.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const { app, BrowserWindow } = require('electron')
  2. const midi = require('midi')
  3. const SCREEN_HEIGHT = 64
  4. const SCREEN_WIDTH = 1200
  5. const createWindow = () => {
  6. const win = new BrowserWindow({
  7. width: SCREEN_WIDTH,
  8. height: SCREEN_HEIGHT,
  9. useContentSize: true,
  10. backgroundColor: '#000000',
  11. resizable: false,
  12. minimizable: false,
  13. maximizable: false,
  14. fullscreenable: false,
  15. webPreferences: {
  16. //devTools: false,
  17. nodeIntegration: true,
  18. }
  19. })
  20. win.loadFile('index.html')
  21. const input = new midi.Input()
  22. if (input.getPortCount() > 0) {
  23. input.openPort(0)
  24. }
  25. input.on('message', (deltaTime, message) => {
  26. const [type, data1, data2] = message
  27. switch (type) {
  28. case 144:
  29. win.webContents.send('note', data1 + ':' + data2)
  30. break
  31. case 176:
  32. win.webContents.send('pedal', data1 + ':' + data2)
  33. break
  34. }
  35. })
  36. }
  37. app
  38. .whenReady()
  39. .then(() => {
  40. createWindow()
  41. })
  42. app.on('window-all-closed', () => {
  43. if (process.platform !== 'darwin') {
  44. app.quit()
  45. }
  46. })
  47. app.on('activate', () => {
  48. if (BrowserWindow.getAllWindows().length === 0) {
  49. createWindow()
  50. }
  51. })