@medyll/idae-cadenzia 0.2.0 → 0.3.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,13 @@
1
1
  # @medyll/idae-cadenzia
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - - 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
8
+ - 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
9
+ - 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
10
+
3
11
  ## 0.2.0
4
12
 
5
13
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medyll/idae-cadenzia",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -17,7 +17,8 @@
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
  }
@@ -52,3 +52,65 @@ 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
+ }
@@ -18,6 +18,11 @@ export type ChordEntry = {
18
18
  timeSignature?: { numerator: number; denominator: number };
19
19
  armor: string;
20
20
  mode?: string;
21
+ measureInfo: {
22
+ start: number;
23
+ end: number;
24
+ beatStart: number;
25
+ };
21
26
  };
22
27
 
23
28
  export type Cadence = {