Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | import player, { PlaybackPosition } from "components/music/helpers/player"; import { playNotePreview } from "components/music/helpers/notePreview"; import API from "renderer/lib/api"; const log = (log: unknown) => { console.log(log); }; const onPlayerInit = (file: Uint8Array) => { if (!file) { log(`COMPILE ERROR`); } else { log(file); log(`COMPILE DONE`); API.music.sendToProjectWindow({ action: "initialized", }); } }; const sfx = decodeURIComponent(window.location.hash).slice(1); player.initPlayer(onPlayerInit, sfx); player.setOnIntervalCallback((playbackUpdate) => { log(playbackUpdate); position = playbackUpdate; API.music.sendToProjectWindow({ action: "update", update: playbackUpdate, }); }); let position: PlaybackPosition = [0, 0]; API.events.music.data.subscribe((_event, d) => { log(d); switch (d.action) { case "load-song": player.reset(); player.loadSong(d.song); API.music.sendToProjectWindow({ action: "log", message: "load song", }); API.music.sendToProjectWindow({ action: "loaded", }); break; case "load-sound": player.loadSound(d.sound); break; case "play": Iif (d.position) { position = d.position; } player.reset(); player.play(d.song, position); API.music.sendToProjectWindow({ action: "log", message: "playing", }); break; case "play-sound": player.playSound(); API.music.sendToProjectWindow({ action: "log", message: "playing SFX", }); break; case "stop": Iif (d.position) { position = d.position; } player.stop(d.position); API.music.sendToProjectWindow({ action: "log", message: "stop", }); break; case "position": Iif (d.position) { position = d.position; } player.setStartPosition(d.position); API.music.sendToProjectWindow({ action: "log", message: "position", }); break; case "set-mute": const channels = player.setChannel(d.channel, d.muted); API.music.sendToProjectWindow({ action: "muted", channels, }); break; case "preview": let waves = d.waveForms || []; const song = player.getCurrentSong(); Iif (waves.length === 0 && song) { waves = song.waves; } playNotePreview(d.note, d.type, d.instrument, d.square2, waves); API.music.sendToProjectWindow({ action: "log", message: "preview", }); break; default: log(`Action ${d.action} not supported`); } }); |