rechordr: Play or save musical chords

Description Usage Arguments Value Author(s) Examples

View source: R/rechordr.R

Description

Play or save musical chords

Usage

1
rechordr(pitch, duration, tempo = 120, sample_rate = 44100, fade_duration = 0.02, output_path = NULL)

Arguments

pitch

a character vector or list of notes using the Latin alphabet. Use a list to play multiple notes simultaneously, placing all notes to be played together in a character vector. An element with no characters results in silence. Append:

  • # for sharp semitones

  • b for flat semitones

  • octave number, by default octave 4

duration

a numeric vector of each note's duration, in beats. Must be same length as pitch.

tempo

integer, tempo to be played in beats per minute.

sample_rate

integer, number of samples per second (Hz).

fade_duration

number of seconds to fade each note in and out. Can be used to avoid audible pops at the beginning and end of each note. Cannot exceed half of the shortest note's duration.

output_path

path to location where wave file will be written. If NULL, music is played in the console.

Value

Music played in R console, or saved wave file.

Author(s)

Ariel Fridman

Examples

1
2
3
4
5
6
rechordr(pitch = list(c("A3", "C4", "F4"), c("G3", "C4", "E4"), c("G3", "C4", "E4"), c("F3", "Bb3", "D4"), "", c("A3", "C4", "F4"), c("G3", "C4", "E4"), c("G3", "C4", "E4"), c("A3", "C4", "F4")),
         duration = c(1, .75, .75, .5, 1, 1, .75, .75, .5))

rechordr(pitch = list(c("A3", "C4", "F4"), c("G3", "C4", "E4"), c("G3", "C4", "E4"), c("F3", "Bb3", "D4"), "", c("A3", "C4", "F4"), c("G3", "C4", "E4"), c("G3", "C4", "E4"), c("A3", "C4", "F4")),
         duration = c(1, .75, .75, .5, 1, 1, .75, .75, .5),
         output_path = "You Can Call Me Al.wav")

arielfri/rechordr documentation built on Sept. 16, 2020, 12:43 a.m.