Skip to content

Commit

Permalink
fix bugs with text brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDavidNewman committed Dec 16, 2023
1 parent 3435bdc commit ef6860f
Show file tree
Hide file tree
Showing 13 changed files with 22,920 additions and 16,497 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typeDocServer.definitionFiles": []
}
8 changes: 8 additions & 0 deletions build/html/smoosic.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
<audio crossOrigin="anonymous" id="samplebb4" data-pitch="bb/4" data-patch="piano"
src="https://aarondavidnewman.github.io/SmoSounds/piano/piano-bb4-iowa.mp3"> </audio>
</div>
<div>
<audio crossOrigin="anonymous" id="sample-piano-a2" data-pitch="a/2" data-patch="piano"
src="https://aarondavidnewman.github.io/SmoSounds/piano/piano-a2.mp3"> </audio>
</div>
<div>
<audio crossOrigin="anonymous" id="sample-piano-fs2" data-pitch="fs/2" data-patch="piano"
src="https://aarondavidnewman.github.io/SmoSounds/piano/piano-fs2.mp3"> </audio>
</div>
<div>
<audio crossOrigin="anonymous" id="sample-cello-bb3" data-pitch="bb/3" data-patch="cello"
src="https://aarondavidnewman.github.io/SmoSounds/strings/cello-bb3-iowa.mp3">
Expand Down
8 changes: 8 additions & 0 deletions release/html/smoosic.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
<audio crossOrigin="anonymous" id="samplebb4" data-pitch="bb/4" data-patch="piano"
src="https://aarondavidnewman.github.io/SmoSounds/piano/piano-bb4-iowa.mp3"> </audio>
</div>
<div>
<audio crossOrigin="anonymous" id="sample-piano-a2" data-pitch="a/2" data-patch="piano"
src="https://aarondavidnewman.github.io/SmoSounds/piano/piano-a2.mp3"> </audio>
</div>
<div>
<audio crossOrigin="anonymous" id="sample-piano-fs2" data-pitch="fs/2" data-patch="piano"
src="https://aarondavidnewman.github.io/SmoSounds/piano/piano-fs2.mp3"> </audio>
</div>
<div>
<audio crossOrigin="anonymous" id="sample-cello-bb3" data-pitch="bb/3" data-patch="cello"
src="https://aarondavidnewman.github.io/SmoSounds/strings/cello-bb3-iowa.mp3">
Expand Down
39,359 changes: 22,871 additions & 16,488 deletions release/smoosic.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/smoosic.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/common/vex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ export function getChordSymbolMetricsForGlyph(code: string) {
if (code === '#') {
code = 'accidentalSharp';
}
const glyphMetrics = VexChordSymbol.metrics;
return (glyphMetrics as any)[code];
const glyphMetrics = VexChordSymbol.metrics.glyphs;
return glyphMetrics[code];
}
/**
* Vex 5 compatibility. yShift
Expand Down
1 change: 1 addition & 0 deletions src/render/audio/oscillator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export class SuiSampler extends SuiOscillator {
if (!sample) {
return node;
}

const cents = 1200 * (Math.log(this.frequency / sample!.frequency))
/ Math.log(2);

Expand Down
20 changes: 20 additions & 0 deletions src/render/audio/samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,26 @@ export class SuiSampleMedia {
instrument: 'piano',
nativeFrequency: SmoAudioPitch.smoPitchToFrequency({ letter: 'b', accidental: 'b', octave: 4 }, 0, null),
});
SuiSampleMedia.insertIntoMap({
sustain: 'percussive',
realOvertones: [],
imaginaryOvertones: [],
sample: 'sample-piano-a2',
family: 'keyboard',
instrument: 'piano',
dynamic: 50,
nativeFrequency: SmoAudioPitch.smoPitchToFrequency({ letter: 'a', accidental: 'n', octave: 2 }, 0, null),
});
SuiSampleMedia.insertIntoMap({
sustain: 'percussive',
realOvertones: [],
imaginaryOvertones: [],
sample: 'sample-piano-fs2',
family: 'keyboard',
instrument: 'piano',
dynamic: 50,
nativeFrequency: SmoAudioPitch.smoPitchToFrequency({ letter: 'f', accidental: '#', octave: 2 }, 0, null),
});
SuiSampleMedia.insertIntoMap({
sustain: 'percussive',
sample: 'basspizz-c2-sso',
Expand Down
2 changes: 1 addition & 1 deletion src/render/sui/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export abstract class SuiMapper {
this.localModifiers.push({ index, selection: sel, modifier: tempo, box: tempo.logicalBox ?? SvgBox.default });
index += 1;
});
sel.staff.getModifiers().forEach((mod) => {
sel.staff.renderableModifiers.forEach((mod) => {
if (SmoSelector.gteq(sel.selector, mod.startSelector) &&
SmoSelector.lteq(sel.selector, mod.endSelector) && mod.logicalBox) {
const exists = this.localModifiers.find((mm) => mm.modifier.ctor === mod.ctor);
Expand Down
2 changes: 1 addition & 1 deletion src/render/sui/scoreRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class SuiScoreRender {
staff.measures.forEach((measure) => {
this.unrenderMeasure(measure);
});
staff.modifiers.forEach((modifier) => {
staff.renderableModifiers.forEach((modifier) => {
if (modifier.element) {
modifier.element.remove();
modifier.element = null;
Expand Down
2 changes: 1 addition & 1 deletion src/render/sui/scoreViewOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
this.renderer.unrenderMeasure(staff.measures[staff.measures.length - 1]);
// A little hacky - delete the modifiers if they start or end on
// the measure
staff.modifiers.forEach((modifier) => {
staff.renderableModifiers.forEach((modifier) => {
if (modifier.startSelector.measure === index || modifier.endSelector.measure === index) {
if (modifier.logicalBox) {
const context = this.renderer.renderer.getRenderer(modifier.logicalBox);
Expand Down
4 changes: 2 additions & 2 deletions src/smo/data/staffModifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ export interface SmoStaffTextBracketParamsSer extends StaffModifierBaseSer{
function isSmoStaffTextBracketParamsSer(params: Partial<SmoStaffTextBracketParamsSer>):
params is SmoStaffTextBracketParamsSer {
if (params.ctor && params.ctor === 'SmoStaffTextBracket') {
return false;
return true;
}
return true;
return false;
}
export type SmoTextBracketStringType = 'text' | 'superscript';
export const SmoTextBracketStringTypes: SmoTextBracketStringType[] = ['text', 'superscript'];
Expand Down
2 changes: 1 addition & 1 deletion src/smo/data/systemStaff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export class SmoSystemStaff implements SmoObjectParams {
return rv;
}
getModifier(modData: any) {
return this.getModifiers().find((mod) =>
return this.renderableModifiers.find((mod) =>
SmoSelector.eq(mod.startSelector, modData.startSelector) && mod.attrs.type === modData.attrs.type);
}
setLyricFont(fontInfo: FontInfo) {
Expand Down

0 comments on commit ef6860f

Please sign in to comment.