Skip to content

Commit

Permalink
Merge branch 'development' into task/127-bug-fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
olschulz authored Aug 4, 2021
2 parents f658e2f + 58ed958 commit 7b5f4d4
Show file tree
Hide file tree
Showing 77 changed files with 292 additions and 136 deletions.
8 changes: 4 additions & 4 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ All packages are named MusicNotation-\<packagename\>. Just use the search functi

## Using the project
To open the editor used to create and modify music projects you can use the following command in a Squeak workspace: `MNEditor open.`
This will open the editor and you can start scripting. More details can be found in the [scripting.md](./scripting.md).
This will open the editor and you can start scripting. For an example script, type `MNEditor openTutorial` instead. More details can be found in the [scripting.md](./scripting.md).

## Understanding the project
We know it can be quite difficult to understand a project with ~12.000 lines of code by just reading all of it. So here is some help:
We know it can be quite difficult to understand a project with ~14.000 lines of code by just reading all of it. So here is some help:
- [Architectural Information](./architectural-information.md)
- [Entry Points](./entry-points.md)

## Enhancing the project
You want to add new features, fix bugs or restructure the project to make it a better fit for you and others?
#### Check out our [issues](https://github.com/hpi-swa-teaching/MusicNotation/issues) and [pull requests](https://github.com/hpi-swa-teaching/MusicNotation/pulls)!
#### Check out our [issues](https://github.com/hpi-swa-teaching/MusicNotation/issues)!
We added a few things there that might be cool to add. Those are labeled with "proposal". Also, we didn't remove the old ones, maybe they help you to understand what we did.
Furthermore, the open pull requests are features that are already partly implemented but not quite finished. Feel free to have a look!
Feel free to have a look!
Binary file added docs/images/smoke_on_the_water_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 99 additions & 1 deletion docs/scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@ To add a new part, put in the following code:
```smalltalk
self project addPart: (MNPart new addMeasure: MNMeasure new).
```
All following notes will be added in the new part.
All following notes will be added in the new part. To make the clef of the new part into a bass clef, use: `self addFClef`.

Notes, measures, parts and projects can be transposed using the `transpose:`, `transposeFlat:` and `transposeSharp:` messages.

To add a tie, type `self startTie` after the note from which it shall start and `self stopTie` after the note, at which it shall end.
Analougly, to add a slur, type `self startSlur` after the note from which it shall start and `self stopSlur` after the note, at which it shall end.

To add a prelude, type `self prelude` after the notes that shall belong to the prelude.

Eights are automatically grouped together. If you want to make three notes a triplet, type `self triole` after the creation of the three notes.

To add volume notation, like piano (p), forte (f), mezzoforte (mf), ... , write `self setDynamics: 'mf'`. The implemented volume signs reach from 'ppp' to 'fff'.

You can use local variables just like in every smalltalk method after declaring them in pipes in the beginning.

The resulting music can be played by adding the line `project asSound play.` (Note: This will result in the project playing whenever it is saved) and converted into MusicXML with `project asXMLString` or `project asXMLElement` or directly saved with `project writeXMLWithFileChooser`.

This is a short example script:

```smalltalk
"Example Script"
| notes1 |
Expand All @@ -47,3 +60,88 @@ notes1 := {c4 . d4 . e4 . f4}.
self measure transposeSharp: 2.
```
![preview of example script](images/example_script_result.png "result of example script")

This is an example song, which implements mostly newer functionalities:

```smalltalk
"Smoke On The Water"
| lickOne |
"set key"
self measure keyFifths: 1.
"easy way to create chords"
d4 + g4 / 4.
"set dynamics"
self setDynamics: 'mf'.
"enter notes"
f4 + a4s / 4.
g4 + c5 / 4 dot.
d4 + g4 / 8.
"create tie"
self startTie.
d4 + g4 / 8.
self stopTie.
f4 + a4s / 4.
g4s + c5s / 8.
g4 + c5 / 2.
d4 + g4 / 4.
f4 + a4s / 4.
g4 + c5 / 4 dot.
f4 + a4s / 8.
self startTie.
f4 + a4s / 8.
self stopTie.
d4 + g4 / 2 dot dot.
"add new track"
project addPart: (MNPart new addMeasure: MNMeasure new).
"change clef"
self addFClef.
self measure keyFifths: 1.
"enter notes"
g1 / 8.
self setDynamics: 'ff'.
g1 / 8.
"create pattern"
lickOne := { g1 . g1 . g1 . g1 . g1 . g1 }.
2 timesRepeat: [ lickOne / 8 ].
g1 / 8 * 2.
g1 / 8 * 2.
"create slur"
self startSlur.
a1s / 8.
self stopSlur.
self startSlur.
a1s / 8.
self stopSlur.
c2 / 8 * 2.
c2 / 8.
a1s / 8.
self startTie.
a1s / 8.
self stopTie.
g1 / 8 * 4.
e1 / 8.
f1 / 8.
f1s / 8.
"play the song"
project asSound play.
```
![preview of smoke on the water](images/smoke_on_the_water_result.png "result of smoke on the water")

As another feature, you can click on the symbols in the preview. They will be highlighted both in the editor and the preview then, so you can easily see, which code lines create which symbols in the preview.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statements
addNewVariableStatement: aString
self content localVariables notEmpty
ifTrue: [^ (aString, (self createNewVariableStatement: aString))]
ifTrue: [^ (aString, (self createNewVariableStatement))]
ifFalse: [^ aString].
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statements
createNewVariableStatement: aString
createNewVariableStatement
| newVariableStatement |

newVariableStatement := '(Dictionary new)'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
evaluating
setException: aMNEditorStatus statement: anInteger
self status: aMNEditorStatus.
self status applyStyleTo: self statement: anInteger.
self status statementNumber: anInteger.
self status applyStyleTo: self statement: anInteger.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ status: anObject
status := anObject.
self changed: #status.
self changed: #statusColor.
self changed: #statusMessage.

"self status applyStyleTo: self".
self changed: #statusMessage.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
symbol selection
updateContentsNotSelected
(1 to: self content contentsList size) do:
[ :i | self content applyStyleSelected: false toStatement: i toEditor: self].
[ :each | self content applyStyleSelected: false toStatement: each toEditor: self].
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"instance" : {
"aboutToStyle:" : "mgjm 7/1/2019 14:59",
"addModelItemsToWindowMenu:" : "mgjm 7/1/2019 18:57",
"addNewVariableStatement:" : "LH 6/26/2021 14:53",
"addNewVariableStatement:" : "ld 8/1/2021 13:15",
"addVariableStatement:" : "RAD 6/26/2021 21:30",
"addVariableStatements:" : "LH 6/26/2021 14:54",
"buildCodePaneWith:" : "RAD 5/27/2021 14:19",
Expand All @@ -21,7 +21,7 @@
"content" : "RAD 6/11/2021 17:42",
"content:" : "RAD 6/11/2021 17:42",
"createEnvironment" : "mgjm 7/1/2019 14:37",
"createNewVariableStatement:" : "RAD 6/29/2021 12:36",
"createNewVariableStatement" : "ld 8/1/2021 13:14",
"defaultWindowColor" : "mgjm 6/25/2019 18:01",
"doItEnvironment" : "mgjm 7/1/2019 19:03",
"doItEnvironment:" : "mgjm 7/1/2019 18:52",
Expand All @@ -45,17 +45,17 @@
"project" : "mgjm 6/25/2019 16:45",
"project:" : "mgjm 6/25/2019 16:45",
"resetDoItEnvironment" : "mgjm 7/1/2019 18:58",
"setException:statement:" : "OS 6/10/2021 18:30",
"setException:statement:" : "ld 8/1/2021 13:53",
"statementAt:" : "LH 6/26/2021 14:59",
"statementMethodCode:" : "RAD 5/16/2021 12:42",
"status" : "mgjm 7/1/2019 15:18",
"status:" : "RAD 5/20/2021 12:44",
"status:" : "ld 8/1/2021 13:21",
"statusColor" : "mgjm 7/1/2019 15:10",
"statusFrame" : "mgjm 7/5/2019 20:52",
"statusMessage" : "mgjm 7/1/2019 15:10",
"statusPaneHeight" : "mgjm 7/1/2019 15:14",
"statusPaneMenu:" : "mgjm 7/25/2019 15:15",
"textContents:" : "mgjm 7/1/2019 14:24",
"updateContents:" : "MP 5/28/2021 16:04",
"updateContentsNotSelected" : "RAD 5/27/2021 14:57",
"updateContentsNotSelected" : "ld 8/1/2021 13:22",
"updateContentsSelectedSymbol:" : "RAD 5/28/2021 15:50" } }
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
statement mapping
endOfStatement: anInteger
^ (self startOfStatement: anInteger) + ((self contentsList at: anInteger) size) - 1
| offset |
offset := 1.
^ (self startOfStatement: anInteger) + ((self contentsList at: anInteger) size) - offset
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
statement mapping
rangeOffsetStatement: anInteger
| offset |
offset := ((1 to: anInteger - 1) collect: [:i | (self contentsList at: i) size] ).
offset := ((1 to: anInteger - 1) collect: [:each| (self contentsList at: each) size] ).
offset
ifEmpty: [^ 0]
ifNotEmpty: [^ offset sum].
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
statement mapping
statementsOf: aMNNote
^ (1 to: self statementMapping size)
select: [ :i | (self statementMapping at: i) includes: aMNNote].
select: [ :each | (self statementMapping at: each) includes: aMNNote].
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
updating style
updateContentsSelect: aCollection toEditor: anEditor
(1 to: self contentsList size) do:
[ :i | self applyStyleSelected: (aCollection includes: i) toStatement: i toEditor: anEditor]
[ :each | self applyStyleSelected: (aCollection includes: each) toStatement: each toEditor: anEditor]
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"applyStyleSelected:toStatement:toEditor:" : "RAD 5/27/2021 14:53",
"contentName" : "MP 5/28/2021 16:02",
"contentsList" : "RAD 6/11/2021 18:17",
"endOfStatement:" : "RAD 5/27/2021 14:38",
"endOfStatement:" : "ld 8/1/2021 13:31",
"initializeLocalVariables" : "RAD 6/26/2021 22:49",
"localVariables" : "LH 6/26/2021 15:19",
"localVariables:" : "LH 6/26/2021 15:19",
"localVariablesBlock" : "LH 6/26/2021 14:46",
"localVariablesStatement:" : "RAD 6/26/2021 21:11",
"placeHolder1" : "RAD 6/26/2021 19:44",
"placeHolder2" : "RAD 6/26/2021 19:44",
"rangeOffsetStatement:" : "RAD 5/27/2021 14:38",
"rangeOffsetStatement:" : "ld 8/1/2021 13:34",
"replaceAllLocalVariablesIn:" : "RAD 6/26/2021 21:10",
"replaceLocalVariable:in:" : "RAD 6/28/2021 09:44",
"replaceRegex:with:in:" : "RAD 6/28/2021 09:39",
Expand All @@ -24,9 +24,9 @@
"startOfStatement:" : "RAD 5/27/2021 14:38",
"statementMapping" : "RAD 6/11/2021 17:41",
"statementMapping:" : "RAD 6/11/2021 17:41",
"statementsOf:" : "RAD 5/27/2021 14:36",
"statementsOf:" : "ld 8/1/2021 13:38",
"text" : "RAD 6/11/2021 17:41",
"text:" : "RAD 6/11/2021 17:42",
"updateContents:" : "LH 6/26/2021 15:22",
"updateContentsSelect:toEditor:" : "RAD 5/28/2021 15:51",
"updateContentsSelect:toEditor:" : "ld 8/1/2021 13:39",
"updateContentsSelectedSymbol:toEditor:" : "RAD 5/28/2021 15:51" } }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
range calculation
rangeOffsetIn: anEditor statement: anInteger
| offset |
offset := ((1 to: anInteger - 1) collect: [:i | (anEditor content contentsList at: i) size] ).
offset := ((1 to: anInteger - 1) collect: [:each | (anEditor content contentsList at: each) size] ).
offset
ifEmpty: [^ 0]
ifNotEmpty: [^ offset sum].

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
"range" : "mgjm 7/1/2019 16:03",
"range:" : "mgjm 7/1/2019 16:03",
"rangeIn:" : "fb 7/25/2019 12:48",
"rangeOffsetIn:" : "OS 6/10/2021 18:26",
"rangeOffsetIn:statement:" : "OS 6/10/2021 18:26",
"rangeOffsetIn:statement:" : "ld 8/1/2021 13:48",
"reduceContext:" : "OS 6/10/2021 19:18",
"statementNumber" : "RAD 5/16/2021 14:01",
"statementNumber:" : "RAD 5/16/2021 14:01",
"syntaxError:in:" : "RAD 5/16/2021 20:01",
"totalRange:in:" : "RAD 5/16/2021 18:12",
"totalRangeIn:" : "OS 6/10/2021 18:27" } }
"syntaxError:in:" : "RAD 5/16/2021 20:01" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
updating
checkForEdgeCases: aCollection
(self shouldIgnoreNote: aCollection) ifTrue: [self ignoreNote: aCollection first].
(self shouldSplitBeam: aCollection) ifTrue: [self splitBeam].
self update.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
updating
checkForEdgeCases
| upNotes downNotes |

downNotes := self notes select: [ :note | note noteLayout up not].
upNotes := self notes select: [ :note | note noteLayout up].
self checkForEdgeCases: downNotes.
self checkForEdgeCases: upNotes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ drawing
draw
| start end |

self checkForEdgeCases.
self removeFlags.
self isDiagonalOrSamePitch ifFalse: [self growStems].

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
drawing
growStemsExcept: aMNNoteMorph
self notes do: [:note | note ~= aMNNoteMorph ifTrue: [note noteLayout stemLength: (self stemOffset: note)]].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
updating
ignoreNote: aMNNoteMorph
(self isOuterNote: aMNNoteMorph) ifFalse: [self growStemsExcept: aMNNoteMorph].
self notes remove: aMNNoteMorph.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
calculating
isOuterNote: aMNNoteMorph
^ aMNNoteMorph = self notes first or: [aMNNoteMorph = self notes last]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
calculating
shouldIgnoreNote: aCollection
^ aCollection size = 1 and: [self notes size > 2]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
calculating
shouldSplitBeam: aCollection
^ aCollection size = 2 and: [self notes size = 4]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
updating
splitBeam
| firstHalf secondHalf |

firstHalf := OrderedCollection new add: self notes first; add: self notes second; yourself.
secondHalf := OrderedCollection new add: self notes third; add: self notes last; yourself.

self notes: firstHalf.
self draw.
self notes: secondHalf.
Loading

0 comments on commit 7b5f4d4

Please sign in to comment.