jimutt / osmd-audio-player Goto Github PK
View Code? Open in Web Editor NEWAudio playback extension for OpenSheetMusicDisplay. Browser based audio player for MusicXML scores.
License: MIT License
Audio playback extension for OpenSheetMusicDisplay. Browser based audio player for MusicXML scores.
License: MIT License
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?
osmd upgrade to 0.76 will Cause no cursor found
the truth untold.zip
this file cause various errors
problem 1. ( measure 4, player play 2 eight note at the same time)
problem 2. ( measure 11, player play half note and next note at the same time)
problem 3. (measure 22, player play 2 half note at the same time)
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
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
Implement staccato support. For midi playback it can be simulated with higher velocity and shorter generation
now playback mark is render correctly,but player isnot work
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
Second rest note (this note makes a sound)
third rest note (this note makes a sound)
fourth rest note
The sample:
test rest note sound.zip
Best Wishes, Thanks
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!
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
When I applied a number of musicxml,
and some xml worked well
so I looked at the similarities and I found that
working well xml use <instrument-name>Piano</instrument-name>
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
Implement generic event/observer support.
Example events:
Interface
Listen/subscribe
osmdAudioPlayer.on('event-name', (p1, p2) => {
});
Emit
this.emit('event-name', p1, p2);
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!
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:
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
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.
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>
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)?
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?
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
in 'vue-player-demo' playing
I don't want the screen to move
but I can't find any related option
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:
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.
An "end of score" callback, useful for adapting the UI elements.
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");
}
}
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!
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.
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?
Hi, I'm not sure this title is right, haha... I'm bad at English
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.
I'm trying to do this myself but it's difficult for me
If you update this, it will be of great help
Thanks :)
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
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.
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
For this score, in the measure 3, the third note will be ignored because the de-sync between bass and treble.
Any thoughts on adding percussion playback? This would be a great feature. I'm thinking about adding this soon. Any thoughts?
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.
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.
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
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
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.
Should setup CI/CD to stop mess up my manual publishes 😄
Read dynamics instructions and control output gain
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.