osmd-audio-player icon indicating copy to clipboard operation
osmd-audio-player copied to clipboard

Chords are not being played

Open Matthew1172 opened this issue 2 years ago • 0 comments

If I have a music XML file that has some named chords in it such as "G7" and "Am" then it shows up in the rendering like this: Screenshot 2022-04-27 004435 And in a program like MuseScore, those chords will be played. However I'm not sure if this is a feature related to OSMD or the OSMD audio player, but they're not being played on my website. Is there something I'm missing or has this feature not been implemented? Here is a skeleton of my code:

let osmd = new opensheetmusicdisplay.OpenSheetMusicDisplay("osmdCanvas", {
    // set options here
    backend: "canvas",
    drawingParameters: "compacttight", // more compact spacing, less padding
    drawMeasureNumbers: false,
    drawFromMeasureNumber: 0,
    drawUpToMeasureNumber: Number.MAX_SAFE_INTEGER // draw all measures, up to the end of the sample
});
let audioPlayer = new OsmdAudioPlayer();

...

mxl = atob(response['scoreXml']);
//play_and_render(mxl);
try {
    osmd.load(mxl)
        .then(function () {
            osmd.render();
            osmd.cursor.show();
            audioPlayer.loadScore(osmd);
            $('#controls').show();
        });
    const instrument = osmd.Sheet.Instruments.flatMap(i => i.Voices);
    $("#instruments option:selected").prop("selected", false)
    $('#instruments option[value="'+instrument[0].midiInstrumentId+'"]');
}catch (e) {
    //osmd could not load the mxl. Most likely it is 'BadArguments' provided duration is not valid.
    alert("OSMD could not load the mxl. Please try again.");
}

Thank you again for your help.

Matthew1172 avatar Apr 27 '22 04:04 Matthew1172