Skip to content

Commit

Permalink
Merge 27cf43e into 08870b1
Browse files Browse the repository at this point in the history
  • Loading branch information
underFlo committed Jun 25, 2019
2 parents 08870b1 + 27cf43e commit ef568c9
Show file tree
Hide file tree
Showing 27 changed files with 88 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
converting
addRestsForDuration: aDuration to: aMorph
| powerOfTwo remainder |
aDuration strictlyPositive
ifFalse: [ ^ self ].

powerOfTwo := Fraction numerator: 8 denominator: 1.
[ powerOfTwo > aDuration ]
whileTrue: [ powerOfTwo := powerOfTwo / 2 ].

remainder := aDuration - powerOfTwo.
self addRestsForDuration: remainder to: aMorph.
self add: (MNNote new duration: powerOfTwo) to: aMorph.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
converting
emptyDurationInMeasure: aMeasure
| sum |
sum := aMeasure notes detectSum: #duration.
^ (aMeasure time - sum) max: 0
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
visiting
visitMeasure: aMeasure
| morph |
| morph emptyDuration |
morph := MNMeasureMorph measure: aMeasure.

self addPrefixOfMeasure: aMeasure after: aMeasure leftSibling to: morph.

self addAll: aMeasure notes to: morph.

emptyDuration := self emptyDurationInMeasure: aMeasure.
self addRestsForDuration: emptyDuration to: morph.

morph addMorphBack: (aMeasure rightSibling
ifNil: [ MNBarLineMorph newFinal ]
ifNotNil: [ MNBarLineMorph newSingle ]).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"add:to:" : "mgjm 6/18/2019 17:59",
"addAll:to:" : "mgjm 6/18/2019 17:59",
"addPrefixOfMeasure:after:to:" : "mgjm 6/18/2019 22:43",
"addRestsForDuration:to:" : "fb 6/25/2019 15:26",
"createTime:" : "mgjm 6/16/2019 20:02",
"emptyDurationInMeasure:" : "fb 6/25/2019 15:22",
"visitClef:" : "mgjm 6/16/2019 19:51",
"visitKey:" : "mgjm 6/18/2019 16:25",
"visitMeasure:" : "mgjm 6/16/2019 19:56",
"visitMeasure:" : "fb 6/25/2019 15:29",
"visitNote:" : "mgjm 6/16/2019 20:01",
"visitPart:" : "mgjm 6/16/2019 20:01",
"visitPitch:" : "mgjm 6/16/2019 19:16",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
context: aContext
^ self new
context: aContext;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
arithmetic
/ aNumber
^ self context addNote: (self createNote: 1 / aNumber)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
createNote: aNumber
^ MNNote new
duration: aNumber
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"class" : {
"context:" : "fb 6/24/2019 12:19" },
"instance" : {
"/" : "fb 6/24/2019 12:14",
"context" : "mgjm 6/19/2019 20:59",
"context:" : "mgjm 6/19/2019 20:59",
"createNote:" : "fb 6/24/2019 12:13" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "MusicNotation-Scripting",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"context" ],
"name" : "MNLengthBuilder",
"pools" : [
],
"super" : "Object",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
instance creation
context: aContext step: anObject
context: aContext step: aStep
^ self new
context: aContext;
step: anObject;
step: aStep;
yourself

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
createNote: aNumber
^ (super createNote: aNumber)
addPitch: self createPitch;
yourself
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"class" : {
"context:step:" : "mgjm 6/19/2019 20:59" },
"context:step:" : "fb 6/24/2019 12:20" },
"instance" : {
"/" : "mgjm 6/19/2019 21:30",
"context" : "mgjm 6/19/2019 20:59",
"context:" : "mgjm 6/19/2019 20:59",
"createPitch" : "mgjm 6/19/2019 21:27",
"step" : "mgjm 6/19/2019 20:59",
"step:" : "mgjm 6/19/2019 20:59" } }
"createNote:" : "fb 6/24/2019 12:16",
"createPitch" : "fb 6/24/2019 12:14",
"step" : "fb 6/24/2019 12:11",
"step:" : "fb 6/24/2019 12:11" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
],
"commentStamp" : "",
"instvars" : [
"context",
"step" ],
"name" : "MNPitchBuilder",
"pools" : [
],
"super" : "Object",
"super" : "MNLengthBuilder",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ printDemoOn: aStream

#cdefgab do: [ :each | aStream
nextPutAll: ('{1} := MNPitchBuilder context: context step: ${1}.' format: { each }); cr ].
aStream nextPutAll: 'r := MNLengthBuilder context: context.'; cr.

aStream
cr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"openAlleMeineEntchen" : "mgjm 6/19/2019 21:33" },
"instance" : {
"open" : "mgjm 6/19/2019 21:52",
"printDemoOn:" : "mgjm 6/19/2019 21:32",
"printDemoOn:" : "fb 6/24/2019 12:21",
"script" : "mgjm 6/19/2019 21:13",
"script:" : "mgjm 6/19/2019 21:12" } }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
as yet unclassified
testAddRest4
| context builder |
context := self createContext.
builder := MNLengthBuilder context: context.

builder / 4.

self assert: 1 equals: context measure notes size.
self assert: 1/4 equals: context measure notes first duration.
self assert: context measure notes first pitches isEmpty.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
"createContext" : "mgjm 6/19/2019 22:05",
"testAddNote4" : "mgjm 6/19/2019 22:08",
"testAddNote4Twice" : "mgjm 6/19/2019 22:08",
"testAddNote8" : "mgjm 6/19/2019 22:08" } }
"testAddNote8" : "mgjm 6/19/2019 22:08",
"testAddRest4" : "fb 6/24/2019 12:27" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"commentStamp" : "",
"instvars" : [
],
"name" : "MNPitchBuilderTest",
"name" : "MNLengthBuilderTest",
"pools" : [
],
"super" : "MNScriptingTestCase",
Expand Down

0 comments on commit ef568c9

Please sign in to comment.