Simple monitor for displaying MIDI status for digital pianos.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

61 linhas
1.2 KiB

  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. })