Comments (5)
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.
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.
Hi @mitchkm,
Thanks, could you post an example syntax that you would prefer?
-Garrett
from midiwriterjs.
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.
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)
- How to change tempo throughout track HOT 1
- Midi arrangement help HOT 3
- Files do not import in DAW HOT 2
- Browser: "Maximum call stack size exceeded error" when creating base64 with many events
- Browser example HOT 3
- How to create a midi file HOT 6
- Deprecation warning from tonaljs
- New Tag HOT 2
- Mysterious crash when merging tracks; I don't know what's going on
- Track names cause merging to break
- Midi Reader Implementation HOT 2
- No way to change HEADER_CHUNK_DIVISION HOT 1
- Unable to set track tempo HOT 3
- Insert Text Event at Specific Tick Position
- How to write out drum tracks HOT 2
- Seems to hang on using the writer HOT 5
- Way to change timebase (ppq) instead of 128 HOT 1
- Two tracks with different instruments at the same time HOT 8
- MIDI imported in FL Studio turns out to be one octave higher HOT 1
- Why does a slower tempo create a little rest between NoteEvents? HOT 2
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 midiwriterjs.