diff --git a/src/App.vue b/src/App.vue index 6f649f6..70a415e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,13 +17,26 @@ const toolTipColorMIDITab = ref("success") const isBusy = ref(null) const sequencer = ref(null) // refs const saveStateSequencer = reactive([]) -const saveStateMIDISetting = reactive({}) +const saveStateMIDISetting = reactive({ + outputDeviceId: null, + inputDeviceId: null, + pcChannel: null, + pcMSB: null, + pcLSB: null, +}) /** * Vue Event */ onMounted(async () => { isBusy.value = false + // set default sequence save state + for(let i = 0; i < 4; i++) { + saveStateSequencer.push({ + name: `Song ${i + 1}`, + sequence: null, + }) + } }) /** @@ -68,19 +81,28 @@ function onMIDISaveAndChange(outputDeviceId, inputDeviceId, pcChannel, pcMSB, pc toastMessageHead.value = "MIDI Setting" toastMessageBody.value = "Setting complited" new Toast(toastMessage.value).show() + // MIDI setting save state + saveStateMIDISetting.outputDeviceId = outputDeviceId + saveStateMIDISetting.inputDeviceId = inputDeviceId + saveStateMIDISetting.pcChannel = pcChannel + saveStateMIDISetting.pcMSB = pcMSB + saveStateMIDISetting.pcLSB = pcLSB } } /** * Vue Emets (from Sequencer) * + * @param {*} index * @param {*} sequence */ -function onSequenceSaveAndChange(sequence) { - console.log(sequence) +function onSequenceSaveAndChange(index, sequence) { + saveStateSequencer[index].sequence = sequence toastMessageHead.value = "Sequencer" - // toastMessageBody.value = "Save complited" - toastMessageBody.value = "Sorry, not implimented yet!" + toastMessageBody.value = "Save complited." + if(sequence === null) { + toastMessageBody.value = "Save cleard." + } new Toast(toastMessage.value).show() } diff --git a/src/components/Sequencer.vue b/src/components/Sequencer.vue index 956bd7f..b0a628c 100644 --- a/src/components/Sequencer.vue +++ b/src/components/Sequencer.vue @@ -45,7 +45,6 @@ const patternBankList = ref([]) const patternNoList = ref([]) const patternScaleList = ref([]) const sequence = reactive([]) -const saveSequence = reactive([]) /** * Vue Event @@ -248,16 +247,53 @@ function onClear() { /** * onSave + * + * @param {*} index */ -function onSave() { - emit("save-and-change", sequence) +function onSave(index) { + let serial = [] + if(sequence.length > 0) { + // serialize + for(let i = 0; i < sequence.length; i++) { + const seq = sequence[i] + serial.push({ + bank: seq.bank, + no: seq.no, + scale: seq.scale, + step: seq.step, + now: 0, + nextPCed: false, + }) + } + } else { + serial = null + } + emit("save-and-change", index, serial) } /** * onLoad + * + * @param {*} index */ - function onLoad() { - emit("save-and-change", sequence) + function onLoad(index) { + const saveState = props.saveState + if(saveState[index] && saveState[index].sequence != null) { + onClear() + for(let i = 0; i < saveState[index].sequence.length; i++) { + const seq = saveState[index].sequence[i] + // deserialize + sequence.push({ + bank: seq.bank, + no: seq.no, + scale: seq.scale, + step: seq.step, + now: 0, + nextPCed: false, + }) + } + } + pcFirstStep() } /** @@ -340,64 +376,41 @@ function defaultValue() {