Giter Club home page Giter Club logo

Comments (5)

grimmdude avatar grimmdude commented on June 15, 2024

Hi @mitchkm,

Thanks for your message. Here are a couple solutions for achieving durations longer than whole:

Passing an array of note durations will give you a duration equal to the sum of those durations. Here's how you could get a dotted whole note:

const note = new MidiWriter.NoteEvent({pitch:['C4'], duration: ['1',  '2']});

You can use the tick based duration option to achieve notes longer than whole. The library is setup to use 128 ticks per beat. So in 4/4 that's 512 ticks per whole note. Something like this would give you a dotted whole note:

const note = new MidiWriter.NoteEvent({pitch:['C4'], duration: 'T768'});

from midiwriterjs.

mitchkm avatar mitchkm commented on June 15, 2024

Thank you for showing me the ways to achieve my goal. But I will say for it to make the most sense in music theory it would be nice to provide a numeric quantity of a quarter note perhaps. ie. 10 quarter notes. I guess I can make an char. array of X quarter notes('4') but it feels a little less intuitive. Especially if arrays get changed to providing the duration for a multitude of pitches also provided in an array.

from midiwriterjs.

grimmdude avatar grimmdude commented on June 15, 2024

Hi @mitchkm,

Thanks, could you post an example syntax that you would prefer?

-Garrett

from midiwriterjs.

mitchkm avatar mitchkm commented on June 15, 2024

Following the way you specify ticks, perhaps:

const note = new MidiWriter.NoteEvent({pitch:['C4'], duration: 'Q10'});

Meaning a duration of 10 quarter notes

from midiwriterjs.

grimmdude avatar grimmdude commented on June 15, 2024

Hi @mitchkm,

I can see your logic with this, but I don't think it's worth implementing this way. It introduces a new prefix Q, and presumably every prefix for all other note types; E for eighth, S for sixteenth, etc. which can get out of hand quickly and not particularly intuitive.

In it's current implementation, using an array of durations to be summed seems much more friendly and flexible from a programmatic standpoint in my opinion. For instance, how would you create a duration of two whole notes and an eighth?

For your case, creating an array of ten "4" is fairly trivial:

const note = new MidiWriter.NoteEvent({pitch:['C4'], duration: new Array(10).fill('4')});

Appreciate your input.

-Garrett

from midiwriterjs.

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.