Title: | Create Music with Ease |
---|---|
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'. |
Authors: | Renfei Mao |
Maintainer: | Renfei Mao <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.0 |
Built: | 2025-03-13 05:02:29 UTC |
Source: | https://github.com/flujoo/gm |
Music
ObjectAdd a component to a Music
object.
## S3 method for class 'Music' music + object
## S3 method for class 'Music' music + object
music |
A |
object |
An object of class |
A list of class Music
.
Music()
for initialization of a Music
object.
# 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) }
# 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) }
Accidental
ObjectCreate an Accidental
object to represent an accidental symbol.
Accidental(name, i, j = NULL, to = NULL, bracket = NULL)
Accidental(name, i, j = NULL, to = NULL, bracket = NULL)
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. |
A list of class Accidental
.
+.Music()
for adding an Accidental
to a Music
object.
# 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 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) }
Articulation
ObjectCreate an Articulation
object to represent an articulation mark.
Articulation(name, i, to = NULL)
Articulation(name, i, to = NULL)
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. |
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.
A list of class Articulation
.
+.Music()
for adding an Articulation
to
a Music
object.
# 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 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) }
Breath
ObjectCreate a Breath
object to represent a breath mark.
Breath(i, to = NULL, symbol = NULL)
Breath(i, to = NULL, symbol = NULL)
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 |
A list of class Breath
.
+.Music()
for adding a breath mark to a Music
object.
# 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 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) }
Clef
ObjectCreate a Clef
object to represent a clef.
Clef(sign, line = NULL, octave = NULL, to = NULL, bar = NULL, offset = NULL)
Clef(sign, line = NULL, octave = NULL, to = NULL, bar = NULL, offset = NULL)
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 |
See Wikipedia for more details.
A list of class Clef
.
+.Music()
for adding a Clef
to a Music
object.
# 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 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) }
Dynamic
ObjectCreate a Dynamic
object to represent a dynamic marking.
Dynamic(marking, i, to = NULL, velocity = NULL, above = NULL)
Dynamic(marking, i, to = NULL, velocity = NULL, above = NULL)
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. |
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
A list of class Dynamic
.
+.Music()
for adding an Dynamic
to a Music
object.
# 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 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) }
Music
ObjectExport a Music
object to a file format such as PNG or MP3.
export(x, ...) ## S3 method for class 'Music' export(x, path, musescore = NULL, ...)
export(x, ...) ## S3 method for class 'Music' export(x, path, musescore = NULL, ...)
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. |
Supported file extensions:
flac
metajson
mid
midi
mlog
mp3
mpos
mscx
mscz
musicxml
mxl
ogg
png
spos
svg
wav
xml
An invisible NULL
. A file is generated in the specified path.
if (interactive()) { music <- Music() + Meter(4, 4) + Line("C4") export(music, tempfile(fileext = ".mp3"), "-r 200 -b 520") }
if (interactive()) { music <- Music() + Meter(4, 4) + Line("C4") export(music, tempfile(fileext = ".mp3"), "-r 200 -b 520") }
Fermata
ObjectCreate a Fermata
object to represent a fermata symbol.
Fermata(i, to = NULL, shape = NULL, above = NULL)
Fermata(i, to = NULL, shape = NULL, above = NULL)
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. |
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.
A list of class Fermata
.
+.Music()
for adding a Fermata
to
a Music
object.
# 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 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) }
Grace
ObjectCreate 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.
Grace(i, to = NULL, slash = NULL)
Grace(i, to = NULL, slash = NULL)
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 |
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.
A list of class Grace
.
+.Music()
for adding a Grace
object to a Music
object.
# 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 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) }
Hairpin
ObjectCreate a Hairpin
object to represent a crescendo or diminuendo symbol.
Hairpin(symbol, i, j, to = NULL, above = NULL)
Hairpin(symbol, i, j, to = NULL, above = NULL)
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
|
A list of class Hairpin
.
+.Music()
for adding a Hairpin
to
a Music
object.
# 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 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) }
Instrument
ObjectCreate an Instrument
object to represent an instrument.
Instrument(instrument, to = NULL, volume = NULL, pan = NULL)
Instrument(instrument, to = NULL, volume = NULL, pan = NULL)
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 |
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
A list of class Instrument
.
+.Music()
for adding an instrument to a Music
object.
# 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 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) }
Key
ObjectCreate a Key
object to represent a key signature.
Key(key, bar = NULL, to = NULL, scope = NULL)
Key(key, bar = NULL, to = NULL, scope = NULL)
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 |
A list of class Key
.
+.Music()
for adding a key signature to a Music
object.
# 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 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) }
Line
ObjectCreate 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.
Line( pitches = NULL, durations = NULL, tie = NULL, name = NULL, as = NULL, to = NULL, after = NULL, bar = NULL, offset = NULL )
Line( pitches = NULL, durations = NULL, tie = NULL, name = NULL, as = NULL, to = NULL, after = NULL, bar = NULL, offset = NULL )
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 |
A list of class Line
.
+.Music()
for adding a musical line to a Music
object.
# 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 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) }
Lyric
ObjectCreate a Lyric
object to represent a unit of lyrics.
Lyric(text, i, to = NULL, verse = NULL)
Lyric(text, i, to = NULL, verse = NULL)
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 |
You can use "-"
and "_"
in argument text
to create the following
structures:
Syllable:
for example, with Lyric("mo-", 1)
and Lyric("-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)
and Lyric("_", 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.
A list of class Lyric
.
+.Music()
for adding a Lyric
to a Music
object.
# 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 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) }
Meter
ObjectCreate a Meter
object to represent a time signature.
Meter( number, unit, bar = NULL, actual_number = NULL, actual_unit = NULL, invisible = NULL )
Meter( number, unit, bar = NULL, actual_number = NULL, actual_unit = NULL, invisible = NULL )
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 |
A list of class Meter
.
+.Music()
for adding a Meter
to a Music
object.
# 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 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) }
Mordent
ObjectCreate a Mordent
object to represent a mordent ornament.
Mordent(i, to = NULL, inverted = NULL, long = NULL, ornament = NULL)
Mordent(i, to = NULL, inverted = NULL, long = NULL, ornament = NULL)
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 |
A list of class Mordent
.
+.Music()
for adding a Mordent
to a Music
object.
# 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) }
# 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) }
Music
ObjectInitialize a Music
object. Other components can be added to it.
Music()
Music()
A list of class Music
.
+.Music()
for adding components to a Music
object.
# Initialize a `Music` Music()
# Initialize a `Music` Music()
Notehead
ObjectCreate a Notehead
object to customize the appearance of a note's head.
Notehead( i, j = NULL, to = NULL, shape = NULL, color = NULL, filled = NULL, bracket = NULL )
Notehead( i, j = NULL, to = NULL, shape = NULL, color = NULL, filled = NULL, bracket = NULL )
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. |
A list of class Notehead
.
+.Music()
for adding a Notehead
to a Music
object.
# 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 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) }
Pedal
ObjectCreate a Pedal
object to represent piano sustain pedal marks.
Pedal(i, j, to = NULL)
Pedal(i, j, to = NULL)
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 |
A list of class Pedal
.
+.Music()
for adding a Pedal
to a Music
object.
# 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 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) }
Schleifer
ObjectCreate a Schleifer
object to represent a slide ornament. See
the MusicXML specification.
Schleifer(i, to = NULL)
Schleifer(i, to = NULL)
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 |
A list of class Schleifer
.
+.Music()
for adding a Schleifer
to a Music
object.
# 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 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) }
Music
ObjectDisplay a Music
object as a music score or audio file.
show(x, to, musescore) ## S3 method for class 'Music' show(x, to = NULL, musescore = NULL)
show(x, to, musescore) ## S3 method for class 'Music' show(x, to = NULL, musescore = NULL)
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. |
This function works in
RStudio
R Markdown files
Jupyter Notebooks
Shiny applications
R.app GUI
An invisible NULL
. A music score or audio file will be
displayed.
if (interactive()) { music <- Music() + Meter(4, 4) + Line("C4") show(music, musescore = "-r 800 -T 5") }
if (interactive()) { music <- Music() + Meter(4, 4) + Line("C4") show(music, musescore = "-r 800 -T 5") }
Slur
ObjectCreate a Slur
object to represent a slur.
Slur(i, j, to = NULL, to_j = NULL, above = NULL)
Slur(i, j, to = NULL, to_j = NULL, above = NULL)
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. |
A list of class Slur
.
+.Music()
for adding a slur to a Music
object.
# 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 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) }
Stem
ObjectCreate a Stem
object to modify the stem of some note.
Stem(direction, i, to = NULL)
Stem(direction, i, to = NULL)
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. |
A list of class Stem
.
+.Music()
for adding a Stem
to a Music
object.
# 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 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) }
Tempo
ObjectCreate a Tempo
object to represent a tempo marking.
Tempo(tempo, unit = NULL, bar = NULL, offset = NULL, marking = NULL)
Tempo(tempo, unit = NULL, bar = NULL, offset = NULL, marking = NULL)
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. |
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 with marking
.
A list of class Tempo
.
+.Music()
for adding a tempo to a Music
object.
# 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 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) }
Tie
ObjectCreate a Tie
to tie some notes together.
Tie(i, j = NULL, to = NULL, above = NULL)
Tie(i, j = NULL, to = NULL, above = NULL)
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. |
A list of class Tie
.
+.Music()
for adding a tie to a Music
object.
# 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 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) }
Tremolo
ObjectCreate a Tremolo
object to represent a tremolo.
Tremolo(number, i, to = NULL, between = NULL)
Tremolo(number, i, to = NULL, between = NULL)
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. |
A list of class Tremolo
.
+.Music()
for adding a tremolo to a Music
object.
# 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 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) }
Trill
ObjectCreate a Trill
object to represent a trill ornament.
Trill(i, j = NULL, to = NULL)
Trill(i, j = NULL, to = NULL)
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. |
A list of class Trill
.
+.Music()
for adding a trill to a Music
object.
# 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 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) }
Turn
ObjectCreate a Turn
object to represent a turn ornament.
Turn(i, to = NULL, inverted = NULL)
Turn(i, to = NULL, inverted = NULL)
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 |
A list of class Turn
.
+.Music()
for adding a turn to a Music
object.
# 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 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) }
Velocity
ObjectCreate a Velocity
object to set some notes' velocities.
Velocity(velocity, to = NULL, i = NULL, j = NULL)
Velocity(velocity, to = NULL, i = NULL, j = NULL)
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. |
A list of class Velocity
.
# 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) }
# 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) }