Duration of Chord Invalid?

• Mar 24, 2015 - 14:17

Hi once again (sorry for the forum spam... :P )
The following code works and creates a note. However, it stops at cursor.next(); and crashes as the duration of the note it creates is 'Invalid' based on the text displaying info about the selected elements on the bottom left of the screen. I've looked through the manual and saw this thingy called the DurationElement inherited by the ChordRest which is inherited by the Chord.

I have already set tempChord.duration to the correct amount of ticks at 1920 PPM, and it plays as long as it should, but it appears to have no stem, and no other elements as well... besides a note head which appears much higher than it should be, but with the correct pitch. The note itself should be invisible but it doesn't really appear to be. cursor.next(); also seems to return false, meaning something is wrong?


for(var i = 0; i <= realNotesInBetweenGliss; i++) { //notesInBetweenGliss refers to the user-selected value
var tempChord = newElement(Element.CHORD);
var tempNote = newElement(Element.NOTE);
tempNote.pitch = startNote.ppitch + round((i / realNotesInBetweenGliss) * (pitchDiff - 1));
console.log("curr. pitch: " + tempNote.pitch);
tempChord.add(tempNote);
tempChord.duration = round(tickLengthDiff / realNotesInBetweenGliss);
console.log("curr. dur: " + tempChord.duration);
tempChord.visible = false;
//(numerator, denominator of a bar) or (ticks, 1920)
cursor.setDuration(tempChord.duration / 1920.0, 1);
cursor.add(tempChord);
var works = cursor.next();
console.log("cursor ticks: " + cursor.tick + ", " + works);
}

Anyways, a screenshot of the weird note appearing is attached, I'd really appreciate the help!

Attachment Size
Screenshot 2015-03-24 22.14.20.png 203.37 KB

Comments

apparently:

cursor.setDuration(tempChord.duration / 1920.0, 1);

is a wrong instruction because tempChord.duration is a fraction itself.

i think you are looking for these values:
tempChord.duration.numerator and tempChord.duration.denominator

Do you still have an unanswered question? Please log in first to post your question.