@medyll/idae-cadenzia 0.3.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,14 @@
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
+
3
12
  ## 0.3.0
4
13
 
5
14
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medyll/idae-cadenzia",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -10,7 +10,7 @@
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({
@@ -28,9 +28,7 @@
28
28
  updateCadences();
29
29
  }
30
30
 
31
- function handleChordChange() {
32
- updateCadences();
33
- }
31
+
34
32
 
35
33
  function toggleTimeSignature(index: number) {
36
34
  if (chordEntries[index].timeSignature) {
@@ -66,12 +64,30 @@
66
64
  <tbody>
67
65
  {#each chordEntries as entry, i}
68
66
  <tr>
69
- <td>{i + 1}</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>
70
74
  <td class="timeSignature">
71
75
  {#if entry.timeSignature}
72
- <input type="number" bind:value={entry.timeSignature.numerator} min="1" max="32" />
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
+ />
73
83
  /
74
- <input type="number" bind:value={entry.timeSignature.denominator} min="1" max="32" />
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
+ />
75
91
  {:else}
76
92
  <button onclick={() => toggleTimeSignature(i)}>Add Time Signature</button>
77
93
  {/if}
@@ -79,7 +95,11 @@
79
95
  <td>
80
96
  <div>
81
97
  <label for="armor-{i}">Armor:</label>
82
- <select id="armor-{i}" bind:value={entry.armor} onchange={handleChordChange}>
98
+ <select
99
+ id="armor-{i}"
100
+ bind:value={entry.armor}
101
+ onchange={() => handleChordChange(i, { armor: entry.armor })}
102
+ >
83
103
  {#each armorOptions as armor}
84
104
  <option value={armor.name}>
85
105
  {armor.name}
@@ -90,7 +110,11 @@
90
110
  </div>
91
111
  <div>
92
112
  <label for="mode-{i}">Mode:</label>
93
- <select id="mode-{i}" bind:value={entry.mode} onchange={handleChordChange}>
113
+ <select
114
+ id="mode-{i}"
115
+ bind:value={entry.mode}
116
+ onchange={() => handleChordChange(i, { mode: entry.mode })}
117
+ >
94
118
  <option value={undefined}>Select mode</option>
95
119
  {#each modes as mode}
96
120
  <option value={mode}>{mode}</option>
@@ -99,9 +123,18 @@
99
123
  </div>
100
124
  </td>
101
125
  <td>
102
- <select bind:value={entry.chord.root} onchange={handleChordChange}>
126
+ <select
127
+ bind:value={entry.chord.root}
128
+ onchange={() => handleChordChange(i, { chord: { ...entry.chord } })}
129
+ >
103
130
  {#each rootNotes as note}
104
- <option value={note} class:not-in-scale={!isChordValid({...entry, chord: {...entry.chord, root: note}})}>
131
+ <option
132
+ value={note}
133
+ class:not-in-scale={!isChordValid({
134
+ ...entry,
135
+ chord: { ...entry.chord, root: note }
136
+ })}
137
+ >
105
138
  {note}
106
139
  </option>
107
140
  {/each}
@@ -111,16 +144,20 @@
111
144
  {#each Object.entries(qualities) as [group, qualityOptions]}
112
145
  <div>
113
146
  {#each qualityOptions as quality}
114
- <label class:not-in-scale={!isChordValid({...entry, chord: {...entry.chord, quality}})}>
147
+ <label
148
+ class:not-in-scale={!isChordValid({
149
+ ...entry,
150
+ chord: { ...entry.chord, quality }
151
+ })}
152
+ >
115
153
  <input
116
154
  type="radio"
117
155
  name={`quality-${group}-${i}`}
118
156
  value={quality}
119
157
  checked={entry.chord[group] === quality}
120
158
  onchange={() => {
121
- entry.chord[group] = quality;
122
- entry.chord.quality = quality;
123
- handleChordChange();
159
+ const updatedChord = { ...entry.chord, [group]: quality, quality };
160
+ handleChordChange(i, { chord: updatedChord });
124
161
  }}
125
162
  />
126
163
  {quality}
@@ -132,7 +169,9 @@
132
169
  </td>
133
170
  <td>
134
171
  {#each modifiers as modifier}
135
- <label class:not-in-scale={!isChordValid({...entry, chord: {...entry.chord, modifier}})}>
172
+ <label
173
+ class:not-in-scale={!isChordValid({ ...entry, chord: { ...entry.chord, modifier } })}
174
+ >
136
175
  <input
137
176
  type="radio"
138
177
  name={`modifier-${i}`}
@@ -148,7 +187,7 @@
148
187
  <input
149
188
  type="text"
150
189
  bind:value={entry.chord.duration}
151
- onchange={handleChordChange}
190
+ onchange={() => handleChordChange(i, { chord: { ...entry.chord } })}
152
191
  placeholder="e.g., 1, 1/2, 3/4"
153
192
  />
154
193
  </td>
@@ -114,3 +114,26 @@ export function updateChordEntry(index: number, updatedEntry: Partial<ChordEntry
114
114
  updateCadences();
115
115
  }
116
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
+ }