| Type: | Package |
| Title: | Create Music with Ease |
| Version: | 2.0.0 |
| Author: | Renfei Mao |
| Maintainer: | Renfei Mao <renfeimao@gmail.com> |
| Description: | Provides a simple and intuitive high-level language for music representation. Generates and embeds music scores and audio files in 'RStudio', 'R Markdown' documents, and R 'Jupyter Notebooks'. Internally, uses 'MusicXML' https://github.com/w3c/musicxml to represent music, and 'MuseScore' https://musescore.org/ to convert 'MusicXML'. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/flujoo/gm, https://flujoo.github.io/gm/ |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| Suggests: | knitr, rmarkdown, rstudioapi, shiny, testthat, tibble |
| Imports: | base64enc, erify, htmltools, utils |
| VignetteBuilder: | knitr |
| SystemRequirements: | MuseScore - https://musescore.org/ |
| NeedsCompilation: | no |
| Packaged: | 2024-07-10 08:39:18 UTC; fei |
| Repository: | CRAN |
| Date/Publication: | 2024-07-10 09:00:01 UTC |
Add Component to Music Object
Description
Add a component to a Music object.
Usage
## S3 method for class 'Music'
music + object
Arguments
music |
A |
object |
An object of class |
Value
A list of class Music.
See Also
Music() for initialization of a Music object.
Examples
# Initialize a `Music` object
music <- Music()
# Add a `Line`
music <- music + Line("C4", 1)
music
# Add a `Meter`
music <- music + Meter(4, 4)
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Accidental Object
Description
Create an Accidental object to represent an accidental symbol.
Usage
Accidental(name, i, j = NULL, to = NULL, bracket = NULL)
Arguments
name |
A single character, which represents the name of the
accidental. |
i |
A single positive integer, which represents the position of the accidental in a musical line. |
j |
Optional. A single positive integer, which represents the position of the accidental in a chord. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the accidental. |
bracket |
Optional. A single logical, which indicates if the accidental is enclosed in brackets. |
Value
A list of class Accidental.
See Also
+.Music() for adding an Accidental to a Music object.
Examples
# Create an `Accidental`
accidental <- Accidental("natural", 2, bracket = TRUE)
accidental
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "C4")) + accidental
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Articulation Object
Description
Create an Articulation object to represent an articulation mark.
Usage
Articulation(name, i, to = NULL)
Arguments
name |
A single character, which represents the name or symbol
of the articulation. For example, to create a staccato dot, |
i |
A single positive integer, which represents the position of the articulation in a musical line. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the articulation. |
Details
Supported articulation names and symbols:
"accent" or ">"
"staccato" or "."
"staccatissimo" or "'"
"tenuto" or "-"
"tenuto-staccato", "detached-legato" or "-."
"marcato", "strong-accent" or "^"
"scoop"
"plop"
"doit"
"fall" or "falloff"
"stress" or ","
"unstress" or "u"
"soft accent", "soft-accent" or "<>"
The names are from the MusicXML specification and MuseScore.
Value
A list of class Articulation.
See Also
+.Music() for adding an Articulation to
a Music object.
Examples
# Create a staccato
staccato <- Articulation(".", 1)
staccato
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + staccato
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Breath Object
Description
Create a Breath object to represent a breath mark.
Usage
Breath(i, to = NULL, symbol = NULL)
Arguments
i |
A single positive integer, which represents the position of the breath mark in a musical line. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the breath mark. |
symbol |
Optional. A single character which can be |
Value
A list of class Breath.
See Also
+.Music() for adding a breath mark to a Music object.
Examples
# Create a breath mark
breath <- Breath(1)
breath
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + breath
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Clef Object
Description
Create a Clef object to represent a clef.
Usage
Clef(sign, line = NULL, octave = NULL, to = NULL, bar = NULL, offset = NULL)
Arguments
sign |
A single character, which can be |
line |
Optional. A single integer, which depends on
|
octave |
Optional. A single integer, which can be
|
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the clef. |
bar |
Optional. A positive integer, which indicates the number of the measure where to add the clef. By default, the clef will be added at the first measure. |
offset |
Optional. A non-negative number,
which indicates the clef's position in a measure. The default value is |
Details
See Wikipedia for more details.
Value
A list of class Clef.
See Also
+.Music() for adding a Clef to a Music object.
Examples
# Create a bass clef
clef <- Clef("F")
clef
# Add the clef to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C3", "D3")) + clef
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Dynamic Object
Description
Create a Dynamic object to represent a dynamic marking.
Usage
Dynamic(marking, i, to = NULL, velocity = NULL, above = NULL)
Arguments
marking |
A single character, which represents the dynamic symbol on
the score. If |
i |
A single positive integer, which represents the position
of the |
to |
Optional. A single character or a single positive integer,
which indicates the musical line where to add the |
velocity |
Optional. A single integer between |
above |
Optional. A single logical, which indicates whether the dynamic symbol should appear above or below the staff. |
Details
Common used dynamic markings and their velocities in MuseScore:
pppppp: 1
ppppp: 5
pppp: 10
ppp: 16
pp: 33
p: 49
mp: 64
mf: 80
f: 96
ff: 112
fff: 126
ffff: 127
fffff: 127
ffffff: 127
fp: 96
pf: 49
sf: 112
sfz: 112
sff: 126
sffz: 126
sfp: 112
sfpp: 112
rfz: 112
rf: 112
fz: 112
m: 96
r: 112
s: 112
z: 80
n: 49
Value
A list of class Dynamic.
See Also
+.Music() for adding an Dynamic to a Music object.
Examples
# Create a `Dynamic`
f <- Dynamic("f", 1)
f
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + f
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Fermata Object
Description
Create a Fermata object to represent a fermata symbol.
Usage
Fermata(i, to = NULL, shape = NULL, above = NULL)
Arguments
i |
A single positive integer, which represents the position of the fermata in a musical line. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the fermata. |
shape |
Optional. A single character, which indicates the shape of
the fermata. The default value is |
above |
Optional. A single logical, which indicates whether the fermata symbol should appear above or below the staff. |
Details
Supported fermata shapes:
"normal"
"short" or "angled"
"long" or "square"
"very short" or "double-angled"
"very long" or "double-square"
"long (Henze)" or "double-dot"
"short (Henze)" or "half-curve"
"curlew"
The shapes are from the MusicXML specification and MuseScore.
Value
A list of class Fermata.
See Also
+.Music() for adding a Fermata to
a Music object.
Examples
# Create a fermata
fermata <- Fermata(1)
fermata
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + fermata
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Grace Object
Description
Create a Grace object. The Grace object can be added to an existing
note or chord. It will turn the note or chord to a grace note or chord.
Usage
Grace(i, to = NULL, slash = NULL)
Arguments
i |
A single positive integer, which represents the position
of the |
to |
Optional. A single character or a single positive integer,
which indicates the musical line where to add the |
slash |
Optional. A single logical, which indicates if there is
a slash symbol on the grace note or chord. The default value is |
Details
A Grace object can not be added to a rest, tuplet, or note or chord
that has a dotted duration. There must be a note or chord after
the note or chord where the Grace object is added.
Value
A list of class Grace.
See Also
+.Music() for adding a Grace object to a Music object.
Examples
# Create a `Grace`
grace <- Grace(1)
grace
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4"), c(0.5, 1)) + grace
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Hairpin Object
Description
Create a Hairpin object to represent a crescendo or diminuendo symbol.
Usage
Hairpin(symbol, i, j, to = NULL, above = NULL)
Arguments
symbol |
A single character, which can be |
i, j |
A single positive integer. They indicate the start
and end position of the |
to |
Optional. A single character or a single positive integer,
which indicates the musical line where to add the |
above |
Optional. A single logical, which indicates whether the
|
Value
A list of class Hairpin.
See Also
+.Music() for adding a Hairpin to
a Music object.
Examples
# Create a crescendo
crescendo <- Hairpin("<", 1, 3)
crescendo
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4", "E4")) + crescendo
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Instrument Object
Description
Create an Instrument object to represent an instrument.
Usage
Instrument(instrument, to = NULL, volume = NULL, pan = NULL)
Arguments
instrument |
A single integer between |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the instrument. |
volume |
Optional. A single integer between |
pan |
Optional. A single integer between |
Details
Supported instruments:
Acoustic Grand Piano
Bright Acoustic Piano
Electric Grand Piano
Honky-Tonk Piano
Electric Piano 1
Electric Piano 2
Harpsichord
Clavinet
Celesta
Glockenspiel
Music Box
Vibraphone
Marimba
Xylophone
Tubular Bells
Dulcimer
Drawbar Organ
Percussive Organ
Rock Organ
Church Organ
Reed Organ
Accordion
Harmonica
Tango Accordion
Acoustic Guitar (Nylon)
Acoustic Guitar (Steel)
Electric Guitar (Jazz)
Electric Guitar (Clean)
Electric Guitar (Muted)
Overdriven Guitar
Distortion Guitar
Guitar Harmonics
Acoustic Bass
Electric Bass (Finger)
Electric Bass (Pick)
Fretless Bass
Slap Bass 1
Slap Bass 2
Synth Bass 1
Synth Bass 2
Violin
Viola
Cello
Contrabass
Tremolo Strings
Pizzicato Strings
Orchestral Harp
Timpani
String Ensemble 1
String Ensemble 2
Synth Strings 1
Synth Strings 2
Choir Aahs
Voice Oohs
Synth Voice
Orchestra Hit
Trumpet
Trombone
Tuba
Muted Trumpet
French Horn
Brass Section
Synth Brass 1
Synth Brass 2
Soprano Sax
Alto Sax
Tenor Sax
Baritone Sax
Oboe
English Horn
Bassoon
Clarinet
Piccolo
Flute
Recorder
Pan Flute
Blown Bottle
Shakuhachi
Whistle
Ocarina
Lead 1 (Square)
Lead 2 (Sawtooth)
Lead 3 (Calliope)
Lead 4 (Chiff)
Lead 5 (Charang)
Lead 6 (Voice)
Lead 7 (Fifths)
Lead 8 (Bass + Lead)
Pad 1 (New Age)
Pad 2 (Warm)
Pad 3 (Polysynth)
Pad 4 (Choir)
Pad 5 (Bowed)
Pad 6 (Metallic)
Pad 7 (Halo)
Pad 8 (Sweep)
FX 1 (Rain)
FX 2 (Soundtrack)
FX 3 (Crystal)
FX 4 (Atmosphere)
FX 5 (Brightness)
FX 6 (Goblins)
FX 7 (Echoes)
FX 8 (Sci-Fi)
Sitar
Banjo
Shamisen
Koto
Kalimba
Bag Pipe
Fiddle
Shanai
Tinkle Bell
Agogo
Steel Drums
Woodblock
Taiko Drum
Melodic Tom
Synth Drum
Reverse Cymbal
Guitar Fret Noise
Breath Noise
Seashore
Bird Tweet
Telephone Ring
Helicopter
Applause
Gunshot
Value
A list of class Instrument.
See Also
+.Music() for adding an instrument to a Music object.
Examples
# Create a flute
flute <- Instrument(74, pan = -90)
flute
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C5", "D5", "E5", "F5")) + flute
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Key Object
Description
Create a Key object to represent a key signature.
Usage
Key(key, bar = NULL, to = NULL, scope = NULL)
Arguments
key |
A single integer between -7 and 7, which indicates the number of flat or sharp symbols in the key signature. |
bar |
Optional. A positive integer, which indicates the number of the measure where to add the key signature. By default, the key signature will be added at the first measure. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the key signature. By default, the key signature will be added to the whole music rather than some specific musical line. |
scope |
Optional. A single character of |
Value
A list of class Key.
See Also
+.Music() for adding a key signature to a Music object.
Examples
# Create a G major
g <- Key(1, to = 1)
g
# Add it only to some part of a `Music`
music <-
Music() +
Meter(4, 4) +
Line(c("C4", "D4")) +
Line("G3") +
g
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Line Object
Description
Create a Line object to represent a musical line. In gm,
the musical line is the basic unit of music. It appears in different
forms, such as voices, staffs, and parts in music scores.
Usage
Line(
pitches = NULL,
durations = NULL,
tie = NULL,
name = NULL,
as = NULL,
to = NULL,
after = NULL,
bar = NULL,
offset = NULL
)
Arguments
pitches |
A list or vector which represents the pitches
of a musical line. The items of
If not provided, the default value is |
durations |
A list or vector which represents the
durations of a musical line. The items of
If not provided, the default value is 1. |
tie |
Deprecated. Was used to add ties to notes. Please use
|
name |
Optional. A single character which represents the name of the musical line. When adding components to a musical line, it can be referred to by its name. |
as |
Optional. A single character which can be |
to |
Optional. A single character or integer, which represents the name or row number of a reference musical line to which to add the current musical line. By default, the musical line will be added at the end of the score. |
after |
Optional. A single logical which indicates whether to add the
musical line after or before the reference musical line. The default value
is |
bar |
Optional. A positive integer, which indicates the number of the measure where to add the musical line. By default, the musical line will be added at the first measure. |
offset |
Optional. A non-negative number,
which indicates the position in a measure where to add the musical line.
The default value is |
Value
A list of class Line.
See Also
+.Music() for adding a musical line to a Music object.
Examples
# Create a musical line
line <- Line(c("C4", "D4", "E4"))
line
# Add it to a music
music <- Music() + Meter(4, 4) + line
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Lyric Object
Description
Create a Lyric object to represent a unit of lyrics.
Usage
Lyric(text, i, to = NULL, verse = NULL)
Arguments
text |
A single character, which usually represents a word or syllable of the lyrics. See the Details section for more complex usage. |
i |
A single positive integer, which represents the position
of the |
to |
Optional. A single character or a single positive integer,
which indicates the musical line where to add the |
verse |
Optional. A positive integer which indicates the verse
where to add the |
Details
You can use "-" and "_" in argument text to create the following
structures:
-
Syllable: for example, with
Lyric("mo-", 1)andLyric("-ther", 3), the two syllables of mother are added to the first and third notes, with a hyphen placed on the second note. -
Melisma: for example, with
Lyric("love_", 1)andLyric("_", 3), the word love is added to the first note, followed by an underscore line which extends over the second and third notes. -
Elision: for example, with
Lyric("my_love", 1), words my and love are both added to the first note, connected by an elision slur.
Use "\\-" and "\\_" if you want to add hyphens and
underscores literally.
Value
A list of class Lyric.
See Also
+.Music() for adding a Lyric to a Music object.
Examples
# Create two syllables
syllable_1 <- Lyric("He-", 1)
syllable_2 <- Lyric("-llo", 3)
syllable_1
syllable_2
# Add them to a `Music`
music <-
Music() +
Meter(4, 4) +
Line(c("C4", "D4", "E4")) +
syllable_1 +
syllable_2
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Meter Object
Description
Create a Meter object to represent a time signature.
Usage
Meter(
number,
unit,
bar = NULL,
actual_number = NULL,
actual_unit = NULL,
invisible = NULL
)
Arguments
number |
A positive integer to represent the upper numeral of the time signature, which indicates how many beats each measure has. |
unit |
A single integer which can be 1, 2, 4, 8, 16, 32 or 64. It represents the lower numeral of the time signature, which indicates the duration of one single beat. |
bar |
Optional. A positive integer, which indicates the number of the measure where to add the time signature. By default, the time signature will be added at the first measure. |
actual_number, actual_unit |
Optional. They define the actual
time signature rather than the one that appears on the score. Usually
used to create a pickup measure. By default, they are the
same as |
invisible |
Optional. A single logical, which indicates whether to
show the time signature on the score. Usually used to create a
pickup measure. The default value is |
Value
A list of class Meter.
See Also
+.Music() for adding a Meter to a Music object.
Examples
# Create a 3/4 time signature
meter <- Meter(3, 4)
# Add it to a `Music`
music <- Music() + Line(c("C4", "D4", "E4")) + meter
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Mordent Object
Description
Create a Mordent object to represent a mordent ornament.
Usage
Mordent(i, to = NULL, inverted = NULL, long = NULL, ornament = NULL)
Arguments
i |
A single positive integer, which represents the position of the mordent in a musical line. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the mordent. |
inverted |
Optional. A single logical, which indicates whether the
mordent is inverted or not. The default value is |
long |
Optional. A single logical, which indicates whether the
mordent is long or not. The default value is |
ornament |
Optional. A single character, which can be |
Value
A list of class Mordent.
See Also
+.Music() for adding a Mordent to a Music object.
Examples
# Create a mordent
mordent <- Mordent(1)
mordent
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + mordent
music
# Generate the music score
if (interactive()) {
show(music)
}
Initialize Music Object
Description
Initialize a Music object. Other components can be added to it.
Usage
Music()
Value
A list of class Music.
See Also
+.Music() for adding components to a Music object.
Examples
# Initialize a `Music`
Music()
Create Notehead Object
Description
Create a Notehead object to customize the appearance of a note's head.
Usage
Notehead(
i,
j = NULL,
to = NULL,
shape = NULL,
color = NULL,
filled = NULL,
bracket = NULL
)
Arguments
i |
A single positive integer, which represents the position of the note in a musical line. |
j |
Optional. A single positive integer, which represents the position of the note in a chord. |
to |
Optional. A single character or a single positive integer,
which indicates the musical line where to apply the |
shape |
Optional. A single character which represents the shape of the note's head. See the MusicXML specification for all shapes. Unfortunately, not all shapes are supported in MuseScore. |
color |
Optional. A single character which represents the color of the note's head. It must be in the hexadecimal RGB or ARGB format. |
filled |
Optional. A single logical, which indicates whether the note's head is filled or hollow. |
bracket |
Optional. A single logical, which indicates whether the note's head is enclosed in brackets. |
Value
A list of class Notehead.
See Also
+.Music() for adding a Notehead to a Music object.
Examples
# Create a `Notehead`
notehead <- Notehead(1, shape = "diamond", color = "#800080")
notehead
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + notehead
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Pedal Object
Description
Create a Pedal object to represent piano sustain pedal marks.
Usage
Pedal(i, j, to = NULL)
Arguments
i, j |
A single positive integer. They indicate the start
and end position of the |
to |
Optional. A single character or a single positive integer,
which indicates the musical line where to add the |
Value
A list of class Pedal.
See Also
+.Music() for adding a Pedal to a Music object.
Examples
# Create a `Pedal`
pedal <- Pedal(1, 3)
pedal
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4", "E4")) + pedal
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Schleifer Object
Description
Create a Schleifer object to represent a slide ornament. See
the MusicXML specification.
Usage
Schleifer(i, to = NULL)
Arguments
i |
A single positive integer, which represents the position
of the |
to |
Optional. A single character or a single positive integer,
which indicates the musical line where to add the |
Value
A list of class Schleifer.
See Also
+.Music() for adding a Schleifer to a Music object.
Examples
# Create a `Schleifer`
schleifer <- Schleifer(1)
schleifer
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + schleifer
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Slur Object
Description
Create a Slur object to represent a slur.
Usage
Slur(i, j, to = NULL, to_j = NULL, above = NULL)
Arguments
i, j |
A single positive integer. They indicate the start and end positions of the slur. |
to, to_j |
Optional. A single character or a single positive integer,
which indicates the musical line where to add the slur. Specify |
above |
Optional. A single logical, which indicates whether the slur should appear above or below the staff. By default, the position is decided by MuseScore. |
Value
A list of class Slur.
See Also
+.Music() for adding a slur to a Music object.
Examples
# Create a slur
slur <- Slur(1, 3)
slur
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4", "E4")) + slur
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Stem Object
Description
Create a Stem object to modify the stem of some note.
Usage
Stem(direction, i, to = NULL)
Arguments
direction |
A single character, which can be |
i |
A single positive integer, which represents the position of the stem in a musical line. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to modify the stem. |
Value
A list of class Stem.
See Also
+.Music() for adding a Stem to a Music object.
Examples
# Create a `Stem`
stem <- Stem("none", 1)
stem
# Add a `Stem` to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + stem
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Tempo Object
Description
Create a Tempo object to represent a tempo marking.
Usage
Tempo(tempo, unit = NULL, bar = NULL, offset = NULL, marking = NULL)
Arguments
tempo |
A positive number, which indicates the number of quarter notes per minute. |
unit |
Deprecated. Was used to specify the beat unit.
Please use |
bar |
Optional. A positive integer, which indicates the number of the measure where to add the tempo. By default, it will be added at the first measure. |
offset |
Optional. A non-negative number, which indicates
the tempo's position in a measure. The default value is |
marking |
Optional. A single character, which represents the marking that appears on the score. See the Details section. |
Details
The parameter tempo is used to specify the actual playback speed, while
marking to represent the marking that appears on the score.
Some examples:
-
Tempo(50): the playback speed is 50 quarter notes per minute. A marking of "quarter = 50" will be added to the score. -
Tempo(50, marking = "Adagio"): the playback speed is 50 quarter notes per minute, while the marking on the score is "Adagio". -
Tempo(50, marking = "Adagio half. = 20"): the playback speed is 50 quarter notes per minute, while the marking on the score is "Adagio half. = 20". -
Tempo(50, marking = "Adagio (quarter = 45-80)"): you can add a speed range and parentheses to the marking. -
Tempo(50, marking = "quarter. = quarter"): you can also indicate metric modulations withmarking.
Value
A list of class Tempo.
See Also
+.Music() for adding a tempo to a Music object.
Examples
# Create a tempo
tempo <- Tempo(50, marking = "Adagio (half = 25)")
tempo
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4", "E4", "F4")) + tempo
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Tie Object
Description
Create a Tie to tie some notes together.
Usage
Tie(i, j = NULL, to = NULL, above = NULL)
Arguments
i |
A single positive integer, which represents the start position of the tie in a musical line. |
j |
Optional. A single positive integer, which represents the start position of the tie in a chord. If not provided, all notes in the chords that have equivalent pitches are tied. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the tie. |
above |
Optional. A single logical, which indicates if the tie is placed above the notes. By default, the position is decided by MuseScore. |
Value
A list of class Tie.
See Also
+.Music() for adding a tie to a Music object.
Examples
# Create a tie
tie <- Tie(1)
tie
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "C4")) + tie
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Tremolo Object
Description
Create a Tremolo object to represent a tremolo.
Usage
Tremolo(number, i, to = NULL, between = NULL)
Arguments
number |
A single integer which can be |
i |
A single positive integer, which represents the position of the tremolo in a musical line. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the tremolo. |
between |
Optional. A single logical which indicates if the tremolo is between notes. |
Value
A list of class Tremolo.
See Also
+.Music() for adding a tremolo to a Music object.
Examples
# Create a tremolo
tremolo <- Tremolo(3, 1, between = TRUE)
tremolo
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4", "E4", "F4")) + tremolo
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Trill Object
Description
Create a Trill object to represent a trill ornament.
Usage
Trill(i, j = NULL, to = NULL)
Arguments
i |
A single positive integer, which represents the position of the trill in a musical line. |
j |
Optional. A single positive integer, which indicates the end position of the trill line in a musical line. If not provided, the trill will appear as a tr symbol above only the trilled note. Otherwise, it will appear as a tr~~~ symbol above the notes between the start and end positions. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the trill. |
Value
A list of class Trill.
See Also
+.Music() for adding a trill to a Music object.
Examples
# Create a trill
trill <- Trill(1, 3)
trill
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4", "E4", "F4")) + trill
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Turn Object
Description
Create a Turn object to represent a turn ornament.
Usage
Turn(i, to = NULL, inverted = NULL)
Arguments
i |
A single positive integer, which represents the position of the turn in a musical line. |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to add the turn. |
inverted |
Optional. A single logical, which indicates if it is
an inverted turn. The default value is |
Value
A list of class Turn.
See Also
+.Music() for adding a turn to a Music object.
Examples
# Create a turn
turn <- Turn(1, inverted = TRUE)
turn
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + turn
music
# Generate the music score
if (interactive()) {
show(music)
}
Create Velocity Object
Description
Create a Velocity object to set some notes' velocities.
Usage
Velocity(velocity, to = NULL, i = NULL, j = NULL)
Arguments
velocity |
A single integer between |
to |
Optional. A single character or a single positive integer, which indicates the musical line where to apply the velocity. If not provided, the velocity will be applied to all notes. |
i |
Optional. A single positive integer, which represents the position of the velocity in a musical line. |
j |
Optional. A single positive integer, which represents the position of the velocity in a chord. |
Value
A list of class Velocity.
See Also
Examples
# Create a `Velocity`
velocity <- Velocity(10)
velocity
# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + velocity
music
# Generate the music score
if (interactive()) {
show(music)
}
Export Music Object
Description
Export a Music object to a file format such as PNG or MP3.
Usage
export(x, ...)
## S3 method for class 'Music'
export(x, path, musescore = NULL, ...)
Arguments
x |
A |
... |
Optional arguments to |
path |
A single character, which specifies the output file path.
For example, |
musescore |
Optional. A character vector, which represents the command line options passed to MuseScore. See MuseScore command line usage for details. |
Details
Supported file extensions:
flac
metajson
mid
midi
mlog
mp3
mpos
mscx
mscz
musicxml
mxl
ogg
pdf
png
spos
svg
wav
xml
Value
An invisible NULL. A file is generated in the specified path.
Examples
if (interactive()) {
music <- Music() + Meter(4, 4) + Line("C4")
export(music, tempfile(fileext = ".mp3"), "-r 200 -b 520")
}
Internal gm Functions
Description
These are not to be called by the user.
Show Music Object
Description
Display a Music object as a music score or audio file.
Usage
show(x, to, musescore)
## S3 method for class 'Music'
show(x, to = NULL, musescore = NULL)
Arguments
x |
A |
to |
Optional. A character vector, which can be |
musescore |
Optional. A character vector, which represents the command line options passed to MuseScore. See MuseScore command line usage for details. |
Details
This function works in
RStudio
R Markdown files
Jupyter Notebooks
Shiny applications
R.app GUI
Value
An invisible NULL. A music score or audio file will be
displayed.
Examples
if (interactive()) {
music <- Music() + Meter(4, 4) + Line("C4")
show(music, musescore = "-r 800 -T 5")
}