GithubHelp home page GithubHelp logo

jimutt / osmd-audio-player Goto Github PK

View Code? Open in Web Editor NEW
121.0 121.0 31.0 3.82 MB

Audio playback extension for OpenSheetMusicDisplay. Browser based audio player for MusicXML scores.

License: MIT License

JavaScript 2.68% TypeScript 97.32%

osmd-audio-player's People

Contributors

csantero avatar dependabot[bot] avatar jimutt avatar joshstovall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osmd-audio-player's Issues

Click to set playback position

First of all, thank the author for providing this player. I have a problem with the use of it now that I need to support click to set playback position. I think it is in your feature list. Is there any progress in this implementation?

this xml file cause various errors

the truth untold.zip
this file cause various errors

problem 1. ( measure 4, player play 2 eight note at the same time)
같이 쳐지는 곳 (measure 4)

problem 2. ( measure 11, player play half note and next note at the same time)
음의 길이가 거의 무시됨 (measure 11)

problem 3. (measure 22, player play 2 half note at the same time)
2분음표인데 빨리지나감

problem 4. (measure 44 ~ end, player getting faster and faster)
점점 빨라짐

I also have other files that cause same errors little but this one have all the errors in it
(If you tell me you need anothor xml file, I'll look for more.)
I don't think this problem is limited to this file.

I hope these problems are solved without difficulty
best wishes, djae88

Need more detailed documentation

Hello there!
Thank you very much for developing this plugin. This feature is exactly what I need! (for hexo blog)
But I am confused, how can I use it?

Obviously write directly in html:

<script src="./app.js"></script>

Is not working.

So I hope to have a more detailed introduction on how users should use it after installation.
Thank you!

Best wishes
Chang

The cursor cannot follow the new page.

image

this project work well when pageformat is endless
but when I set pageformat option (or newPageFromXML option) like "a4 p" or others
cursor cannot follow the new page
it came back to starting point (but it wasn't an exact location)

image

image

Thanks

Staccato support

Implement staccato support. For midi playback it can be simulated with higher velocity and shorter generation

The rest note makes a sound

The rest note's supposed to be silent, but
when the display-step and display-octave is set and
it is lower than octave 5, D
this makes a sound.

this sample is made of four rest notes.
first rest note
image
Second rest note (this note makes a sound)
image
third rest note (this note makes a sound)
image
fourth rest note
image

The sample:
image
test rest note sound.zip

Best Wishes, Thanks

Player dependent upon online connection?

Hi,
I'm using your player in my app, which loads all files and html/js locally. I notice that if the device is offline for a period of time, the audio player eventually stops working (the buttons don't respond even though OSMD rendering continues to work fine). I'm not sure if this is a WKWebkit issue or something to do with the player. But does the player rely on being online for its functionality? If so, is there a way to bypass that requirement and make it consistently work offline? Thanks!

Error with ionic

Hi guys,
I find to use library with my ionic app
pakage.json
{
"name": "SolfeggioApp",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"start": "ionic-app-scripts serve",
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint"
},
"dependencies": {
"@angular-devkit/schematics": "^10.2.0",
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/platform-browser": "5.2.11",
"@angular/platform-browser-dynamic": "5.2.11",
"@capacitor/core": "2.4.0",
"@ionic-native/core": "4.20.0",
"@ionic-native/device": "^5.29.0",
"@ionic-native/media": "^5.29.0",
"@ionic-native/native-audio": "^5.29.0",
"@ionic-native/splash-screen": "4.20.0",
"@ionic-native/status-bar": "4.20.0",
"@ionic/storage": "2.2.0",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^6.0.0",
"@types/node": "^14.14.5",
"ionic-angular": "3.9.9",
"ionicons": "3.0.0",
"osmd-angular": "^1.0.3",
"osmd-audio-player": "^0.6.2",
"rxjs": "^5.5.11",
"soundfont-player": "^0.12.0",
"standardized-audio-context": "^25.1.4",
"sw-toolbox": "3.6.0",
"typescript": "^4.0.3",
"zone.js": "0.8.29"
},
"devDependencies": {
"@capacitor/cli": "2.4.0",
"@ionic/app-scripts": "3.2.4",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-nativeaudio": "^3.0.9"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-nativeaudio": {},
"cordova-plugin-device": {}
}
}
}
In a component I use library in this way:
import { PlaybackEvent } from 'osmd-audio-player/src/PlaybackEngine';
import AudioPlayer from 'osmd-audio-player/src';
.....
ngAfterViewInit() {
try {
const canvas: HTMLElement = document.getElementById("score");
this.openSheetMusicDisplay = new OpenSheetMusicDisplay(canvas);
this.openSheetMusicDisplay.setLogLevel('error');
this.openSheetMusicDisplay
.load("../../assets/esercizi/dettati/livello_base/esercizio_1/Dettato_Melodico_Esercizio1_music_xml.xml")
.then(
() =>
this.init(),
(err) => console.error(err)
)
.then(
() => console.log("Sheet music displayed."),
(err) => console.error(err)
);
} catch (e) {
console.error(e);
}

}

async init() {
this.openSheetMusicDisplay.render();
const audioPlayer = new AudioPlayer();
await audioPlayer.loadScore(this.openSheetMusicDisplay);
audioPlayer.on(PlaybackEvent.ITERATION, notes => {
console.log(notes);
});
}
and got this error:
Error: Module build failed: Error: ENOENT: no such file or directory, open '....\node_modules\osmd-audio-player\src\PlaybackEngine.js'

Please Do you know why?
Thanks

intrument error

When I applied a number of musicxml,

some xml caused error
sdfsf

and some xml worked well

so I looked at the similarities and I found that

working well xml use <instrument-name>Piano</instrument-name>
image

and others use something else
image
image

image
no errors have occurred since it was overwritten

I think if instrument-name is not in list (available instrument list?)
It seems to be causing an error

so I think adding
if instument-name in xml is not in list
then overwrite piano or similar instrument(available)
will solve the error

thanks for reading

Generic events

Implement generic event/observer support.

Example events:

  • Playback state update
  • Note scheduling events

Interface

Listen/subscribe

osmdAudioPlayer.on('event-name', (p1, p2) => {

});

Emit

this.emit('event-name', p1, p2);

Adding score XML string in demo does not show cursor

For a quick test, I am replacing https://github.com/jimutt/osmd-audio-player/blob/master/demos/umd-web/app.js#L5-L7 with something like:

const scoreXml = `
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
 <score-partwise version="3.1">
   <movement-title>Chord Symbol Example</movement-title>
   <identification>
   [...]
`.trim();

which puts the XML straight into the demo source. The XML file is here.

The sheet gets displayed properly, and I can play it, but the green cursor does not show or advance. What am I missing? Thanks!

Safari support

I'm using the player on Safari 13.1, and it's not working so well in this browser. When I try to execute the player, the console shows this message:

ReferenceError: Can't find variable: AudioContext

... I think that AudioContext needs to be replaced by the webkitAudioContext in Safari. The Player works when I explicit pass the proper AudioContext in the PlaybackEngine constructor but it crashes when I try to stop it:

image

Future binary?

Hi,
I have written an ios app using OSMD. It uses a WKWebview but all files are loaded locally. I would love to incorporate your audio player. I have just started to experiment with it. I can run the basic demo locally but am trying to figure out how I am going to add this to my XCode project.

Do you think it may be possible for you to provide a master binary in your future releases? I don't know Javascript well so am not sure if this is practical. But with OSMD, I just add the binary opensheetmusicdisplay.min.js to the project and I can easily reference everything using that and get it all to work. With the audio player, importing and connecting all of the various parts of the project (../../dist/PlaybackEngine, etc.) make it relatively complicated and impractical for an app development situation.
Please let me know if the binary idea makes sense and is a possibility. I would appreciate any advice otherwise.
Thank you!
Matt

Implementations of <transpose> tags, swing 8th's, and click/count-in option ?

Hello,

I am having good luck with your player, in general. Thanks for your wonderful work and the quick response with the UMD!

I have a few questions. Forgive me for the length of this message. I realize that some of these are probably already on your to-do list. Nonetheless, I believe these features will probably be needed by many users so thought I'd ask.

  1. Are you planning on implementing the tags anytime soon so that transposing instruments are adjusted to play at concert pitch? For instance, if the instrument is Eb alto saxophone and the key is concert C (actual sounding pitches), the score will be written in A major but should sound down a minor 6th, 9 semitones, implementing the tags:
    <transpose>
    <diatonic>-5</diatonic>
    <chromatic>-9</chromatic>
    </transpose>

Tenor sax in Bb would sound down 14 semitones from the written score:
<transpose>
\ <diatonic>-1</diatonic>
<chromatic>-2</chromatic>
\ <octave-change>-1</octave-change>
</transpose>

Guitar would be down an octave, since it's a tenor instrument.
<transpose>
<diatonic>0</diatonic>
<chromatic>0</chromatic>
<octave-change>-1</octave-change>
</transpose>

  1. Are there any plans to have an optional click, and to also have the option to count-in before the music plays (for instance, 4 clicks before start)?

  2. Implementing Swing 8ths? (This is something you would need to coordinate with OSMD, and I will also ask them.) I think the only music xml way now is to change the eighth note durations (for instance, 170 + 86). This sounds right in your audio player but this changes the notation when rendered by OSMD (it puts triple dots after each eight note). (FYI, when Sibelius opens the same xml file, it looks OK [except the spacing is changed a little]. MuseScore will not even open the file.) Any other way to implement swing in your player/OSMD?

  3. Is there a function to purge the audio from the AudioPlayer? My app injects the javascript without always reloading the html, so sometimes the player will play all of the previous scores at the same time because the players or scores are still in memory.

Thanks for your consideration!

Matt

Chords are not being played

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.

simple event addition : end of score EVENT

An "end of score" callback, useful for adapting the UI elements.

PlaybackEngine.ts

export enum PlaybackEvent {
  STATE_CHANGE = "state-change",
  ITERATION = "iteration",
  END_OF_SCORE = "end-of-score", // new event
}

// callback
  private endOfScoreCallback(message: string) {
    this.events.emit(PlaybackEvent.END_OF_SCORE, message);
  }

 // check for "end of score" and firing cb
private iterationCallback() {
    if (this.state !== PlaybackState.PLAYING) return;
    if (this.currentIterationStep > 0) this.cursor.next();
    ++this.currentIterationStep;	
// Checking here
if (this.currentIterationStep > this.iterationSteps) {
      this.endOfScoreCallback("End of score");
    }
}

About repeat, alternate ending, D.C. coda, etc

If I to play by the sheetmusic with a repeat and alternate ending, the playback just will go to the next measure and ignore the repeat in music.
Maybe I missed some settings... Or it can be fixed in future?
I think it will be very cool to support this!

Repeat support

  • Handle barline repeats
  • Support toggling repeats on/off

Basic repeat handling would first need to be supported by the iterator/cursor in OSMD. Then it should be quite straight forward to just start using it here.

Scheduler question

Hey just a question not really an issue.
Trying to investigate general principles and design.
Do I understand correctly scheduler implementation is mainly to correctly playback audio?
I am looking into how possible to make something like step sequencer but without audio ( just getting current note info ). Is it simply achievable or calculating audio context related timestamps embedded and part of scheduler / iteration?
Thank you! Code looking clean, wish better understand it.

edit: just discovered https://github.com/opensheetmusicdisplay/opensheetmusicdisplay/wiki/Tutorial:-Extracting-note-timing-for-playing - is it based on such concepts?

Select instrument per instrument not voice?

Hi, I'm not sure this title is right, haha... I'm bad at English

image

in this example above, first staff is for vocal and second, third staves are for piano part
and I don't think there are many people who need to change the piano part (second and the third) seperately.
because it was originally designated as one instrument (by writer)

So I think it's better to show select option per instrument, not voice

I came up with this idea, because of some writer's sheet gets more voices than staves in one instrument (for no reason),
and It doesn't look good.
image

I'm trying to do this myself but it's difficult for me
If you update this, it will be of great help

Thanks :)

How do we switch instruments

I'm using bare javascript and I was thinking I could do something like this

audioPlayer.loadScore(osmd);
audioPlayer.setInstrument(new Soundfont.instrument(audioPlayer.ac['_nativeAudioContext'], 'acoustic_grand_piano'), 0);

But it doesn't do anything

The tuplet speed up the song

I find one of the reasons why the song is unusually fast.
If the score has two or more staves, and tuplet is on one staff and not on the other,
It makes the song fast.

image
The tuplet speed up the song.zip

I hope be able to PR someday but
I'm not very good at programming, My limit is to report like this
Thanks for reading
Best wishes

Percussion playback?

Any thoughts on adding percussion playback? This would be a great feature. I'm thinking about adding this soon. Any thoughts?

Feature: Callback/event on note play

Hi! Awesome little project you've put together here.

Haven't really dug too deep into your code yet, but I am in search of some sort of way of doing a number of things related to whenever a note is played/right before a note is played.

A callback or event of some sort that I could attach to that provides me with the PlaybackEngine object (or something along those lines) would be very much appreciated.

Get time

Is there a way to get the exact time of note(and NoteTie)?

I tried to get it from OsmdAudioPlayer.min.js it works for all except ties.

Cursor reference problems on Ionic/Angular

image

OSMDisplay lib is working fine on Ionic, and the Audio Player actually plays the music, however the PlaybackEngine.cursor object seems to be being duplicated on the Audio-Player library files, so its not referencing the same osmd.cursor that is being showed on the screen
image
As you can see above, the hidden variable is different on both objects, one is being printed on our own project file and the other one was added to PlaybackEngine.js from the osmd-audio-player files

Custom soundfont player

I'd like to avoid the current dependency of soundfont-player and supply a custom web audio pipeline for playback to gain more control of the low level audio features.

Setup CI/CD

Should setup CI/CD to stop mess up my manual publishes 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.