-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The issue of missing audio effects. #3775
Comments
A request for mordents, trills, turn, etc for MIDI export has an issue already: #1928 Algorithms that take tempo (and note score-based durations) are needed in order to realize mordents, trills, and turns (and to some extent for grace notes). If there are published algorithms for generating ornaments, this it is more likely that these ornaments will be added to verovio. I.e., at tempo 100, how should auxiliary notes for a mordent on a quarter note be realized, at a tempo of 180 on an 8th note?, etc. Providing such algorithms would make it more likely to be implement in verovio. Do you mean where in the C++ code to add for a PR? @lpugin could answer that. Basically in There have been other samplers of ornaments to realize in MIDI in the past week: The MusicXML excerpt is nice, but preferably a complete file is desired (that can be loaded into verovio, since an excerpt cannot be loaded). Otherwise, nothing can be down with the excerpt, such as check to see if there is a problem in the MusicXML import as compared to grace notes in the MEI form of the data. grace notes do note have a duration, so it cannot be wrong :-) <grace/>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<voice>2</voice>
<type>32nd</type>
<stem>down</stem>
<staff>1</staff>
<beam number="1">begin</beam>
<beam number="2">begin</beam>
<beam number="3">forward hook</beam>
</note>
void GenerateMIDIFunctor::GenerateGraceNoteMIDI(
const Note *refNote, double startTime, int tpq, int channel, int velocity)
{
double graceNoteDur = 0.0;
if (m_accentedGraceNote && !m_graceNotes.empty()) {
const double totalDur = refNote->GetScoreTimeDuration() / 2.0;
this->DeferMIDINote(refNote, totalDur, true);
graceNoteDur = totalDur / m_graceNotes.size();
}
else {
graceNoteDur = UNACC_GRACENOTE_DUR * m_currentTempo / 60000.0;
const double totalDur = graceNoteDur * m_graceNotes.size();
if (startTime >= totalDur) {
startTime -= totalDur;
}
else {
this->DeferMIDINote(refNote, totalDur, true);
}
}
for (const MIDIChord &chord : m_graceNotes) {
const double stopTime = startTime + graceNoteDur;
for (int pitch : chord.pitches) {
m_midiFile->addNoteOn(m_midiTrack, startTime * tpq, channel, pitch, velocity);
m_midiFile->addNoteOff(m_midiTrack, stopTime * tpq, channel, pitch);
}
startTime = stopTime;
}
} Line 75 of #define UNACC_GRACENOTE_DUR 27 // in milliseconds |
At present, this should be a normal grace note. I have isolated the problematic part of the XML instance. After consulting with a friend who studies music, they suggested that at 60 BPM, a single quarter grace note should last 0.25 seconds. For the first group of grace notes, the durations should be 0.03125 seconds, 0.03125 seconds, and 0.125 seconds respectively. They mentioned that the grace notes are generally too fast, making them hard to hear clearly, while the second group of grace notes is too slow. Details<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
<work>
<work-title>未命名乐谱</work-title>
</work>
<identification>
<creator type="composer">作曲 / 编排</creator>
<encoding>
<software>MuseScore 4.3.0</software>
<encoding-date>2024-09-14</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="no"/>
<supports element="print" attribute="new-system" type="no"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>钢琴</part-name>
<part-abbreviation>Pno.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>钢琴</instrument-name>
<instrument-sound>keyboard.piano</instrument-sound>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>1</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<direction placement="above">
<direction-type>
<words font-weight="bold" font-size="12">Grave</words>
</direction-type>
<staff>1</staff>
<sound tempo="35"/>
</direction>
<direction placement="below">
<direction-type>
<pedal type="resume" line="yes" sign="yes"/>
</direction-type>
<staff>1</staff>
</direction>
<note>
<pitch>
<step>D</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<direction placement="below">
<direction-type>
<pedal type="stop" line="yes" sign="no"/>
</direction-type>
<staff>1</staff>
</direction>
<backup>
<duration>4</duration>
</backup>
<note>
<grace/>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<voice>2</voice>
<type>32nd</type>
<stem>down</stem>
<staff>1</staff>
<beam number="1">begin</beam>
<beam number="2">begin</beam>
<beam number="3">forward hook</beam>
</note>
<note>
<grace/>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<voice>2</voice>
<type>16th</type>
<stem>down</stem>
<staff>1</staff>
<beam number="1">continue</beam>
<beam number="2">end</beam>
</note>
<note>
<grace slash="yes"/>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<staff>1</staff>
<beam number="1">end</beam>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>quarter</type>
<stem>down</stem>
<staff>1</staff>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>quarter</type>
<stem>down</stem>
<staff>1</staff>
</note>
<note>
<grace/>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<voice>2</voice>
<type>32nd</type>
<stem>down</stem>
<staff>1</staff>
<beam number="1">begin</beam>
<beam number="2">begin</beam>
<beam number="3">begin</beam>
</note>
<note>
<grace/>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<voice>2</voice>
<type>32nd</type>
<stem>down</stem>
<staff>1</staff>
<beam number="1">end</beam>
<beam number="2">end</beam>
<beam number="3">end</beam>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>quarter</type>
<stem>down</stem>
<staff>1</staff>
</note>
<note>
<grace/>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<staff>1</staff>
</note>
<note>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>quarter</type>
<stem>down</stem>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>5</voice>
<staff>2</staff>
</note>
<barline location="right">
<bar-style>light-light</bar-style>
</barline>
</measure>
<measure number="2">
<direction placement="above">
<direction-type>
<words font-weight="bold" font-size="12">Largo</words>
</direction-type>
<staff>1</staff>
<sound tempo="50"/>
</direction>
<direction placement="below">
<direction-type>
<dynamics>
<p/>
</dynamics>
</direction-type>
<staff>1</staff>
<sound dynamics="54.44"/>
</direction>
<direction placement="below">
<direction-type>
<pedal type="resume" line="yes" sign="yes"/>
</direction-type>
<staff>1</staff>
</direction>
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>whole</type>
<time-modification>
<actual-notes>2</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>
<staff>1</staff>
<notations>
<ornaments>
<tremolo type="start">3</tremolo>
</ornaments>
</notations>
</note>
<note>
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>whole</type>
<time-modification>
<actual-notes>2</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>
<staff>1</staff>
<notations>
<ornaments>
<tremolo type="stop">3</tremolo>
</ornaments>
</notations>
</note>
<direction placement="below">
<direction-type>
<pedal type="stop" line="yes" sign="no"/>
</direction-type>
<staff>1</staff>
</direction>
<backup>
<duration>4</duration>
</backup>
<note>
<pitch>
<step>E</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>whole</type>
<time-modification>
<actual-notes>2</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>
<staff>2</staff>
<notations>
<ornaments>
<tremolo type="start">1</tremolo>
</ornaments>
</notations>
</note>
<note>
<pitch>
<step>C</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>whole</type>
<time-modification>
<actual-notes>2</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>
<staff>2</staff>
<notations>
<ornaments>
<tremolo type="stop">1</tremolo>
</ornaments>
</notations>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise> |
Related to the duplication of the tempo markings in the verovio MIDI output, this test MEI file does not have a problem: Click to view MEI data for above example<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="5.0">
<meiHead>
<fileDesc>
<titleStmt>
<title />
</titleStmt>
<pubStmt>
</pubStmt>
</fileDesc>
<encodingDesc>
<appInfo>
<application isodate="2024-09-14T00:48:52" version="4.3.0-dev-bf6b697-dirty">
<name>Verovio</name>
<p>Transcoded from Humdrum</p>
</application>
</appInfo>
</encodingDesc>
<extMeta>
<frames xmlns="http://www.humdrum.org/ns/humxml" />
</extMeta>
</meiHead>
<music decls="#work1_encoded">
<body>
<mdiv xml:id="m16x8r3f">
<score xml:id="sdszddl">
<scoreDef xml:id="ss3btj4" midi.bpm="80.000000" tempo.dist="3.0000vu">
<staffGrp xml:id="s1eluelt" bar.thru="true" symbol="brace">
<staffDef xml:id="staffdef-L1F2" n="1" lines="5">
<clef xml:id="c47hkko" shape="G" line="2" />
<meterSig xml:id="metersig-L2F2" count="4" unit="4" />
</staffDef>
<staffDef xml:id="staffdef-L1F1" n="2" lines="5">
<clef xml:id="cwsinwy" shape="F" line="4" />
<meterSig xml:id="metersig-L2F1" count="4" unit="4" />
</staffDef>
</staffGrp>
</scoreDef>
<section xml:id="section-L1F1">
<measure xml:id="measure-L1">
<staff xml:id="staff-L1F2" n="1">
<layer xml:id="layer-L1F2N1" n="1">
<note xml:id="note-L4F2" dur="1" oct="5" pname="c" accid.ges="n" />
</layer>
</staff>
<staff xml:id="staff-L1F1" n="2">
<layer xml:id="layer-L1F1N1" n="1">
<note xml:id="note-L4F1" dur="1" oct="3" pname="c" accid.ges="n" />
</layer>
</staff>
</measure>
</section>
</score>
</mdiv>
</body>
</music>
</mei> MIDI output from verovio: "MThd" ; MIDI header chunk marker
4'6 ; bytes to follow in header chunk
2'1 ; file format: Type-1 (multitrack)
2'3 ; number of tracks
2'120 ; ticks per quarter note
;;; TRACK 0 ----------------------------------
"MTrk" ; MIDI track chunk marker
4'11 ; bytes to follow in track chunk
v0 ff 51 v3 t80 ; tempo
v0 ff 2f v0 ; end-of-track
;;; TRACK 1 ----------------------------------
"MTrk" ; MIDI track chunk marker
4'21 ; bytes to follow in track chunk
v0 ff 58 v4 '4 '2 '24 '8 ; time signature
v0 90 '72 '90 ; note-on C5
v480 90 '72 '0 ; note-off C5
v0 ff 2f v0 ; end-of-track
;;; TRACK 2 ----------------------------------
"MTrk" ; MIDI track chunk marker
4'21 ; bytes to follow in track chunk
v0 ff 58 v4 '4 '2 '24 '8 ; time signature
v0 90 '48 '90 ; note-on C3
v480 90 '48 '0 ; note-off C3
v0 ff 2f v0 ; end-of-track Only one tempo change (q=80) is present in the MIDI output from verovio for this short example. |
Sure, thank you very much for your response. We found that both MuseScore and Sibelius confirm what you said. Just a quick question: are effects like multi-note tremolos and trills in your plans? |
The problem with the two unaccented 32nd grace notes (grace notes 4 & 5 that you label as "too slow") are related to this discussion: #2579. |
There is also a problem that will need to be address at some point related to unaccented grace notes at the start of the music. Such grace notes cannot be place in negative time, so some extra time padding needs to be added to insert unaccented grace notes before regular notes at tick-time 0. Adding any padding to the MIDI data will require coordination with the timemap to make sure the extra time padding to the start of the music is included in the timemap timings. For example if an unaccented grace note needs to be inserted at time -27 ms, then the first regular notes should start at time 27 ms (and all other notes after time 0 should have 27 ms added to them to account for this padding). This example has a strange example mixing accented and unaccented grace notes, which should be considered a data error. But if the first two were marked as unaccented (by adding a slash in the MusicXML data for them), then there should be time padding added for these three three grace notes at the start of the music. It may be useful to add an option to verovio to set the duration of unaccented grace notes so that durations other than 27 ms could be rendered in the MIDI output. Ideally MEI would add a prarameter (if it is not already there) for grace notes to specify the duration of grace notes. This would be useful for both accented and unaccented grace notes, and it is not unreasonable to have different durations for unaccented grace notes within one work (particularly if there are grace notes in both slow and fast tempos). For unaccented grace notes, it would be much preferred to use a modern interpretation, where the time stolen from the following note is equal to the visual duration(s) of the accented grace notes. Using an attribute on the grace notes that gives their durations in seconds (or milliseconds) can be used to control the rendering of the durations of the grace notes in the MIDI output (and indirectly the duration of the following note, which would be the duration of that note minus the duration(s) of the appoggiatura notes before it. In other words, the current system seems to be taking 1/2 of the following notes duration and splitting it between the two accented grace notes in this example, making the two grace notes render as sixteenth notes. Instead it should be noted that the two unaccented grace notes are visually 32nd notes, so only a sixteenth note duration should be taken from the following note. If another duration should be used for these notes, then ideally |
Yes, but note that the original request was from 2021 (and I think there may have been one in 2016), so you can project from those date on when other ornamentations may be added 😉 Making lots of assumptions, the Secretary Problem can be used to predict that it should be implemented within the next five years. (3 years is 37% of 8 years, so 5 more years ( |
Hello,
The currently generated MIDI file has incorrect durations for grace notes, and there are no playback effects for mordents, trills, turns, and inverted turns. Could you please advise on where I can make changes to include the logic for these elements in the generated MIDI?
Thank you!
Here is my XML:
In the first measure, there is an issue with the grace note playback. At standard tempo, it might be inaudible, making it seem like there is no sound
The text was updated successfully, but these errors were encountered: