Giter Club home page Giter Club logo

Comments (12)

danigb avatar danigb commented on July 16, 2024

Currently there's no support for abc notation. If you mean convert a note from, for example "c" to "C5", it should be easy to implement using note.build function.

What do you need this for?

from tonal.

jisike avatar jisike commented on July 16, 2024

I'm trying to computationally parse an abc string it into an object, manipulate it (ie change tones, pitch and etc) using tonal and convert it back into a string.

from tonal.

danigb avatar danigb commented on July 16, 2024

I've wrote the tonal-abc-notation: http://danigb.github.io/tonal/api/module-abc-notation.html

You can install it using npm. Hope it helps.

from tonal.

jisike avatar jisike commented on July 16, 2024

Thanks for the reply! How can I use that module in the browser?

from tonal.

danigb avatar danigb commented on July 16, 2024

You can use a tool that can convert from node modules to browser modules. I think the easiest one is browserify: http://browserify.org/

The other option is to use a tool like budo: https://github.com/mattdesl/budo. It's easier to get started, but after you will need to use browserify or something similar.

Hope it helps.

from tonal.

jisike avatar jisike commented on July 16, 2024

Thanks! I have Tonal running in the browser but now I'm not able to call functions from it in the console. Any tips?

from tonal.

danigb avatar danigb commented on July 16, 2024

If you are using the including the file from the dist/ folder, like this: <script src="tonal.min.js"></script>, you can write at the console: Tonal.midi('c4') and it should work.

But abc-notation module is not included in the bundled file. So, to use it, you need to create a file like index.js with something like:

// use the Abc module standalone
const Abc = require("tonal-abc-notation");
console.log(Abc.toAbc("C#4"));

// use it with Tonal
const Tonal = require("tonal");
console.log(Tonal.Scale.notes("Bb major").map(Abc.toAbc));

and then use browserify to create a browser compatible version (and load that file with a <script> tag inside an html file). Hope it helps.

from tonal.

jisike avatar jisike commented on July 16, 2024

Thanks. As I mentioned I have it bundled using browserify and running in the browser. I just asking if its possible to call functions in the console. If so how? Thanks again!

from tonal.

danigb avatar danigb commented on July 16, 2024

Yes, I don't know if I get you 😆

You can open a console using the browser's developer tools, and write Tonal.Scale.notes("C major") and you will see the output (an array of notes). This just works.

from tonal.

jisike avatar jisike commented on July 16, 2024

It doesnt work for me. When I tried to call:

Tonal.Scale.notes("C major")

and I get this error:

VM2704:1 Uncaught ReferenceError: Tonal is not defined
    at <anonymous>:1:1

from tonal.

danigb avatar danigb commented on July 16, 2024

If you use the tonal.min.js dist file, it works out of the box. If you are transpiling your own sources, you must export the tonal facade inside your code: window.Tonal = Tonal; (and window.Abc = Abc; if you want to use it from the console)

Hope it helps!

from tonal.

jisike avatar jisike commented on July 16, 2024

That works! Thanks for answering these general JS questions! Can I also ask how you recommend structuring the other vars and functions (that aren't in a class) to access in the same way? I tried using a closure but that didn't work.

from tonal.

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.