GithubHelp home page GithubHelp logo

Comments (12)

moinejf avatar moinejf commented on September 28, 2024

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.

joaocc avatar joaocc commented on September 28, 2024

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.

moinejf avatar moinejf commented on September 28, 2024

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.

joaocc avatar joaocc commented on September 28, 2024

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.

moinejf avatar moinejf commented on September 28, 2024

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.

Ralex86 avatar Ralex86 commented on September 28, 2024

'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.

Ralex86 avatar Ralex86 commented on September 28, 2024

Ok seems as I am using template string in the code above Github code insertion is having a bad time

from abc2svg.

moinejf avatar moinejf commented on September 28, 2024

@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.

moinejf avatar moinejf commented on September 28, 2024

'const' removed everywhere. Last commit: 738c173
Also, audio generation has been splitted into generic and HTML5 audio scripts by the commit a5ad5d9

from abc2svg.

joaocc avatar joaocc commented on September 28, 2024

@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.

moinejf avatar moinejf commented on September 28, 2024

@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.

joaocc avatar joaocc commented on September 28, 2024

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)

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.