Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note length values #1

Open
niahoo opened this issue Feb 23, 2019 · 6 comments
Open

Note length values #1

niahoo opened this issue Feb 23, 2019 · 6 comments

Comments

@niahoo
Copy link

niahoo commented Feb 23, 2019

Hello,

It is unclear to me how to play quarter-notes, sixteenths, etc.

Is it possible to play triplets, sextuplets, any length ... and add silences/pauses ?

How to know that we are on 1, 2 or more bars, have a time signature of 3/4 or 7/8 ...

Thank you.

edit: if any of this is missing I may able to do it, but I need a started guide :)

@niahoo
Copy link
Author

niahoo commented Feb 23, 2019

Ok, working on it, i figured out that when you say each item in a patter array is a beat, you acutally mean a division beat, not a bpm beat.

So, for example with 60bpm :
If my timing is 60000/60/4, it means that each item in the array will be cycled an played each 1/4 of a second. So in this example it is sixteenth notes.

I notices also that if the array contains only 3 items, with 60000/60/4 the first bpm will play items 0, 1, 2, 0.

So ... If y want to play quarter notes, but also another pattern in triplets, this cannot work. I tried something : make two players, start and stop them in parallel. And it workd. Would you say that it is the recommended approach ? Does it harm to have multiple players altogether ? Or would you divide the bpm by a common divisor, like 60000/60/36 (36 = 4 * 12, because 12 triplets notes in a bar).

Thank you

@cdauth
Copy link
Contributor

cdauth commented Feb 23, 2019

beatbox.js is agnostic to time signature, it simply plays notes after each other in a certain interval.

If you want to support triplets, use the common divisor. The 36 sound good. Personally I use 240 to support even more variations of time measures.

To save memory on your pattern array, simply don't define the empty beats in it.

@niahoo
Copy link
Author

niahoo commented Feb 24, 2019

Hey, thank you.

To save memory on your pattern array, simply don't define the empty beats in it.

What do you mean ?

const pattern = [
    ['snare'],
    [],
    [],
    ['snare'],
]

How would you write this with removed entries ? I cannot simply remove the empty arrays, or the melody changes.

@lud
Copy link

lud commented Jul 23, 2019

Hello,

I'm also interested on the memory-saving technique.

@cdauth
Copy link
Contributor

cdauth commented Jul 23, 2019

Like this:

const pattern = [];
pattern[0] = ['snare'];
pattern[3] = ['snare'];

@lud
Copy link

lud commented Jul 23, 2019

Aha, so simple. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants