Spaces:
Running
Running
Commit ·
8f6ab9b
1
Parent(s): f65fe85
updated asset files.
Browse filesFiles changed (6)
- Dockerfile-3
- jison/lilypond.jisonAdded+2884
- jison/measureLayout.jisonAdded+253
- ly/articulate-lotus.lyAdded+1060
- ly/lotus.lyAdded+11
- ly/rhythmSymbols.lyAdded+8
23 unmodified lines24252627282930313223 unmodified lines# Copy the entire project including node_modulesCOPY . .# Remove .env.local if existsRUN rm -f .env.local# Set all environment variablesENV PORT=7860ENV HOST=0.0.0.023 unmodified lines24252627282923 unmodified lines# Copy the entire project including node_modulesCOPY . .# Set all environment variablesENV PORT=7860ENV HOST=0.0.0.0
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884
%{ const preferNumber = x => Number.isFinite(Number(x)) ? Number(x) : x;
const location = (begin, end) => ({proto: "_PLAIN", lines: [begin.first_line, end.last_line], columns: [begin.first_column, end.last_column]});
const commandSubProtos = { markup: "MarkupCommand", repeat: "Repeat", relative: "Relative", parallelMusic: "ParallelMusic", time: "TimeSignature", partial: "Partial", times: "Times", tuplet: "Tuplet", clef: "Clef", key: "KeySignature", ottava: "OctaveShift", include: "Include", version: "Version", lyricmode: "LyricMode", chordmode: "ChordMode", grace: "Grace", acciaccatura: "Grace", appoggiatura: "Grace", slashedGrace: "Grace", afterGrace: "AfterGrace", language: "Language", transposition: "Transposition", stemUp: "StemDirection", stemDown: "StemDirection", stemNeutral: "StemDirection", change: "Change", };
const root = (sections = []) => ({proto: "Root", sections});
const appendSection = (list, item) => { list.sections.push(item);
return list; };
const string = exp => ({proto: "LiteralString", exp});
const command = (cmd, ...args) => ({proto: commandSubProtos[cmd.substr(1)] || "Command", cmd: cmd.substr(1), args});
const variable = name => ({proto: "Variable", name: name.substr(1)});
const chord = (pitches, duration, {locations, post_events, ...options} = {}) => ({proto: "Chord", pitches, duration, post_events, _location: location(...locations), options: {...options, proto: "_PLAIN"}});
const rest = ({name, duration, post_events = null, locations}) => ({proto: "Rest", name, duration, post_events, _location: location(...locations)});
const chordElem = (pitch, {locations, ...options}) => ({proto: "ChordElement", pitch, _location: location(...locations), options: {...options, proto: "_PLAIN"}});
const briefChord = (body, {locations, post_events = null} = {}) => ({proto: "BriefChord", body: {...body, proto: "_PLAIN"}, post_events, _location: location(...locations)});
const block = (block, head, body = []) => ({proto: "Block", block, head, body});
const inlineBlock = body => ({proto: "InlineBlock", body});
const scheme = exp => ({proto: "Scheme", exp});
const schemeFunction = (func, args) => ({proto: "SchemeFunction", func, args});
const schemePair = (left, right) => ({proto: "SchemePair", left, right});
const schemePointer = value => ({proto: "SchemePointer", value});
const schemeEmbed = value => ({proto: "SchemeEmbed", value});
const assignment = (key, value) => ({proto: "Assignment", key, value});
const numberUnit = (number, unit) => ({proto: "NumberUnit", number: preferNumber(number), unit});
const musicBlock = body => ({proto: "MusicBlock", body});
const simultaneousList = list => ({proto: "SimultaneousList", list});
const contextedMusic = (head, body, lyrics) => ({proto: "ContextedMusic", head, body, lyrics});
const tempo = (beatsPerMinute, unit, text) => ({proto: "Tempo", beatsPerMinute: preferNumber(beatsPerMinute), unit: preferNumber(unit), text});
const postEvent = (direction, arg) => ({proto: "PostEvent", direction, arg});
const fingering = value => ({proto: "Fingering", value: preferNumber(value)});
const markup = (head, body) => ({proto: "Markup", head, body});
const lyric = (content, {locations, ...options}) => ({proto: "Lyric", content, _location: location(...locations), ...options});
const duration = ({number, dots, multipliers}) => ({proto: "Duration", number, dots, multipliers});
const comment = ({loc, ...data}) => ({proto: "Comment", _location: location(loc, loc), ...data});
let lineHeadTable = {}; let lineTailTable = {};
const lineHead = (loc, term) => { if (!term || typeof term !== "object") return;
if (!lineHeadTable[loc.first_line] || lineHeadTable[loc.first_line].column > loc.first_column) lineHeadTable[loc.first_line] = {column: loc.first_column, term}; };
const lineTail = (loc, term) => { if (!term || typeof term !== "object") return;
if (!lineTailTable[loc.last_line] || lineTailTable[loc.last_line].column < loc.last_column) lineTailTable[loc.last_line] = {column: loc.last_column, term}; };
const lineRegister = (loc, term) => { lineHead(loc, term); lineTail(loc, term); };
const attachComments = yy => { if (yy.$lotusComments && yy.$lotusComments.length > 0) { //console.log("attachComments:", yy.$lotusComments, lineTable); const headLineNumbers = Object.keys(lineHeadTable).map(Number);
yy.$lotusComments.forEach(data => { const comm = comment(data);
const tailLine = lineTailTable[data.loc.first_line]; if (tailLine) { tailLine.term._tailComment = comm; return; }
const line = headLineNumbers.find(line => line >= data.loc.last_line); if (Number.isFinite(line) && lineHeadTable[line]) { lineHeadTable[line].term._headComment = comm; return; }
// TODO: attach on root's tail }); }
// reset parser states lineHeadTable = {}; lineTailTable = {}; };%}
%lex
%option flex unicode
A [a-zA-Z\200-\377]AA {A}|_N [0-9]ANY_CHAR (.|\n)SYMBOL {A}([-_]{A}|{A})*COMMAND \\{SYMBOL}/* SPECIAL category is for every letter that needs to get passed to * the parser rather than being redefinable by the user */SPECIAL [-+*/=<>{}!?_^'',.:]SHORTHAND (.|\\.)UNSIGNED {N}+E_UNSIGNED \\{N}+FRACTION {N}+\/{N}+//INT [-]?{UNSIGNED}//REAL ({INT}\.{N}*)|([-]?\.{N}+)STRICTREAL {UNSIGNED}\.{UNSIGNED}WHITE [ \n\t\f\r]HORIZONTALWHITE [ \t]BLACK [^ \n\t\f\r]RESTNAME [rRs](?=[\W\d_])ESCAPED [nt\\''""]//EXTENDER \_\_//HYPHEN \-\-PRE_EXTENDER \_(?=\_)PRE_HYPHEN \-(?=\-)BOM_UTF8 \357\273\277
PHONET [abcdefgqh]PITCH {PHONET}(([i][s])*|([e][s])*|[s][e][s]|[s]*|[f]*)(?=[\W\d_])//PLACEHOLDER_PITCH [s](?=[\W\d_^-])//DURATION "1"|"2"|"4"|"8"|"16"|"32"|"64"|"128"|"256"
//UNICODE_HAN [\p{Script=Han}]
%%
// extra lex// TODO: parse the dollar expression details[$][(][^()]*[)] return 'DOLLAR_SCHEME_EXPRESSION'
\s+ {} // spaces\%\{(.|\n)*?\%\} yy.$lotusComments = yy.$lotusComments || []; yy.$lotusComments.push({text: yytext, loc: yylloc, scoped: true}); // scoped comments\%.* yy.$lotusComments = yy.$lotusComments || []; yy.$lotusComments.push({text: yytext, loc: yylloc}); // scoped comments\"(\\\"|[^"])*\" return 'STRING';
//{EXTENDER} return 'EXTENDER';//{HYPHEN} return 'HYPHEN';{PRE_EXTENDER} return 'PRE_EXTENDER';{PRE_HYPHEN} return 'PRE_HYPHEN';
//"/+" return CHORD_BASS;//"^" return CHORD_CARET;//":" return CHORD_COLON;//"-" return CHORD_MINUS;//"/" return CHORD_SLASH;
//"<" return 'ANGLE_OPEN';//">" return 'ANGLE_CLOSE';"<<" return 'DOUBLE_ANGLE_OPEN';">>" return 'DOUBLE_ANGLE_CLOSE';
"\\\\" return 'E_BACKSLASH';
{E_UNSIGNED} return 'E_UNSIGNED';
"\\new" return 'NEWCONTEXT';
"\\cm" return 'CENTIMETER';"\\mm" return 'MILLIMETER';
"\\overrideProperty" return 'OVERRIDEPROPERTY';
// binary commands"\\relative" return 'CMD_RELATIVE';"\\tweak" return 'CMD_TWEAK';"\\key" return 'CMD_KEY';//"\\times" return 'CMD_TIMES';[\\][t][i][m][e][s] return 'CMD_TIMES';"\\afterGrace" return 'CMD_AFTERGRACE';"\\parallelMusic" return 'CMD_PARALLELMUSIC';"\\shape" return 'CMD_SHAPE';"\\tag" return 'CMD_TAG';"\\scaleDurations" return 'CMD_SCALEDURATIONS';
// unitary commands"\\clef" return 'CMD_CLEF';"\\time" return 'CMD_TIME';"\\stemUp" return 'CMD_STEMUP';"\\stemDown" return 'CMD_STEMDOWN';"\\stemNeutral" return 'CMD_STEMNEUTRAL';"\\bar" return 'CMD_BAR';"\\omit" return 'CMD_OMIT';"\\ottava" return 'CMD_OTTAVA';"\\barNumberCheck" return 'CMD_BARNUMBERCHECK';"\\partial" return 'CMD_PARTIAL';"\\mark" return 'CMD_MARK';"\\include" return 'CMD_INCLUDE';"\\tupletSpan" return 'CMD_TUPLETSPAN';"\\tuplet" return 'CMD_TUPLET';"\\tupletNeutral" return 'CMD_TUPLETNEUTRAL';"\\skip" return 'CMD_SKIP';"\\skip"(?=\d) return 'CMD_SKIP';"\\parenthesize" return 'CMD_PARENTHESIZE';"\\unfoldRepeats" return 'CMD_UNFOLDREPEATS';"\\grace" return 'CMD_GRACE';"\\acciaccatura" return 'CMD_ACCIACCATURA';"\\appoggiatura" return 'CMD_APPOGGIATURA';"\\slashedGrace" return 'CMD_SLASHEDGRACE';"\\language" return 'CMD_LANGUAGE';"\\once" return 'CMD_ONCE';"\\accidentalStyle" return 'CMD_ACCIDENTALSTYLE';"\\numericTimeSignature" return 'CMD_NUMERICTIMESIGNATURE';"\\defaultTimeSignature" return 'CMD_DEFAULTTIMESIGNATURE';"\\bendAfter" return 'CMD_BENDAFTER';"\\compoundMeter" return 'CMD_COMPOUNDMETER';"\\transposition" return 'CMD_TRANSPOSITION';"\\absolute" return 'CMD_ABSOLUTE';"\\hide" return 'CMD_HIDE';"\\crossStaff" return 'CMD_CROSSSTAFF';"\\keepWithTag" return 'CMD_KEEPWITHTAG';"\\articulate" return 'CMD_ARTICULATE';
// zero commands"\\tempoLegend" return 'CMD_TEMPOLEGEND';"\\fermata" return 'CMD_FERMATA';"\\mergeDifferentlyDottedOn" return 'CMD_MERGEDIFFERENTLYDOTTEDON';"\\mergeDifferentlyHeadedOn" return 'CMD_MERGEDIFFERENTLYHEADEDON';"\\voiceOne" return 'CMD_VOICE_NUMBER';"\\voiceTwo" return 'CMD_VOICE_NUMBER';"\\voiceThree" return 'CMD_VOICE_NUMBER';"\\voiceFour" return 'CMD_VOICE_NUMBER';//"\\voiceFive" return 'CMD_VOICE_NUMBER';"\\Score" return 'CMD_SCORE';"\\Voice" return 'CMD_VOICE';"\\Staff" return 'CMD_STAFF';"\\PianoStaff" return 'CMD_PIANOSTAFF';"\\arpeggio" return 'CMD_ARPEGGIO';"\\arpeggioArrowDown" return 'CMD_ARPEGGIOARROWDOWN';"\\arpeggioArrowUp" return 'CMD_ARPEGGIOARROWUP';"\\arpeggioNormal" return 'CMD_ARPEGGIONORMAL';"\\arpeggioBracket" return 'CMD_ARPEGGIOBRACKET';"\\arpeggioParenthesis" return 'CMD_ARPEGGIOPARENTHESIS';"\\arpeggioParenthesisDashed" return 'CMD_ARPEGGIOPARENTHESISDASHED';"\\glissando" return 'CMD_GLISSANDO';"\\mordent" return 'CMD_MORDENT';"\\musicglyph" return 'CMD_MUSICGLYPH';"\\powerChords" return 'CMD_POWERCHORDS';"\\prall" return 'CMD_PRALL';"\\sustainOff" return 'CMD_SUSTAINOFF';"\\sustainOn" return 'CMD_SUSTAINON';"\\trill" return 'CMD_TRILL';"\\turn" return 'CMD_TURN';"\\pointAndClickOff" return 'CMD_POINTANDCLICKOFF';"\\upbow" return 'CMD_UPBOW';"\\downbow" return 'CMD_DOWNBOW';"\\breathe" return 'CMD_BREATHE';"\\startTextSpan" return 'CMD_STARTTEXTSPAN';"\\stopTextSpan" return 'CMD_STOPTEXTSPAN';"\\flageolet" return 'CMD_FLAGEOLET';"\\slurDashed" return 'CMD_SLURDASHED';"\\slurSolid" return 'CMD_SLURSOLID';"\\break" return 'CMD_BREAK';"\\pageBreak" return 'CMD_PAGEBREAK';"\\startTrillSpan" return 'CMD_STARTTRILLSPAN';"\\stopTrillSpan" return 'CMD_STOPTRILLSPAN';"\\cadenzaOn" return 'CMD_CADENZAON';"\\cadenzaOff" return 'CMD_CADENZAOFF';"\\cresc" return 'CMD_CRESC';"\\crescTextCresc" return 'CMD_CRESCTEXTCRESC';"\\crescHairpin" return 'CMD_CRESCHAIRPIN';"\\dim"(?=[\W]) return 'CMD_DIM';"\\dimTextDim" return 'CMD_DIMTEXTDIM';"\\dynamicUp" return 'CMD_DYNAMICUP';"\\hideNotes" return 'CMD_HIDENOTES';"\\unHideNotes" return 'CMD_UNHIDENOTES';"\\newSpacingSection" return 'CMD_NEWSPACINGSECTION';"\\noBeam" return 'CMD_NOBEAM';"\\oneVoice" return 'CMD_ONEVOICE';"\\phrasingSlurDown" return 'CMD_PHRASINGSLURDOWN';"\\phrasingSlurNeutral" return 'CMD_PHRASINGSLURNEUTRAL';"\\phrasingSlurUp" return 'CMD_PHRASINGSLURUP';"\\slurDown" return 'CMD_SLURDOWN';"\\slurNeutral" return 'CMD_SLURNEUTRAL';"\\slurUp" return 'CMD_SLURUP';"\\tieDown" return 'CMD_TIEDOWN';"\\tieNeutral" return 'CMD_TIENEUTRAL';"\\tieUp" return 'CMD_TIEUP';"\\tupletUp" return 'CMD_TUPLETUP';"\\tupletDown" return 'CMD_TUPLETDOWN';"\\shiftOn" return 'CMD_SHIFTON';"\\repeatTie" return 'CMD_REPEATTIE';"\\marcato" return 'CMD_MARCATO';"\\stopped" return 'CMD_STOPPED';"\\tenuto" return 'CMD_TENUTO';"\\staccatissimo" return 'CMD_STACCATISSIMO';"\\accent" return 'CMD_ACCENT';"\\staccato" return 'CMD_STACCATO';"\\portato" return 'CMD_PORTATO';
"\\mp"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\mf"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\"[p]+(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\"[f]+(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\sf"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\sff"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\sfp"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\sfpp"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\fp"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\mfp"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\rf"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\rfz"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\sfz"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\sffz"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\fz"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\fzp"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\ffz"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';"\\ppz"(?=[\W]) return 'CMD_DYNAMIC_MARKINGS';
"\\breve" return 'CMD_BREVE';"\\longa" return 'CMD_LONGA';
// markup commands "\\version" return 'CMD_VERSION';"\\column" return 'CMD_COLUMN';"\\line" return 'CMD_LINE';"\\bold" return 'CMD_BOLD';"\\italic" return 'CMD_ITALIC';"\\box" return 'CMD_BOX';"\\whiteout" return 'CMD_WHITEOUT';"\\dynamic" return 'CMD_DYNAMIC';"\\abs-fontsize" return 'CMD_ABS_FONTSIZE';"\\with-color" return 'CMD_WITH_COLOR';"\\char" return 'CMD_CHAR';"\\center-column" return 'CMD_CENTER_COLUMN';"\\right-column" return 'CMD_RIGHT_COLUMN';"\\with-url" return 'CMD_WITH_URL';"\\sans" return 'CMD_SANS';"\\concat" return 'CMD_CONCAT';"\\maintainer" return 'CMD_MAINTAINER';"\\footnote" return 'CMD_FOOTNOTE';"\\natural" return 'CMD_NATURAL';"\\flat" return 'CMD_FLAT';"\\sharp" return 'CMD_SHARP';"\\hspace" return 'CMD_HSPACE';"\\footer" return 'CMD_FOOTER';"\\center-align" return 'CMD_CENTER_ALIGN';"\\right-align" return 'CMD_RIGHT_ALIGN';"\\general-align" return 'CMD_GENERAL_ALIGN';"\\lower" return 'CMD_LOWER';"\\finger" return 'CMD_FINGER';"\\fontsize" return 'CMD_FONTSIZE';"\\raise" return 'CMD_RAISE';"\\note" return 'CMD_NOTE';"\\circle" return 'CMD_CIRCLE';"\\pad-markup" return 'CMD_PAD_MARKUP';"\\smaller" return 'CMD_SMALLER';"\\normal-text" return 'CMD_NORMAL_TEXT';
"\\huge" return 'CMD_HUGE';"\\large" return 'CMD_LARGE';"\\normalsize" return 'CMD_NORMALSIZE';"\\small" return 'CMD_SMALL';"\\tiny" return 'CMD_TINY';"\\teeny" return 'CMD_TEENY';"\\medium" return 'CMD_MEDIUM';
// syntax commands "\\header" return 'HEADER';"\\markup" return 'MARKUP';"\\markuplist" return 'MARKUPLIST';"\\repeat" return 'REPEAT';"\\context" return 'CONTEXT';"\\accepts" return 'ACCEPTS';"\\addlyrics" return 'ADDLYRICS';"\\alias" return 'ALIAS';"\\alternative" return 'ALTERNATIVE';"\\book" return 'BOOK';"\\bookpart" return 'BOOKPART';"\\change" return 'CHANGE';"\\chordmode" return 'CHORDMODE';"\\chords" return 'CHORDS';"\\consists" return 'CONSISTS';"\\default" return 'DEFAULT';"\\defaultchild" return 'DEFAULTCHILD';"\\denies" return 'DENIES';"\\description" return 'DESCRIPTION';"\\drummode" return 'DRUMMODE';"\\drums" return 'DRUMS';"\\etc" return 'ETC';"\\figuremode" return 'FIGUREMODE';"\\figures" return 'FIGURES';"\\version-error" return 'INVALID';"\\layout" return 'LAYOUT';"\\lyricmode" return 'LYRICMODE';"\\lyrics" return 'LYRICS';"\\lyricsto" return 'LYRICSTO';"\\midi" return 'MIDI';"\\name" return 'NAME';"\\notemode" return 'NOTEMODE';"\\override" return 'OVERRIDE';"\\paper" return 'PAPER';"\\remove" return 'REMOVE';"\\rest" return 'REST';"\\revert" return 'REVERT';"\\score" return 'SCORE';"\\score-lines" return 'SCORELINES';"\\sequential" return 'SEQUENTIAL';"\\set" return 'SET';"\\simultaneous" return 'SIMULTANEOUS';"\\tempo" return 'TEMPO';"\\type" return 'TYPE';"\\unset" return 'UNSET';"\\with" return 'WITH';
// simple commands"\\<" return 'CMD_CRESCENDO_BEGIN';"\\>" return 'CMD_DECRESCENDO_BEGIN';"\\!" return 'CMD_DYNAMICS_END';
{COMMAND} return 'COMMAND';
{PITCH} return 'PITCH';//{PLACEHOLDER_PITCH} return 'PLACEHOLDER_PITCH';//{UNSIGNED} return 'POST_UNSIGNED';{RESTNAME} return 'RESTNAME';
{FRACTION} return 'FRACTION';//{REAL} return 'REAL';{UNSIGNED} return 'UNSIGNED';
//{INT} return 'INT';
// CHORD_MODIFIER[m][a][j](?=[\W\d]) return 'CHORD_MODIFIER_WORD';m(?=[\W\d]) return 'CHORD_MODIFIER_WORD';[a][u][g](?=[\W\d]) return 'CHORD_MODIFIER_WORD';[d][i][m](?=[\W\d]) return 'CHORD_MODIFIER_WORD';[s][u][s](?=[\W\d]) return 'CHORD_MODIFIER_WORD';
"inf.0" return yytext;
{SYMBOL} return 'SYMBOL';
"#f" return 'SCM_FALSE';"#t" return 'SCM_TRUE';
"#x"[\da-fA-F]+ return 'SCM_HEX';
"#:"{SYMBOL} return 'SCM_COLON';
"\\(" return yytext;"\\)" return yytext;
\.(?=\d) return 'DOT_NUMBER_R';//(?<=\d)\. return 'DOT_NUMBER_L';
{SPECIAL} return yytext;\| return 'DIVIDE';
[()] return yytext;
"[" return yytext;"]" return yytext;
"#" return yytext;"~" return yytext;"`" return yytext;
. return 'UNKNOWN_CHAR';
<<EOF>> return 'EOF';
/lex
%start start_symbol
%%
start_symbol : lilypond EOF { attachComments(yy); return $1; } //| embedded_lilypond ;
lilypond : %empty {$$ = root();} | version {$$ = root([$1]); lineRegister(@1, $1);} | lilypond toplevel_expression {$$ = appendSection($1, $2); lineRegister(@2, $2);} | lilypond assignment {$$ = appendSection($1, $2); lineRegister(@2, $2);} ;
version : CMD_VERSION literal_string {$$ = command($1, $2);} ;
toplevel_expression : header_block {$$ = $1;} | composite_music {$$ = $1;} | full_markup {$$ = $1;} | output_def {$$ = $1;} | score_block {$$ = $1;} | book_block {$$ = $1;} | scm_identifier {$$ = $1;} //| full_markup_list // {$$ = $1;} //| bookpart_block //| BOOK_IDENTIFIER //| SCM_TOKEN //| embedded_scm_active ;
score_block : SCORE '{' score_body '}' {$$ = block("score", $1, $3);} ;
book_block : BOOK '{' book_body '}' {$$ = block("book", $1, $3);} ;
book_body : %empty {$$ = [];} //| BOOK_IDENTIFIER | book_body paper_block {$$.push($2);} //| book_body bookpart_block // {$$.push($2);} | book_body score_block {$$.push($2);} | book_body composite_music {$$.push($2);} | book_body full_markup {$$.push($2);} | book_body full_markup_list {$$.push($2);} //| book_body SCM_TOKEN | book_body embedded_scm_active {$$.push($2);} | book_body lilypond_header {$$.push($2);} //| book_body error ;
paper_block : output_def {$$ = $1;} ;
header_block : lilypond_header {$$ = $1;} ;
lilypond_header : HEADER '{' lilypond_header_body '}' {$$ = block("header", $1, $3);} ;
lilypond_header_body : %empty {$$ = [];} | lilypond_header_body assignment {$$.push($2); lineRegister(@2, $2);} //| lilypond_header_body SCM_TOKEN //| lilypond_header_body embedded_scm_active ;
assignment : assignment_id '=' identifier_init {$$ = assignment($1, $3);} | assignment_id '.' property_path '=' identifier_init {$$ = assignment($1 + "." + $3, $5);} //| markup_mode_word '=' identifier_init ;
assignment_id : literal_string {$$ = $1;} | SYMBOL {$$ = $1;} // extra formula | PITCH {$$ = $1;} // extra formula | CHORD_MODIFIER_WORD {$$ = $1;} ;
property_path : symbol_list_rev {$$ = $1;} ;
symbol_list_rev : symbol_list_part {$$ = $1;} | symbol_list_rev '.' symbol_list_part {$$ = $1 + "." + $3;} | symbol_list_rev ',' symbol_list_part {$$ = $1 + "," + $3;} ;
symbol_list_part : symbol_list_part_bare {$$ = $1;} | embedded_scm_bare {$$ = $1;} ;
symbol_list_part_bare : SYMBOL {$$ = $1;} | symbol_list_element {$$ = $1;} ;
symbol_list_element : literal_string {$$ = $1;} | UNSIGNED {$$ = $1;} ;
identifier_init : identifier_init_nonumber {$$ = $1;} | number_expression {$$ = $1;} //| symbol_list_part_bare '.' property_path // {$$ = $1 + "." + $3;} //| symbol_list_part_bare ',' property_path // {$$ = $1 + "," + $3;} | post_event_nofinger post_events {$$ = [$1, $2];} ;
number_expression : number_expression '+' number_term | number_expression '-' number_term | number_term ;
number_term : number_factor | number_factor '*' number_factor | number_factor '/' number_factor ;
number_factor : '-' number_factor | bare_number ;
identifier_init_nonumber : header_block {$$ = $1;} | music_assign {$$ = $1;} //| full_markup_list // {$$ = $1;} | string {$$ = $1;} | pitch_or_music {$$ = $1;} | FRACTION {$$ = $1;} | embedded_scm {$$ = $1;} | score_block {$$ = $1;} | output_def {$$ = $1;} | context_modification {$$ = $1;} | book_block {$$ = $1;} //| bookpart_block //| context_def_spec_block //| partial_markup //| partial_function ETC ;
string : literal_string {$$ = $1;} | SYMBOL {$$ = $1;} | full_markup {$$ = $1;} ;
text : literal_string {$$ = $1;} | SYMBOL {$$ = $1;} | full_markup {$$ = $1;} | embedded_scm_bare {$$ = $1;} ;
full_markup_list : MARKUPLIST {$$ = $1;} | markup_list {$$ = $1;} ;
markup_list : markup_composed_list {$$ = $1;} | markup_uncomposed_list {$$ = [$1];} ;
markup_composed_list : markup_head_1_list markup_uncomposed_list //{$$ = block("markup", $1, $2);} {$$ = [...$1, $2];} ;
markup_head_1_list : markup_head_1_item {$$ = [$1];} | markup_head_1_list markup_head_1_item {$$ = $1.concat([$2]);} ;
markup_head_1_item //: markup_function EXPECT_MARKUP markup_command_list_arguments //: markup_function markup_command_list_arguments // {$$ = {func: $1, args: $2};} : markup_function //{$$ = {func: $1};} {$$ = $1;} ;
// equivalent for MARKUP_FUNCTION in lilypond's parser.yymarkup_function //: CMD_COLUMN // {$$ = $1;} : CMD_LINE {$$ = $1;} //| CMD_BOLD // {$$ = $1;} //| CMD_ITALIC // {$$ = $1;} //| markup_font_size // {$$ = $1;} | CMD_BOX {$$ = $1;} | CMD_WHITEOUT {$$ = $1;} | CMD_DYNAMIC {$$ = $1;} //| CMD_CENTER_COLUMN // {$$ = $1;} //| CMD_WITH_URL // {$$ = $1;} //| CMD_SANS // {$$ = $1;} //| CMD_CONCAT // {$$ = $1;} | CMD_MAINTAINER {$$ = $1;} ;
// extra syntaxmarkup_font_size : CMD_HUGE {$$ = $1;} | CMD_LARGE {$$ = $1;} | CMD_NORMALSIZE {$$ = $1;} | CMD_SMALL {$$ = $1;} | CMD_TINY {$$ = $1;} | CMD_TEENY {$$ = $1;} | CMD_MEDIUM {$$ = $1;} ;
markup_uncomposed_list : markup_braced_list {$$ = $1;} //| markup_command_list //| markup_scm MARKUPLIST_IDENTIFIER //| SCORELINES '{' score_body '}' ;
markup_braced_list : '{' markup_braced_list_body '}' {$$ = inlineBlock($2);} ;
markup_braced_list_body : %empty {$$ = [];} | markup_braced_list_body markup {$$ = $1.concat([$2]);} | markup_braced_list_body markup_list {$$ = $1.concat($2);} ;
markup : markup_head_1_list simple_markup //{$$ = $1.concat([$2]);} {$$ = markup($1, $2);} | simple_markup {$$ = $1;} ;
simple_markup : markup_word {$$ = $1;} | simple_markup_noword {$$ = $1;} ;
markup_word : literal_string {$$ = $1;} | SYMBOL {$$ = $1;} | unsigned_number {$$ = $1;} | CMD_MUSICGLYPH {$$ = command($1);} | CMD_NATURAL {$$ = $1;} | CMD_FLAT {$$ = $1;} | CMD_SHARP {$$ = $1;} | CMD_FOOTER {$$ = $1;} | scm_identifier {$$ = $1;} // extra formula | music_property_def {$$ = $1;} | context_change {$$ = $1;} | pitch_mode_music {$$ = $1;} // extra formula | PITCH {$$ = $1;} // extra formula | REAL {$$ = $1;} // extra formula | INT {$$ = $1;} // extra formula | general_text {$$ = $1;} ;
// extra syntaxlong_extender : PRE_EXTENDER "_" {$$ = $1 + $2} | PRE_EXTENDER long_extender {$$ = $1 + $2} ;
// extra syntaxgeneral_text : CHORD_MODIFIER_WORD {$$ = $1;} | "." {$$ = $1;} | "-" {$$ = $1;} | "_" {$$ = $1;} | PRE_HYPHEN {$$ = $1;} | long_extender {$$ = $1;} | "=" {$$ = $1;} | "'" {$$ = $1;} | "," {$$ = $1;} | ":" {$$ = $1;} | "/" {$$ = $1;} | "(" {$$ = $1;} | ")" {$$ = $1;} | "*" {$$ = $1;} | "~" {$$ = $1;} | "!" {$$ = $1;} | "?" {$$ = $1;} | UNKNOWN_CHAR {$$ = $1;} //| PLACEHOLDER_PITCH // {$$ = $1;} | RESTNAME {$$ = $1;} ;
simple_markup_noword : SCORE '{' score_body '}' //{$$ = {score: $3};} {$$ = block("score", $1, $3);} | markup_function markup_command_basic_arguments //{$$ = {func: $1, args: $2};} {$$ = command($1, ...$2);} //| markup_scm MARKUP_IDENTIFIER // extra formula | OVERRIDE scm_identifier {$$ = command($1, $2);} // extra formula | CMD_ABS_FONTSIZE scm_identifier markup {$$ = command($1, $2, $3);} // extra formula | CMD_ABS_FONTSIZE scm_identifier markup_list {$$ = command($1, $2, ...$3);} // extra formula | CMD_WITH_COLOR scm_identifier markup {$$ = command($1, $2, $3);} // extra formula | CMD_CHAR scm_identifier {$$ = command($1, $2);} // extra formula | CMD_HSPACE scm_identifier {$$ = command($1, $2);} // extra formula | CMD_SANS markup {$$ = command($1, $2);} // extra formula | CMD_SANS markup_list {$$ = command($1, ...$2);} // extra formula | CMD_CONCAT markup_list {$$ = command($1, ...$2);} // extra formula | CMD_COLUMN markup_list {$$ = command($1, ...$2);} // extra formula | CMD_CENTER_COLUMN markup_list {$$ = command($1, ...$2);} // extra formula | CMD_RIGHT_COLUMN markup_list {$$ = command($1, ...$2);} // extra formula | CMD_FOOTNOTE string string {$$ = command($1, $2, $3);} // extra formula | CMD_WITH_URL scalar string {$$ = command($1, $2, $3);} // extra formula | CMD_WITH_URL scalar markup_list {$$ = command($1, $2, ...$3);} // extra formula | CMD_BOLD markup_list {$$ = command($1, ...$2);} // extra formula | CMD_BOLD markup {$$ = command($1, $2);} // extra formula | markup_font_size markup {$$ = command($1, $2);} // extra formula | markup_font_size markup_list {$$ = command($1, ...$2);} // extra formula | CMD_ITALIC markup {$$ = command($1, $2);} // extra formula | CMD_ITALIC markup_list {$$ = command($1, ...$2);} // extra formula | CMD_CENTER_ALIGN markup_list {$$ = command($1, ...$2);} // extra formula | CMD_CENTER_ALIGN markup {$$ = command($1, $2);} // extra formula | CMD_RIGHT_ALIGN markup_list {$$ = command($1, ...$2);} // extra formula | CMD_RIGHT_ALIGN markup {$$ = command($1, $2);} // extra formula | CMD_GENERAL_ALIGN scm_identifier scm_identifier markup {$$ = command($1, $2, $3, $4);} // extra formula | CMD_LOWER scm_identifier {$$ = command($1, $2);} // extra formula | CMD_FINGER string {$$ = command($1, $2);} // extra formula | CMD_FONTSIZE scm_identifier markup {$$ = command($1, $2, $3);} // extra formula | CMD_FONTSIZE scm_identifier markup_list {$$ = command($1, $2, $3);} // extra formula | CMD_RAISE scm_identifier {$$ = command($1, $2);} // extra formula | CMD_NOTE scm_identifier scm_identifier markup {$$ = command($1, $2, $3, $4);} // extra formula | CMD_CIRCLE markup_list {$$ = command($1, ...$2);} // extra formula | CMD_CIRCLE markup {$$ = command($1, $2);} // extra formula | CMD_PAD_MARKUP scm_identifier {$$ = command($1, $2);} // extra formula | CMD_SMALLER markup {$$ = command($1, $2);} // extra formula | CMD_NORMAL_TEXT markup {$$ = command($1, $2);} ;
markup_command_basic_arguments : %emtpy {$$ = [];} | /*EXPECT_MARKUP_LIST*/ markup_command_list_arguments markup_list {$$ = $1.concat($2);} | /*EXPECT_SCM*/ markup_command_list_arguments markup_command_embedded_lilypond {$$ = $1.concat($2);} //| EXPECT_SCM markup_command_list_arguments embedded_scm //| EXPECT_SCM markup_command_list_arguments mode_changed_music //| EXPECT_SCM markup_command_list_arguments MUSIC_IDENTIFIER //| EXPECT_SCM markup_command_list_arguments literal_string //| EXPECT_NO_MORE_ARGS ;
markup_command_list_arguments : markup_command_basic_arguments {$$ = [$1];} | /*EXPECT_MARKUP*/ markup_command_list_arguments markup {$$ = $1.concat($2);} ;
markup_command_embedded_lilypond : '{' embedded_lilypond '}' {$$ = $2;} ;
embedded_lilypond : %empty {$$ = $1;} | identifier_init_nonumber {$$ = $1;} | embedded_lilypond_number {$$ = $1;} | post_event {$$ = $1;} //| duration post_events %prec ':' | music_embedded music_embedded music_list {$$ = [$1, $2, $3];} //| error //| INVALID embedded_lilypond ;
embedded_lilypond_number : '-' embedded_lilypond_number {$$ = -$1;} | bare_number_common {$$ = $1;} //| UNSIGNED NUMBER_IDENTIFIER ;
bare_number_common : REAL {$$ = Number($1);} //| NUMBER_IDENTIFIER //| REAL NUMBER_IDENTIFIER | number_identifier {$$ = $1;} | FRACTION {$$ = $1;} ;
// extra syntaxdot : "." {$$ = $1;} | DOT_NUMBER_R {$$ = $1;} ;
INT : UNSIGNED {$$ = Number($1);} | "-" UNSIGNED {$$ = -Number($2);} ;
// extra syntaxpositive_real : UNSIGNED DOT_NUMBER_R UNSIGNED {$$ = Number($1 + $2 + $3);} //| UNSIGNED DOT_NUMBER_L // {$$ = Number($1 + $2);} | DOT_NUMBER_R UNSIGNED {$$ = Number($1 + $2);} ;
REAL : positive_real {$$ = $1;} | "-" positive_real {$$ = -$2;} ;
// equivalent for NUMBER_IDENTIFIER in lilypond's parser.yynumber_identifier : REAL number_unit {$$ = numberUnit($1, $2);} //| INT number_unit // {$$ = numberUnit($1, $2);} | UNSIGNED number_unit {$$ = numberUnit($1, $2);} ;
// addon term to construct number_identifiernumber_unit : CENTIMETER {$$ = $1;} | MILLIMETER {$$ = $1;} ;
score_body : score_items {$$ = $1;} //| score_body error ;
score_items : %empty {$$ = [];} | score_items score_item {$$ = $1.concat([$2]); lineHead(@2, $2);} | score_items lilypond_header {$$ = $1.concat([$2]); lineHead(@2, $2);} ;
score_item : music {$$ = $1;} | output_def {$$ = $1;} //: embedded_scm ;
//markup_command_list// : MARKUP_LIST_FUNCTION markup_command_list_arguments// ;
markup_scm : embedded_scm {$$ = $1;} ;
embedded_scm : embedded_scm_bare {$$ = $1;} //| scm_function_call //| lookup ;
scm_function_call : SCM_FUNCTION function_arglist ;
function_arglist : function_arglist_nonbackup {$$ = $1;} //| EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT ;
function_arglist_nonbackup : function_arglist_common //| EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup post_event_nofinger //| EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup '-' UNSIGNED //| EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup '-' REAL //| EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup '-' NUMBER_IDENTIFIER //| EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg //| EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup bare_number_common | function_arglist_nonbackup_reparse REPARSE pitch_or_music | function_arglist_nonbackup_reparse REPARSE duration | function_arglist_nonbackup_reparse REPARSE reparsed_rhythm | function_arglist_nonbackup_reparse REPARSE bare_number_common | function_arglist_nonbackup_reparse REPARSE SCM_ARG | function_arglist_nonbackup_reparse REPARSE lyric_element_music | function_arglist_nonbackup_reparse REPARSE symbol_list_arg ;
function_arglist_common //: EXPECT_NO_MORE_ARGS : %empty //| EXPECT_SCM function_arglist_optional embedded_scm_arg //| EXPECT_SCM function_arglist_optional bare_number_common //| EXPECT_SCM function_arglist_optional post_event_nofinger //| EXPECT_SCM function_arglist_optional '-' NUMBER_IDENTIFIER | function_arglist_common_reparse REPARSE SCM_ARG | function_arglist_common_reparse REPARSE lyric_element_music | function_arglist_common_reparse REPARSE pitch_or_music | function_arglist_common_reparse REPARSE bare_number_common | function_arglist_common_reparse REPARSE duration | function_arglist_common_reparse REPARSE reparsed_rhythm | function_arglist_common_reparse REPARSE symbol_list_arg ;
lookup : LOOKUP_IDENTIFIER {$$ = $1;} | LOOKUP_IDENTIFIER '.' symbol_list_rev {$$ = $1 + "." + $2;} ;
symbol_list_part : symbol_list_part_bare {$$ = $1;} | embedded_scm_bare {$$ = $1;} ;
embedded_scm_bare //: SCM_TOKEN //| SCM_IDENTIFIER : scm_identifier {$$ = $1;} ;
// equivalent for SCM_IDENTIFIER in lilypond parser.yyscm_identifier //: SCM_FALSE // {$$ = scheme(false);} //| SCM_TRUE // {$$ = scheme(true);} //| SCM_INT // {$$ = scheme($1.substr(1));} //| "#" "'" SYMBOL // {$$ = scheme("'" + $3);} : "#" scheme_expression {$$ = scheme($2);} | DOLLAR_SCHEME_EXPRESSION {$$ = $1;} ;
composite_music : basic_music {$$ = $1;} | contexted_basic_music {$$ = $1;} //| basic_music new_lyrics ;
contexted_basic_music : context_prefix contextable_music new_lyrics {$$ = contextedMusic($1, $2, $3);} | context_prefix contextable_music {$$ = contextedMusic($1, $2);} | context_prefix contexted_basic_music {$$ = contextedMusic($1, $2);} ;
contextable_music : basic_music {$$ = $1;} | pitch_as_music {$$ = $1;} | event_chord {$$ = $1;} // extra formula | variable_command {$$ = $1;} ;
new_lyrics : ADDLYRICS optional_context_mods lyric_mode_music {$$ = [{addLyrics: $3, mods: $2}];} | new_lyrics ADDLYRICS optional_context_mods lyric_mode_music {$$ = $1.concat([{addLyrics: $4, mods: $3}]);} ;
lyric_mode_music : grouped_music_list {$$ = $1;} //| MUSIC_IDENTIFIER | music_identifier {$$ = $1;} ;
context_prefix : CONTEXT symbol optional_id optional_context_mods //{$$ = {context: $2, assign: $3, mods: $4};} {$$ = command($1, $2, $3, ...$4);} | NEWCONTEXT symbol optional_id optional_context_mods //{$$ = {context: $2, new: true, assign: $3, mods: $4};} {$$ = command($1, $2, $3, ...$4);} ;
optional_id : %empty {$$ = null;} | '=' simple_string {$$ = assignment(null, $2);} ;
optional_context_mods : context_modification_mods_list {$$ = $1;} ;
context_modification_mods_list : %empty {$$ = [];} | context_modification_mods_list context_modification {$$ = $1.concat($2);} ;
basic_music : repeated_music {$$ = $1;} | music_bare {$$ = $1;} | LYRICSTO simple_string lyric_mode_music {$$ = command($1, $2, $3);} | LYRICSTO symbol '=' simple_string lyric_mode_music {$$ = command($1, assignment($2, $4), $5);} ;
music_bare : grouped_music_list {$$ = $1;} | music_identifier {$$ = $1;} | mode_changed_music {$$ = $1;} ;
mode_changed_music : mode_changing_head grouped_music_list {$$ = command($1, $2);} | mode_changing_head_with_context optional_context_mods grouped_music_list {$$ = command($1, ...$2, $3);} // extra formula | CHORDMODE chordmode_braced_music_list {$$ = command($1, $2);} // extra formula | LYRICMODE lyricmode_braced_music_list {$$ = command($1, $2);} ;
// extra syntaxlyricmode_braced_music_list : '{' lyricmode_music_list '}' {$$ = musicBlock($2);} ;
// extra syntaxlyricmode_music_list : %empty {$$ = [];} | lyricmode_music_list lyricmode_music {$$ = $1.concat([$2]);} ;
// extra syntaxlyricmode_music : lyric_element_music {$$ = $1;} //| music_assign // {$$ = $1;} | music_property_def {$$ = $1;} | lyricmode_music_identifier {$$ = $1;} | lyricmode_repeated_music {$$ = $1;} | lyricmode_braced_music_list {$$ = $1;} ;
// extra syntaxlyricmode_music_identifier : zero_command {$$ = $1;} | CMD_TIME FRACTION {$$ = command($1, $2);} | CMD_BAR string {$$ = command($1, $2);} | CMD_OMIT property_path {$$ = command($1, $2);} | CMD_OTTAVA property_path {$$ = command($1, $2);} | CMD_BARNUMBERCHECK scm_identifier {$$ = command($1, $2);} | CMD_BARNUMBERCHECK unsigned_number {$$ = command($1, $2);} | CMD_MARK full_markup {$$ = command($1, $2);} | CMD_SKIP duration {$$ = command($1, $2);} | CMD_UNFOLDREPEATS lyricmode_music {$$ = command($1, $2);} | CMD_ONCE music_assign {$$ = command($1, $2);} | CMD_PARTIAL duration {$$ = command($1, $2);} | CMD_TUPLETSPAN duration {$$ = command($1, $2);} | CMD_TUPLETSPAN DEFAULT {$$ = command($1, $2);} | CMD_TUPLET FRACTION lyricmode_music {$$ = command($1, $2, $3);} | CMD_TUPLET FRACTION duration lyricmode_music {$$ = command($1, $2, $3, $4);} | CMD_TWEAK property_path scalar {$$ = command($1, $2, $3);} | CMD_TIMES FRACTION lyricmode_music {$$ = command($1, $2, $3);} | CMD_SHAPE scm_identifier symbol {$$ = command($1, $2, $3);} | CMD_ACCIDENTALSTYLE grob_prop_spec {$$ = command($1, $2);} | CMD_NUMERICTIMESIGNATURE lyricmode_music_identifier {$$ = command($1, $2);} | CMD_DEFAULTTIMESIGNATURE {$$ = command($1);} | CMD_BENDAFTER scm_identifier {$$ = command($1, $2);} | CMD_COMPOUNDMETER scm_identifier {$$ = command($1, $2);} ;
// extra syntaxlyricmode_repeated_music : REPEAT simple_string unsigned_number lyricmode_braced_music_list {$$ = command($1, $2, $3, $4);} | REPEAT simple_string unsigned_number lyricmode_braced_music_list ALTERNATIVE lyricmode_braced_music_list {$$ = command($1, $2, $3, $4, command($5, $6));} ;
// extra syntaxchordmode_braced_music_list : '{' chordmode_music_list '}' {$$ = musicBlock($2);} ;
// extra syntaxchordmode_music_list : %empty {$$ = [];} | chordmode_music_list chordmode_music {$$ = $1.concat([$2]);} ;
// extra syntaxchordmode_music : new_chord post_events {$$ = briefChord($1, {post_events: $2, locations: [@1, @2]});} | music_assign {$$ = $1;} | chordmode_repeated_music {$$ = $1;} | chordmode_braced_music_list {$$ = $1;} ;
// extra syntaxchordmode_repeated_music : REPEAT simple_string unsigned_number chordmode_braced_music_list {$$ = command($1, $2, $3, $4);} | REPEAT simple_string unsigned_number chordmode_braced_music_list ALTERNATIVE chordmode_braced_music_list {$$ = command($1, $2, $3, $4, command($5, $6));} ;
mode_changing_head_with_context : DRUMS {$$ = $1;} | FIGURES {$$ = $1;} | CHORDS {$$ = $1;} | LYRICS {$$ = $1;} ;
mode_changing_head : NOTEMODE {$$ = $1;} | DRUMMODE {$$ = $1;} | FIGUREMODE {$$ = $1;} //| CHORDMODE // {$$ = $1;} //| LYRICMODE // {$$ = $1;} ;
grouped_music_list : sequential_music {$$ = $1;} | simultaneous_music {$$ = $1;} ;
simultaneous_music : SIMULTANEOUS braced_music_list {$$ = command($1, $2);} //| DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE // {$$ = simultaneousList($2);} | DOUBLE_ANGLE_OPEN multiple_voices_music_list DOUBLE_ANGLE_CLOSE {$$ = simultaneousList($2);} ;
// extra syntaxmultiple_voices_music_list : music_list {$$ = $1;} | multiple_voices_music_list E_BACKSLASH music_list {$$ = [...$1, $2, ...$3];} ;
sequential_music : SEQUENTIAL braced_music_list {$$ = command($2);} | braced_music_list {$$ = $1;} ;
braced_music_list : '{' music_list '}' {$$ = musicBlock($2);} ;
music_list : %empty {$$ = [];} | music_list music_embedded {$$ = $1.concat([$2]); lineRegister(@2, $2);} ;
music_embedded : music {$$ = $1;} | post_event {$$ = $1;} | music_embedded_backup {$$ = $1;} //| music_embedded_backup BACKUP lyric_element_music //| duration post_events %prec ':' ;
music_embedded_backup : embedded_scm {$$ = $1;} ;
music : music_assign {$$ = $1;} | pitch_as_music {$$ = $1;} //| lyric_element_music ;
// extra syntaxvariable_command : COMMAND {$$ = variable($1);} // some test case use \lower as a variable name!? | CMD_LOWER {$$ = variable($1);} ;
lyric_element_music : lyric_element optional_notemode_duration post_events {$$ = lyric($1, {duration: $2, post_events: $3, locations: [@1, @3]});} // extra formula | variable_command optional_notemode_duration post_events {$$ = lyric($1, {duration: $2, post_events: $3, locations: [@1, @3]});} ;
lyric_element : full_markup {$$ = $1;} | SYMBOL {$$ = $1;} | literal_string {$$ = $1;} //| LYRIC_ELEMENT // extra formula | general_text {$$ = $1;} // extra formula | "'" {$$ = $1;} // extra formula | UNSIGNED {$$ = $1;} // extra formula | PITCH {$$ = $1;} | UNKNOWN_CHAR {$$ = $1;} ;
pitch_as_music : pitch_or_music {$$ = $1;} ;
music_assign : simple_music {$$ = $1;} | composite_music {$$ = $1;} ;
simple_music : event_chord {$$ = $1;} | music_property_def {$$ = $1;} | context_change {$$ = $1;} // extra formula | variable_command {$$ = $1;} // extra formula | COMMAND full_markup {$$ = command($1, $2);} ;
context_change : CHANGE symbol '=' simple_string {$$ = command($1, assignment($2, $4));} ;
music_property_def : OVERRIDE grob_prop_path '=' scalar {$$ = command($1, assignment($2, $4));} // extra formula | OVERRIDEPROPERTY grob_prop_spec scm_identifier {$$ = command($1, $2, $3);} //| REVERT simple_revert_context revert_arg // {$$ = command($1, $2, $3);} | REVERT revert_arg {$$ = command($1, $2);} | SET context_prop_spec '=' scalar {$$ = command($1, assignment($2, $4));} | UNSET context_prop_spec {$$ = command($1, $2);} ;
revert_arg //: revert_arg_backup BACKUP symbol_list_arg : revert_arg_backup {$$ = $1;} // extra formula | revert_arg_backup symbol_list_arg {$$ = [$1, $2];} ;
revert_arg_backup : revert_arg_part {$$ = $1;} ;
revert_arg_part : symbol_list_part {$$ = $1;} | revert_arg_backup '.' symbol_list_part {$$ = $1 + "." + $3;} //| revert_arg_backup BACKUP SCM_ARG '.' symbol_list_part //| revert_arg_backup BACKUP SCM_ARG ',' symbol_list_part //| revert_arg_backup BACKUP SCM_ARG symbol_list_part ;
symbol_list_arg : SYMBOL_LIST {$$ = $1;} | SYMBOL_LIST '.' symbol_list_rev {$$ = $1.toString() + $2 + $3.toString();} | SYMBOL_LIST ',' symbol_list_rev {$$ = $1.toString() + $2 + $3.toString();} ;
// extra syntaxSYMBOL_LIST : symbol_list_part {$$ = $1;} ;
simple_revert_context : symbol_list_part {$$ = $1;} ;
grob_prop_path : grob_prop_spec {$$ = [$1];} | grob_prop_spec property_path {$$ = [$1, $2];} ;
grob_prop_spec : symbol_list_rev {$$ = $1;} ;
context_prop_spec : symbol_list_rev {$$ = $1;} ;
event_chord : note_chord_element {$$ = $1;} | tempo_event {$$ = $1;} | simple_element post_events {$$ = rest({...$1, post_events: $2, locations: [@1, @2]});} //| CHORD_REPETITION optional_notemode_duration post_events //| MULTI_MEASURE_REST optional_notemode_duration post_events ;
tempo_event : TEMPO steno_duration '=' tempo_range //{$$ = {tempo: $4, unit: $2};} {$$ = tempo($4, $2);} | TEMPO text steno_duration '=' tempo_range //{$$ = {tempo: $5, unit: $3, text: $2};} {$$ = tempo($5, $3, $2);} | TEMPO text {$$ = tempo(undefined, undefined, $2);} | TEMPO CMD_TEMPOLEGEND {$$ = tempo(undefined, undefined, $2);} ;
tempo_range : unsigned_number {$$ = $1;} | unsigned_number '-' unsigned_number {$$ = {from: $1, to: $2};} ;
simple_element //: DRUM_PITCH optional_notemode_duration : RESTNAME optional_notemode_duration {$$ = {name: $1, duration: $2};} ;
optional_notemode_duration : %empty {$$ = null;} | duration {$$ = $1;} ;
duration : steno_duration multipliers //{$$ = $1 + $2;} {$$ = duration({...$1, multipliers: $2});} ;
steno_duration : unsigned_number dots //{$$ = $1 + $2;} {$$ = duration({number: $1, dots: $2.length});} | DURATION_IDENTIFIER dots {$$ = duration({number: $1, dots: $2.length});} ;
DURATION_IDENTIFIER : CMD_BREVE {$$ = $1;} | CMD_LONGA {$$ = $1;} ;
dots : %empty {$$ = "";} | dots dot {$$ = $1 + $2;} ;
multipliers : %empty {$$ = [];} | multipliers '*' unsigned_number {$$ = [...$1, $3];} | multipliers '*' FRACTION {$$ = [...$1, $3];} //| multipliers '*' multiplier_scm ;
repeated_music : REPEAT simple_string unsigned_number music {$$ = command($1, $2, $3, $4);} | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list {$$ = command($1, $2, $3, $4, command($5, $6));} ;
unsigned_number : UNSIGNED {$$ = $1;} //| POST_UNSIGNED // {$$ = $1;} //| NUMBER_IDENTIFIER //| embedded_scm ;
simple_string : literal_string {$$ = $1;} | SYMBOL {$$ = $1;} ;
// all kinds commands in music list, seems named as MUSIC_IDENTIFIER in lilypond's parser.yymusic_identifier : zero_command {$$ = $1;} | CMD_CLEF string {$$ = command($1, $2);} | CMD_TIME FRACTION {$$ = command($1, $2);} | CMD_BAR string {$$ = command($1, $2);} | CMD_OMIT property_path {$$ = command($1, $2);} | CMD_OTTAVA property_path {$$ = command($1, $2);} | CMD_BARNUMBERCHECK scm_identifier {$$ = command($1, $2);} | CMD_BARNUMBERCHECK unsigned_number {$$ = command($1, $2);} | CMD_MARK full_markup {$$ = command($1, $2);} // TODO: | CMD_INCLUDE string {$$ = command($1, $2);} | CMD_SKIP duration {$$ = command($1, $2);} //| CMD_PARENTHESIZE property_path // {$$ = command($1, $2);} | CMD_UNFOLDREPEATS music {$$ = command($1, $2);} | CMD_GRACE music {$$ = command($1, $2);} | CMD_ACCIACCATURA music {$$ = command($1, $2);} | CMD_APPOGGIATURA music {$$ = command($1, $2);} | CMD_SLASHEDGRACE music {$$ = command($1, $2);} | CMD_LANGUAGE string {$$ = command($1, $2);} | CMD_ONCE music_assign {$$ = command($1, $2);} | CMD_PARTIAL duration {$$ = command($1, $2);} | CMD_TUPLETSPAN duration {$$ = command($1, $2);} | CMD_TUPLETSPAN DEFAULT {$$ = command($1, $2);} | CMD_TUPLET FRACTION music {$$ = command($1, $2, $3);} | CMD_TUPLET FRACTION duration music {$$ = command($1, $2, $3, $4);} | CMD_TWEAK property_path scalar {$$ = command($1, $2, $3);} | CMD_KEY PITCH COMMAND {$$ = command($1, $2, $3);} | CMD_TIMES FRACTION music {$$ = command($1, $2, $3);} | CMD_AFTERGRACE music music {$$ = command($1, $2, $3);} | CMD_PARALLELMUSIC scm_identifier composite_music {$$ = command($1, $2, $3);} | CMD_SHAPE scm_identifier symbol {$$ = command($1, $2, $3);} | CMD_ACCIDENTALSTYLE grob_prop_spec {$$ = command($1, $2);} | CMD_NUMERICTIMESIGNATURE music_identifier {$$ = command($1, $2);} | CMD_DEFAULTTIMESIGNATURE {$$ = command($1);} | CMD_BENDAFTER scm_identifier {$$ = command($1, $2);} | CMD_COMPOUNDMETER scm_identifier {$$ = command($1, $2);} | CMD_TRANSPOSITION pitch {$$ = command($1, chordElem($2, {locations: [@2, @2]}));} | CMD_ABSOLUTE music {$$ = command($1, $2);} | CMD_HIDE symbol {$$ = command($1, $2);} | CMD_CROSSSTAFF composite_music {$$ = command($1, $2);} | CMD_KEEPWITHTAG symbol {$$ = command($1, $2);} | CMD_TAG symbol composite_music {$$ = command($1, $2, $3);} | CMD_SCALEDURATIONS FRACTION composite_music {$$ = command($1, $2, $3);} | CMD_TUPLETNEUTRAL music {$$ = command($1, $2);} | CMD_ARTICULATE music {$$ = command($1, $2);} | markup_font_size music {$$ = command($1, $2);} | pitch_mode_music {$$ = $1;} | "(" {$$ = $1;} | ")" {$$ = $1;} | "[" {$$ = $1;} | "]" {$$ = $1;} | DIVIDE {$$ = {proto: "Divide"};} | expressive_mark {$$ = $1;} ;
// extra syntaxzero_command : CMD_FERMATA {$$ = command($1);} | CMD_STEMUP {$$ = command($1);} | CMD_STEMDOWN {$$ = command($1);} | CMD_STEMNEUTRAL {$$ = command($1);} | CMD_MERGEDIFFERENTLYDOTTEDON {$$ = command($1);} | CMD_MERGEDIFFERENTLYHEADEDON {$$ = command($1);} | CMD_VOICE_NUMBER {$$ = command($1);} | CMD_SCORE {$$ = command($1);} | CMD_VOICE {$$ = command($1);} | CMD_STAFF {$$ = command($1);} | CMD_PIANOSTAFF {$$ = command($1);} | CMD_ARPEGGIO {$$ = command($1);} | CMD_ARPEGGIOARROWDOWN {$$ = command($1);} | CMD_ARPEGGIOARROWUP {$$ = command($1);} | CMD_ARPEGGIONORMAL {$$ = command($1);} | CMD_ARPEGGIOBRACKET {$$ = command($1);} | CMD_ARPEGGIOPARENTHESIS {$$ = command($1);} | CMD_ARPEGGIOPARENTHESISDASHED {$$ = command($1);} | CMD_GLISSANDO {$$ = command($1);} | CMD_MORDENT {$$ = command($1);} | CMD_POWERCHORDS {$$ = command($1);} | CMD_PRALL {$$ = command($1);} //| CMD_SUSTAINOFF // {$$ = command($1);} //| CMD_SUSTAINON // {$$ = command($1);} | CMD_TRILL {$$ = command($1);} | CMD_TURN {$$ = command($1);} | CMD_POINTANDCLICKOFF {$$ = command($1);} | CMD_UPBOW {$$ = command($1);} | CMD_DOWNBOW {$$ = command($1);} | CMD_BREATHE {$$ = command($1);} | CMD_STARTTEXTSPAN {$$ = command($1);} | CMD_STOPTEXTSPAN {$$ = command($1);} | CMD_FLAGEOLET {$$ = command($1);} | CMD_SLURDASHED {$$ = command($1);} | CMD_SLURSOLID {$$ = command($1);} | CMD_BREAK {$$ = command($1);} | CMD_PAGEBREAK {$$ = command($1);} | CMD_STARTTRILLSPAN {$$ = command($1);} | CMD_STOPTRILLSPAN {$$ = command($1);} | CMD_CADENZAON {$$ = command($1);} | CMD_CADENZAOFF {$$ = command($1);} | CMD_CRESC {$$ = command($1);} | CMD_CRESCTEXTCRESC {$$ = command($1);} | CMD_CRESCHAIRPIN {$$ = command($1);} | CMD_DIM {$$ = command($1);} | CMD_DIMTEXTDIM {$$ = command($1);} | CMD_DYNAMICUP {$$ = command($1);} | CMD_HIDENOTES {$$ = command($1);} | CMD_UNHIDENOTES {$$ = command($1);} | CMD_NEWSPACINGSECTION {$$ = command($1);} | CMD_NOBEAM {$$ = command($1);} | CMD_ONEVOICE {$$ = command($1);} | CMD_PHRASINGSLURDOWN {$$ = command($1);} | CMD_PHRASINGSLURNEUTRAL {$$ = command($1);} | CMD_PHRASINGSLURUP {$$ = command($1);} | CMD_SLURDOWN {$$ = command($1);} | CMD_SLURNEUTRAL {$$ = command($1);} | CMD_SLURUP {$$ = command($1);} | CMD_TIEDOWN {$$ = command($1);} | CMD_TIENEUTRAL {$$ = command($1);} | CMD_TIEUP {$$ = command($1);} | CMD_PARENTHESIZE {$$ = command($1);} | CMD_TUPLETUP {$$ = command($1);} | CMD_TUPLETDOWN {$$ = command($1);} | CMD_SHIFTON {$$ = command($1);} | CMD_REPEATTIE {$$ = command($1);} ;
// extra syntaxexpressive_mark : CMD_CRESCENDO_BEGIN {$$ = $1;} | CMD_DECRESCENDO_BEGIN {$$ = $1;} | CMD_DYNAMICS_END {$$ = $1;} | CMD_FERMATA {$$ = $1;} | CMD_TWEAK property_path scalar {$$ = command($1, $2, $3);} | CMD_BENDAFTER scm_identifier {$$ = command($1, $2);} | CMD_DYNAMIC_MARKINGS {$$ = command($1);} | CMD_MARCATO {$$ = command($1);} | CMD_STOPPED {$$ = command($1);} | CMD_TENUTO {$$ = command($1);} | CMD_STACCATISSIMO {$$ = command($1);} | CMD_ACCENT {$$ = command($1);} | CMD_STACCATO {$$ = command($1);} | CMD_PORTATO {$$ = command($1);} | CMD_MORDENT {$$ = command($1);} | CMD_PRALL {$$ = command($1);} | CMD_TURN {$$ = command($1);} | CMD_ARPEGGIO {$$ = command($1);} | CMD_TRILL {$$ = command($1);} | CMD_STARTTRILLSPAN {$$ = command($1);} | CMD_STOPTRILLSPAN {$$ = command($1);} | "~" {$$ = $1;} | "(" {$$ = $1;} | ")" {$$ = $1;} | "\(" {$$ = $1;} | "\)" {$$ = $1;} ;
// extra syntaxpitch_mode_music : CMD_RELATIVE pitch music {$$ = command($1, chordElem($2, {locations: [@2, @2]}), $3);} | CMD_RELATIVE music {$$ = command($1, $2);} ;
pitch_or_music //: pitch exclamations questions octave_check maybe_notemode_duration erroneous_quotes optional_rest post_events : pitch exclamations questions optional_notemode_duration optional_rest post_events {$$ = chord([chordElem($1, {locations: [@1, @1]})], $4, {exclamations: $2, questions: $3, rest: $5, post_events: $6, locations: [@1, @6]});} //| new_chord post_events // {$$ = briefChord($1, {post_events: $2});} ;
new_chord //: steno_tonic_pitch maybe_notemode_duration : pitch optional_notemode_duration {$$ = {pitch: $1, duration: $2};} //| steno_tonic_pitch optional_notemode_duration chord_separator chord_items | pitch optional_notemode_duration chord_separator chord_items {$$ = {pitch: $1, duration: $2, separator: $3, items: $4};} ;
chord_items : %empty {$$ = [];} | chord_items chord_item {$$ = $1.concat($2);} ;
chord_item : chord_separator {$$ = $1;} | step_numbers {$$ = $1;} | CHORD_MODIFIER {$$ = $1;} ;
// m, m7, dim, dim7, aug, maj, maj7CHORD_MODIFIER : CHORD_MODIFIER_WORD {$$ = $1;} //| CHORD_MODIFIER_WORD UNSIGNED // {$$ = $1 + $2;} ;
step_numbers : step_number {$$ = $1;} | step_numbers dot step_number {$$ = $1 + $2 + $3;} ;
step_number : UNSIGNED {$$ = $1;} | UNSIGNED '+' {$$ = $1 + $2;} | UNSIGNED CHORD_MINUS {$$ = $1 + $2;} ;
maybe_notemode_duration : %empty {$$ = null;} | duration {$$ = $1;} ;
steno_tonic_pitch : TONICNAME_PITCH quotes {$$ = $1 + $2;} ;
CHORD_BASS : "/" "+" {$$ = $1 + $2;} ;
CHORD_CARET : "^" {$$ = $1;} ;
CHORD_COLON : ":" {$$ = $1;} ;
CHORD_MINUS : "-" {$$ = $1;} ;
CHORD_SLASH : "/" {$$ = $1;} ;
chord_separator : CHORD_COLON {$$ = $1;} | CHORD_CARET {$$ = $1;} //| CHORD_SLASH steno_tonic_pitch | CHORD_SLASH pitch {$$ = $1 + $2;} //| CHORD_BASS steno_tonic_pitch | CHORD_BASS pitch {$$ = $1 + $2;} ;
exclamations : %empty {$$ = [];} | exclamations '!' {$$ = $1.concat($2);} ;
questions : %empty {$$ = [];} | questions '?' {$$ = $1.concat($2);} ;
post_events : %empty {$$ = [];} | post_events post_event {$$ = $1.concat($2);} ;
note_chord_element : chord_body optional_notemode_duration post_events {$$ = chord($1, $2, {withAngle: true, post_events: $3, locations: [@1, @2]});} ;
chord_body : "<" chord_body_elements ">" {$$ = $2;} //| FIGURE_OPEN figure_list FIGURE_CLOSE ;
chord_body_elements : %empty {$$ = [];} | chord_body_elements chord_body_element {$$ = $1.concat([$2]);} ;
chord_body_element //: pitch_or_tonic_pitch exclamations questions octave_check post_events %prec ':' : pitch_or_tonic_pitch exclamations questions post_events //{$$ = $1 + $2 + $3 + $4;} {$$ = chordElem($1, {locations: [@1, @4], exclamations: $2, questions: $3, post_events: $4});} //| DRUM_PITCH post_events %prec ':' | music_function_chord_body {$$ = $1;} //| post_event ;
music_function_chord_body //: music_function_call //| MUSIC_IDENTIFIER //| embedded_scm : music_identifier {$$ = $1;} ;
pitch_or_tonic_pitch : pitch {$$ = $1;} //| steno_tonic_pitch ;
/*// extra syntaxpitches : pitches pitch {$$ = $1.concat([$2]);} | pitch {$$ = [$1];} ;*/
pitch : PITCH quotes {$$ = $1 + $2;} //| steno_pitch // extra formula //| PLACEHOLDER_PITCH // {$$ = $1;} ;
quotes : %empty {$$ = "";} | sub_quotes {$$ = $1;} | sup_quotes {$$ = $1;} ;
sup_quotes : "'" {$$ = $1;} | sup_quotes "'" {$$ = $1 + $2;} ;
sub_quotes : "," {$$ = $1;} | sub_quotes "," {$$ = $1 + $2;} ;
post_event : post_event_nofinger {$$ = $1;} | '-' fingering //{$$ = {type: "fingering", direction: "middle", value: $2};} {$$ = postEvent("middle", fingering($2));} ;
HYPHEN : PRE_HYPHEN "-" {$$ = "--";} | PRE_HYPHEN PRE_HYPHEN {$$ = "--";} ;
EXTENDER : PRE_EXTENDER "_" {$$ = "__";} | PRE_EXTENDER PRE_EXTENDER {$$ = "__";} ;
post_event_nofinger : '^' fingering //{$$ = {direction: "up", fingering: $2};} {$$ = postEvent("up", fingering($2));} | '_' fingering //{$$ = {direction: "down", fingering: $2};} {$$ = postEvent("down", fingering($2));} | direction_less_event {$$ = $1;} | script_dir music_function_call {$$ = postEvent($1, $2);} | HYPHEN {$$ = $1;} | EXTENDER {$$ = $1;} | script_dir direction_reqd_event {$$ = postEvent($1, $2);} | script_dir direction_less_event {$$ = postEvent($1, $2);} // extra formula | script_dir zero_command {$$ = postEvent($1, $2);} // extra formula | script_dir expressive_mark {$$ = postEvent($1, $2);} // extra formula | expressive_mark {$$ = postEvent(null, $1);} // extra formula | CMD_SUSTAINOFF {$$ = postEvent(null, $1);} // extra formula | CMD_SUSTAINON {$$ = postEvent(null, $1);} // extra formula | "[" {$$ = $1;} // extra formula | "]" {$$ = $1;} // extra formula | script_dir "[" {$$ = postEvent($1, $2);} // extra formula | script_dir "]" {$$ = postEvent($1, $2);} // extra formula | "(" {$$ = $1;} // extra formula | ")" {$$ = $1;} // extra formula | script_dir variable_command {$$ = postEvent($1, $2);} ;
direction_reqd_event : gen_text_def {$$ = $1;} | script_abbreviation {$$ = $1;} ;
gen_text_def : full_markup {$$ = $1;} | literal_string {$$ = $1;} | SYMBOL {$$ = $1;} | embedded_scm {$$ = $1;} ;
script_abbreviation : '^' {$$ = $1;} | '+' {$$ = $1;} | '-' {$$ = $1;} | '!' {$$ = $1;} | '>' {$$ = $1;} | dot {$$ = $1;} | '_' {$$ = $1;} ;
direction_less_event : string_number_event {$$ = $1;} //| EVENT_IDENTIFIER | tremolo_type {$$ = $1;} | event_function_event {$$ = $1;} ;
string_number_event : E_UNSIGNED {$$ = $1;} ;
tremolo_type : ':' {$$ = ":";} | ':' UNSIGNED {$$ = ":" + $2;} ;
event_function_event : EVENT_FUNCTION function_arglist ;
music_function_call : MUSIC_FUNCTION function_arglist ;
script_dir : "_" {$$ = "down";} | "^" {$$ = "up";} | "-" {$$ = "middle";} ;
fingering : UNSIGNED {$$ = $1;} ;
full_markup : markup_mode markup_top {$$ = command($1, ...$2);} | markup_mode_word {$$ = $1;} ;
markup_mode : MARKUP {$$ = $1;} ;
markup_top : markup_list {$$ = $1;} | markup_head_1_list simple_markup //{$$ = {head: $1, body: $2};} {$$ = $1.concat([$2]);} | simple_markup_noword {$$ = [$1];} ;
markup_mode_word : markup_mode markup_word {$$ = command($1, $2);} ;
output_def : output_def_body '}' {$$ = $1;} ;
output_def_body : output_def_head_with_mode_switch '{' {$$ = block("score", $1);} | output_def_body assignment { $1.body.push($2); $$ = $1; } | output_def_body music_or_context_def { $1.body.push($2); $$ = $1; } | output_def_body scm_identifier { $1.body.push($2); $$ = $1; } //| output_def_body embedded_scm_active //| output_def_body SCM_TOKEN //| output_def_body error ;
output_def_head_with_mode_switch : output_def_head {$$ = $1;} ;
output_def_head : PAPER {$$ = $1;} | MIDI {$$ = $1;} | LAYOUT {$$ = $1;} ;
music_or_context_def : music_assign {$$ = $1;} | context_def_spec_block {$$ = $1;} ;
context_def_spec_block : CONTEXT '{' context_def_spec_body '}' {$$ = block("context", $1, $3);} ;
context_def_spec_body : %empty {$$ = [];} | context_def_spec_body context_mod {$$ = $1.concat([$2]);} | context_def_spec_body context_modification {$$ = $1.concat([$2]);} | context_def_spec_body context_mod_arg {$$ = $1.concat([$2]);} ;
context_mod_arg : embedded_scm {$$ = $1;} | composite_music {$$ = $1;} ;
context_modification : WITH '{' context_mod_list '}' {$$ = command($1, inlineBlock($3));} | WITH context_modification_arg {$$ = command($1, $2);} ;
context_modification_arg : embedded_scm {$$ = $1;} //| MUSIC_IDENTIFIER | music_identifier {$$ = $1;} ;
context_mod_list : %empty {$$ = [];} | context_mod_list context_mod {$$ = $1.concat($2);} | context_mod_list context_mod_arg {$$ = $1.concat($2);} ;
context_mod : property_operation {$$ = $1;} //| context_def_mod SYMBOL | context_def_mod symbol {$$ = command($1, $2);} //| context_def_mod embedded_scm ;
property_operation : symbol '=' scalar {$$ = assignment($1, $3);} | UNSET symbol {$$ = command($1, $2);} | OVERRIDE revert_arg '=' scalar {$$ = command($1, assignment($2, $4));} | REVERT revert_arg {$$ = command($1, $2);} ;
symbol : literal_string {$$ = $1;} | SYMBOL {$$ = $1;} | embedded_scm_bare {$$ = $1;} ;
scalar //: embedded_scm_arg : pitch_or_music {$$ = $1;} | scm_identifier {$$ = $1;} | bare_number {$$ = $1;} | '-' bare_number {$$ = -$1;} | string {$$ = $1;} | symbol_list_part_bare '.' property_path {$$ = $1 + "." + $3;} | symbol_list_part_bare ',' property_path {$$ = $1 + "," + $3;} // extra formula | UNSIGNED ',' property_path {$$ = $1 + "," + $3;} // extra formula | COMMAND {$$ = $1;} ;
bare_number : bare_number_common {$$ = $1;} | UNSIGNED {$$ = Number($1);} //| UNSIGNED NUMBER_IDENTIFIER ;
context_def_mod : CONSISTS {$$ = $1;} | REMOVE {$$ = $1;} | ACCEPTS {$$ = $1;} | DEFAULTCHILD {$$ = $1;} | DENIES {$$ = $1;} | ALIAS {$$ = $1;} | TYPE {$$ = $1;} | DESCRIPTION {$$ = $1;} | NAME {$$ = $1;} ;
embedded_scm_active //: SCM_IDENTIFIER : scm_identifier {$$ = $1;} | scm_function_call {$$ = $1;} | lookup {$$ = $1;} ;
/*// extra syntax, maybe the substitution for embedded_scm_active in lilypond's parserembedded_scheme_expression : "#" scheme_expression {$$ = scheme($2);} ;*/
// extra syntaxscheme_expression : SCM_TRUE {$$ = true;} | SCM_FALSE {$$ = false;} | SCM_HEX {$$ = $1} | SCM_COLON {$$ = $1} | bare_number {$$ = $1;} | INT {$$ = $1;} | "(" ")" {$$ = null;} | "+" "inf.0" {$$ = $1 + $2;} | "-" "inf.0" {$$ = $1 + $2;} | "(" scheme_expression "." scheme_expression ")" {$$ = schemePair($2, $4);} | "(" scheme_expression scheme_args ")" {$$ = schemeFunction($2, $3);} | scheme_token {$$ = $1;} | scheme_token "?" {$$ = $1 + $2;} | "'" scheme_expression {$$ = schemePointer($2);} | "`" scheme_expression {$$ = schemePointer($2);} | "#" "{" lilypond "#" "}" {$$ = schemeEmbed($3);} | "*" {$$ = $1;} ;
scheme_args : %empty {$$ = [];} | scheme_args scheme_expression {$$ = $1.concat($2);} ;
scheme_token : bare_number {$$ = $1;} | symbol {$$ = $1;} | symbol ":" scheme_token {$$ = $1 + $2 + $3;} | symbol ":" ":" scheme_token {$$ = $1 + $2 + $3 + $4;} ;
optional_rest : %empty {$$ = null;} | REST {$$ = $1;} ;
// extra syntax, the substitution of STRINGliteral_string : STRING {$$ = string($1);} ;123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
%{ const root = (type, data) => ({__prototype: "MesaureLayout", type, data});
const singleLayout = n => ({__prototype: "SingleMLayout", measure: Number(n)}); const blockLayout = seq => ({__prototype: "BlockMLayout", seq}); const voltaBlock = (times, body, alternates) => ({__prototype: "VoltaMLayout", times: Number(times), body, alternates}); const abaBlock = (main, rest) => ({__prototype: "ABAMLayout", main, rest});
const segment = n => ({segment: true, length: Number(n)});
const alternates = items => items.map(item => { if (item.__prototype === "BlockMLayout") return item.seq;
return [item]; });
const range = (start, end) => { start = Number(start); end = Number(end);
if (!(end >= start)) throw new Error(`invalid measure range: ${start}..${end}`);
return Array(end + 1 - start).fill(0).map((_, i) => singleLayout(start + i)); };
const serializeSeq = (item, options) => { if (item.segment) { const index = options.index; options.index += item.length;
return Array(item.length).fill(0).map((_, i) => singleLayout(index + i)); }
return [serialize(item, options)]; };
const serialize = (item, options = {index: 1}) => { const speard = seq => [].concat(...seq.map(it => serializeSeq(it, options)));
switch (item.__prototype) { case "BlockMLayout": item.seq = speard(item.seq);
break; case "VoltaMLayout": item.body = speard(item.body); item.alternates = item.alternates && item.alternates.map(speard);
break; case "ABAMLayout": item.main = serialize(item.main, options); item.rest = speard(item.rest);
break; }
return item; };%}
%lex
%option flex unicode
A [a-z]N [1-9]N0 [0-9]UNSIGNED {N}{N0}*WORD {A}+
SPECIAL [*,\[\]<>{}]
%%
\s+ {} // spaces
{SPECIAL} return yytext;
{UNSIGNED} return 'UNSIGNED'{WORD}":" return yytext".." return yytext
<<EOF>> return 'EOF';
/lex
%start start_symbol
%%
start_symbol : measure_layout EOF { return $1; } ;
measure_layout : index_wise_measure_layout {$$ = root(null, $1);} | 'i:' index_wise_measure_layout {$$ = root("index-wise", $2);} | 's:' segment_wise_measure_layout {$$ = root("segment-wise", serialize($2));} ;
index_wise_measure_layout : iw_sequence { if ($1.length === 1 && $1[0].__prototype === "BlockMLayout") $$ = $1[0]; else $$ = blockLayout($1); } ;
iw_sequence : iw_item {$$ = [$1];} | range {$$ = $1;} | iw_sequence ',' iw_item {$$ = [...$1, $3];} | iw_sequence ',' range {$$ = [...$1, ...$3];} ;
range : UNSIGNED '..' UNSIGNED {$$ = range($1, $3);} ;
iw_item : single {$$ = $1;} | iw_block_item {$$ = $1;} | iw_volta {$$ = $1;} | iw_aba {$$ = $1;} ;
single : UNSIGNED {$$ = singleLayout($1);} ;
iw_block_item : iw_block {$$ = blockLayout($1);} ;
iw_block : '[' iw_sequence ']' {$$ = $2;} ;
iw_volta : UNSIGNED '*' iw_block iw_optional_alternates {$$ = voltaBlock($1, $3, $4);} ;
iw_optional_alternates : %empty {$$ = null;} | iw_alternates {$$ = $1;} ;
iw_alternates : '{' iw_sequence '}' {$$ = alternates($2);} ;
iw_aba : '<' iw_item ',' iw_sequence '>' {$$ = abaBlock($2, $4);} ;
segment_wise_measure_layout : sw_sequence { if ($1.length === 1 && $1[0].__prototype === "BlockMLayout") $$ = $1[0]; else $$ = blockLayout($1); } ;
sw_sequence : sw_item {$$ = [$1];} | sw_sequence sw_item {$$ = [...$1, $2];} ;
sw_item : segment {$$ = blockLayout([$1]);} | sw_block_item {$$ = $1;} | sw_volta {$$ = $1;} | sw_aba {$$ = $1;} ;
segment : UNSIGNED {$$ = segment($1);} ;
sw_block_item : sw_block {$$ = blockLayout($1);} ;
sw_block : '[' sw_sequence ']' {$$ = $2;} ;
sw_volta : UNSIGNED '*' sw_block sw_optional_alternates {$$ = voltaBlock($1, $3, $4);} ;
sw_optional_alternates : %empty {$$ = null;} | sw_alternates {$$ = $1;} ;
sw_alternates : '{' sw_sequence '}' {$$ = alternates($2);} ;
sw_aba : '<' sw_item sw_sequence '>' {$$ = abaBlock($2, $3);} ;1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060%% Copyright (C) 2008, 2009, 2010, 2011 NICTA% Author: Peter Chubb <peter.chubb AT nicta.com.au>% $Id: articulate.ly,v 1.7 2011-03-24 00:40:00 peterc Exp $%%% This program is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License, version 3,% as published by the Free Software Foundation.%% WARNING: this file under GPLv3 only, not GPLv3+%% This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.% See the GNU General Public License for more details. It is% available in the Lilypond source tree, or at% http://www.gnu.org/licenses/gpl-3.0.html%% This script tries to make MIDI output from LilyPond a little more realistic.% It tries to take articulations (slurs, staccato, etc) into account, by% replacing notes with sequential music of suitably time-scaled note plus% skip.%% Trills, turns, mordents and pralls are expanded with rallentendo% and accelerando taken into account.%% As my scheme knowledge is poor (I was teaching myself as I went), there% is much scope for improvement.
% See: http://nicta.com.au/people/chubbp/articulate for additional% information about how the articulate function works.
%%% Supported items:% Articulations on a single note (staccato, staccatissimo, portato, tenuto).% Slurs and phrasing slurs.% Ornaments (i.e. mordents, trills, turns).% Rallentando, accelerando, ritard and 'a tempo'.%% Please refer to 'MIDI output' (Section 3.5) in the Notation Reference% Manual for a more detailed list of supported items.
%%% Technical Details:% * Any note not under a slur or phrasing slur, and not marked with an% explicit articulation, is shortened by ac:normalFactor (default 7/8).% (Shortening a note means replacing the note with a note of a smaller% duration, and a rest to make up for the difference between the durations% of the original and the shortened note.)% * Notes marked with articulations are shortened by factors specific to the% articulation as follows:% staccato not under a slur: ac:staccatoFactor (default 1/2)% under a slur: ac:portatoFactor (default 3/4)% staccatissimo ac:staccatissimoFactor (default 1/4)% portato ac:portatoFactor (default 3/4)% tenuto ac:tenutoFactor (default 1/1 - by default, notes marked% tenuto are not shortened)% * Appoggiaturas are made to take half the value of the note following,% without taking dots into account (so in \appoggiatura c8 d2. the c% will take the time of a crotchet).% * Trills and turns are expanded. The algorithm tries to choose notes% within the time of the current tempo that lead to each twiddle being% around 1/8 seconds; this can be adjusted with the ac:maxTwiddleTime% variable.% * Rall, poco rall and a tempo are observed. It'd be fairly trivial to% make accel. and stringendo and so on work too.
%%%%USAGE% In the \score section do:% \articulate <<% all the rest of the score% >>% or use the lilywrap script.%% TO DO:%% * Dynamics.% * Fix quantisation for dynamics on single note (replace note% with tied 128th notes?) -- started, needs work.% * Make \fp do the right thing (loud start, then quiet).%% * Inegalite. Notes on-beat steal time from notes off-beat.% Degree of stealing is a parameter: from 1.0 (straight)% to 1.5 (extreme swing). Also fix tenuto to use this.%% * add accel (to match rall), and molto rall. I've never seen% molto accel but some composer somewhere has probably used it.%% * Fermata, and Fermata Lunga% * Add more synonyms for accel and rall: rit ritard stringendo%% * Phrasing.% * Rall at end of piece% * Very slight accel into a phrase, rall out of it.% * Dynamics during a phrase???? unclear how these should be in% the general case%% * Trill algorithm needs work.%% * Cope with more ornaments/articulations.% inverted-turns, etc.% -- accent needs better control of dynamics.% -- Handling of generic ornaments (in lily, `\stopped'; in% most early music: ornament this note (trill, turn% or mordent as the player wishes))
% * Automatic gruppetto at end of trill; better handling of% initial/final grace notes on trill
% * Automatic ornaments.% * Spot cadences and ornament% * Look for quaver-dotted note for trills, for example.% * Fill in steps. (Needs lookahead/lookbehind.)% * `afterturn' -- a turn after the start of a note.% * accidentals for trills and turns
% CHANGELOG% * Heikki Tauriainen: handle also the \portato articulation (both as an% explicit articulation, and as the articulation to use for slurred% notes marked \staccato).% * David Kastrup: remove redefinitions of \afterGrace and \appoggiatura% and let their actions be performed when \articulate is called by% recognizing and replacing LilyPond's default code for these constructs.% Cf issue 4517 in LilyPond's tracker.% * David Kastrup: basic 2.15.28 compatibility by using event-chord-wrap!% This should really be done by rewriting the code more thoroughly.% * From Iain Nicol: appoggiatura timings were out; add staccatissimo; fix% trillSpanner endpoints.% * Also handle Breathing events (by throwing them away). This isn't ideal;% one should really shorten the note before a little. But I don't know% how to do lookahead in scheme.% * Also ignore explicit line breaks.% * Add Mordents (reported by Patrick Karl)% * Thomas Morley: extend unfold-repeats to reflect the possibility to% customize its effect to user-settable repeat-types. Here the most general% setting is hard-coded, resulting in unchanged behaviour.
\version "2.19.22"
#(use-modules (srfi srfi-1))#(use-modules (srfi srfi-11))#(use-modules (ice-9 debug))#(use-modules (scm display-lily))
% PARAMETERS% How much to compress notes marked Staccato. CPE Bach says `as short as% may conveniently be played, as if the keys were too hot to touch'.% Most modern sources say 1/2 the notated length of a note.#(define ac:staccatoFactor '(1 . 2))
% How much to compress notes marked staccatissimo.#(define ac:staccatissimoFactor '(1 . 4))
% Shortening factor for notes marked portato (or slurred notes marked% staccato).#(define ac:portatoFactor '(3 . 4))
% And tenuto (if we ever implement time stealing, this should be >1.0)#(define ac:tenutoFactor '(1 . 1))
% How much to articulate normal notes. CPE Bach says 1/2 (and% staccato should be `as short as may conveniently be played') but this% sounds too short for modern music. 7/8 sounds about right.#(define ac:normalFactor '(7 . 8))
% How much to slow down for a rall. or a poco rall.% (or speed up for accel or poco accel)#(define ac:rallFactor (ly:make-moment 60/100)) % 40% slowdown#(define ac:pocoRallFactor (ly:make-moment 90/100)) % 10% slowdown
% The absolute time for a twiddle in a trill, in minutes.% Start with 1/4 seconds == 1/240 minutes#(define ac:maxTwiddleTime (ly:make-moment 1/240))
% How long ordinary grace notes should be relative to their notated% duration. 9/40 is LilyPond's built-in behaviour for MIDI output% (though the notation reference says 1/4).#(define ac:defaultGraceFactor 9/40)
% What proportion of an ordinary grace note's time should be stolen% from preceding notes (as opposed to stealing from the principal note).% Composers' intentions for this vary. Taking all from the preceding% notes is LilyPond's built-in behaviour for MIDI output.#(define ac:defaultGraceBackwardness 1)
% Internal variables, don't touch.% (should probably be part of a context somehow)
% Whether to slur, or not#(define ac:inSlur #f)#(define ac:inPhrasingSlur #f)
% Whether the current noteevent is in a trill spanner#(define ac:inTrill #f)
% assume start in C major. Key change events override this.% Could get from context, but don't know how.#(define ac:current-key (make-music 'KeyChangeEvent 'tonic (ly:make-pitch -1 0 0) 'pitch-alist (list (cons 0 0) (cons 1 0) (cons 2 0) (cons 3 0) (cons 4 0) (cons 5 0) (cons 6 0))))
#(define ac:currentTempo (ly:make-moment 15/1)) % 4 = 60, measured wholes per minute#(define ac:lastTempo ac:currentTempo) % for 'a tempo' or 'tempo I'
% The duration of the current note. Start at a crotchet% for no good reason.#(define ac:currentDuration (ly:make-duration 2 0 1/1))
% Amount of musical time (in whole notes) that we need to steal from the% next events seen.#(define ac:stealForward 0)
% List of events in the output so far, in reverse order, from which we can% steal time.#(define ac:eventsBackward '())
% Log events for the backward chain.#(define (ac:logEventsBackward music) (music-map (lambda (m) (case (ly:music-property m 'name) ((EventChord) (set! ac:eventsBackward (cons m ac:eventsBackward)) m) ((BarCheck SkipMusic) (let ((wm (make-sequential-music (list m)))) (set! ac:eventsBackward (cons wm ac:eventsBackward)) wm)) (else m))) music))
% Steal time from the backward chain. Adds to ac:stealForward (with a% warning) if it couldn't backward-steal all that was desired.#(define (ac:stealTimeBackward tosteal) (if (<= tosteal 0) #t (if (null? ac:eventsBackward) (begin (ly:warning (_ "articulation failed to steal ~a note backward at beginning of music; stealing forward instead") tosteal) (set! ac:stealForward (+ ac:stealForward tosteal))) (let* ((lastev (car ac:eventsBackward)) (levlen (ly:moment-main (ly:music-length lastev)))) (if (< tosteal levlen) (begin (ly:music-compress lastev (ly:make-moment (/ (- levlen tosteal) levlen))) #t) (begin (if (any (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property lastev 'elements)) (ly:warning (_ "stealing the entirety of a note's time"))) (set! (ly:music-property lastev 'elements) '()) (set! ac:eventsBackward (cdr ac:eventsBackward)) (ac:stealTimeBackward (- tosteal levlen))))))))
% Debugging: display a moment plus some text.% Returns its moment argument so can be used in-line.#(define (display-moment text m) (display text) (display (list (ly:moment-main-numerator m) "/" (ly:moment-main-denominator m))) m)
% Track tempo (and maybe later, other context properties)% as they change. Needs to better cope with saving only Tempo I,% otherwise "a tempo" goes back to the tempo before the last change.#(define (ac:adjust-props sym music) (case sym ((tempoWholesPerMinute) (set! ac:currentTempo (ly:music-property music 'value)) (set! ac:lastTempo ac:currentTempo) )))
% Raise note one step in the current diatonic scale.#(define (ac:up note) (let* ((pitch (ly:music-property note 'pitch)) (notename (ly:pitch-notename pitch)) (new-notename (if (eqv? notename 6) 0 (+ 1 notename))) (alterations (ly:music-property ac:current-key 'pitch-alist)) (new-alteration (cdr (assq new-notename alterations))) (new-octave (if (eqv? new-notename 0) (+ 1 (ly:pitch-octave pitch)) (ly:pitch-octave pitch))) ) (set! (ly:music-property note 'pitch)(ly:make-pitch new-octave new-notename new-alteration))))
% Lower note one step in the current diatonic scale.#(define (ac:down note) (begin (let* ((pitch (ly:music-property note 'pitch)) (notename (ly:pitch-notename pitch)) (new-notename (if (eqv? notename 0) 6 (- notename 1))) (alterations (ly:music-property ac:current-key 'pitch-alist)) (new-alteration (cdr (assq new-notename alterations))) (new-octave (if (eqv? new-notename 6) (- (ly:pitch-octave pitch) 1) (ly:pitch-octave pitch))) ) (set! (ly:music-property note 'pitch)(ly:make-pitch new-octave new-notename new-alteration)))))
% Shorten a note, and save the note's original duration in ac:currentDuration#(define (ac:articulate-one-note m fraction) "Replace m with m*fraction" (if (eq? 'NoteEvent (ly:music-property m 'name)) (let* ((dur (ly:music-property m 'duration)) (l (ly:duration-log dur)) (d (ly:duration-dot-count dur)) (factor (ly:duration-factor dur)) (num (car fraction)) (denom (cdr fraction))) (begin (set! ac:currentDuration dur) (set! (ly:music-property m 'duration) (ly:make-duration l d (* num (car factor)) (* denom (cdr factor)))))) m))
% helper routine to set duration.#(define (ac:setduration music duration) "Set a note's duration." (let ((eventtype (ly:music-property music 'name))) (if (or (eq? eventtype 'NoteEvent) (eq? eventtype 'RestEvent) (eq? eventtype 'SkipEvent)) (set! (ly:music-property music 'duration) duration))))
% Add an articulation event to a note.% Used in afterGrace to mark all notes as tenuto, so they're not shortened#(define (ac:add-articulation type music) (music-map (lambda (m) (if (eq? 'EventChord (ly:music-property m 'name)) (set! (ly:music-property m 'elements) (append (ly:music-property m 'elements) (list (make-music 'ArticulationEvent 'articulation-type type))))) m) music))
% Convert a long note to an equivalent set of short notes, tied together.% This is needed to get smooth dynamics changes.% Need to deal properly with stuff other than the notes (dynamics, markup etc)% Still experimental, so disabled for now.#(define (ac:to128 music) music)
#(define (ac:to128_disabled music) (if (or (eq? 'SkipEvent (ly:music-property music 'name)) (eq? 'NoteEvent (ly:music-property music 'name))) (let* ((dur (ly:music-property music 'duration)) (log2 (ly:duration-log dur)) (shiftcount (- 6 log2)) (lastm (ly:music-deep-copy (shift-duration-log music shiftcount 0)))) (set! (ly:music-property music 'elements) (cons (make-music 'TieEvent) (ly:music-property music 'elements))) (make-sequential-music (list (make-repeat "unfold" (1- (expt 2 shiftcount)) (make-sequential-music (list music)) '()) lastm))) music))
% absolute time in minutes of a length of music, as a rational number (moment)#(define (ac:abstime music) (ly:moment-div (ly:music-length music) ac:currentTempo))
% convert absolute time (in minutes) to a moment in the current tempo#(define (ac:abs->mom m) (ly:moment-mul m ac:currentTempo))
% a moment that is ac:maxTwiddletime seconds at the current tempo.#(define (ac:targetTwiddleTime) (ac:abs->mom ac:maxTwiddleTime))
% Nearest twiddletime (in minutes) achievable with power-of-2 divisions of% the original music. (twiddletime is the time for one pair of notes% in a trill)% If the music has a precomputed twiddletime (e.g., from \afterGrace) use that.#(define (ac:twiddletime music) (let* ((tr (filter (lambda (x) (and (eq? 'ArticulationEvent (ly:music-property x 'name)) (string= "trill" (ly:music-property x 'articulation-type)))) (ly:music-property music 'elements))) (pre-t (if (pair? tr) (ly:music-property (car tr) 'twiddle) '())) (hemisemimom (ly:make-moment 1/64)) (t (ac:targetTwiddleTime))) (if (ly:moment? pre-t) pre-t hemisemimom)))
% Note: I'm assuming early music practice of starting on the auxiliary note.% Needs to add gruppetto if it's a long trill (TODO)#(define (ac:trill music) " Replace music with time-compressed repeats of the music, maybe accelerating if the length is longer than a crotchet " (let* ((hemisemidur (ly:make-duration 5 0 1/1)) (orig-len (ly:music-length music)) (t (ac:twiddletime music)) (uppernote '()) (note_moment (ly:moment-mul t (ly:make-moment 1/2))) (c1 (ly:moment-div orig-len t)) (c2 (inexact->exact (round (/ (ly:moment-main-numerator c1) (* 2 (ly:moment-main-denominator c1)))))) (count (if (< c2 2) 2 c2)))
(set! (ly:music-property music 'elements) (filter (lambda (y) (eq? 'NoteEvent (ly:music-property y 'name))) (ly:music-property music 'elements))) (map (lambda (y) (ac:setduration y hemisemidur)) (ly:music-property music 'elements)) (set! uppernote (ly:music-deep-copy music)) (map ac:up (filter (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property uppernote 'elements)))
(let* ((trillMusicElements (let loop ((so_far (list uppernote music)) (c count)) (if (> c 1) (loop (append (list (ly:music-deep-copy uppernote) (ly:music-deep-copy music)) so_far) (1- c)) so_far))) (trillMusic (make-sequential-music trillMusicElements)) (newlen (ly:music-length trillMusic)) (factor (ly:moment-div orig-len newlen))) (ly:music-compress trillMusic factor); accelerating the music seems to put lily into an infinite loop in; its layout and midi engines.; (let* ((realfactor (exp (* (/ 1.0 count) (log 0.75)))); (factor (ly:make-moment (inexact->exact (round (* 1024 realfactor))); 1024))); (ac:accel trillMusic factor)) )))
% Copy music and strip articulations, ties, etc., for generating% mordents etc.#(define (ac:note-copy music) "return a copy of music that is only notes, no articulations, ties, slurs etc" (let ((new-music (ly:music-deep-copy music))) (set! (ly:music-property new-music 'articulations) '()) (set! (ly:music-property new-music 'elements) (filter (lambda (y) (eq? 'NoteEvent (ly:music-property y 'name))) (ly:music-property new-music 'elements))) new-music))
%% Generate a tempoChangeEvent and its associated property setting.%#(define (ac:tempoChange tempo) (make-sequential-music (list (make-music 'TempoChangeEvent 'metronome-count tempo 'tempo-unit (ly:make-duration 0 0 1/1)) (context-spec-music (make-property-set 'tempoWholesPerMinute tempo) 'Score))))
%% Totally unfold repeats, so that the non-obvious sequencing doesn't% confuse us. This is necessary for time stealing to work, because% that relies on the sequence in which we see events matching their% audible sequence. Also unfold multi-measure rests to equivalent% skips, with preceding and following bar checks, so that time stealing% can change the length of the pause without falling foul of the% implicit bar checks.%#(define (ac:unfoldMusic music) (music-map (lambda (m) (case (ly:music-property m 'name) ((UnfoldedRepeatedMusic) (let ((body (ly:music-property m 'element)) (altl (ly:music-property m 'elements)) (rc (ly:music-property m 'repeat-count))) (if (null? altl) (make-sequential-music (list-tabulate rc (lambda (i) (ly:music-deep-copy body)))) (let ((ealtl (if (> (length altl) rc) (take altl rc) altl))) (make-sequential-music (apply append! (append! (list-tabulate (- rc (length ealtl)) (lambda (i) (list (ly:music-deep-copy body) (ly:music-deep-copy (car ealtl))))) (map (lambda (alt) (list (ly:music-deep-copy body) alt)) ealtl)))))))) ((EventChord) (let-values (((trem evl) (partition (lambda (v) (eq? (ly:music-property v 'name) 'TremoloEvent)) (ly:music-property m 'elements)))) (if (null? trem) m (let* ((tremtype (ly:music-property (car trem) 'tremolo-type)) (tremtype-log (1- (integer-length tremtype))) (durev (find (lambda (v) (not (null? (ly:music-property v 'duration)))) evl)) (totaldur (if durev (ly:music-property durev 'duration) (ly:make-duration tremtype-log 0 1))) (tgt-nrep (/ (duration-visual-length totaldur) (duration-log-factor tremtype-log))) (eff-nrep (max (truncate tgt-nrep) 1)) (tremdur (ly:make-duration tremtype-log 0 (* (/ tgt-nrep eff-nrep) (ly:duration-scale totaldur))))) (or (and (= eff-nrep tgt-nrep) (= (ash 1 tremtype-log) tremtype)) (ly:warning (_ "non-integer tremolo ~a:~a") (duration->lily-string (duration-visual totaldur) #:force-duration #t #:time-scale 1) tremtype)) (for-each (lambda (v) (or (null? (ly:music-property v 'duration)) (set! (ly:music-property v 'duration) tremdur))) evl) (set! (ly:music-property m 'elements) evl) (make-sequential-music (list-tabulate eff-nrep (lambda (i) (ly:music-deep-copy m)))))))) ((MultiMeasureRestMusic) (make-sequential-music (list (make-music 'BarCheck) (make-music 'SkipMusic 'duration (ly:music-property m 'duration)) (make-music 'BarCheck)))) (else m))) (unfold-repeats '() music)))
% If there's an articulation, use it.% If in a slur, use (1 . 1) instead (unless the note is marked staccato,% in which case use ac:portatoFactor).% Treat phrasing slurs as slurs, but allow explicit articulation.%% Expect an EventChord.%% trills, turns, ornaments etc. are also treated as Articulations.% Split into two functions:% ac:getactions traverses the elements in the EventChord% and calculates the parameters.% ac:articulate-chord applies the actions to each NoteEvent in% the EventChord.#(define (ac:getactions music) (let ((at-end-of-slur #f)) (let loop ((factor ac:normalFactor) (newelements '()) (es (ly:music-property music 'elements)) (actions '())) (if (null? es) (begin (set! (ly:music-property music 'elements) (reverse newelements)) (if (not (any (lambda (m) (music-is-of-type? m 'rhythmic-event)) newelements)) actions (append (let ((st ac:stealForward)) (if (= st 0) '() (begin (set! ac:stealForward 0) (list 'steal st)))) actions (cond (ac:inTrill '(trill)) ((and (eq? factor ac:normalFactor) (or ac:inSlur ac:inPhrasingSlur)) (list 'articulation '(1 . 1))) ((and (eq? factor ac:staccatoFactor) (or ac:inSlur at-end-of-slur)) (list 'articulation ac:portatoFactor)) (else (list 'articulation factor)))))) ; else part (let ((e (car es)) (tail (cdr es))) (case (ly:music-property e 'name)
((BeamEvent) ; throw away beam events, or they'll be duplicated by turn or trill (loop factor newelements tail actions))
((LineBreakEvent FingeringEvent MarkEvent BreathingEvent TieEvent SkipEvent RestEvent) ; pass through some events. (loop (cons 1 1) (cons e newelements) tail actions))
((ArticulationEvent) (let ((articname (ly:music-property e 'articulation-type))) ; TODO: add more here (cond ((string= articname "staccato") (loop ac:staccatoFactor newelements tail actions)) ((string= articname "staccatissimo") (loop ac:staccatissimoFactor newelements tail actions)) ((string= articname "portato") (loop ac:portatoFactor newelements tail actions)) ((string= articname "tenuto") (loop ac:tenutoFactor newelements tail actions)) ((string= articname "mordent") (loop (cons 1 1) newelements tail (cons 'mordent actions))) ((string= articname "prall") (loop (cons 1 1) newelements tail (cons 'prall actions))) ((string= articname "trill") (loop (cons 1 1) newelements tail (cons 'trill actions))) ((string= articname "turn") (loop (cons 1 1) newelements tail (cons 'turn actions))) (else (loop factor (cons e newelements) tail actions)))))
((TextScriptEvent) (let ((t (ly:music-property e 'text))) (if (not (string? t)) (loop factor (cons e newelements) tail actions) (begin (cond ((or (string= t "rall") (string= t "Rall") (string= t "rit.") (string= t "rall.")) (loop factor (cons e newelements) tail (cons 'rall actions))) ((or (string= t "accelerando") (string= t "accel") (string= t "accel.")) (loop factor (cons e newelements) tail (cons 'accel actions))) ((or (string= t "poco accel.")) (loop factor (cons e newelements) tail (cons 'pocoAccel actions))) ((or (string= t "poco rall.") (string= t "poco rit.")) (loop factor (cons e newelements) tail (cons 'pocoRall actions))) ((or (string= t "a tempo") (string= t "tempo I")) (loop factor (cons e newelements) tail (cons 'aTempo actions))) (else (loop factor (cons e newelements) tail actions)))))))
((SlurEvent) (let ((direction (ly:music-property e 'span-direction))) (set! ac:inSlur (eqv? direction -1)) (set! at-end-of-slur (eqv? direction 1)) (loop factor newelements tail actions)))
((TrillSpanEvent) (let ((direction (ly:music-property e 'span-direction))) (set! ac:inTrill (eqv? direction -1)) (if ac:inTrill (loop factor newelements tail (cons 'trill actions)) (loop factor (cons e newelements) tail actions))))
((PhrasingSlurEvent) (let ((direction (ly:music-property e 'span-direction))) (set! ac:inPhrasingSlur (eqv? direction -1)) (loop factor newelements tail actions)))
(else (loop factor (cons e newelements) tail actions))))))))
#(define (ac:articulate-chord music) (cond ((eq? 'EventChord (ly:music-property music 'name)) (ac:logEventsBackward (let loop ((actions (ac:getactions music))) (if (null? actions) (if (ly:moment<? (ly:make-moment 1/4) (ly:music-length music)) (ac:to128 music) music)
(case (car actions)
((articulation) (map (lambda (x) (ac:articulate-one-note x (cadr actions))) (ly:music-property music 'elements)) (let* ((num (caadr actions)) (denom (cdadr actions)) (mult (ly:duration-factor ac:currentDuration)) (newnum (* (- denom num) (car mult))) (newdenom (* (cdr mult) denom)) (len (ly:duration-log ac:currentDuration)) (dots (ly:duration-dot-count ac:currentDuration)))
(if (not (eqv? num denom)) (make-sequential-music (list (ac:to128 music) (make-music 'EventChord 'elements (list (make-music 'RestEvent 'duration (ly:make-duration len dots newnum newdenom)))))) music)))
((accel) (set! ac:lastTempo ac:currentTempo) (set! ac:currentTempo (ly:moment-div ac:currentTempo ac:rallFactor)) (let ((pset (ac:tempoChange ac:currentTempo))) (if (null? (cdr actions)) (make-sequential-music (list pset music)) (make-sequential-music (list pset (loop (cdr actions)))))))
((pocoAccel) (set! ac:lastTempo ac:currentTempo) (set! ac:currentTempo (ly:moment-div ac:currentTempo ac:pocoRallFactor)) (let ((pset (ac:tempoChange ac:currentTempo))) (if (null? (cdr actions)) (make-sequential-music (list pset music)) (make-sequential-music (list pset (loop (cdr actions)))))))
((rall) (set! ac:lastTempo ac:currentTempo) (set! ac:currentTempo (ly:moment-mul ac:currentTempo ac:rallFactor)) (let ((pset (ac:tempoChange ac:currentTempo))) (if (null? (cdr actions)) (make-sequential-music (list pset music)) (make-sequential-music (list pset (loop (cdr actions)))))))
((pocoRall) (set! ac:lastTempo ac:currentTempo) (set! ac:currentTempo (ly:moment-mul ac:currentTempo ac:pocoRallFactor)) (let ((pset (ac:tempoChange ac:currentTempo))) (if (null? (cdr actions)) (make-sequential-music (list pset music)) (make-sequential-music (list pset (loop (cdr actions)))))))
((aTempo) (set! ac:currentTempo ac:lastTempo)
(let ((pset (ac:tempoChange ac:currentTempo))) (if (null? (cdr actions)) (make-sequential-music (list pset music)) (make-sequential-music (list pset (loop (cdr actions)))))))
((trill) (ac:trill music))
((prall) ; A pralltriller symbol can either mean an inverted mordent ; or a half-shake -- a short, two twiddle trill. ; We implement as a half-shake. (let* ((origlength (ly:music-length music)) (gracedur (ly:make-duration 5 0 1/1)) (gracenote (ac:note-copy music)) (abovenote (ac:note-copy music)) (abovenoteTwo (ac:note-copy music)) (mainnote (ly:music-deep-copy music)))
(map (lambda (y) (ac:setduration y gracedur)) (ly:music-property gracenote 'elements)) (map (lambda (y) (ac:setduration y gracedur)) (ly:music-property abovenote 'elements)) (map (lambda (y) (ac:setduration y gracedur)) (ly:music-property abovenoteTwo 'elements)) (map ac:up (filter (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property abovenote 'elements))) (map ac:up (filter (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property abovenoteTwo 'elements))) (let* ((prallMusic (make-sequential-music (list abovenote gracenote abovenoteTwo mainnote))) (newlen (ly:music-length prallMusic)) (factor (ly:moment-div origlength newlen))) (ly:music-compress prallMusic factor))))
((mordent) (let* ((origlength (ly:music-length music)) (gracedur (ly:make-duration 5 0 1/1)) (gracenote (ac:note-copy music)) (belownote (ac:note-copy music))) (map (lambda (y) (ac:setduration y gracedur)) (ly:music-property gracenote 'elements)) (map (lambda (y) (ac:setduration y gracedur)) (ly:music-property belownote 'elements)) (map ac:down (filter (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property belownote 'elements)))
(let* ((mordentMusic (make-sequential-music (list gracenote belownote music))) (newlen (ly:music-length mordentMusic)) (factor (ly:moment-div origlength newlen))) (ly:music-compress mordentMusic factor))))
((turn) (let* ((dur (ly:music-property (car (ly:music-property music 'elements)) 'duration)) (factor (ly:duration-factor dur)) (newdur (ly:make-duration (+ (ly:duration-log dur) 2) (ly:duration-dot-count dur) (car factor)(cdr factor)))) (begin (map (lambda (y) (ac:setduration y newdur)) (ly:music-property music 'elements)) (let* ((above (ly:music-deep-copy music)) (below (ly:music-deep-copy music)) (newmusic (make-sequential-music (list above music below music)))) (begin (map ac:down (filter (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property below 'elements))) (map ac:up (filter (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property above 'elements))) newmusic))))) ((steal) (let ((totallen (ly:moment-main (ly:music-length music))) (steallen (cadr actions))) (if (>= steallen totallen) (begin (if (any (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name))) (ly:music-property music 'elements)) (ly:warning (_ "stealing the entirety of a note's time"))) (set! ac:stealForward (- steallen totallen)) (make-sequential-music '())) (begin (ly:music-compress music (ly:make-moment (/ (- totallen steallen) totallen))) (loop (cddr actions)))))) )))))
((eq? 'GraceMusic (ly:music-property music 'name)) (let ((first-ev (call-with-current-continuation (lambda (yield-fev) (music-map (lambda (m) (if (eq? 'EventChord (ly:music-property m 'name)) (yield-fev m) m)) music) #f)))) (if first-ev (let ((fev-pos (find-tail (lambda (m) (eq? m first-ev)) ac:eventsBackward))) (if fev-pos (set! ac:eventsBackward (cdr fev-pos)) (ly:warning (_ "articulation of grace notes has gone awry")))))) (let* ((gmus (ly:music-compress (ly:music-property music 'element) (ly:make-moment ac:defaultGraceFactor))) (glen (ly:moment-main (ly:music-length gmus)))) (ac:stealTimeBackward (* glen ac:defaultGraceBackwardness)) (set! ac:stealForward (+ ac:stealForward (* glen (- 1 ac:defaultGraceBackwardness)))) gmus))
((memq (ly:music-property music 'name) '(BarCheck SkipMusic)) (let ((totallen (ly:moment-main (ly:music-length music))) (steallen ac:stealForward)) (cond ((= steallen 0) (ac:logEventsBackward music)) ((< steallen totallen) (set! ac:stealForward 0) (ac:logEventsBackward (ly:music-compress music (ly:make-moment (/ (- totallen steallen) totallen))))) (else (set! ac:stealForward (- steallen totallen)) (make-sequential-music '())))))
((eq? 'KeyChangeEvent (ly:music-property music 'name)) (set! ac:current-key music) music)
((eq? 'PropertySet (ly:music-property music 'name)) (ac:adjust-props (ly:music-property music 'symbol) music) music)
(else music)))
% At last ... here's the music function that applies all the above to a% score.%% NOTE: 'articulate-unfold' is the function of original version,%% now 'articulate' is the version which 'unfoldMusic' was removed.articulate = #(define-music-function (music) (ly:music?) "Adjust times of note to add tenuto, staccato and normal articulations. " (dynamic-wind (lambda () (set! ac:stealForward 0) (set! ac:eventsBackward '())) (lambda () (music-map ac:articulate-chord (ac:startup-replacements music))) (lambda () (or (= ac:stealForward 0) (begin (ly:warning (_ "articulation failed to steal ~a note at end of music") ac:stealForward) (set! ac:stealForward 0))) (set! ac:eventsBackward '()))))
articulate-unfold = #(define-music-function (music) (ly:music?) "Adjust times of note to add tenuto, staccato and normal articulations. " (dynamic-wind (lambda () (set! ac:stealForward 0) (set! ac:eventsBackward '())) (lambda () (music-map ac:articulate-chord (ac:startup-replacements-unfold music))) (lambda () (or (= ac:stealForward 0) (begin (ly:warning (_ "articulation failed to steal ~a note at end of music") ac:stealForward) (set! ac:stealForward 0))) (set! ac:eventsBackward '()))))
#(define (ac:startup-replacements music) (fold (lambda (f m) (f m)) music (list event-chord-wrap! ac:replace-aftergrace ac:replace-appoggiatura )))
#(define (ac:startup-replacements-unfold music) (fold (lambda (f m) (f m)) music (list event-chord-wrap! ac:replace-aftergrace ac:replace-appoggiatura ac:unfoldMusic )))
#(define (ac:replace-aftergrace music) (map-some-music (lambda (expr) (with-music-match (expr (music 'SimultaneousMusic elements (?before-grace (music 'SequentialMusic elements ((music 'SkipMusic) (music 'GraceMusic element ?grace)))))) (ac:aftergrace ?before-grace ?grace))) music))
#(define (ac:replace-appoggiatura music) ;; appoggiature are ugly to deal with since they require a main ;; note following them. We only try dealing with this followership ;; in sequential music (map-some-music (lambda (m) (if (eq? 'SequentialMusic (ly:music-property m 'name)) (pair-for-each (lambda (elts) (let ((expr (car elts)) (main (and (pair? (cdr elts)) (cadr elts)))) (and main ;;stolen from define-music-display-methods (with-music-match (expr (music 'GraceMusic element (music 'SequentialMusic elements (?start ?music ?stop)))) ;; we check whether ?start and ?stop look like ;; startAppoggiaturaMusic stopAppoggiaturaMusic (and (with-music-match (?start (music 'SequentialMusic elements ((music 'EventChord elements ((music 'SlurEvent span-direction START)))))) #t) (with-music-match (?stop (music 'SequentialMusic elements ((music 'EventChord elements ((music 'SlurEvent span-direction STOP)))))) #t) (let* ((app (ac:appoggiatura ?music main)) (apps (ly:music-property app 'elements))) (set-car! elts (car apps)) (set-car! (cdr elts) (cadr apps)) #f)))))) (ly:music-property m 'elements))) #f) music))
% Override \afterGrace to be in terms of audio, not spacing.% Special handling for a gruppetto after a trill.#(define (ac:aftergrace main grace) (let* ((main-length (ly:music-length main)) (grace-orig-length (ly:music-length grace)) (gracelen (ac:twiddletime main)) (grace-factor (ly:moment-div gracelen grace-orig-length)) (new-main-length (ly:moment-sub main-length gracelen)) (factor (ly:moment-div new-main-length main-length)) ) (map (lambda (y) (set! (ly:music-property y 'twiddle) gracelen)) (filter (lambda (z) (and (eq? 'ArticulationEvent (ly:music-property z 'name)) (string= "trill" (ly:music-property z 'articulation-type)))) (ly:music-property main 'elements))) (ac:add-articulation "tenuto" grace) (make-sequential-music (list (ly:music-compress main factor) (ly:music-compress grace grace-factor)))))
% An appoggiatura takes half the duration of the main note,% or 1/3 if the note is dotted (i.e., half the undotted equivalent time)% Somewhere around the end of the 19th, start of 20th century the rules% changed, but my main interest is early music.#(define (ac:appoggiatura grace main) (let* ((maindur (ly:music-length main)) (grace-orig-len (ly:music-length grace)) (main-orig-len (ly:music-length main)) (numerator (ly:moment-main-numerator maindur)) (factor (if (eqv? (remainder numerator 3) 0) (ly:make-moment 1/3) (ly:make-moment 1/2)))) (ly:music-compress grace (ly:moment-mul factor (ly:moment-div main-orig-len grace-orig-len))) (ly:music-compress main (ly:moment-sub (ly:make-moment 1/1) factor))
(set! (ly:music-property grace 'elements) (append (ly:music-property grace 'elements) (list (make-music 'SlurEvent 'span-direction -1)))) (set! (ly:music-property main 'elements) (append (ly:music-property main 'elements) (list (make-music 'SlurEvent 'span-direction 1)))) (make-sequential-music (list grace main))))1234567891011
% \lotusRepeatABA { {A} B }% ->% {A} B {A}lotusRepeatABA = #(define-music-function (music) (ly:music?) "The placeholder function to represent a music repeat type AB -> ABA, e.g. Da Capo al Fine, Da Segno al Coda, etc. " music)12345678
dotB = \markup { \char ##x25cf }dotW = \markup { \char ##x25cb }
lyrRed = { \override Lyrics.LyricText.color = #red \override Lyrics.LyricText.font-series = #'bold }lyrGreen = { \override Lyrics.LyricText.color = #darkgreen \override Lyrics.LyricText.font-series = #'bold }lyrYellow = { \override Lyrics.LyricText.color = #(rgb-color 0.6 0.4 0) \override Lyrics.LyricText.font-series = #'bold }lyrGray = { \override Lyrics.LyricText.color = #(rgb-color 0.8 0.8 0.8) \revert Lyrics.LyricText.font-series }Dockerfile-3
jison/lilypond.jisonAdded+2884
jison/measureLayout.jisonAdded+253
ly/articulate-lotus.lyAdded+1060
ly/lotus.lyAdded+11
ly/rhythmSymbols.lyAdded+8