| 1 | import * as config from "#config"; |
| 2 | import { lucide, mdi, stack, timeSignature, txt } from "@clo/clover-control/icons"; |
| 3 | import { Reaper } from "@clo/clover-control/Reaper"; |
| 4 | import { effect } from "@clo/clover-control/signals"; |
| 5 | |
| 6 | export default config.forApp( |
| 7 | "com.cockos.reaper", |
| 8 | ({ keypad, dialpad, mac }) => { |
| 9 | const reaper = new Reaper(); |
| 10 | const { tempo, timeSignature: timeSig, playing } = reaper.state; |
| 11 | |
| 12 | const addInstrument = keypad.menu((menu) => { |
| 13 | menu.key("up-left", txt("KK"), () => { |
| 14 | mac.toast("Add Komplete Kontrol"); |
| 15 | reaper.runScript("insert_komplete_kontrol_track"); |
| 16 | keypad.back(); |
| 17 | }); |
| 18 | menu.key("up", txt("AD2"), () => { |
| 19 | mac.toast("Add Addictive Drums"); |
| 20 | reaper.runScript("insert_addictive_drums_track"); |
| 21 | keypad.back(); |
| 22 | }); |
| 23 | menu.key("up-right", txt("Blank"), () => { |
| 24 | mac.toast("Blank Track"); |
| 25 | reaper.runScript("insert_blank_track"); |
| 26 | keypad.back(); |
| 27 | }); |
| 28 | }); |
| 29 | |
| 30 | const recording = keypad.overlay((overlay) => { |
| 31 | overlay.key("down-left", lucide("Save").fg("green"), () => { |
| 32 | reaper.runAction("transport-stop-save-all-recorded-media"); |
| 33 | reaper.runAction("transport-record"); |
| 34 | }); |
| 35 | overlay.key("down", lucide("Undo").fg("red"), () => { |
| 36 | reaper.runAction("transport-stop-delete-all-recorded-media"); |
| 37 | reaper.runAction("transport-record"); |
| 38 | }); |
| 39 | overlay.key("down-right", lucide("Trash").fg("red"), () => { |
| 40 | reaper.runAction("transport-stop-delete-all-recorded-media"); |
| 41 | }); |
| 42 | }); |
| 43 | |
| 44 | keypad.key("up-left", () => mdi("metronome").fg(reaper.state.metronomeOn() ? "teal" : "white"), () => { |
| 45 | reaper.runAction("options-toggle-metronome"); |
| 46 | }); |
| 47 | keypad.key("up", () => timeSignature(timeSig()), () => { |
| 48 | reaper.runScript("insert_time_signature"); |
| 49 | }); |
| 50 | keypad.key("up-right", () => stack(Math.round(tempo()), "BPM"), () => { |
| 51 | reaper.runAction("tempo-envelope-insert-tempo-time-signature-change-marker-at-edit-cursor"); |
| 52 | }); |
| 53 | keypad.key("left", lucide("Plus"), () => { |
| 54 | addInstrument.open(); |
| 55 | }); |
| 56 | keypad.key("down-left", lucide("Mic").fg("red"), () => { |
| 57 | reaper.runAction("transport-record"); |
| 58 | }); |
| 59 | keypad.key("down-right", () => lucide(playing() ? "Pause" : "Play"), () => { |
| 60 | reaper.runAction("transport-play-stop"); |
| 61 | }); |
| 62 | keypad.key("center", () => mdi("magnet").fg(reaper.state.snapOn() ? "teal" : "white"), () => { |
| 63 | reaper.runAction("options-toggle-snapping"); |
| 64 | }); |
| 65 | |
| 66 | effect(() => { |
| 67 | recording.active = reaper.state.recording(); |
| 68 | }); |
| 69 | |
| 70 | dialpad.on("rotate", (delta) => { |
| 71 | console.log({ delta }); |
| 72 | reaper.runAction( |
| 73 | delta > 0 |
| 74 | ? "tempo-increase-current-project-tempo-0-1-bpm" |
| 75 | : "tempo-decrease-current-project-tempo-0-1-bpm", |
| 76 | ); |
| 77 | }); |
| 78 | }, |
| 79 | ); |