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

"factor of" block #719

Closed
pikurasa opened this issue Jul 31, 2017 · 29 comments
Closed

"factor of" block #719

pikurasa opened this issue Jul 31, 2017 · 29 comments
Milestone

Comments

@pikurasa
Copy link
Collaborator

I want (or at least I think I want) to do the following:

if factor_of notes_played (beat_number) = 8
then_do x
else_do y

basically, I want to do this for automated rhythmic structure.

I could build upon this such that 2 and 4 (factor of 2) are always "snare drum", but when it reaches a factor of 8, there is a little bit more embellished drum turn-around, and then when it reaches 16, it runs a drum fill.

Thoughts?

@pikurasa
Copy link
Collaborator Author

@walterbender has made progress on a "on beat x do y" block.

Improvement suggested via chat:

One thing that (I hope is helpful) is: Musicians are always thinking of the subdivisions, so when I am thinking of doing something on beat(s) x, y, and/or z, I am also internally thinking of the eighth note subdivisions, perhaps even the 16th as well.

So, maybe it would be helpful if MB also "subdivided"

  • a) as a possible solution to this issue and
  • b) so that, in the future, we can say "do x on 'and' of y"

@walterbender walterbender modified the milestone: GCI 2017 Sep 7, 2017
@walterbender walterbender modified the milestones: Post GCI, future Feb 14, 2018
@walterbender
Copy link
Member

I need to work out the math, but otherwise I have this working.
I have notes played based on some beat factor, by default, a quarter note.
So after the first quarter note, it is 1 note played.

Do we want to specify the factor as 1/4 or 4?

@walterbender
Copy link
Member

test at https://github.com/walterbender/musicblocks/tree/on-factor

I guess I am still a bit confused by some of the details. Do we calculate the factor based on what we have played before the note, or what we will have played after the current note plays? Right now, I have implemented the former, which means, for example, everything matches at time 0. Seems wrong.

@walterbender
Copy link
Member

[[0,["start",{"collapsed":false,"xcor":0,"ycor":0,"heading":270,"color":0,"shade":50,"pensize":5,"grey":100}],640,75,[null,28,null]],[1,["newnote",{}],653.5,178.5,[28,2,5,9]],[2,["divide",{}],749.72119140625,178.5,[1,3,4]],[3,["number",{"value":1}],835.22119140625,178.5,[2]],[4,["number",{"value":4}],835.22119140625,210,[2]],[5,["vspace",{}],667,210,[1,6]],[6,["pitch",{}],667,241.5,[5,7,8,null]],[7,["solfege",{"value":"sol"}],740.5,241.5,[6]],[8,["number",{"value":4}],740.5,273,[6]],[9,["hidden",{}],653.5,336,[1,10]],[10,["newnote",{}],653.5,336,[9,11,14,18]],[11,["divide",{}],749.72119140625,336,[10,12,13]],[12,["number",{"value":1}],835.22119140625,336,[11]],[13,["number",{"value":4}],835.22119140625,367.5,[11]],[14,["vspace",{}],667,367.5,[10,15]],[15,["pitch",{}],667,399,[14,16,17,null]],[16,["solfege",{"value":"mi"}],740.5,399,[15]],[17,["number",{"value":4}],740.5,430.5,[15]],[18,["hidden",{}],653.5,493.5,[10,19]],[19,["newnote",{}],653.5,493.5,[18,20,23,27]],[20,["divide",{}],749.72119140625,493.5,[19,21,22]],[21,["number",{"value":1}],835.22119140625,493.5,[20]],[22,["number",{"value":2}],835.22119140625,525,[20]],[23,["vspace",{}],667,525,[19,24]],[24,["pitch",{}],667,556.5,[23,25,26,null]],[25,["solfege",{"value":"sol"}],740.5,556.5,[24]],[26,["number",{"value":4}],740.5,588,[24]],[27,["hidden",{}],653.5,651,[19,null]],[28,["onfactordo",{}],653.5,115.5,[0,29,30,1]],[29,["number",{"value":4}],740.36669921875,115.5,[28]],[30,["text",{"value":"action"}],740.36669921875,147,[28]],[31,["action",{"collapsed":false}],245,123,[null,32,33,null]],[32,["text",{"value":"action"}],339.5,132,[31]],[33,["hidden",{}],258.5,163.5,[31,34]],[34,["right",{}],258.5,163.5,[33,35,36]],[35,["number",{"value":90}],332,163.5,[34]],[36,["newnote",{}],258.5,195,[34,37,40,43]],[37,["divide",{}],354.72119140625,195,[36,38,39]],[38,["number",{"value":1}],440.22119140625,195,[37]],[39,["number",{"value":4}],440.22119140625,226.5,[37]],[40,["vspace",{}],272,226.5,[36,41]],[41,["playdrum",{}],272,258,[40,42,null]],[42,["drumname",{"value":"kick drum"}],345.5,258,[41]],[43,["hidden",{}],258.5,321,[36,null]],[44,0,[0,"notes",["C2"],0.6666666666666666,"kick drum",null,null]],[45,0,[0,"notes","G4",0.6666666666666666,"default",{"doVibrato":false,"doDistortion":false,"doTremolo":false,"doPhaser":false,"doChorus":false,"doPartials":true,"doPortamento":true,"doNeighbor":false,"vibratoIntensity":0,"vibratoFrequency":0,"distortionAmount":0,"tremoloFrequency":0,"tremoloDepth":0,"rate":0,"octaves":0,"baseFrequency":0,"chorusRate":0,"delayTime":0,"chorusDepth":0,"partials":[1],"portamento":0,"neighborArgNote1":[],"neighborArgNote2":[],"neighborArgBeat":0,"neighborArgCurrentBeat":0},null]],[46,0,[0,"right",90]],[47,0,[0.6666666666666666,"notes",["C2"],0.6666666666666666,"kick drum",null,null]],[48,0,[0.6666666666666666,"notes","E4",0.6666666666666666,"default",{"doVibrato":false,"doDistortion":false,"doTremolo":false,"doPhaser":false,"doChorus":false,"doPartials":true,"doPortamento":true,"doNeighbor":false,"vibratoIntensity":0,"vibratoFrequency":0,"distortionAmount":0,"tremoloFrequency":0,"tremoloDepth":0,"rate":0,"octaves":0,"baseFrequency":0,"chorusRate":0,"delayTime":0,"chorusDepth":0,"partials":[1],"portamento":0,"neighborArgNote1":[],"neighborArgNote2":[],"neighborArgBeat":0,"neighborArgCurrentBeat":0},null]],[49,0,[0.6666666666666666,"right",90]],[50,0,[1.3333333333333333,"notes",["C2"],0.6666666666666666,"kick drum",null,null]],[51,0,[1.3333333333333333,"notes","G4",1.3333333333333333,"default",{"doVibrato":false,"doDistortion":false,"doTremolo":false,"doPhaser":false,"doChorus":false,"doPartials":true,"doPortamento":true,"doNeighbor":false,"vibratoIntensity":0,"vibratoFrequency":0,"distortionAmount":0,"tremoloFrequency":0,"tremoloDepth":0,"rate":0,"octaves":0,"baseFrequency":0,"chorusRate":0,"delayTime":0,"chorusDepth":0,"partials":[1],"portamento":0,"neighborArgNote1":[],"neighborArgNote2":[],"neighborArgBeat":0,"neighborArgCurrentBeat":0},null]],[52,0,[1.4333333333333333,"right",90]]]

@pikurasa
Copy link
Collaborator Author

I am testing.

Right now, I have implemented the former, which means, for example, everything matches at time 0. Seems wrong.

I did notice this and, yes, we do not want this.

Do we calculate the factor based on what we have played before the note, or what we will have played after the current note plays?

If I understand you correctly, then we want the latter.

@pikurasa
Copy link
Collaborator Author

Do we want to specify the factor as 1/4 or 4?

We want the latter (which you have) b/c we are specifying factor of beats, not note value.

@walterbender
Copy link
Member

So this is just onBeat on steroids?

onFactor 4 === onbeat 1 onbeat 2 onbeat 3 onbeat 4 ??? (when the meter is 4:4)

onFactor 8, we'd also trigger on beat 0,5, 1.5, 2.5, and 3.5 ???

@pikurasa
Copy link
Collaborator Author

So this is just onBeat on steroids?

Yes, but the idea is a little different.

onFactor 4 === onbeat 1 onbeat 2 onbeat 3 onbeat 4 ??? (when the meter is 4:4)

For this example, it would only trigger on the 4th onbeat

(this example would not be different than doing something on beat 4; it would make more sense for any number above 4.)

This would be nice as typically something extra happens at these factor points. For example, a drum beat might have something special here.

onFactor 8, we'd also trigger on beat 0,5, 1.5, 2.5, and 3.5 ???

This would be the result for onFactor 1/2

@walterbender
Copy link
Member

I don't understand the difference between onBeat and onFactor. Seems from your previous comment that they are identical.

@walterbender
Copy link
Member

Or are you suggesting that onFactor 8 would trigger on every other beat 4?

@pikurasa
Copy link
Collaborator Author

Or are you suggesting that onFactor 8 would trigger on every other beat 4?

Yes.

@walterbender
Copy link
Member

Why not just overload the onbeat block? We could make onbeat 8 do this.

@pikurasa
Copy link
Collaborator Author

Why not just overload the onbeat block? We could make onbeat 8 do this.

That makes sense to me.

@walterbender
Copy link
Member

I think the onbeat block should be behaving as per our discussion:

any beat value > the number of beats per measure will trigger an event when that number is a factor of the number of beats played. Please test based on lasted commit to master.

@aviral243
Copy link
Member

@walterbender Issue still valid?

@walterbender
Copy link
Member

Never heard back from Devin if my patch worked

@pikurasa
Copy link
Collaborator Author

(Sorry for not responding. Testing again now, and...)

It does not work right now, and I think the reason has to do with our shift from "onbeat" block to "on strong beat" block.

What confirms my suspicion is that the .tb file pasted into #719 (comment) opens as an "unkown" block.

@walterbender
Copy link
Member

Yes. It should be an on-strong-beat-do block.
But here is the problem: beat 4 comes during the half-note. There is no note that begins on beat 4. So the action is never triggered.

How should this actually work?

@walterbender
Copy link
Member

[[0,["start",{"collapsed":false,"xcor":0,"ycor":0,"heading":90,"color":0,"shade":60,"pensize":5,"grey":171.42857142857142}],1044,113,[null,42,null]],[1,["newnote",{"collapsed":false}],1072,249,[44,2,5,9]],[2,"divide",1174,249,[1,3,4]],[3,["number",{"value":1}],1260,249,[2]],[4,["number",{"value":4}],1260,281,[2]],[5,"vspace",1086,281,[1,6]],[6,"pitch",1086,313,[5,7,8,null]],[7,["solfege",{"value":"sol"}],1160,313,[6]],[8,["number",{"value":4}],1160,345,[6]],[9,"hidden",1072,407,[1,10]],[10,["newnote",{"collapsed":false}],1072,407,[9,11,14,18]],[11,"divide",1174,407,[10,12,13]],[12,["number",{"value":1}],1260,407,[11]],[13,["number",{"value":4}],1260,439,[11]],[14,"vspace",1086,439,[10,15]],[15,"pitch",1086,471,[14,16,17,null]],[16,["solfege",{"value":"mi"}],1160,471,[15]],[17,["number",{"value":4}],1160,503,[15]],[18,"hidden",1072,565,[10,19]],[19,["newnote",{"collapsed":false}],1072,565,[18,20,23,27]],[20,"divide",1174,565,[19,21,22]],[21,["number",{"value":1}],1260,565,[20]],[22,["number",{"value":2}],1260,597,[20]],[23,"vspace",1086,597,[19,24]],[24,"pitch",1086,629,[23,25,26,null]],[25,["solfege",{"value":"sol"}],1160,629,[24]],[26,["number",{"value":4}],1160,661,[24]],[27,"hidden",1072,723,[19,null]],[28,["number",{"value":4}],1182,154,[42]],[29,["action",{"collapsed":false}],669,128,[null,30,31,null]],[30,["text",{"value":"action"}],801,137,[29]],[31,"hidden",683,169,[29,32]],[32,"right",683,169,[31,33,34]],[33,["number",{"value":90}],757,169,[32]],[34,["newnote",{"collapsed":false}],683,201,[32,35,38,41]],[35,"divide",785,201,[34,36,37]],[36,["number",{"value":1}],871,201,[35]],[37,["number",{"value":4}],871,233,[35]],[38,"vspace",697,233,[34,39]],[39,"playdrum",697,265,[38,40,null]],[40,["drumname",{"value":"kick drum"}],771,265,[39]],[41,"hidden",683,327,[34,null]],[42,"onbeatdo",1058,154,[0,28,43,44]],[43,["text",{"value":"action"}],1182,186,[42]],[44,"repeat",1058,217,[42,45,1,null]],[45,["number",{"value":4}],1160,217,[44]],[46,1,[2,"right",11.25]],[47,1,[2.0829166666666667,"right",11.25]],[48,1,[2.1658333333333335,"right",11.25]],[49,1,[2.24875,"right",11.25]],[50,1,[2.3316666666666666,"right",11.25]],[51,1,[2.4145833333333333,"right",11.25]],[52,1,[2.4975,"right",11.25]],[53,1,[2.5804166666666664,"right",11.25]],[54,1,[4.666666666666666,"right",11.25]],[55,1,[4.749583333333333,"right",11.25]],[56,1,[4.8325,"right",11.25]],[57,1,[4.915416666666666,"right",11.25]],[58,1,[4.998333333333333,"right",11.25]],[59,1,[5.081249999999999,"right",11.25]],[60,1,[5.164166666666666,"right",11.25]],[61,1,[5.247083333333332,"right",11.25]]]

@pikurasa
Copy link
Collaborator Author

What I did to test it was to change the 4 to an 8 in hopes that the "overload" feature would occur (by triggering for every eighth note).

...this being said, I am trying to figure out how "on strong beat" and "on weak beat" has impacted the proposal of this feature.

@walterbender
Copy link
Member

The problem I encountered is different. If we are triggering on 4 or 8, but those beats are never triggered because they occur inside of a half note, that seems wrong. We'll need to do some overhauling of the code to fix that.

@pikurasa
Copy link
Collaborator Author

I think what would be nice is something that worked at an abstract level, such that it could be a kind of "automated drum machine"

Perhaps triggered by the following construct:

Screenshot at 2020-03-23 18:20:08 beat factor proposal

@walterbender
Copy link
Member

Not sure I was clear in my previous comment.

if we are in 4:4 and I want to kick on 4 and snare and tomtom on 8, it will work with the current code, except:

If I play a loop: 1/4 1/4 1/2 then we never see beat 4 or beat 8 since they occur during the 1/2 note.
So. if we have something queued for a beat, do we trigger it on that beat, whether or not a note is triggered on that beat? Seems we should, but the current implementation doesn't work that way. Only triggers when there is a note that starts on that beat.

@pikurasa
Copy link
Collaborator Author

but the current implementation doesn't work that way. Only triggers when there is a note that starts on that beat.

Yes. Since "beat" is inherently abstract (as opposed to "on every note"), I think that it should be triggered even if there is no note starting on a given beat.

Or another way to think about it is, a given beat is passed (temporally) whether or not anything is placed there. The only remaining question would be at what level--"beat factor" as we are calling in--we want to drill down to with regard to placing actions.

@pikurasa
Copy link
Collaborator Author

I cannot seem to get anything other than "0" for print beat factor.

This is my current test project (image below and file at bottom):
testing-on-beat-factor

Working-on-Beat-Factor.html.zip

@walterbender
Copy link
Member

Cannot find a note for turtle 0

@walterbender
Copy link
Member

I think I have fixed this. The reason Devin's example was not working was that if we played a drum by itself, the lastNotePlayed was not being updated. We calculate the beat factor from the last note played, so that calculation failed. I added glue to update the lastNotePlayed in turtle-singer.js and I believe tha Devin's test example works as expected now.

@pikurasa
Copy link
Collaborator Author

Fun.

It works. Thanks!

@pikurasa
Copy link
Collaborator Author

#2655

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

No branches or pull requests

3 participants