باختصار
فصل من كتاب في نظرية الموسيقى عن الطريقة التي تنتهي بها الجمل الموسيقية. تُكتب الأمثلة سطورًا قصيرة من النص داخل الفصل، ويرسمها Postext مدرجات ونوتات؛ وأطولها يكمل في الصفحة التالية كما تكمل الفقرة.
ما الذي ستنضده
الفصل الخامس من مقرر في الهارموني على آلة المفاتيح، بمقاس 180 × 250 mm بخط Libre Caslon، عن القفلات الخمس: القفلة التامة والناقصة، ونصف القفلة، والقفلة البلاغية، والقفلة الخادعة. لكل قفلة فقرتان قصيرتان ومثال بثلاثة أصوات تحت مدرجه أرقامه الرومانية، مكتوب بلغة ABC داخل Markdown نفسه. وينتهي الفصل بلحن Greensleeves في لا الصغير، فوق كل مازورة رقم روماني، وهذا اللحن أطول من المساحة الباقية في الصفحة 3: يضع فيها ثلاثة أسطر موسيقية، والسطرين الأخيرين في أعلى الصفحة 4، منقسمًا بين الأسطر الموسيقية كما تنقسم الفقرة بين الأسطر. يُضبط حجم المدرج والخط الموسيقي والتباعد مرة واحدة في الإعدادات، فتشترك الأمثلة الخمسة واللحن في مظهر واحد.
تجيب هذه الوصفة عن
- كيف أضع أمثلة موسيقية داخل نص كتاب مدرسي، مكتوبةً تدوينًا؟
الجواب المختصر
// Each ```abc fence in the chapter is engraved at the width of the text column and cut
// into systems. The style is set once here; the Markdown only holds the notation.
const scoreStyle = {
staffSize: mm(5.5), // a textbook's rastral: examples read at arm's length on a desk
musicFont: 'Bravura', // the traditional engraved look, heavy enough beside Caslon
textFont: 'Libre Caslon Text', // the Roman numerals of `w:` lines, in the text face
spacing: 1.6, // air between the chords: an example reads as a progression, not a cluster
barNumbers: 'system',
systemGap: mm(4),
marginTop: pt(LEAD / 2),
marginBottom: pt(LEAD / 2),
color: col('ink'),
// A long example runs on into the next page between two systems, never leaving one
// system alone at the foot of a page or at the head of the next.
minSystemsAtBreak: 2,
};
المكونات
- الميزات
- التدوين الموسيقينمط المدوّنة الموسيقيةصفحات افتتاح مصمَّمةسمات العنوانالترويسات وأرقام الصفحاتهوامش متناظرةالترويسات بحسب دور الصفحةإطارات التنبيهأنماط الفقراتلوحة ألوان دلاليةالأسطر الأرامل والأسطر اليتيمة والكلمات المعزولةالتصدير إلى PDF
- الخطوط
- Libre Caslon Text, Libre Caslon Display, Libre Franklin (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · اكتب المثال حيث يحتاج إليه النص
كتلة موسومة بـabc تحمل التدوين، ويكمل النص بعدها. يجعل L:1/2 كل تآلف بلا مدة نوتة بيضاء، ويرصّ [Bdg] ثلاث نوتات في صوت واحد، ويضع سطر w: كلمة تحت كل تآلف، وهي هنا الأرقام الرومانية. والسمة alt هي ما يقوله قارئ الشاشة وملف PDF الموسوم بدلًا من الصورة.
```abc {alt="قفلة تامة في صول الكبير: I، IV، V، I"}
X:1
M:4/4
L:1/2
K:G
[Bdg] [ceg] | [Adf] [Bdg] |]
w: I IV V I
```#2 · امنح كل مدونة مظهر الكتاب
الجواب المختصر هو تصميم الموسيقى كله: مدرج بارتفاع 5.5 mm، كما تستعمله كتب الهارموني لأمثلة تُقرأ على آلة المفاتيح، وBravura بجانب نص Caslon، والأرقام بخط النص بدلًا من خط Times الذي يستعمله الناقش. يوزّع spacing: 1.6 أربعة تآلفات بيضاء على ثلث عرض السطر، فيُقرأ التتابع الهارموني تآلفًا تآلفًا. والإعداد نفسه يحدد كم مازورة من Greensleeves تتسع في سطر موسيقي واحد: ثلاث، في عرض سطر 125 mm.
#3 · دع المثال الطويل يكمل
minSystemsAtBreak: 2 هو ما يُبقي Greensleeves مقروءًا عند قلب الصفحة. يخرج اللحن في خمسة أسطر موسيقية؛ تتسع ثلاثة منها في أسفل الصفحة 3، فينتقل اثنان إلى الصفحة 4، ولا تبقى أي صفحة بسطر موسيقي واحد. والمدونة التي تقل عن أربعة أسطر تنتقل كاملة إلى الصفحة التالية، كما كانت ستفعل أمثلة القفلات القصيرة.
#4 · شغّل الناقش قبل البناء
// The engraver (Verovio) loads only for books with music: start it before the build,
// or every score is laid out as a grey placeholder box.
await initMusicEngine();
const doc = await buildDocumentWithFonts({ markdown }, config, kitFonts(FONTS));
showPages(doc, { title: t({ en: 'Harmony textbook', es: 'Manual de armonía' }) });
// The PDF draws every system as vector paths, the numerals in the embedded text face.
offerPdf(() => renderToPdf(doc, { fontProvider: fontsourceProvider }), `${RECIPE}.pdf`);
يبلغ Verovio نحو 3.7 MB من WebAssembly، لذلك لا يحمّله المحرك إلا حين تطلبه. ومن غير initMusicEngine() يجري الإخراج مع ذلك، وتكون كل مدونة مربعًا رماديًا بالحجم الصحيح. ولا يحتاج renderToPdf إلى شيء آخر: يرسم ملف PDF كل سطر موسيقي مسارات متجهية، ويضع الأرقام بخط Caslon المضمّن.
#5 · افتتح الفصل بعنوان منخفض
const opener = {
enabled: true,
minHeight: mm(48),
slot: { elements: [
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', fontFamily: LABEL, fontSize: pt(8.5),
fontWeight: 700, letterSpacing: pt(1.7), textTransform: 'uppercase', color: col('accent'),
align: 'left', placement: { anchor: { to: 'container', edge: 'top-left' },
offset: { x: mm(0), y: mm(12) } } },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: 'Libre Caslon Display',
fontSize: pt(34), lineHeight: 1.05, color: col('ink'), align: 'left', overflow: 'wrap',
placement: { anchor: { to: '#kicker', edge: 'below' }, offset: { x: mm(0), y: mm(3) },
size: { width: mm(110), height: 'auto' } } },
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(1.5),
color: col('accent'),
placement: { anchor: { to: '#title', edge: 'below' }, offset: { x: mm(0), y: mm(5) },
size: { width: mm(16) } } },
] },
};
تأخذ صفحة الافتتاح سطرها التمهيدي من السمة kicker في العنوان، وتحجز 48 mm، وهي تكفي للعنوان وخطه مع بقاء المثال الأول في الصفحة 1.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 163 · Harmony textbook with ABC examples ═════════════
// https://postext.dev/en/cookbook/harmony-textbook-abc-examples
// Code: MIT · Text: original (CC BY 4.0) · Music: Greensleeves (traditional, PD)
// Fonts: Libre Caslon Text & Display, Libre Franklin (SIL OFL 1.1) · Needs postext ≥ 1.54.0
import {
buildDocumentWithFonts, renderPageToCanvas, initMusicEngine,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'harmony-textbook-abc-examples';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a conservatory green for the accents, warm ink for text and notes
const palette = {
ink: '#1f1c19', // text and notation: a warm near-black
accent: '#2f5d4f', // kickers, rules, Roman numerals in the table
tint: '#edf2ef', // the box of key terms
rule: '#c3cfc9', // hairlines
muted: '#5c6863', // running heads, colophon
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
// The engine's defaults link to main-color: point it at the accent, never the default blue.
{ id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion
const TRIM = { width: 180, height: 250 };
const MARGIN = { top: 22, bottom: 24, inner: 22, outer: 33 }; // a 125 mm measure
const LEAD = 14.5; // body leading in pt: the baseline grid
const LABEL = 'Libre Franklin';
// #region answer: one score style for every example in the text
// Each ```abc fence in the chapter is engraved at the width of the text column and cut
// into systems. The style is set once here; the Markdown only holds the notation.
const scoreStyle = {
staffSize: mm(5.5), // a textbook's rastral: examples read at arm's length on a desk
musicFont: 'Bravura', // the traditional engraved look, heavy enough beside Caslon
textFont: 'Libre Caslon Text', // the Roman numerals of `w:` lines, in the text face
spacing: 1.6, // air between the chords: an example reads as a progression, not a cluster
barNumbers: 'system',
systemGap: mm(4),
marginTop: pt(LEAD / 2),
marginBottom: pt(LEAD / 2),
color: col('ink'),
// A long example runs on into the next page between two systems, never leaving one
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#استعمل Leland لصفحة أخف
Leland، خط MuseScore، سيقانه أرق ورؤوس نوتاته أصغر من Bravura؛ ويناسب كتابًا منضدًا بخط نص خفيف.
- musicFont: 'Bravura',
+ musicFont: 'Leland',#اكتب صوتًا ثانيًا بصيغة أخرى
قارئ ABC يأخذ صوتًا واحدًا. ولكتابة السوبرانو والباص على مدرجين منفصلين، اكتب المثال بصيغة Humdrum أو MusicXML؛ منهج المعهد الموسيقي ينضد الكورالات الرباعية الأصوات بهذه الطريقة.
أخطاء شائعة
- اكتب مدة التآلف داخل الأقواس المعقوفة،
[B2d2g2]، أو اضبطL:على قيمة التآلف: المدة المكتوبة بعد القوس،[Bdg]2، تُقرأ على أنها المدة الافتراضية. - قارئ ABC في Verovio يعطي كل مقطع من سطر
w:للنوتة التالية ويتجاهل*و_، فلا يستطيع سطرw:تخطي نوتات. ولتعليم بضع مازورات، اكتب العلامات رموزًا للأكوردات فوق المدرج، كما يفعل مثال Greensleeves. - نادرًا ما يحتوي خط النص على علامتي ♯ و♭: اكتب «فا دييز» في النص، وإلا وضع المتصفح العلامة من خط من خطوط النظام.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- The chapter on cadences and its examples, written for this recipe · Ignacio Ferro · CC BY 4.0
- Greensleeves, English tune of the sixteenth century, in its common modern form · Traditional · ملك عام
- الخطوط
- Libre Caslon Text (SIL OFL 1.1) · Libre Caslon Display (SIL OFL 1.1) · Libre Franklin (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


