From f3ebe603c42c726ef64c325c5b31d7ccb4542772 Mon Sep 17 00:00:00 2001 From: Benjamin Dehli Date: Sat, 25 May 2024 22:05:06 +0200 Subject: [PATCH] Add getters --- src/classes/Button.js | 3 +++ src/classes/Midi.js | 3 +++ src/classes/Note.js | 3 +++ src/classes/State.js | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/classes/Button.js b/src/classes/Button.js index dc3092d..ba4f886 100644 --- a/src/classes/Button.js +++ b/src/classes/Button.js @@ -40,6 +40,9 @@ export class Button { getStateItems() { return this.childElements?.filter((childElement) => childElement instanceof State); } + getStateItemByIndex(index) { + return this.getStateItems()[index]; + } toJson(decentSampler) { const jsonObject = { $: { diff --git a/src/classes/Midi.js b/src/classes/Midi.js index 13c516b..6ca1302 100644 --- a/src/classes/Midi.js +++ b/src/classes/Midi.js @@ -42,6 +42,9 @@ export class Midi { getNoteItems() { return this.childElements?.filter((childElement) => childElement instanceof Note); } + getNoteItemByIndex(index) { + return this.getNoteItems()[index]; + } toJson(decentSampler) { const jsonObject = {}; jsonObject["#name"] = this.elementType; diff --git a/src/classes/Note.js b/src/classes/Note.js index 8856648..65618d7 100644 --- a/src/classes/Note.js +++ b/src/classes/Note.js @@ -41,6 +41,9 @@ export class Note { getBindingItems() { return this.childElements?.filter((childElement) => childElement instanceof Binding); } + getBindingItemByIndex(index) { + return this.getBindingItems()[index]; + } toJson(decentSampler) { const jsonObject = { $: { diff --git a/src/classes/State.js b/src/classes/State.js index 02d3d36..0ebf83b 100644 --- a/src/classes/State.js +++ b/src/classes/State.js @@ -34,6 +34,9 @@ export class State { getBindingItems() { return this.childElements?.filter((childElement) => childElement instanceof Binding); } + getBindingItemByIndex(index) { + return this.getBindingItems()[index]; + } toJson(decentSampler) { const jsonObject = { $: {