@medyll/idae-cadenzia 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @medyll/idae-cadenzia
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- - feat(améliorer): la gestion des changements d'accords avec une fonction dédiée et mise à jour des entrées d'accords ([9f58fc5](https://github.com/medyll/idae/commit/9f58fc5470ea3f0a19780fdd994e83a9d3b4a63a)) - 2024-11-19 by @medyll
|
|
8
|
+
- feat(ajouter): la gestion des informations de mesure pour les entrées d'accords ([b0641d0](https://github.com/medyll/idae/commit/b0641d0e4c236717555b6cb2a853f127092ee194)) - 2024-11-18 by @medyll
|
|
9
|
+
- feat(ajouter): des constantes musicales et améliorer la gestion des accords avec des options d'armure ([0f48cd9](https://github.com/medyll/idae/commit/0f48cd947ceabadf13a7488110c8bbdc6b32e638)) - 2024-11-16 by @medyll
|
|
10
|
+
- feat(ajouter): le composant App et les composants associés pour la visualisation des accords ([e7c9517](https://github.com/medyll/idae/commit/e7c95178e328e56f514678bed4c96015e7ef7529)) - 2024-11-16 by @medyll
|
|
11
|
+
|
|
12
|
+
## 0.3.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- - feat(ajouter): la gestion des informations de mesure pour les entrées d'accords ([b0641d0](https://github.com/medyll/idae/commit/b0641d0e4c236717555b6cb2a853f127092ee194)) - 2024-11-18 by @medyll
|
|
17
|
+
- feat(ajouter): des constantes musicales et améliorer la gestion des accords avec des options d'armure ([0f48cd9](https://github.com/medyll/idae/commit/0f48cd947ceabadf13a7488110c8bbdc6b32e638)) - 2024-11-16 by @medyll
|
|
18
|
+
- feat(ajouter): le composant App et les composants associés pour la visualisation des accords ([e7c9517](https://github.com/medyll/idae/commit/e7c95178e328e56f514678bed4c96015e7ef7529)) - 2024-11-16 by @medyll
|
|
19
|
+
|
|
3
20
|
## 0.2.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
import { getScaleNotes, isChordInScale } from '$lib/functions/rules.js';
|
|
11
11
|
|
|
12
12
|
import type { ChordEntry } from '$lib/types/types.js';
|
|
13
|
-
import { chordEntries, updateCadences, toggleModifier } from '../functions/functions.svelte.js';
|
|
13
|
+
import { chordEntries, updateCadences, toggleModifier, handleChordChange } from '../functions/functions.svelte.js';
|
|
14
14
|
|
|
15
15
|
function addChordEntry() {
|
|
16
16
|
chordEntries.push({
|
|
17
17
|
chord: { root: 'C', quality: qualities.mode[0], modifier: undefined, duration: '1' },
|
|
18
18
|
timeSignature: chordEntries.length === 0 ? { numerator: 4, denominator: 4 } : undefined,
|
|
19
19
|
armor: '',
|
|
20
|
-
mode: undefined
|
|
20
|
+
mode: undefined,
|
|
21
|
+
measureInfo: { start: 1, end: 1, beatStart: 0 }
|
|
21
22
|
});
|
|
22
23
|
updateCadences();
|
|
23
24
|
}
|
|
@@ -27,9 +28,7 @@
|
|
|
27
28
|
updateCadences();
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
updateCadences();
|
|
32
|
-
}
|
|
31
|
+
|
|
33
32
|
|
|
34
33
|
function toggleTimeSignature(index: number) {
|
|
35
34
|
if (chordEntries[index].timeSignature) {
|
|
@@ -65,12 +64,30 @@
|
|
|
65
64
|
<tbody>
|
|
66
65
|
{#each chordEntries as entry, i}
|
|
67
66
|
<tr>
|
|
68
|
-
<td>
|
|
67
|
+
<td>
|
|
68
|
+
{#if entry.measureInfo.start === entry.measureInfo.end}
|
|
69
|
+
{entry.measureInfo.start}
|
|
70
|
+
{:else}
|
|
71
|
+
{entry.measureInfo.start} - {entry.measureInfo.end}
|
|
72
|
+
{/if}
|
|
73
|
+
</td>
|
|
69
74
|
<td class="timeSignature">
|
|
70
75
|
{#if entry.timeSignature}
|
|
71
|
-
<input
|
|
76
|
+
<input
|
|
77
|
+
type="number"
|
|
78
|
+
bind:value={entry.timeSignature.numerator}
|
|
79
|
+
min="1"
|
|
80
|
+
max="32"
|
|
81
|
+
onchange={() => handleChordChange(i, { timeSignature: entry.timeSignature })}
|
|
82
|
+
/>
|
|
72
83
|
/
|
|
73
|
-
<input
|
|
84
|
+
<input
|
|
85
|
+
type="number"
|
|
86
|
+
bind:value={entry.timeSignature.denominator}
|
|
87
|
+
min="1"
|
|
88
|
+
max="32"
|
|
89
|
+
onchange={() => handleChordChange(i, { timeSignature: entry.timeSignature })}
|
|
90
|
+
/>
|
|
74
91
|
{:else}
|
|
75
92
|
<button onclick={() => toggleTimeSignature(i)}>Add Time Signature</button>
|
|
76
93
|
{/if}
|
|
@@ -78,7 +95,11 @@
|
|
|
78
95
|
<td>
|
|
79
96
|
<div>
|
|
80
97
|
<label for="armor-{i}">Armor:</label>
|
|
81
|
-
<select
|
|
98
|
+
<select
|
|
99
|
+
id="armor-{i}"
|
|
100
|
+
bind:value={entry.armor}
|
|
101
|
+
onchange={() => handleChordChange(i, { armor: entry.armor })}
|
|
102
|
+
>
|
|
82
103
|
{#each armorOptions as armor}
|
|
83
104
|
<option value={armor.name}>
|
|
84
105
|
{armor.name}
|
|
@@ -89,7 +110,11 @@
|
|
|
89
110
|
</div>
|
|
90
111
|
<div>
|
|
91
112
|
<label for="mode-{i}">Mode:</label>
|
|
92
|
-
<select
|
|
113
|
+
<select
|
|
114
|
+
id="mode-{i}"
|
|
115
|
+
bind:value={entry.mode}
|
|
116
|
+
onchange={() => handleChordChange(i, { mode: entry.mode })}
|
|
117
|
+
>
|
|
93
118
|
<option value={undefined}>Select mode</option>
|
|
94
119
|
{#each modes as mode}
|
|
95
120
|
<option value={mode}>{mode}</option>
|
|
@@ -98,9 +123,18 @@
|
|
|
98
123
|
</div>
|
|
99
124
|
</td>
|
|
100
125
|
<td>
|
|
101
|
-
<select
|
|
126
|
+
<select
|
|
127
|
+
bind:value={entry.chord.root}
|
|
128
|
+
onchange={() => handleChordChange(i, { chord: { ...entry.chord } })}
|
|
129
|
+
>
|
|
102
130
|
{#each rootNotes as note}
|
|
103
|
-
<option
|
|
131
|
+
<option
|
|
132
|
+
value={note}
|
|
133
|
+
class:not-in-scale={!isChordValid({
|
|
134
|
+
...entry,
|
|
135
|
+
chord: { ...entry.chord, root: note }
|
|
136
|
+
})}
|
|
137
|
+
>
|
|
104
138
|
{note}
|
|
105
139
|
</option>
|
|
106
140
|
{/each}
|
|
@@ -110,16 +144,20 @@
|
|
|
110
144
|
{#each Object.entries(qualities) as [group, qualityOptions]}
|
|
111
145
|
<div>
|
|
112
146
|
{#each qualityOptions as quality}
|
|
113
|
-
<label
|
|
147
|
+
<label
|
|
148
|
+
class:not-in-scale={!isChordValid({
|
|
149
|
+
...entry,
|
|
150
|
+
chord: { ...entry.chord, quality }
|
|
151
|
+
})}
|
|
152
|
+
>
|
|
114
153
|
<input
|
|
115
154
|
type="radio"
|
|
116
155
|
name={`quality-${group}-${i}`}
|
|
117
156
|
value={quality}
|
|
118
157
|
checked={entry.chord[group] === quality}
|
|
119
158
|
onchange={() => {
|
|
120
|
-
entry.chord[group]
|
|
121
|
-
|
|
122
|
-
handleChordChange();
|
|
159
|
+
const updatedChord = { ...entry.chord, [group]: quality, quality };
|
|
160
|
+
handleChordChange(i, { chord: updatedChord });
|
|
123
161
|
}}
|
|
124
162
|
/>
|
|
125
163
|
{quality}
|
|
@@ -131,7 +169,9 @@
|
|
|
131
169
|
</td>
|
|
132
170
|
<td>
|
|
133
171
|
{#each modifiers as modifier}
|
|
134
|
-
<label
|
|
172
|
+
<label
|
|
173
|
+
class:not-in-scale={!isChordValid({ ...entry, chord: { ...entry.chord, modifier } })}
|
|
174
|
+
>
|
|
135
175
|
<input
|
|
136
176
|
type="radio"
|
|
137
177
|
name={`modifier-${i}`}
|
|
@@ -147,7 +187,7 @@
|
|
|
147
187
|
<input
|
|
148
188
|
type="text"
|
|
149
189
|
bind:value={entry.chord.duration}
|
|
150
|
-
onchange={handleChordChange}
|
|
190
|
+
onchange={() => handleChordChange(i, { chord: { ...entry.chord } })}
|
|
151
191
|
placeholder="e.g., 1, 1/2, 3/4"
|
|
152
192
|
/>
|
|
153
193
|
</td>
|
|
@@ -52,3 +52,88 @@ export function getArmorInfo(armorName: string) {
|
|
|
52
52
|
const armor = armorOptions.find((a) => a.name === armorName);
|
|
53
53
|
return armor ? `${armor.name}${armor.value ? ` (${armor.value})` : ''}` : '';
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
function getDurationValue(duration: string): number {
|
|
57
|
+
const [numerator, denominator] = duration.split('/').map(Number);
|
|
58
|
+
return denominator ? numerator / denominator : numerator;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function updateMeasureInfo() {
|
|
62
|
+
let currentMeasure = 1;
|
|
63
|
+
let currentBeat = 0;
|
|
64
|
+
let currentTimeSignature = { numerator: 4, denominator: 4 };
|
|
65
|
+
|
|
66
|
+
for (let i = 0; i < chordEntries.length; i++) {
|
|
67
|
+
const entry = chordEntries[i];
|
|
68
|
+
|
|
69
|
+
if (entry.timeSignature) {
|
|
70
|
+
currentTimeSignature = entry.timeSignature;
|
|
71
|
+
if (currentBeat > 0) {
|
|
72
|
+
currentMeasure++;
|
|
73
|
+
currentBeat = 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const chordDuration = getDurationValue(entry.chord.duration);
|
|
78
|
+
const beatsPerMeasure = currentTimeSignature.numerator;
|
|
79
|
+
|
|
80
|
+
const measureStart = currentMeasure;
|
|
81
|
+
const beatStart = currentBeat;
|
|
82
|
+
|
|
83
|
+
currentBeat += chordDuration * beatsPerMeasure;
|
|
84
|
+
while (currentBeat >= beatsPerMeasure) {
|
|
85
|
+
currentMeasure++;
|
|
86
|
+
currentBeat -= beatsPerMeasure;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
chordEntries[i] = {
|
|
90
|
+
...entry,
|
|
91
|
+
measureInfo: {
|
|
92
|
+
start: measureStart,
|
|
93
|
+
end: currentMeasure,
|
|
94
|
+
beatStart: beatStart
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function addChordEntry() {
|
|
101
|
+
const newEntry = {
|
|
102
|
+
chord: { root: 'C', quality: 'maj', modifier: undefined, duration: '1' },
|
|
103
|
+
timeSignature: chordEntries.length === 0 ? { numerator: 4, denominator: 4 } : undefined,
|
|
104
|
+
armor: '',
|
|
105
|
+
measureInfo: { start: 1, end: 1, beatStart: 0 }
|
|
106
|
+
};
|
|
107
|
+
chordEntries.push(newEntry);
|
|
108
|
+
updateCadences();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function updateChordEntry(index: number, updatedEntry: Partial<ChordEntry>) {
|
|
112
|
+
if (index >= 0 && index < chordEntries.length) {
|
|
113
|
+
chordEntries[index] = { ...chordEntries[index], ...updatedEntry };
|
|
114
|
+
updateCadences();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function handleChordChange(index: number, changes: Partial<ChordEntry>) {
|
|
119
|
+
if (index >= 0 && index < chordEntries.length) {
|
|
120
|
+
const currentEntry = chordEntries[index];
|
|
121
|
+
const updatedEntry: ChordEntry = { ...currentEntry };
|
|
122
|
+
|
|
123
|
+
if (changes.chord) {
|
|
124
|
+
updatedEntry.chord = { ...currentEntry.chord, ...changes.chord };
|
|
125
|
+
}
|
|
126
|
+
if (changes.timeSignature) {
|
|
127
|
+
updatedEntry.timeSignature = changes.timeSignature;
|
|
128
|
+
}
|
|
129
|
+
if (changes.armor !== undefined) {
|
|
130
|
+
updatedEntry.armor = changes.armor;
|
|
131
|
+
}
|
|
132
|
+
if (changes.mode !== undefined) {
|
|
133
|
+
updatedEntry.mode = changes.mode;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
chordEntries[index] = updatedEntry;
|
|
137
|
+
updateCadences();
|
|
138
|
+
}
|
|
139
|
+
}
|
package/src/lib/types/types.ts
CHANGED