Comments (12)
I fixed the 'const' problem. May you check if playing works now?
About play.js, it seems hard to make it work out of its context, i.e. web browser, abc2svg core and ABC extraction (abcemb.js). Which usage are you thinking about?
from abc2svg.
Hi @moinejf.
We are also trying to use abc2svg in a webpage context and we also found some problem with "strict". In case you are interested, we have setup an example at https://github.com/highskillz/ng-xml2abc2svg/commit/4e86bd8e4824eead15445cfb369a7ba2b39d6739 .
Thanks!
from abc2svg.
Hi @jaocc,
Your link points to the commit, but I could not find any example.
May you give me more information about the problem?
from abc2svg.
Sorry about the hurried post. Should have made this clearer.
That example is a test to using abc2svg in an Angular4 environment.
In that repo, in the 2 most recent commits, we have tried to update the version of the library to 1.13.1.
When running the version on commit 0a112b3 we have an error (https://i.imgur.com/S1dffDx.png).
By removing the "strict" directive (commit 4e86bd8 the code starts working again.
Hope this helps
from abc2svg.
The error image is not clear to me. It says:
"ReferenceError: Abc is not defined"
but I can't see the code that raises this error.
Also, I don't know about a file 'abc2svg.ts' and there is no 'new Abc2svg' in my code.
In my 'abc2svg-1.js', "use strict" is at the head of the file. So, if you appended some other file(s) to this one, the mode will be extended to the added file(s), and, then, the error may appear in these ones.
But, normally, with a dynamic load (as it should be), such a problem would not occur.
from abc2svg.
'Use strict' is essential for me as I am using React (and not angular) and this library only allows you strict mode as it is a good practice. As I said everything works fine for me when replacing const
by var
.
About the usage of play-1.js I was think about this scenario :
I have a string with all the abc data needed (header + abc music notation + \n at the end of each line)
I am using this function as mentioned in the core tutorial you used to provide on your webpage
convert(src, callback){ var errtxt = "", new_page = "" var user = { img_out: function(str){ this.svg = ((typeof this.svg === 'undefined') ? "" : this.svg + '\n') + str if (str == "</div>") callback(this.svg) }, errmsg: function(msg,l,c){ errtxt += msg + '\n' console.log(errtxt) console.log('line, column', l, c) }, page_format: true } var abc = new Abc(user) abc.tosvg("a", src) }
Then instead of adding the svg in my database I want to store the output into a var I could use later (DOM insertion) :
this.src =
X: ${result[i].id}\n+
T: ${result[i].T.split('\n')[0]}\n+
R: ${result[i].R}\n+
M: ${result[i].M}\n+
K: ${result[i].K}\n+
${result[i].body}\n`
this.convert(this.src, (svg) => {
var insert = `INSERT INTO ${this.dest_table} (tuneID, svg) VALUES (
${result[i].id},
"${this.mysql_real_escape_string(svg)}")`
this.connection.query(insert, (err, result) => {
if (err) throw err
console.log("1 record inserted")
})
}) // convert`
I wish I could do the same with play-1.js. Having the midi output stored somewhere, somehow and using it with a midi player.
Here is a node script exemple using your api : https://github.com/Ralex86/Tunesbook-backend/blob/master/utils/sheet2database.js
from abc2svg.
Ok seems as I am using template string in the code above Github code insertion is having a bad time
from abc2svg.
@Ralex86
(sorry for I did not understand your last message)
About MIDI, play-1.js does not output MIDI. Actually, it contains 2 parts:
- the generation of notes from the parsed ABC
- playing the notes through HTML5 audio
For MIDI generation, only the code of the first part, i.e. the function add(), is useful.
This one has to be called from (or as) the user.get_model callback function.
It creates an array (a_e) of the notes to be played. Then, this array could be used to generate a MIDI file.
I will have a look for splitting the script play.js into two different scripts. Then, the note generation script could be used in both the browser and shell contexts.
Is this OK for you?
from abc2svg.
'const' removed everywhere. Last commit: 738c173
Also, audio generation has been splitted into generic and HTML5 audio scripts by the commit a5ad5d9
from abc2svg.
@moinejf It seems that "use script" still causes problems (uploaded for test under https://github.com/highskillz/ng-xml2abc2svg). Do you prefer we open a separate issue? Thx
from abc2svg.
@joaocc I still think that the problem is on your side, and, also, it could not occur if you use require().
But, anyway, I will move "use strict" inside the Abc object.
from abc2svg.
Thanks for the fix and update.
Regarding your question, it is possible to use require, but we have been trying to follow what seems to be the standard way of importing modules in an Electron+WebPack+Angular4. We can look into it if you later decide to revert the decision.
from abc2svg.
Related Issues (20)
- psxygl is undefined HOT 1
- problem with abc2svg-doc and sth HOT 1
- grid2 only works the first time HOT 2
- Problem with line continuation and |: HOT 11
- Playing audio in node-js HOT 4
- Identifying music note types HOT 9
- Note spacing HOT 2
- Playback of ornaments / arpegio's and other italian terms in the score? HOT 1
- Error: Bar character ')' HOT 1
- error:Invalid note duration undefined HOT 2
- Musicxml import HOT 7
- Support for chord names and lyrics HOT 1
- Line too much shrunk issue HOT 2
- Question: PostScript code that works in abcm2ps not working in abc2svg--how to fix? HOT 2
- How to prevent lines of invisible notes from collapsing? HOT 2
- A couple display issues with %%grid2 HOT 1
- Feature request: Support for tab clef? HOT 7
- How to introduce VUE HOT 4
- Use the xml exported by musescore to generate an abc file prompt: bad tie HOT 2
- how to write 'cross-staff slur'?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abc2svg.